From 78c70af472854f3d1a6a8ece3cc64d7824ceaf9f Mon Sep 17 00:00:00 2001 From: richonguzman Date: Thu, 25 Jul 2024 02:06:30 -0400 Subject: [PATCH] fixing minor things to start testing if it does smartbeacon --- src/LoRa_APRS_Tracker.cpp | 16 ++++++++-------- src/gps_utils.cpp | 7 ++++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index 28049db..d79d2b4 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -46,7 +46,7 @@ TinyGPSPlus gps; OneButton userButton = OneButton(BUTTON_PIN, true, true); #endif -String versionDate = "2024.07.24"; +String versionDate = "2024.07.25"; uint8_t myBeaconsIndex = 0; int myBeaconsSize = Config.beacons.size(); @@ -88,9 +88,9 @@ bool smartBeaconValue = true; int ackRequestNumber; -extern bool wakeUpFlag; -extern bool wakeUpByButton; -extern uint32_t wakeUpByButtonTime; +uint32_t lastGPSCheck = 0; +uint32_t lastGPSTime = 0; + APRSPacket lastReceivedPacket; @@ -203,8 +203,8 @@ void loop() { Utils::checkStatus(); STATION_Utils::checkTelemetryTx(); } - lastTx = millis() - lastTxTime; - + lastTx = millis() - lastTxTime; + lastGPSCheck = millis() - lastGPSTime; if (!sendUpdate && gps_loc_update && smartBeaconValue) { GPS_Utils::calculateDistanceTraveled(); if (!sendUpdate) { @@ -222,9 +222,9 @@ void loop() { refreshDisplayTime = millis(); } } else { - if (millis() > lastTxTime + txInterval) { + if (millis() > lastGPSTime + txInterval) { SLEEP_Utils::gpsWakeUp(); - Serial.println(txInterval); + lastGPSTime = millis(); } if (millis() - refreshDisplayTime >= 1000) { MENU_Utils::showOnScreen(); diff --git a/src/gps_utils.cpp b/src/gps_utils.cpp index c66a500..07b0034 100644 --- a/src/gps_utils.cpp +++ b/src/gps_utils.cpp @@ -26,6 +26,8 @@ extern bool sendUpdate; extern bool sendStandingUpdate; extern uint32_t lastTxTime; +extern uint32_t lastGPSCheck; +extern uint32_t lastGPSTime; extern uint32_t txInterval; extern double lastTxLat; extern double lastTxLng; @@ -69,10 +71,13 @@ namespace GPS_Utils { void calculateDistanceTraveled() { currentHeading = gps.course.deg(); lastTxDistance = TinyGPSPlus::distanceBetween(gps.location.lat(), gps.location.lng(), lastTxLat, lastTxLng); - if (lastTx >= txInterval) { + if (lastGPSCheck >= txInterval) { if (lastTxDistance > currentBeacon->minTxDist) { sendUpdate = true; sendStandingUpdate = false; + } else { + SLEEP_Utils::gpsSleep(); + lastGPSTime = millis(); } } }