/** * TODO file description */ // // Created by MightyPork on 2023/04/09. // #include #include #include "app_gui.h" #include "gui_event.h" #include "ds_rtc.h" #include "app_io.h" static uint32_t last_time = 0; static struct rtc_time rtc_time = {}; static uint16_t moisture = 0; static uint8_t showbuf_wp = 0; void screen_home(GuiEvent event) { uint32_t now = timestamp(); uint32_t elapsed = now - last_time; switch (event) { case GUI_EVENT_SCREEN_INIT: // pass case GUI_EVENT_SCREEN_TICK: if (elapsed >= 100) { last_time = now; rtc_get_time(&rtc_time); moisture = moisture_read(); request_paint(); } break; case GUI_EVENT_PAINT:; // TODO uint32_t moisture_pt = ((uint32_t)(moisture > 2800 ? 0 : (2800 - moisture)) * 100) / (2800 - 1600); sprintf(stmp, " %2d:%02d:%02d %3d%% 🌢 ", rtc_time.hour, rtc_time.minute, rtc_time.second, moisture_pt); LcdBuffer_Write(&lcd, 0, 0, stmp); LcdBuffer_Write(&lcd, 1, 0, "Plán. závlaha 7:15"); LcdBuffer_Write(&lcd, 2, 0, "❶Spustit ❷Přeskočit"); LcdBuffer_Write(&lcd, 3, 0, "🅰Nastavení"); break; case GUI_EVENT_KEY_1: // TODO switch_screen(screen_cyklus, true); // fake cycle break; case GUI_EVENT_KEY_2: // TODO break; case GUI_EVENT_KEY_A: switch_screen(screen_settings, true); break; } }