/** * TODO file description */ #ifndef ZAVLAHA_APP_GUI_H #define ZAVLAHA_APP_GUI_H #include #include #include #include "gui_event.h" #include "lcd/lcdbuf.h" #include "ds_rtc.h" // πŸŒ’πŸ…°πŸ…±πŸ…²πŸ…³βΆβ·βΈβΉβŠ›Β€β–Œβ†‘β†“βœ” /// Temporary scratch buffer extern char sbuf[100]; #define sbuf_len 100 extern struct LcdBuffer lcd; /** * Screen callback type. The event is either INIT, PAINT, or one of the input events. */ typedef void (*screen_t)(GuiEvent event); static inline uint32_t timestamp_ms() { return to_ms_since_boot(get_absolute_time()); } /** Input beep (push or knob turn) */ void input_sound_effect(); void gui_loop_iter(GuiEvent message); void gui_init(); /** Switch to a different screen. Handles initial push state handling (so release * does not cause a "click" event). * * @param pScreen - screen to switch to * @param init - call the INIT event immediately after */ void switch_screen(screen_t pScreen, bool init); void switch_to_subscreen(screen_t pScreen); void switch_to_parent_screen(screen_t pScreen); void request_paint(); // prototypes for screen handlers void screen_home(GuiEvent event); void screen_cyklus(GuiEvent event); extern struct AppConfig settings_scratch; void screen_settings(GuiEvent event); void screen_set_time(GuiEvent event); void screen_set_moisture_threshold(GuiEvent event); void screen_moisture_calib(GuiEvent event); void screen_delka_zalivky(GuiEvent event); void screen_kompenzace_tlaku(GuiEvent event); void screen_program_prehled(GuiEvent event); void screen_suche_dny(GuiEvent event); void screen_manual_control(GuiEvent event); uint8_t days_to_next_watering(); extern int pgm_edit_slot; void screen_program_edit(GuiEvent event); // XXX other prototypes void gui_read_moisture(); // This is actually the global app state! struct State { struct rtc_time rtc_time; uint16_t moisture_raw; uint16_t moisture_pt; struct rtc_time last_cycle_time; bool cycle_time_checking; // This is used to prevent cycle being started again and again during the same minute - it is cleared once the HH:MM time changes. /// Repaint was requested from the screen code bool paint_needed; /// Pointer to the currently active screen func screen_t screen; uint32_t last_10ms_time; uint32_t last_100ms_time; uint32_t last_1s_time; uint32_t screen_open_time; bool today_is_watering_day; uint8_t last_watering_day_wd; }; extern struct State s_app; #endif //ZAVLAHA_APP_GUI_H