Skip to content

Commit

Permalink
added DelayDeepSleep flag; v1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jpichlbauer committed Mar 10, 2024
1 parent 25ab47e commit 7dde150
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- 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
1 change: 1 addition & 0 deletions include/common-functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ extern void wifi_down();
// Declare common global vars
//
extern bool JustBooted;
extern bool DelayDeepSleep;

#endif // COMMON_FUNCTIONS_H
2 changes: 1 addition & 1 deletion include/generic-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7dde150

Please sign in to comment.