Dispatch antiburn on connect #134

This commit is contained in:
fvanroie 2021-11-06 02:01:42 +01:00
parent 884a466ca9
commit 47eb19b9b2
3 changed files with 10 additions and 5 deletions

View File

@ -203,9 +203,9 @@ void hasp_set_antiburn(int32_t repeat_count, uint32_t period)
/**
* Check if Anti Burn-in protection is enabled
*/
bool hasp_get_antiburn()
hasp_event_t hasp_get_antiburn()
{
return antiburn_task != NULL;
return (antiburn_task != NULL) ? HASP_EVENT_ON : HASP_EVENT_OFF;
}
/**

View File

@ -69,7 +69,7 @@ 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_set_wakeup_touch(bool en);
bool hasp_get_antiburn();
hasp_event_t hasp_get_antiburn();
void hasp_set_antiburn(int32_t repeat_count,uint32_t period);
void hasp_init(void);

View File

@ -953,8 +953,12 @@ void dispatch_web_update(const char*, const char* espOtaUrl, uint8_t source)
void dispatch_antiburn(const char*, const char* payload, uint8_t source)
{
if(strlen(payload) > 0) {
bool state = Parser::is_true(payload); // ON, TRUE, YES or 1
hasp_set_antiburn(state ? 30 : 0, 1000); // ON = 25 cycles of 1000 milli seconds (i.e. 25 sec)
} else {
dispatch_state_antiburn(hasp_get_antiburn());
}
}
// restart the device
@ -1167,6 +1171,7 @@ void dispatch_current_state(uint8_t source)
dispatch_current_page();
dispatch_send_sensordata(NULL, NULL, source);
dispatch_send_discovery(NULL, NULL, source);
dispatch_state_antiburn(hasp_get_antiburn());
}
// Format filesystem and erase EEPROM