scrolling workks without speed and some optimalization
This commit is contained in:
@@ -31,7 +31,7 @@ short getTextNodeX2(TextNode *node)
|
||||
void addNewTextNode
|
||||
(
|
||||
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);
|
||||
@@ -58,16 +58,18 @@ void addNewTextNode
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void scrollAllScrollableTexts(bool split_scroll_mode = false)
|
||||
{
|
||||
for (unsigned char i = 0; i < MAX_TEXT_NODES_COUNT; i++)
|
||||
{
|
||||
if (!text_nodes[i].is_deleted)
|
||||
{
|
||||
if(text_nodes[i].is_scrolling)
|
||||
if (text_nodes[i].is_deleted || !text_nodes[i].is_scrolling) {continue;}
|
||||
if (text_nodes[i].scroll_slowness < text_nodes[i].scroll_progress)
|
||||
{
|
||||
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)
|
||||
@@ -77,7 +79,7 @@ void scrollAllScrollableTexts(bool split_scroll_mode = false)
|
||||
text_nodes[i].is_deleted = true;
|
||||
continue;
|
||||
}
|
||||
text_nodes[i].pos_x -= text_nodes[i].scroll_slowness;
|
||||
text_nodes[i].pos_x--;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -86,8 +88,7 @@ void scrollAllScrollableTexts(bool split_scroll_mode = false)
|
||||
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;
|
||||
@@ -100,11 +101,9 @@ void scrollAllScrollableTexts(bool split_scroll_mode = false)
|
||||
{
|
||||
ch = ' ';
|
||||
}
|
||||
|
||||
drawCharacter(font7x5[ch - ' '], text_nodes[i].characterSize.height, text_nodes[i].characterSize.width, text_nodes[i].color, &cursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
@@ -117,7 +116,6 @@ void setup()
|
||||
|
||||
addNewTextNode("NET", 0xFF050505);
|
||||
addNewTextNode("AWAIT", 0xFF050505, 0, 9);
|
||||
scrollAllScrollableTexts();
|
||||
|
||||
pixels.show();
|
||||
start_server();
|
||||
@@ -129,7 +127,8 @@ void loop()
|
||||
handle_server();
|
||||
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();
|
||||
pixels.show();
|
||||
|
||||
@@ -31,11 +31,12 @@ struct TextNode
|
||||
} characterSize;
|
||||
unsigned char character_count;
|
||||
unsigned char scroll_slowness;
|
||||
unsigned char scroll_progress;
|
||||
bool is_deleted;
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user