Skip to content

Commit

Permalink
Rename function deepSleep and move it to make it works :D
Browse files Browse the repository at this point in the history
  • Loading branch information
valentintintin committed Apr 6, 2024
1 parent 0fb3f5b commit a9d538e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/LoRa_APRS_Tracker.cpp
Expand Up @@ -134,7 +134,7 @@ APRSPacket lastReceivedPacket;
logging::Logger logger;

void checkBluetoothState();
void deepSleep();
void checkDeepSleepNeeded();

void setup() {
Serial.begin(115200);
Expand Down Expand Up @@ -252,6 +252,7 @@ void loop() {
GPS_Utils::calculateHeadingDelta(currentSpeed);
}
STATION_Utils::checkStandingUpdateTime();
checkDeepSleepNeeded();
}
STATION_Utils::checkSmartBeaconState();
if (sendUpdate && gps_loc_update) STATION_Utils::sendBeacon("GPS");
Expand All @@ -262,12 +263,6 @@ void loop() {
MENU_Utils::showOnScreen();
refreshDisplayTime = millis();
}

if (Config.secondsToSleepWhenNoMotion > 0 && sendStandingUpdate && !bluetoothConnected && !POWER_Utils::isUsbConnected()) {
deepSleep();
}

delay(10);
}

void checkBluetoothState() {
Expand Down Expand Up @@ -310,7 +305,14 @@ void checkBluetoothState() {
}
}

void deepSleep() {
void checkDeepSleepNeeded() {
if (Config.secondsToSleepWhenNoMotion <= 0 // Sleep not activated
|| !sendStandingUpdate // We are moving so can't sleep
|| bluetoothConnected // Device connected on Bluetooth so can't sleep
|| POWER_Utils::isUsbConnected()) { // USB connected so don't need to sleep
return;
}

logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "Module goes to sleep");
POWER_Utils::disableChgLed();
POWER_Utils::deactivateMeasurement();
Expand Down

0 comments on commit a9d538e

Please sign in to comment.