From e58dafad2bbdaa6cc4be256227b92f88c6c81796 Mon Sep 17 00:00:00 2001 From: ondra Date: Sun, 30 Jun 2024 16:51:06 +0200 Subject: [PATCH] blbuvzdor 2 - exit manual mode after 1 hour --- src/screens/app_gui.c | 8 ++++++++ src/screens/app_gui.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/screens/app_gui.c b/src/screens/app_gui.c index 9ac7c47..910591b 100644 --- a/src/screens/app_gui.c +++ b/src/screens/app_gui.c @@ -65,6 +65,7 @@ static void read_time_and_moisture() } else { uint8_t cur_wd = s_app.rtc_time.weekday; if (cur_wd != prev_wd) { + // Weekday change, decide now s_app.today_is_watering_day = false; uint8_t now_normalized = cur_wd + (cur_wd < s_app.last_watering_day_wd ? 7 : 0); uint8_t elapsed_days = now_normalized - s_app.last_watering_day_wd; @@ -143,6 +144,13 @@ void gui_loop_iter(GuiEvent message) } } + // exit manual mode after long time + if (s_app.screen == screen_manual_control) { + if ((tickNow - s_app.screen_open_time) >= (3600 * 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); diff --git a/src/screens/app_gui.h b/src/screens/app_gui.h index 08181f2..62ca2e0 100644 --- a/src/screens/app_gui.h +++ b/src/screens/app_gui.h @@ -79,7 +79,7 @@ struct State { uint16_t moisture_raw; uint16_t moisture_pt; struct rtc_time last_cycle_time; - bool cycle_time_checking; + bool cycle_time_checking; // TODO unclear what this does??? /// Repaint was requested from the screen code bool paint_needed;