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
+38 -39
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,51 +58,50 @@ 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 x2 = getTextNodeX2(&text_nodes[i]);
if (split_scroll_mode || text_nodes[i].pos_y < 7)
{
if (x2 < 0)
{ {
short x1 = text_nodes[i].pos_x; text_nodes[i].is_deleted = true;
short x2 = getTextNodeX2(&text_nodes[i]); continue;
if (split_scroll_mode || text_nodes[i].pos_y < 7)
{
if (x2 < 0)
{
text_nodes[i].is_deleted = true;
continue;
}
text_nodes[i].pos_x -= text_nodes[i].scroll_slowness;
}
else
{
if (x1 > PANEL_MAX_X)
{
text_nodes[i].is_deleted = true;
continue;
}
text_nodes[i].pos_x += text_nodes[i].scroll_slowness;
}
} }
text_nodes[i].pos_x--;
cursor.x = text_nodes[i].pos_x; }
cursor.y = text_nodes[i].pos_y; else
{
for (unsigned char j = 0; j < text_nodes[i].character_count; j++) if (x1 > PANEL_MAX_X)
{ {
char ch = text_nodes[i].content[j]; text_nodes[i].is_deleted = true;
if (ch < '!' || ch > '~') continue;
{
ch = ' ';
}
drawCharacter(font7x5[ch - ' '], text_nodes[i].characterSize.height, text_nodes[i].characterSize.width, text_nodes[i].color, &cursor);
} }
text_nodes[i].pos_x++;
}
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);
} }
} }
} }
@@ -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