handling nodes almoast works

This commit is contained in:
2026-01-29 10:56:20 +01:00
parent 62be6be733
commit 365cae1551
+32 -6
View File
@@ -14,8 +14,18 @@
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
TextNode text_nodes[MAX_TEXT_NODES_COUNT]; TextNode text_nodes[MAX_TEXT_NODES_COUNT];
Cursor cursor; Cursor cursor;
unsigned short ever_created_text_nodes = 0;
unsigned short getTextNodeY2(TextNode *node)
{
return node.pos_y + node.characterSize.height - 1;
}
unsigned short getTextNodeX2(TextNode *node)
{
return node.pos_x + node.characterSize.width * node.character_count + node.character_count - 1;
}
void addNewTextNode void addNewTextNode
( (
@@ -31,14 +41,24 @@ void addNewTextNode
{ {
strncpy(text_nodes[i].content, text, TEXT_MAX_LENGTH); strncpy(text_nodes[i].content, text, TEXT_MAX_LENGTH);
text_nodes[i].color = color; text_nodes[i].color = color;
text_nodes[i].pos_x = (pos_x == 65535) ? PANEL_MAX_X + 1 : pos_x;
text_nodes[i].pos_x = pos_x;
text_nodes[i].pos_y = pos_y; text_nodes[i].pos_y = pos_y;
const unsigned short = getTextNodeX2(&(text_nodes)[i]);
if (pos_x2 > PANEL_MAX_X)
{
text_node[i].pos_x -= pos_x2 - PANEL_MAX_X;
}
text_nodes[i].characterSize.height = is_small ? SMALL_TEXT_HEIGHT : MEDIUM_TEXT_HEIGHT; 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].characterSize.width = is_small ? SMALL_TEXT_WIDTH : MEDIUM_TEXT_WIDTH;
text_nodes[i].character_count = text_length; text_nodes[i].character_count = text_length;
text_nodes[i].scroll_slowness = scroll_slowness; text_nodes[i].scroll_slowness = scroll_slowness;
text_nodes[i].is_scrolling = is_scrolling; text_nodes[i].is_scrolling = is_scrolling;
text_nodes[i].is_deleted = false; text_nodes[i].is_deleted = false;
ever_created_text_nodes++;
break; break;
} }
} }
@@ -71,7 +91,7 @@ void drawTextNodes(bool reset_cursor = true)
} }
} }
void scrollAllScrollableTexts(split_scroll_mode = false) void scrollAllScrollableTexts(bool split_scroll_mode = false)
{ {
for (unsigned char i = 0; i < MAX_TEXT_NODES_COUNT; i++) for (unsigned char i = 0; i < MAX_TEXT_NODES_COUNT; i++)
{ {
@@ -79,11 +99,11 @@ void scrollAllScrollableTexts(split_scroll_mode = false)
{ {
short x1 = text_nodes[i].pos_x; short x1 = text_nodes[i].pos_x;
short y1 = text_nodes[i].pos_y; short y1 = text_nodes[i].pos_y;
short x2 = text_nodes[i].pos_x + text_nodes[i].characterSize.width * text_nodes[i].character_count + text_nodes[i].character_count - 1; short x2 = getTextNodeX2(&text_nodes[i]);
short y2 = text_nodes[i].pos_y + text_nodes[i].characterSize.height - 1; short y2 = getTextNodeY2(&text_nodes[i]);
if (split_scroll_mode || text_nodes[i].pos_y < 7) if (split_scroll_mode || text_nodes[i].pos_y < 7)
{ {
if (x2 < 0) if (x2 == 0)
{ {
text_nodes[i].is_deleted = true; text_nodes[i].is_deleted = true;
continue; continue;
@@ -108,6 +128,7 @@ void scrollAllScrollableTexts(split_scroll_mode = false)
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
Serial.println("----------------------------------------------------");
pixels.begin(); pixels.begin();
pixels.clear(); pixels.clear();
@@ -125,4 +146,9 @@ void loop()
scrollAllScrollableTexts(); scrollAllScrollableTexts();
pixels.show(); pixels.show();
handle_server(); handle_server();
if (text_nodes[0].is_deleted && text_nodes[1].is_deleted)
{
addNewTextNode("test", 0xFF121212);
drawTextNodes();
}
} }