Require a wakeup touch when backlight is off

This commit is contained in:
fvanroie 2021-02-11 02:56:40 +01:00
parent 72a9afd6a9
commit 3c92b61cfa
4 changed files with 16 additions and 2 deletions

View File

@ -127,6 +127,13 @@ bool hasp_update_sleep_state()
return (hasp_sleep_state != HASP_SLEEP_OFF);
}
void hasp_enable_wakeup_touch()
{
LOG_VERBOSE(TAG_HASP,F("Wakeup touch enabled"));
lv_obj_set_click(lv_disp_get_layer_sys(NULL), true); // enable first touch
lv_obj_set_event_cb(lv_disp_get_layer_sys(NULL), wakeup_event_handler);
}
/**
* Return the sleep times
*/

View File

@ -73,6 +73,7 @@ lv_font_t * hasp_get_font(uint8_t fontid);
bool hasp_update_sleep_state();
void hasp_get_sleep_time(uint16_t & short_time, uint16_t & long_time);
void hasp_set_sleep_time(uint16_t short_time, uint16_t long_time);
void hasp_enable_wakeup_touch();
/**********************
* MACROS

View File

@ -348,8 +348,12 @@ void generic_event_handler(lv_obj_t * obj, lv_event_t event)
void wakeup_event_handler(lv_obj_t * obj, lv_event_t event)
{
if(obj == lv_disp_get_layer_sys(NULL)) {
hasp_update_sleep_state(); // wakeup?
lv_obj_set_click(obj, false); // disable fist click
hasp_update_sleep_state(); // wakeup?
if(event == LV_EVENT_CLICKED) {
lv_obj_set_click(obj, false); // disable first touch
LOG_VERBOSE(TAG_HASP, F("Wakeup touch disabled"));
}
}
}

View File

@ -448,6 +448,8 @@ void guiSetBacklight(bool lighton)
{
guiBacklightIsOn = lighton;
if(!lighton) hasp_enable_wakeup_touch();
if(guiBacklightPin >= 0) {
#if defined(ARDUINO_ARCH_ESP32)