mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 05:06:44 +00:00
Fix idle state wonkiness
This commit is contained in:
parent
fe5e80529a
commit
8c2fbe9c4b
@ -114,13 +114,13 @@ bool IRAM_ATTR hasp_update_sleep_state()
|
|||||||
{
|
{
|
||||||
uint32_t idle = lv_disp_get_inactive_time(NULL);
|
uint32_t idle = lv_disp_get_inactive_time(NULL);
|
||||||
|
|
||||||
if(idle >= (sleepTimeShort + sleepTimeLong) * 1000U) {
|
if(sleepTimeLong > 0 && idle >= (sleepTimeShort + sleepTimeLong) * 1000U) {
|
||||||
if(hasp_sleep_state != HASP_SLEEP_LONG && sleepTimeLong > 0) {
|
if(hasp_sleep_state != HASP_SLEEP_LONG) {
|
||||||
dispatch_output_idle_state(HASP_SLEEP_LONG);
|
dispatch_output_idle_state(HASP_SLEEP_LONG);
|
||||||
hasp_sleep_state = HASP_SLEEP_LONG;
|
hasp_sleep_state = HASP_SLEEP_LONG;
|
||||||
}
|
}
|
||||||
} else if(idle >= sleepTimeShort * 1000U) {
|
} else if(sleepTimeShort > 0 && idle >= sleepTimeShort * 1000U) {
|
||||||
if(hasp_sleep_state != HASP_SLEEP_SHORT && sleepTimeShort > 0) {
|
if(hasp_sleep_state != HASP_SLEEP_SHORT) {
|
||||||
dispatch_output_idle_state(HASP_SLEEP_SHORT);
|
dispatch_output_idle_state(HASP_SLEEP_SHORT);
|
||||||
hasp_sleep_state = HASP_SLEEP_SHORT;
|
hasp_sleep_state = HASP_SLEEP_SHORT;
|
||||||
}
|
}
|
||||||
@ -134,6 +134,24 @@ bool IRAM_ATTR hasp_update_sleep_state()
|
|||||||
return (hasp_sleep_state != HASP_SLEEP_OFF);
|
return (hasp_sleep_state != HASP_SLEEP_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the sleep times
|
||||||
|
*/
|
||||||
|
void hasp_get_sleep_time(uint16_t & short_time, uint16_t & long_time)
|
||||||
|
{
|
||||||
|
short_time = sleepTimeShort;
|
||||||
|
long_time = sleepTimeLong;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the sleep times
|
||||||
|
*/
|
||||||
|
void hasp_set_sleep_time(uint16_t short_time, uint16_t long_time)
|
||||||
|
{
|
||||||
|
sleepTimeShort = short_time;
|
||||||
|
sleepTimeLong = long_time;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if we went to sleep, wake up is handled in the event handlers
|
* Checks if we went to sleep, wake up is handled in the event handlers
|
||||||
*/
|
*/
|
||||||
|
@ -71,6 +71,8 @@ bool haspSetConfig(const JsonObject & settings);
|
|||||||
lv_font_t * hasp_get_font(uint8_t fontid);
|
lv_font_t * hasp_get_font(uint8_t fontid);
|
||||||
|
|
||||||
bool IRAM_ATTR hasp_update_sleep_state();
|
bool IRAM_ATTR 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_wakeup(void);
|
void hasp_wakeup(void);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
|
@ -55,8 +55,6 @@ static bool guiShowPointer = false;
|
|||||||
static bool guiBacklightIsOn = true;
|
static bool guiBacklightIsOn = true;
|
||||||
static int8_t guiDimLevel = -1;
|
static int8_t guiDimLevel = -1;
|
||||||
static int8_t guiBacklightPin = TFT_BCKL;
|
static int8_t guiBacklightPin = TFT_BCKL;
|
||||||
static uint16_t guiSleepTime1 = 60; // 1 second resolution
|
|
||||||
static uint16_t guiSleepTime2 = 120; // 1 second resolution
|
|
||||||
static uint8_t guiTickPeriod = 20;
|
static uint8_t guiTickPeriod = 20;
|
||||||
static uint8_t guiRotation = TFT_ROTATION;
|
static uint8_t guiRotation = TFT_ROTATION;
|
||||||
static uint8_t guiInvertDisplay = INVERT_COLORS;
|
static uint8_t guiInvertDisplay = INVERT_COLORS;
|
||||||
@ -487,6 +485,9 @@ int8_t guiGetDim()
|
|||||||
bool guiGetConfig(const JsonObject & settings)
|
bool guiGetConfig(const JsonObject & settings)
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
uint16_t guiSleepTime1;
|
||||||
|
uint16_t guiSleepTime2;
|
||||||
|
hasp_get_sleep_time(guiSleepTime1, guiSleepTime2);
|
||||||
|
|
||||||
if(guiTickPeriod != settings[FPSTR(F_GUI_TICKPERIOD)].as<uint8_t>()) changed = true;
|
if(guiTickPeriod != settings[FPSTR(F_GUI_TICKPERIOD)].as<uint8_t>()) changed = true;
|
||||||
settings[FPSTR(F_GUI_TICKPERIOD)] = guiTickPeriod;
|
settings[FPSTR(F_GUI_TICKPERIOD)] = guiTickPeriod;
|
||||||
@ -556,6 +557,8 @@ bool guiSetConfig(const JsonObject & settings)
|
|||||||
{
|
{
|
||||||
configOutput(settings, TAG_GUI);
|
configOutput(settings, TAG_GUI);
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
uint16_t guiSleepTime1;
|
||||||
|
uint16_t guiSleepTime2;
|
||||||
|
|
||||||
changed |= configSet(guiTickPeriod, settings[FPSTR(F_GUI_TICKPERIOD)], F("guiTickPeriod"));
|
changed |= configSet(guiTickPeriod, settings[FPSTR(F_GUI_TICKPERIOD)], F("guiTickPeriod"));
|
||||||
changed |= configSet(guiBacklightPin, settings[FPSTR(F_GUI_BACKLIGHTPIN)], F("guiBacklightPin"));
|
changed |= configSet(guiBacklightPin, settings[FPSTR(F_GUI_BACKLIGHTPIN)], F("guiBacklightPin"));
|
||||||
@ -564,6 +567,8 @@ bool guiSetConfig(const JsonObject & settings)
|
|||||||
changed |= configSet(guiRotation, settings[FPSTR(F_GUI_ROTATION)], F("guiRotation"));
|
changed |= configSet(guiRotation, settings[FPSTR(F_GUI_ROTATION)], F("guiRotation"));
|
||||||
changed |= configSet(guiInvertDisplay, settings[FPSTR(F_GUI_INVERT)], F("guiInvertDisplay"));
|
changed |= configSet(guiInvertDisplay, settings[FPSTR(F_GUI_INVERT)], F("guiInvertDisplay"));
|
||||||
|
|
||||||
|
hasp_set_sleep_time(guiSleepTime1, guiSleepTime2);
|
||||||
|
|
||||||
if(!settings[FPSTR(F_GUI_POINTER)].isNull()) {
|
if(!settings[FPSTR(F_GUI_POINTER)].isNull()) {
|
||||||
if(guiShowPointer != settings[FPSTR(F_GUI_POINTER)].as<bool>()) {
|
if(guiShowPointer != settings[FPSTR(F_GUI_POINTER)].as<bool>()) {
|
||||||
Log.verbose(TAG_GUI, F("guiShowPointer set"));
|
Log.verbose(TAG_GUI, F("guiShowPointer set"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user