diff --git a/README.md b/README.md index b424194..168e9e0 100644 --- a/README.md +++ b/README.md @@ -181,4 +181,7 @@ Initial Release ## Release v1.3.2 - Fixed bug in handling `EpochTime` and `TimeInfo` variables, they are now also updated when WiFi is off -- Minor improvement to allow re-defining MQTT settings in `user-config.h` to allow over-writing `mqtt-ota-config.h` when upgrading the framework \ No newline at end of file +- Minor improvement to allow re-defining MQTT settings in `user-config.h` to allow over-writing `mqtt-ota-config.h` when upgrading the framework + +## Release v1.3.3 +- Added ability to delay DeepSleep (either `E32_DEEP_SLEEP`or `SLEEP_UNTIL`); as long as `DelayDeepSleep` flag is `true`, the framework will keep looping \ No newline at end of file diff --git a/include/common-functions.h b/include/common-functions.h index 77c9b97..d75606f 100644 --- a/include/common-functions.h +++ b/include/common-functions.h @@ -25,5 +25,6 @@ extern void wifi_down(); // Declare common global vars // extern bool JustBooted; +extern bool DelayDeepSleep; #endif // COMMON_FUNCTIONS_H \ No newline at end of file diff --git a/include/generic-config.h b/include/generic-config.h index 1565bac..db4432f 100644 --- a/include/generic-config.h +++ b/include/generic-config.h @@ -12,7 +12,7 @@ // #define FIRMWARE_NAME "PIO ESP32 Template" #define FIRMWARE_VERSION "1.0.0" // Add firmware version info of your custom code here -#define TEMPLATE_VERSION "1.3.2" +#define TEMPLATE_VERSION "1.3.3" // // Serial Output configuration diff --git a/src/main.cpp b/src/main.cpp index 8533d94..038380d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -142,7 +142,7 @@ void loop() // Handle SleepUntil // #ifdef SLEEP_UNTIL - if (NTPSyncCounter > 0 && EpochTime < SleepUntilEpoch) + if (NTPSyncCounter > 0 && EpochTime < SleepUntilEpoch && !DelayDeepSleep) { time(&EpochTime); // System time synced and received sleep-until time in the future -> OK! @@ -164,10 +164,13 @@ void loop() // Handle DeepSleep // #ifdef E32_DEEP_SLEEP - // disconnect WiFi and go to sleep - DEBUG_PRINTLN("Good night for " + String(DS_DURATION_MIN) + " minutes."); - wifi_down(); - esp_deep_sleep((uint64_t)DS_DURATION_MIN * 60000000); + if (!DelayDeepSleep) + { + // disconnect WiFi and go to sleep + DEBUG_PRINTLN("Good night for " + String(DS_DURATION_MIN) + " minutes."); + wifi_down(); + esp_deep_sleep((uint64_t)DS_DURATION_MIN * 60000000ULL); + } #endif // First iteration of main loop finished diff --git a/src/setup.cpp b/src/setup.cpp index d89e04b..ce2a7d1 100644 --- a/src/setup.cpp +++ b/src/setup.cpp @@ -6,6 +6,7 @@ // Define generic global vars bool JustBooted = true; // Helper to let you know you're running the first iteration of the main loop() +bool DelayDeepSleep = false; // skips DeepSleep execution in main loop when true // Define WiFi Variables const char *ssid = WIFI_SSID; const char *password = WIFI_PSK;