diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 9c1ef409..8c74394c 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -21,7 +21,7 @@ #endif #ifndef LOOP_DELAY_TIME -#define LOOP_DELAY_TIME 10 // Delay for this millis in the main loop [0-250] +#define LOOP_DELAY_TIME 1 // Delay for this millis in the main loop [0-250] (see https://github.com/xoseperez/espurna/issues/1541) #endif //------------------------------------------------------------------------------ diff --git a/code/espurna/system.ino b/code/espurna/system.ino index 791ba99c..33bbf267 100644 --- a/code/espurna/system.ino +++ b/code/espurna/system.ino @@ -10,7 +10,10 @@ Copyright (C) 2018 by Xose PĂ©rez // ----------------------------------------------------------------------------- +#if WIFI_SLEEP_MODE != WIFI_NONE_SLEEP unsigned long _loop_delay = 0; +#endif + bool _system_send_heartbeat = false; unsigned char _heartbeat_mode = HEARTBEAT_MODE; unsigned long _heartbeat_interval = HEARTBEAT_INTERVAL; @@ -72,10 +75,11 @@ bool systemGetHeartbeat() { return _system_send_heartbeat; } +#if WIFI_SLEEP_MODE != WIFI_NONE_SLEEP unsigned long systemLoopDelay() { return _loop_delay; } - +#endif unsigned long systemLoadAverage() { return _load_average; @@ -157,7 +161,9 @@ void systemLoop() { // Power saving delay // ------------------------------------------------------------------------- - delay(_loop_delay); + #if WIFI_SLEEP_MODE != WIFI_NONE_SLEEP + delay(_loop_delay); + #endif } @@ -196,8 +202,10 @@ void systemSetup() { _systemSetupSpecificHardware(); // Cache loop delay value to speed things (recommended max 250ms) - _loop_delay = atol(getSetting("loopDelay", LOOP_DELAY_TIME).c_str()); - _loop_delay = constrain(_loop_delay, 0, 300); + #if WIFI_SLEEP_MODE != WIFI_NONE_SLEEP + _loop_delay = atol(getSetting("loopDelay", LOOP_DELAY_TIME).c_str()); + _loop_delay = constrain(_loop_delay, 0, 300); + #endif // Register Loop espurnaRegisterLoop(systemLoop); diff --git a/code/espurna/utils.ino b/code/espurna/utils.ino index 23c6ea03..888f3963 100644 --- a/code/espurna/utils.ino +++ b/code/espurna/utils.ino @@ -469,7 +469,9 @@ void info() { #if ADC_MODE_VALUE == ADC_VCC DEBUG_MSG_P(PSTR("[MAIN] Power: %u mV\n"), ESP.getVcc()); #endif - DEBUG_MSG_P(PSTR("[MAIN] Power saving delay value: %lu ms\n"), systemLoopDelay()); + #if WIFI_SLEEP_MODE != WIFI_NONE_SLEEP + DEBUG_MSG_P(PSTR("[MAIN] Power saving delay value: %lu ms\n"), systemLoopDelay()); + #endif // -------------------------------------------------------------------------