|
|
|
@ -5,8 +5,9 @@ |
|
|
|
|
#include <stdbool.h> |
|
|
|
|
#include <string.h> |
|
|
|
|
#include "app_gui.h" |
|
|
|
|
#include "../lcd/lcdbuf.h" |
|
|
|
|
#include "lcd/lcdbuf.h" |
|
|
|
|
#include "lcd.h" |
|
|
|
|
#include "app_config.h" |
|
|
|
|
|
|
|
|
|
struct State s_app = {}; |
|
|
|
|
|
|
|
|
@ -26,18 +27,38 @@ char sbuf[100]; |
|
|
|
|
void gui_init() |
|
|
|
|
{ |
|
|
|
|
switch_screen(screen_home, true); |
|
|
|
|
s_app.last_tick_time = timestamp(); |
|
|
|
|
rtc_get_time(&s_app.rtc_time); |
|
|
|
|
|
|
|
|
|
LcdBuffer_Init(&lcd, CGROM_A00, CGRAM_CZ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void gui_loop_iter(GuiEvent message) { |
|
|
|
|
uint32_t tickNow = timestamp(); |
|
|
|
|
uint32_t tickNow = timestamp_ms(); |
|
|
|
|
|
|
|
|
|
// screen auto-close
|
|
|
|
|
if (s_app.screen != screen_home && s_app.screen != screen_cyklus) { |
|
|
|
|
if ((tickNow - s_app.screen_open_time) >= (MENU_AUTOEXIT_TIME_S * 1000)) { |
|
|
|
|
switch_screen(screen_home, true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Read RTC every second
|
|
|
|
|
if (tickNow - s_app.last_1s_time >= 1000) { |
|
|
|
|
s_app.screen(GUI_EVENT_SCREEN_TICK_1S); |
|
|
|
|
rtc_get_time(&s_app.rtc_time); // now is a good time to update timestamp - we could just increment it though
|
|
|
|
|
s_app.last_1s_time = tickNow; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 100ms tick event
|
|
|
|
|
if (tickNow - s_app.last_100ms_time >= 100) { |
|
|
|
|
s_app.screen(GUI_EVENT_SCREEN_TICK_100MS); |
|
|
|
|
s_app.last_100ms_time = tickNow; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 10ms tick event
|
|
|
|
|
if (tickNow - s_app.last_tick_time > 10) { |
|
|
|
|
if (tickNow - s_app.last_10ms_time >= 10) { |
|
|
|
|
s_app.screen(GUI_EVENT_SCREEN_TICK_10MS); |
|
|
|
|
s_app.last_tick_time = tickNow; |
|
|
|
|
s_app.last_10ms_time = tickNow; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (message != GUI_EVENT_NONE) { |
|
|
|
@ -68,12 +89,18 @@ void switch_screen(screen_t pScreen, bool init) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
s_app.screen_open_time = timestamp_ms(); |
|
|
|
|
s_app.screen = pScreen; |
|
|
|
|
|
|
|
|
|
LcdBuffer_Clear(&lcd); |
|
|
|
|
LcdBuffer_SetCursor(&lcd, 0, 0, CURSOR_NONE); // always start with a hidden cursor. If the page wants a visible cursor, it should do that in PAINT
|
|
|
|
|
request_paint(); |
|
|
|
|
|
|
|
|
|
// Reset the timers, so the screen has nicely aligned events
|
|
|
|
|
s_app.last_10ms_time = s_app.last_100ms_time = s_app.last_1s_time = timestamp_ms(); |
|
|
|
|
// also read time so we have the latest greatest
|
|
|
|
|
rtc_get_time(&s_app.rtc_time); |
|
|
|
|
|
|
|
|
|
if (init) { |
|
|
|
|
pScreen(GUI_EVENT_SCREEN_INIT); |
|
|
|
|
} |
|
|
|
|