Remove SkipSleep() in favour of FUNC_SLEEP_LOOP

This commit is contained in:
Theo Arends 2022-11-12 15:57:46 +01:00
parent b0dbe32f22
commit 4e5193fdad
4 changed files with 3 additions and 22 deletions

View File

@ -314,7 +314,6 @@ struct TasmotaGlobal_t {
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 skip_sleep; // Abandon sleep and allow loop
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
@ -549,7 +548,7 @@ void setup(void) {
#endif #endif
#endif // USE_EMULATION #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 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) // 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) { void SleepDelay(uint32_t mseconds) {
if (!TasmotaGlobal.backlog_nodelay && mseconds) { if (!TasmotaGlobal.backlog_nodelay && mseconds) {
uint32_t wait = millis() + 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); XdrvCall(FUNC_SLEEP_LOOP);
delay(1); delay(1);
} }

View File

@ -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 * 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++) { for (uint32_t i = 0; i < MAX_PULSETIMERS; i++) {
if (TasmotaGlobal.pulse_timer[i] != 0L) { // Timer active? if (TasmotaGlobal.pulse_timer[i] != 0L) { // Timer active?
if (TimeReached(TasmotaGlobal.pulse_timer[i])) { // Timer finished? if (TimeReached(TasmotaGlobal.pulse_timer[i])) { // Timer finished?

View File

@ -1394,6 +1394,7 @@ bool Xdrv03(uint32_t function)
else if (TasmotaGlobal.energy_driver) { else if (TasmotaGlobal.energy_driver) {
switch (function) { switch (function) {
case FUNC_LOOP: case FUNC_LOOP:
case FUNC_SLEEP_LOOP:
XnrgCall(FUNC_LOOP); XnrgCall(FUNC_LOOP);
break; break;
case FUNC_EVERY_250_MSECOND: case FUNC_EVERY_250_MSECOND:

View File

@ -536,7 +536,6 @@ void Ade7880Cycle(void) {
void Ade7880Service0(void) { void Ade7880Service0(void) {
// Poll sequence // Poll sequence
SkipSleep(false);
Ade7880Cycle(); Ade7880Cycle();
Ade7880.watchdog = 0; Ade7880.watchdog = 0;
Ade7880.irq0_state = 0; Ade7880.irq0_state = 0;
@ -546,7 +545,6 @@ void IRAM_ATTR Ade7880Isr0(void) {
// Poll sequence // Poll sequence
if (!Ade7880.irq0_state) { if (!Ade7880.irq0_state) {
Ade7880.irq0_state = 1; Ade7880.irq0_state = 1;
SkipSleep(true);
} }
} }