app: add scrolling text animation

This commit is contained in:
King Kévin 2022-05-26 10:39:03 +02:00
parent 5e688d467d
commit beb6d33f85
1 changed files with 10 additions and 0 deletions

View File

@ -879,11 +879,14 @@ void main(void)
rgbmatrix_puts(1, 1, "DACHBODEN", FONT_KING10, false, true, false);
rgbmatrix_puts(1, 12, "ZEIT", FONT_KING10, false, true, true);
rgbmatrix_puts(1, 23, "MASCHINE", FONT_KING10, true, true, false);
sleep_ms(3000); // show the text for a tiny bit
// start main loop
bool action = false; // if an action has been performed don't go to sleep
button_flag = false; // reset button flag
led_on(); // switch LED to indicate booting completed
const char* scroll_text = "DACHBODEN ZEITMASCHINE";
int16_t scroll_pos = 64;
while (true) { // infinite loop
iwdg_reset(); // kick the dog
if (user_input_available) { // user input is available
@ -894,6 +897,13 @@ void main(void)
}
if (wakeup_flag) { // time to do periodic checks
wakeup_flag = false; // clear flag
rgbmatrix_clear();
rgbmatrix_puts(scroll_pos, 8, scroll_text, FONT_KING14, true, true, true);
if (scroll_pos < -1 * (int16_t)strlen(scroll_text) * (fonts[FONT_KING14].width + 1)) {
scroll_pos = 64;
} else {
scroll_pos -= 1;
}
}
if (second_flag) { // one second passed
second_flag = false; // clear flag