Merge pull request #9048 from stefanbode/patch-19

Ported DeepSleep to ESP32
This commit is contained in:
Theo Arends 2020-08-07 14:56:31 +02:00 committed by GitHub
commit e85b2753e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -36,7 +36,6 @@
// Not ported (yet)
#undef USE_DISCOVERY
#undef USE_DEEPSLEEP
#undef USE_MY92X1
#undef USE_TUYA_MCU
#undef USE_PS_16_DZ

View File

@ -71,7 +71,12 @@ void DeepSleepReInit(void)
AddLog_P2(LOG_LEVEL_ERROR, PSTR("DSL: Remain DeepSleep %d"), RtcSettings.ultradeepsleep);
RtcSettingsSave();
RtcRebootReset();
#ifdef ESP8266
ESP.deepSleep(100 * RtcSettings.deepsleep_slip * (DEEPSLEEP_MAX_CYCLE < RtcSettings.ultradeepsleep ? DEEPSLEEP_MAX_CYCLE : RtcSettings.ultradeepsleep), WAKE_RF_DEFAULT);
#else // ESP32
esp_sleep_enable_timer_wakeup(100 * RtcSettings.deepsleep_slip * (DEEPSLEEP_MAX_CYCLE < RtcSettings.ultradeepsleep ? DEEPSLEEP_MAX_CYCLE : RtcSettings.ultradeepsleep));
esp_deep_sleep_start();
#endif // ESP8266 or ESP32
yield();
// Sleeping
}
@ -136,8 +141,12 @@ void DeepSleepStart(void)
WifiShutdown();
RtcSettings.ultradeepsleep = RtcSettings.nextwakeup - UtcTime();
RtcSettingsSave();
#ifdef ESP8266
ESP.deepSleep(100 * RtcSettings.deepsleep_slip * deepsleep_sleeptime);
#else // ESP32
esp_sleep_enable_timer_wakeup(100 * RtcSettings.deepsleep_slip * deepsleep_sleeptime);
esp_deep_sleep_start();
#endif // ESP8266 or ESP32
yield();
}