diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000..a55e7a1
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/editor.xml b/.idea/editor.xml
index ae802b3..52e64bf 100644
--- a/.idea/editor.xml
+++ b/.idea/editor.xml
@@ -25,7 +25,7 @@
-
+
@@ -82,7 +82,7 @@
-
+
diff --git a/config.h b/config.h
index eb03cc2..f3e1402 100644
--- a/config.h
+++ b/config.h
@@ -10,4 +10,7 @@
#define TEXT_MAX_LENGTH 64
#define MAX_TEXT_NODES_COUNT 4
#define SMALL_TEXT_HEIGHT 7
-#define SMALL_TEXT_WIDTH 5
\ No newline at end of file
+#define SMALL_TEXT_WIDTH 5
+
+#define MEDIUM_TEXT_HEIGHT 7
+#define MEDIUM_TEXT_WIDTH 5
\ No newline at end of file
diff --git a/ledy.ino b/ledy.ino
index 599faab..6e634e5 100644
--- a/ledy.ino
+++ b/ledy.ino
@@ -11,22 +11,76 @@
#include // Required for 16 MHz Adafruit Trinket
#endif
-
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
+TextNode text_nodes[MAX_TEXT_NODES_COUNT];
+
+void addNewTextNode
+ (
+ char text[TEXT_MAX_LENGTH + 1], uint32_t color = 0x00010101, unsigned short pos_x = 65535, unsigned short pos_y = 0,
+ bool is_small = true
+ )
+{
+ unsigned char text_length = strlen(text);
+ if (text_length == 0){return;}
+ for (unsigned char i = 0; i < MAX_TEXT_NODES_COUNT; i++)
+ {
+ if (text_nodes[i].is_deleted)
+ {
+ strncpy(text_nodes[i].content, text, TEXT_MAX_LENGTH);
+ text_nodes[i].color = color;
+ text_nodes[i].pos_x = (pos_x == 65535) ? PANEL_MAX_X + 1 : pos_x;
+ text_nodes[i].pos_y = pos_y;
+ text_nodes[i].characterSize.height = is_small ? SMALL_TEXT_HEIGHT : MEDIUM_TEXT_HEIGHT;
+ text_nodes[i].characterSize.width = is_small ? SMALL_TEXT_WIDTH : MEDIUM_TEXT_WIDTH;
+ text_nodes[i].character_count = text_length;
+ text_nodes[i].is_deleted = false;
+ break;
+ }
+ }
+}
+
+void drawTextNodes()
+{
+ for (unsigned char i = 0; i < MAX_TEXT_NODES_COUNT; i++)
+ {
+ if (!text_nodes[i].is_deleted)
+ {
+ Cursor cursor;
+ cursor.x = text_nodes[i].pos_x;
+ cursor.y = text_nodes[i].pos_y;
+
+ for (unsigned char j = 0; j < text_nodes[i].character_count; j++)
+ {
+ char ch = text_nodes[i].content[j];
+ if (ch < '!' || ch > '~')
+ {
+ ch = ' ';
+ }
+ drawCharacter(font7x5[ch - '!'], text_nodes[i].characterSize.height, text_nodes[i].characterSize.width, text_nodes[i].color, &cursor);
+ }
+ }
+ }
+}
+
+// void scrollTextNodeByAmount(unsigned )
+
void setup()
{
Serial.begin(115200);
pixels.begin();
pixels.clear();
- drawCharacter(font7x5['A' - '!'], 7, 5, 0x00010101, &cursor1);
+
+ addNewTextNode("TEst", 0x0001700, 0, 0, true);
+ drawTextNodes();
pixels.show();
start_server();
}
void loop()
{
+ shiftGivenRectangle(0, 0, 23, 7, 1);
pixels.show();
handle_server();
}
\ No newline at end of file
diff --git a/structs.h b/structs.h
index 4307f43..7758a26 100644
--- a/structs.h
+++ b/structs.h
@@ -18,7 +18,7 @@ struct Pixel
uint32_t color;
};
-struct Text
+struct TextNode
{
char content[TEXT_MAX_LENGTH];
uint32_t color;
@@ -30,10 +30,11 @@ struct Text
unsigned short width;
} characterSize;
unsigned char character_count;
- bool deleted;
+ bool is_deleted;
+ bool is_scrolled;
- Text() : color(0), pos_x(0), pos_y(0), character_count(0), characterSize({7,5}), deleted(true) {}
+ TextNode() : color(0), pos_x(0), pos_y(0), character_count(0), characterSize({7,5}), is_deleted(true) {}
};
#endif // STRUCTS_H