mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-26 20:56:37 +00:00
Add hasp_send_idle_state and hasp_send_idle_state
This commit is contained in:
parent
702e67078a
commit
c5db446925
@ -99,31 +99,38 @@ lv_font_t* hasp_get_font(uint8_t fontid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void hasp_send_idle_state()
|
||||||
|
{
|
||||||
|
char payload[6];
|
||||||
|
hasp_get_sleep_state(payload);
|
||||||
|
dispatch_send_idle_state(payload);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if sleep state needs to be updated
|
* Check if sleep state needs to be updated
|
||||||
*/
|
*/
|
||||||
HASP_ATTRIBUTE_FAST_MEM void hasp_update_sleep_state()
|
HASP_ATTRIBUTE_FAST_MEM void hasp_update_sleep_state()
|
||||||
{
|
{
|
||||||
uint32_t idle = lv_disp_get_inactive_time(lv_disp_get_default()) / 1000;
|
uint32_t idle = lv_disp_get_inactive_time(lv_disp_get_default()) / 1000;
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
if(sleepTimeLong > 0 && idle >= (sleepTimeShort + sleepTimeLong)) {
|
if(sleepTimeLong > 0 && idle >= (sleepTimeShort + sleepTimeLong)) {
|
||||||
if(hasp_sleep_state != HASP_SLEEP_LONG) {
|
if(hasp_sleep_state != HASP_SLEEP_LONG) {
|
||||||
hasp_sleep_state = HASP_SLEEP_LONG;
|
hasp_sleep_state = HASP_SLEEP_LONG;
|
||||||
dispatch_idle(NULL, NULL);
|
hasp_send_idle_state();
|
||||||
}
|
}
|
||||||
} else if(sleepTimeShort > 0 && idle >= sleepTimeShort) {
|
} else if(sleepTimeShort > 0 && idle >= sleepTimeShort) {
|
||||||
if(hasp_sleep_state != HASP_SLEEP_SHORT) {
|
if(hasp_sleep_state != HASP_SLEEP_SHORT) {
|
||||||
hasp_sleep_state = HASP_SLEEP_SHORT;
|
hasp_sleep_state = HASP_SLEEP_SHORT;
|
||||||
dispatch_idle(NULL, NULL);
|
hasp_send_idle_state();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(hasp_sleep_state != HASP_SLEEP_OFF) {
|
if(hasp_sleep_state != HASP_SLEEP_OFF) {
|
||||||
hasp_sleep_state = HASP_SLEEP_OFF;
|
hasp_sleep_state = HASP_SLEEP_OFF;
|
||||||
dispatch_idle(NULL, NULL);
|
hasp_disable_wakeup_touch();
|
||||||
|
hasp_send_idle_state();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// return (hasp_sleep_state != HASP_SLEEP_OFF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void hasp_set_sleep_state(uint8_t state)
|
void hasp_set_sleep_state(uint8_t state)
|
||||||
|
@ -71,6 +71,7 @@ void dispatch_web_update(const char*, const char* espOtaUrl);
|
|||||||
void dispatch_statusupdate(const char*, const char*);
|
void dispatch_statusupdate(const char*, const char*);
|
||||||
void dispatch_send_discovery(const char*, const char*);
|
void dispatch_send_discovery(const char*, const char*);
|
||||||
void dispatch_idle(const char*, const char*);
|
void dispatch_idle(const char*, const char*);
|
||||||
|
void hasp_send_idle_state(const char* payload);
|
||||||
void dispatch_calibrate(const char*, const char*);
|
void dispatch_calibrate(const char*, const char*);
|
||||||
void dispatch_wakeup(const char*, const char*);
|
void dispatch_wakeup(const char*, const char*);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user