Sleep fix when saving Config

This commit is contained in:
richonguzman 2025-04-24 16:17:29 -04:00
parent aba82ef3e0
commit 14473cb7c7
2 changed files with 14 additions and 9 deletions

View file

@ -4,6 +4,9 @@
#include "display.h"
bool shouldSleepStop = true;
void Configuration::writeFile() {
Serial.println("Saving config...");
@ -166,6 +169,7 @@ bool Configuration::readFile() {
digi.mode = data["digi"]["mode"] | 0;
digi.ecoMode = data["digi"]["ecoMode"] | 0;
if (digi.ecoMode == 1) shouldSleepStop = false;
loramodule.txFreq = data["lora"]["txFreq"] | 433775000;
loramodule.rxFreq = data["lora"]["rxFreq"] | 433775000;

View file

@ -6,6 +6,7 @@
extern Configuration Config;
extern bool shouldSleepStop;
extern uint32_t lastBeaconTx;
bool wakeUpFlag = false;
@ -48,15 +49,15 @@ namespace SLEEP_Utils {
}
void startSleeping() {
uint32_t timeToSleep = getSecondsToSleep();
esp_sleep_enable_timer_wakeup(timeToSleep * 1000000); // 1 min = 60sec
Serial.print("(Sleeping : "); Serial.print(timeToSleep); Serial.println("seconds)");
//esp_sleep_enable_timer_wakeup(getSecondsToSleep() * 1000000); // 1 min = 60sec
delay(100);
LoRa_Utils::wakeRadio();
esp_light_sleep_start();
if (!shouldSleepStop) {
uint32_t timeToSleep = getSecondsToSleep();
esp_sleep_enable_timer_wakeup(timeToSleep * 1000000); // 1 min = 60sec
Serial.print("(Sleeping : "); Serial.print(timeToSleep); Serial.println("seconds)");
delay(100);
LoRa_Utils::wakeRadio();
esp_light_sleep_start();
}
}
}