mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 21:26:43 +00:00
Fix wakeup touch
This commit is contained in:
parent
28c41ac889
commit
aac809e478
@ -137,6 +137,12 @@ void hasp_enable_wakeup_touch()
|
||||
lv_obj_set_event_cb(lv_disp_get_layer_sys(NULL), wakeup_event_handler);
|
||||
}
|
||||
|
||||
void hasp_disable_wakeup_touch()
|
||||
{
|
||||
LOG_VERBOSE(TAG_HASP, F("Wakeup touch disabled"));
|
||||
lv_obj_set_click(lv_disp_get_layer_sys(NULL), false); // disable first touch
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the sleep times
|
||||
*/
|
||||
|
@ -81,6 +81,7 @@ 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();
|
||||
void hasp_disable_wakeup_touch();
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -43,7 +43,7 @@ dispatch_conf_t dispatch_setings = {.teleperiod = 10};
|
||||
|
||||
uint32_t dispatchLastMillis;
|
||||
uint8_t nCommands = 0;
|
||||
haspCommand_t commands[17];
|
||||
haspCommand_t commands[18];
|
||||
|
||||
struct moodlight_t
|
||||
{
|
||||
@ -952,7 +952,17 @@ void dispatch_moodlight(const char* topic, const char* payload)
|
||||
void dispatch_backlight(const char*, const char* payload)
|
||||
{
|
||||
// Set the current state
|
||||
if(strlen(payload) != 0) haspDevice.set_backlight_power(Utilities::is_true(payload));
|
||||
if(strlen(payload) != 0) {
|
||||
bool power = Utilities::is_true(payload);
|
||||
|
||||
if(haspDevice.get_backlight_power() != power) {
|
||||
haspDevice.set_backlight_power(power);
|
||||
if(power)
|
||||
hasp_disable_wakeup_touch();
|
||||
else
|
||||
hasp_enable_wakeup_touch();
|
||||
}
|
||||
}
|
||||
|
||||
// Return the current state
|
||||
char topic[8];
|
||||
@ -1067,6 +1077,12 @@ void dispatch_calibrate(const char* topic = NULL, const char* payload = NULL)
|
||||
void dispatch_wakeup(const char*, const char*)
|
||||
{
|
||||
lv_disp_trig_activity(NULL);
|
||||
hasp_disable_wakeup_touch();
|
||||
}
|
||||
|
||||
void dispatch_sleep(const char*, const char*)
|
||||
{
|
||||
hasp_enable_wakeup_touch();
|
||||
}
|
||||
|
||||
void dispatch_reboot(const char*, const char*)
|
||||
@ -1105,6 +1121,7 @@ void dispatchSetup()
|
||||
dispatch_add_command(PSTR("json"), dispatch_parse_json);
|
||||
dispatch_add_command(PSTR("page"), dispatch_page);
|
||||
dispatch_add_command(PSTR("wakeup"), dispatch_wakeup);
|
||||
dispatch_add_command(PSTR("sleep"), dispatch_sleep);
|
||||
dispatch_add_command(PSTR("statusupdate"), dispatch_output_statusupdate);
|
||||
dispatch_add_command(PSTR("clearpage"), dispatch_clear_page);
|
||||
dispatch_add_command(PSTR("jsonl"), dispatch_parse_jsonl);
|
||||
|
@ -52,7 +52,7 @@ void dispatch_page_next();
|
||||
void dispatch_page_prev();
|
||||
|
||||
void dispatch_dim(const char* level);
|
||||
void dispatch_backlight(const char* payload);
|
||||
void dispatch_backlight(const char*, const char* payload);
|
||||
|
||||
void dispatch_web_update(const char* espOtaUrl);
|
||||
void dispatch_reboot(bool saveConfig);
|
||||
|
@ -276,12 +276,12 @@ void hasp_send_obj_attribute_color(lv_obj_t* obj, const char* attribute, lv_colo
|
||||
*/
|
||||
void wakeup_event_handler(lv_obj_t* obj, lv_event_t event)
|
||||
{
|
||||
if(obj == lv_disp_get_layer_sys(NULL)) {
|
||||
if(event == LV_EVENT_RELEASED && obj == lv_disp_get_layer_sys(NULL)) {
|
||||
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"));
|
||||
if(!haspDevice.get_backlight_power())
|
||||
dispatch_backlight(NULL, "1"); // backlight on and also disable wakeup touch
|
||||
else {
|
||||
hasp_disable_wakeup_touch(); // only disable wakeup touch
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user