Refactor backlog nodelay in relation to sleep

This commit is contained in:
Theo Arends 2021-04-09 14:00:09 +02:00
parent dd7cecc064
commit 60de9696d8
2 changed files with 2 additions and 8 deletions

View File

@ -323,11 +323,7 @@ void CmndBacklog(void) {
if (XdrvMailbox.data_len) { if (XdrvMailbox.data_len) {
if (0 == XdrvMailbox.index) { if (0 == XdrvMailbox.index) {
if (!TasmotaGlobal.backlog_nodelay) {
TasmotaGlobal.backlog_sleep = TasmotaGlobal.sleep;
}
TasmotaGlobal.backlog_nodelay = true; TasmotaGlobal.backlog_nodelay = true;
TasmotaGlobal.sleep = 0;
} }
#ifdef SUPPORT_IF_STATEMENT #ifdef SUPPORT_IF_STATEMENT

View File

@ -170,7 +170,6 @@ struct {
uint8_t latching_relay_pulse; // Latching relay pulse timer uint8_t latching_relay_pulse; // Latching relay pulse timer
uint8_t active_device; // Active device in ExecuteCommandPower uint8_t active_device; // Active device in ExecuteCommandPower
uint8_t sleep; // Current copy of Settings.sleep uint8_t sleep; // Current copy of Settings.sleep
uint8_t backlog_sleep; // Copy of sleep
uint8_t leds_present; // Max number of LED supported uint8_t leds_present; // Max number of LED supported
uint8_t led_inverted; // LED inverted flag (1 = (0 = On, 1 = Off)) uint8_t led_inverted; // LED inverted flag (1 = (0 = On, 1 = Off))
uint8_t led_power; // LED power state uint8_t led_power; // LED power state
@ -405,15 +404,14 @@ void BacklogLoop(void) {
} }
TasmotaGlobal.backlog_mutex = false; TasmotaGlobal.backlog_mutex = false;
} }
if (BACKLOG_EMPTY && TasmotaGlobal.backlog_nodelay) { if (BACKLOG_EMPTY) {
TasmotaGlobal.backlog_nodelay = false; TasmotaGlobal.backlog_nodelay = false;
TasmotaGlobal.sleep = TasmotaGlobal.backlog_sleep;
} }
} }
} }
void SleepDelay(uint32_t mseconds) { void SleepDelay(uint32_t mseconds) {
if (mseconds) { if (!TasmotaGlobal.backlog_nodelay && mseconds) {
uint32_t wait = millis() + mseconds; uint32_t wait = millis() + mseconds;
while (!TimeReached(wait) && !Serial.available()) { // We need to service serial buffer ASAP as otherwise we get uart buffer overrun while (!TimeReached(wait) && !Serial.available()) { // We need to service serial buffer ASAP as otherwise we get uart buffer overrun
delay(1); delay(1);