#include #include "app_gui.h" #include "gui_event.h" #include "app_io.h" #include "app_config.h" static int phase = 0; static uint16_t sample_dry = 0; void screen_moisture_calib(GuiEvent event) { switch (event) { case GUI_EVENT_SCREEN_INIT: phase = 0; // pass through case GUI_EVENT_SCREEN_TICK_100MS: gui_read_moisture(); request_paint(); // will read new measurement break; case GUI_EVENT_PAINT: if (phase == 0) { LcdBuffer_Write(&lcd, 0, 0, "Dej čidlo do vyschlé"); LcdBuffer_Write(&lcd, 1, 0, "půdy (vlhkost 0%)"); } else { LcdBuffer_Write(&lcd, 0, 0, "Dej čidlo do mokré"); LcdBuffer_Write(&lcd, 1, 0, "půdy (vlhkost 100%)"); } snprintf(sbuf, sbuf_len, "Vlhkost %4d/4095", s_app.moisture_raw); LcdBuffer_Write(&lcd, 2, 0, sbuf); LcdBuffer_Write(&lcd, 3, 0, "🅳Zrušit 🅰Potvrdit"); break; case GUI_EVENT_KEY_A: // Confirm if (phase == 0) { sample_dry = s_app.moisture_raw; phase++; LcdBuffer_Clear(&lcd); // make sure there isnt overlap with previous step } else { settings_scratch.moisture_dry = sample_dry; settings_scratch.moisture_wet = s_app.moisture_raw; switch_to_parent_screen(screen_settings); } break; case GUI_EVENT_KEY_D: // CANCEL switch_to_parent_screen(screen_settings); break; } }