From 4e5193fdad079b4af81a17e8708dbf82572acba3 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 12 Nov 2022 15:57:46 +0100 Subject: [PATCH] Remove SkipSleep() in favour of FUNC_SLEEP_LOOP --- tasmota/tasmota.ino | 5 ++--- tasmota/tasmota_support/support_tasmota.ino | 17 ----------------- tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino | 1 + tasmota/tasmota_xnrg_energy/xnrg_23_ade7880.ino | 2 -- 4 files changed, 3 insertions(+), 22 deletions(-) diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 126a10c51..688deed4a 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -314,7 +314,6 @@ struct TasmotaGlobal_t { uint8_t latching_relay_pulse; // Latching relay pulse timer uint8_t active_device; // Active device in ExecuteCommandPower uint8_t sleep; // Current copy of Settings->sleep - uint8_t skip_sleep; // Abandon sleep and allow loop uint8_t leds_present; // Max number of LED supported uint8_t led_inverted; // LED inverted flag (1 = (0 = On, 1 = Off)) uint8_t led_power; // LED power state @@ -549,7 +548,7 @@ void setup(void) { #endif #endif // USE_EMULATION -// AddLog(LOG_LEVEL_INFO, PSTR("DBG: TasmotaGlobal size %d, data %*_H"), sizeof(TasmotaGlobal), 100, (uint8_t*)&TasmotaGlobal); +// AddLog(LOG_LEVEL_INFO, PSTR("DBG: TasmotaGlobal size %d, data %100_H"), sizeof(TasmotaGlobal), (uint8_t*)&TasmotaGlobal); if (Settings->param[P_BOOT_LOOP_OFFSET]) { // SetOption36 // Disable functionality as possible cause of fast restart within BOOT_LOOP_TIME seconds (Exception, WDT or restarts) @@ -681,7 +680,7 @@ void BacklogLoop(void) { void SleepDelay(uint32_t mseconds) { if (!TasmotaGlobal.backlog_nodelay && mseconds) { uint32_t wait = millis() + mseconds; - while (!TimeReached(wait) && !Serial.available() && !TasmotaGlobal.skip_sleep) { // 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 XdrvCall(FUNC_SLEEP_LOOP); delay(1); } diff --git a/tasmota/tasmota_support/support_tasmota.ino b/tasmota/tasmota_support/support_tasmota.ino index f6fd5981f..803bd0adf 100644 --- a/tasmota/tasmota_support/support_tasmota.ino +++ b/tasmota/tasmota_support/support_tasmota.ino @@ -1027,19 +1027,6 @@ void MqttPublishTeleperiodSensor(void) { } } -void SkipSleep(bool state) { - if (state) { - TasmotaGlobal.skip_sleep += 2; - } else { - if (TasmotaGlobal.skip_sleep) { - TasmotaGlobal.skip_sleep--; - } - if (TasmotaGlobal.skip_sleep) { - TasmotaGlobal.skip_sleep--; - } - } -} - /*********************************************************************************************\ * State loops \*********************************************************************************************/ @@ -1202,10 +1189,6 @@ void Every100mSeconds(void) } } - if (TasmotaGlobal.skip_sleep) { - TasmotaGlobal.skip_sleep--; // Clean up possible residue - } - for (uint32_t i = 0; i < MAX_PULSETIMERS; i++) { if (TasmotaGlobal.pulse_timer[i] != 0L) { // Timer active? if (TimeReached(TasmotaGlobal.pulse_timer[i])) { // Timer finished? diff --git a/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino b/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino index 5795800d1..27b941ac2 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino @@ -1394,6 +1394,7 @@ bool Xdrv03(uint32_t function) else if (TasmotaGlobal.energy_driver) { switch (function) { case FUNC_LOOP: + case FUNC_SLEEP_LOOP: XnrgCall(FUNC_LOOP); break; case FUNC_EVERY_250_MSECOND: diff --git a/tasmota/tasmota_xnrg_energy/xnrg_23_ade7880.ino b/tasmota/tasmota_xnrg_energy/xnrg_23_ade7880.ino index 181fbd9ed..37d157d16 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_23_ade7880.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_23_ade7880.ino @@ -536,7 +536,6 @@ void Ade7880Cycle(void) { void Ade7880Service0(void) { // Poll sequence - SkipSleep(false); Ade7880Cycle(); Ade7880.watchdog = 0; Ade7880.irq0_state = 0; @@ -546,7 +545,6 @@ void IRAM_ATTR Ade7880Isr0(void) { // Poll sequence if (!Ade7880.irq0_state) { Ade7880.irq0_state = 1; - SkipSleep(true); } }