diff --git a/openrtx/src/ui.c b/openrtx/src/ui.c index 82dd5306..107b8053 100644 --- a/openrtx/src/ui.c +++ b/openrtx/src/ui.c @@ -90,6 +90,7 @@ typedef struct layout_t layout_t layout; bool layout_ready = false; color_t color_white = {255, 255, 255}; +bool first_run = true; layout_t _ui_calculateLayout() { @@ -239,39 +240,39 @@ void ui_main() { OS_ERR os_err; - // Init the graphic stack - gfx_init(); - platform_setBacklightLevel(255); - - // Print splash screen - point_t splash_origin = {0, SCREEN_HEIGHT / 2}; - color_t color_yellow_fab413 = {250, 180, 19}; - char *splash_buf = "OpenRTX"; - gfx_clearScreen(); - gfx_print(splash_origin, splash_buf, FONT_SIZE_4, TEXT_ALIGN_CENTER, color_yellow_fab413); - gfx_render(); - while(gfx_renderingInProgress()); - OSTimeDlyHMSM(0u, 0u, 1u, 0u, OS_OPT_TIME_HMSM_STRICT, &os_err); - - // Clear screen - gfx_clearScreen(); - gfx_render(); - while(gfx_renderingInProgress()); - - // UI update infinite loop - while(1) + if(first_run) { - state_t state = state_update(); - uint32_t keys = kbd_getKeys(); - bool renderNeeded = ui_update(state, keys); - if(renderNeeded) - { - gfx_render(); - while(gfx_renderingInProgress()); - } - OSTimeDlyHMSM(0u, 0u, 0u, 100u, OS_OPT_TIME_HMSM_STRICT, &os_err); + first_run = false; + // Init the graphic stack + gfx_init(); + platform_setBacklightLevel(255); + + // Print splash screen + point_t splash_origin = {0, SCREEN_HEIGHT / 2}; + color_t color_yellow_fab413 = {250, 180, 19}; + char *splash_buf = "OpenRTX"; + gfx_clearScreen(); + gfx_print(splash_origin, splash_buf, FONT_SIZE_4, TEXT_ALIGN_CENTER, color_yellow_fab413); + gfx_render(); + while(gfx_renderingInProgress()); + OSTimeDlyHMSM(0u, 0u, 1u, 0u, OS_OPT_TIME_HMSM_STRICT, &os_err); + + // Clear screen + gfx_clearScreen(); + gfx_render(); + while(gfx_renderingInProgress()); + } + + state_t state = state_update(); + uint32_t keys = kbd_getKeys(); + bool renderNeeded = ui_update(state, keys); + if(renderNeeded) + { + gfx_render(); + while(gfx_renderingInProgress()); } } + bool ui_update(state_t state, uint32_t keys) { if(!layout_ready)