Change to hasp_set_wakeup_touch #134

This commit is contained in:
fvanroie 2021-09-27 13:44:54 +02:00
parent 53b093a245
commit 389ab10a9b
4 changed files with 15 additions and 13 deletions

View File

@ -146,13 +146,14 @@ void hasp_get_sleep_state(char* payload)
}
}
/* ****** Anti Burn-in protection ******* */
/**
* Anti Burn-in protection
*/
static lv_task_t* anti_burnin_task;
void hasp_anti_burnin_cb(lv_task_t* task)
{
lv_color_t color[6] = {LV_COLOR_WHITE, LV_COLOR_BLACK, LV_COLOR_RED, LV_COLOR_LIME, LV_COLOR_BLUE};
lv_color_t color[6] = {LV_COLOR_BLACK, LV_COLOR_WHITE, LV_COLOR_RED, LV_COLOR_LIME, LV_COLOR_BLUE};
lv_obj_set_style_local_bg_color(lv_disp_get_layer_sys(NULL), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT,
color[task->repeat_count % 5]);
@ -163,6 +164,9 @@ void hasp_anti_burnin_cb(lv_task_t* task)
}
}
/**
* Enable/Disable Anti Burn-in protection
*/
void hasp_set_anti_burnin(bool en)
{
lv_obj_t* layer = lv_disp_get_layer_sys(NULL);

View File

@ -68,8 +68,8 @@ void hasp_get_sleep_state(char* payload);
void hasp_set_sleep_state(uint8_t 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();
void hasp_set_wakeup_touch(bool en);
void hasp_set_anti_burnin(bool en);
void hasp_init(void);
void hasp_load_json(void);

View File

@ -914,10 +914,7 @@ void dispatch_backlight(const char*, const char* payload, uint8_t source)
// toggle power and wakeup touch if changed
if(haspDevice.get_backlight_power() != power) {
haspDevice.set_backlight_power(power);
if(power)
hasp_disable_wakeup_touch();
else
hasp_enable_wakeup_touch();
hasp_set_wakeup_touch(!power);
}
// Return the current state
@ -1011,6 +1008,7 @@ void dispatch_send_sensordata(const char*, const char*, uint8_t source)
char data[1024];
size_t len = serializeJson(doc, data);
(void)len; // unused
switch(mqtt_send_state(MQTT_TOPIC_SENSORS, data)) {
case MQTT_ERR_OK:
@ -1165,12 +1163,12 @@ 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 dim, light and brightness
lv_disp_trig_activity(NULL);
hasp_disable_wakeup_touch();
hasp_set_wakeup_touch(false);
}
void dispatch_sleep(const char*, const char*, uint8_t source)
{
hasp_enable_wakeup_touch();
hasp_set_wakeup_touch(false);
}
void dispatch_idle(const char*, const char* payload, uint8_t source)
@ -1180,7 +1178,7 @@ void dispatch_idle(const char*, const char* payload, uint8_t source)
// idle off command
if(payload && strlen(payload) && !Parser::is_true(payload)) {
hasp_disable_wakeup_touch();
hasp_set_wakeup_touch(false);
hasp_set_sleep_state(HASP_SLEEP_OFF);
lv_disp_trig_activity(NULL);
}

View File

@ -320,7 +320,7 @@ void wakeup_event_handler(lv_obj_t* obj, lv_event_t event)
if(!haspDevice.get_backlight_power()) {
dispatch_backlight(NULL, "on", TAG_EVENT); // backlight on and also disable wakeup touch
}
hasp_disable_wakeup_touch(); // only disable wakeup touch
hasp_set_wakeup_touch(false); // only disable wakeup touch
}
}