Fix backlight state not sent on first touch event

This commit is contained in:
fvanroie 2023-04-14 02:33:50 +02:00
parent 3855d32713
commit 75997bcde8
5 changed files with 27 additions and 26 deletions

View File

@ -158,7 +158,7 @@ void hasp_set_sleep_state(uint8_t state)
break;
case HASP_SLEEP_OFF:
hasp_set_sleep_offset(0);
hasp_set_wakeup_touch(false);
// hasp_set_wakeup_touch(false);
break;
default:
return;

View File

@ -1337,21 +1337,6 @@ void dispatch_calibrate(const char*, const char*, uint8_t source)
guiCalibrate();
}
void dispatch_wakeup()
{
if(hasp_get_sleep_state() == HASP_SLEEP_OFF) return;
hasp_set_sleep_state(HASP_SLEEP_OFF);
dispatch_idle_state(HASP_SLEEP_OFF);
}
void dispatch_wakeup_obsolete(const char* topic, const char*, uint8_t source)
{
LOG_WARNING(TAG_MSGR, F(D_ATTRIBUTE_OBSOLETE D_ATTRIBUTE_INSTEAD), topic,
"idle=off"); // TODO: obsolete wakeup
dispatch_wakeup();
hasp_set_wakeup_touch(false);
}
void dispatch_sleep(const char*, const char*, uint8_t source)
{
hasp_set_wakeup_touch(false);
@ -1385,6 +1370,20 @@ void dispatch_idle(const char*, const char* payload, uint8_t source)
dispatch_idle_state(hasp_get_sleep_state()); // always send the current state
}
void dispatch_wakeup(uint8_t source)
{
// if(hasp_get_sleep_state() == HASP_SLEEP_OFF) return;
dispatch_idle(NULL, "off", source);
}
void dispatch_wakeup_obsolete(const char* topic, const char*, uint8_t source)
{
LOG_WARNING(TAG_MSGR, F(D_ATTRIBUTE_OBSOLETE D_ATTRIBUTE_INSTEAD), topic,
"idle=off"); // TODO: obsolete wakeup
dispatch_wakeup(source);
hasp_set_wakeup_touch(false);
}
void dispatch_reboot(const char*, const char*, uint8_t source)
{
dispatch_reboot(true);

View File

@ -78,7 +78,7 @@ void dispatch_send_sensordata(const char*, const char*, uint8_t source);
void dispatch_idle_state(uint8_t state);
void dispatch_calibrate(const char*, const char*, uint8_t source);
void dispatch_antiburn(const char*, const char* payload, uint8_t source);
void dispatch_wakeup();
void dispatch_wakeup(uint8_t source);
void dispatch_run_script(const char*, const char* payload, uint8_t source);
void dispatch_config(const char* topic, const char* payload, uint8_t source);

View File

@ -377,12 +377,14 @@ void first_touch_event_handler(lv_obj_t* obj, lv_event_t event)
if(event == LV_EVENT_RELEASED) {
bool changed = hasp_stop_antiburn(); // Disable antiburn task
if(!haspDevice.get_backlight_power()) {
dispatch_backlight(NULL, "on", TAG_EVENT); // backlight on and also disable wakeup touch
hasp_set_wakeup_touch(false); // only disable wakeup touch
} else {
hasp_set_wakeup_touch(false); // only disable wakeup touch
}
/* if(!haspDevice.get_backlight_power()) { */
dispatch_backlight(NULL, "on", TAG_EVENT); // backlight on and also disable wakeup touch
hasp_set_wakeup_touch(false); // only disable wakeup touch
/* } else {
hasp_set_wakeup_touch(false); // only disable wakeup touch
}*/
hasp_update_sleep_state(); // wakeup, send Idle off
if(changed) dispatch_state_antiburn(hasp_get_antiburn()); // publish the new state

View File

@ -1274,15 +1274,15 @@ static void handleFileCreate()
}
}
if(webServer.hasArg(F("init"))) {
dispatch_wakeup();
dispatch_wakeup(TAG_HTTP);
hasp_init();
}
if(webServer.hasArg(F("load"))) {
dispatch_wakeup();
dispatch_wakeup(TAG_HTTP);
hasp_load_json();
}
if(webServer.hasArg(F("page"))) {
dispatch_wakeup();
dispatch_wakeup(TAG_HTTP);
dispatch_page(NULL, webServer.arg(F("page")).c_str(), TAG_HTTP);
// uint8_t pageid = atoi(webServer.arg(F("page")).c_str());
// dispatch_set_page(pageid, LV_SCR_LOAD_ANIM_NONE);