scrolling workks without speed and some optimalization

This commit is contained in:
2026-01-30 09:17:06 +01:00
parent c5a15269c3
commit f669c2f292
2 changed files with 40 additions and 40 deletions
+12 -13
View File
@@ -31,7 +31,7 @@ short getTextNodeX2(TextNode *node)
void addNewTextNode void addNewTextNode
( (
char text[TEXT_MAX_LENGTH + 1], uint32_t color = 0x00010101, short pos_x = 0, short pos_y = 0, char text[TEXT_MAX_LENGTH + 1], uint32_t color = 0x00010101, short pos_x = 0, short pos_y = 0,
unsigned char scroll_slowness = 1, bool is_scrolling = true, bool is_small = true unsigned char scroll_slowness = 0, bool is_scrolling = true, bool is_small = true
) )
{ {
unsigned char text_length = strlen(text); unsigned char text_length = strlen(text);
@@ -58,16 +58,18 @@ void addNewTextNode
} }
} }
void scrollAllScrollableTexts(bool 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++)
{ {
if (!text_nodes[i].is_deleted) if (text_nodes[i].is_deleted || !text_nodes[i].is_scrolling) {continue;}
{ if (text_nodes[i].scroll_slowness < text_nodes[i].scroll_progress)
if(text_nodes[i].is_scrolling)
{ {
text_nodes[i].scroll_progress++;
continue;
}
text_nodes[i].scroll_progress = 0;<
short x1 = text_nodes[i].pos_x; short x1 = text_nodes[i].pos_x;
short x2 = getTextNodeX2(&text_nodes[i]); short x2 = getTextNodeX2(&text_nodes[i]);
if (split_scroll_mode || text_nodes[i].pos_y < 7) if (split_scroll_mode || text_nodes[i].pos_y < 7)
@@ -77,7 +79,7 @@ void scrollAllScrollableTexts(bool split_scroll_mode = false)
text_nodes[i].is_deleted = true; text_nodes[i].is_deleted = true;
continue; continue;
} }
text_nodes[i].pos_x -= text_nodes[i].scroll_slowness; text_nodes[i].pos_x--;
} }
else else
{ {
@@ -86,8 +88,7 @@ void scrollAllScrollableTexts(bool split_scroll_mode = false)
text_nodes[i].is_deleted = true; text_nodes[i].is_deleted = true;
continue; continue;
} }
text_nodes[i].pos_x += text_nodes[i].scroll_slowness; text_nodes[i].pos_x++;
}
} }
cursor.x = text_nodes[i].pos_x; cursor.x = text_nodes[i].pos_x;
@@ -100,12 +101,10 @@ void scrollAllScrollableTexts(bool split_scroll_mode = false)
{ {
ch = ' '; ch = ' ';
} }
drawCharacter(font7x5[ch - ' '], text_nodes[i].characterSize.height, text_nodes[i].characterSize.width, text_nodes[i].color, &cursor); drawCharacter(font7x5[ch - ' '], text_nodes[i].characterSize.height, text_nodes[i].characterSize.width, text_nodes[i].color, &cursor);
} }
} }
} }
}
void setup() void setup()
{ {
@@ -117,7 +116,6 @@ void setup()
addNewTextNode("NET", 0xFF050505); addNewTextNode("NET", 0xFF050505);
addNewTextNode("AWAIT", 0xFF050505, 0, 9); addNewTextNode("AWAIT", 0xFF050505, 0, 9);
scrollAllScrollableTexts();
pixels.show(); pixels.show();
start_server(); start_server();
@@ -129,7 +127,8 @@ void loop()
handle_server(); handle_server();
if (text_nodes[0].is_deleted && text_nodes[1].is_deleted) if (text_nodes[0].is_deleted && text_nodes[1].is_deleted)
{ {
addNewTextNode("test", 0xFF121212, (short)100); addNewTextNode("test", 0xFF121212, 49);
addNewTextNode("test", 0xFF121212, -30, 9, 10);
} }
scrollAllScrollableTexts(); scrollAllScrollableTexts();
pixels.show(); pixels.show();
+2 -1
View File
@@ -31,11 +31,12 @@ struct TextNode
} characterSize; } characterSize;
unsigned char character_count; unsigned char character_count;
unsigned char scroll_slowness; unsigned char scroll_slowness;
unsigned char scroll_progress;
bool is_deleted; bool is_deleted;
bool is_scrolling; bool is_scrolling;
TextNode() : color(0), pos_x(0), pos_y(0), character_count(0), scroll_slowness(1), characterSize({7,5}), is_deleted(true), is_scrolling() {} TextNode() : color(0), pos_x(0), pos_y(0), character_count(0), scroll_slowness(0), scroll_progress(0), characterSize({7,5}), is_deleted(true), is_scrolling() {}
}; };
#endif // STRUCTS_H #endif // STRUCTS_H