diff --git a/src/hasp/hasp.cpp b/src/hasp/hasp.cpp index 1b31c8b8..a378b75f 100644 --- a/src/hasp/hasp.cpp +++ b/src/hasp/hasp.cpp @@ -99,31 +99,38 @@ lv_font_t* hasp_get_font(uint8_t fontid) } } +static void hasp_send_idle_state() +{ + char payload[6]; + hasp_get_sleep_state(payload); + dispatch_send_idle_state(payload); +} + /** * Check if sleep state needs to be updated */ HASP_ATTRIBUTE_FAST_MEM void hasp_update_sleep_state() { uint32_t idle = lv_disp_get_inactive_time(lv_disp_get_default()) / 1000; + bool changed = false; if(sleepTimeLong > 0 && idle >= (sleepTimeShort + sleepTimeLong)) { if(hasp_sleep_state != HASP_SLEEP_LONG) { hasp_sleep_state = HASP_SLEEP_LONG; - dispatch_idle(NULL, NULL); + hasp_send_idle_state(); } } else if(sleepTimeShort > 0 && idle >= sleepTimeShort) { if(hasp_sleep_state != HASP_SLEEP_SHORT) { hasp_sleep_state = HASP_SLEEP_SHORT; - dispatch_idle(NULL, NULL); + hasp_send_idle_state(); } } else { if(hasp_sleep_state != HASP_SLEEP_OFF) { hasp_sleep_state = HASP_SLEEP_OFF; - dispatch_idle(NULL, NULL); + hasp_disable_wakeup_touch(); + hasp_send_idle_state(); } } - - // return (hasp_sleep_state != HASP_SLEEP_OFF); } void hasp_set_sleep_state(uint8_t state) diff --git a/src/hasp/hasp_dispatch.h b/src/hasp/hasp_dispatch.h index d0912870..9ba7d88a 100644 --- a/src/hasp/hasp_dispatch.h +++ b/src/hasp/hasp_dispatch.h @@ -71,6 +71,7 @@ void dispatch_web_update(const char*, const char* espOtaUrl); void dispatch_statusupdate(const char*, const char*); void dispatch_send_discovery(const char*, const char*); void dispatch_idle(const char*, const char*); +void hasp_send_idle_state(const char* payload); void dispatch_calibrate(const char*, const char*); void dispatch_wakeup(const char*, const char*);