From 7e26e97a12243382bae3fd44ba8ae44c97cc5869 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Thu, 25 Jul 2024 13:35:49 -0400 Subject: [PATCH] Tbeam test initial commit --- platformio.ini | 6 ++++++ src/LoRa_APRS_Tracker.cpp | 1 - src/configuration.cpp | 29 +++++++++++++++-------------- src/configuration.h | 29 +++++++++++++++-------------- src/display.cpp | 2 +- src/gps_utils.cpp | 13 +++++++------ src/keyboard_utils.cpp | 5 ++++- src/menu_utils.cpp | 2 +- src/sleep_utils.cpp | 39 +++++++++++++++++++++------------------ src/station_utils.cpp | 3 +-- 10 files changed, 71 insertions(+), 58 deletions(-) diff --git a/platformio.ini b/platformio.ini index a06b8f3..1b22133 100644 --- a/platformio.ini +++ b/platformio.ini @@ -52,6 +52,7 @@ build_flags = -DHAS_SX1278 -DHAS_AXP2101 -DHAS_BT_CLASSIC + -DHAS_GPS_CTRL lib_deps = ${common.lib_deps} lewisxhe/XPowersLib @ 0.2.4 @@ -68,6 +69,7 @@ build_flags = -DHAS_SX1276 -DHAS_AXP2101 -DHAS_BT_CLASSIC + -DHAS_GPS_CTRL lib_deps = ${common.lib_deps} lewisxhe/XPowersLib @ 0.2.4 @@ -85,6 +87,7 @@ build_flags = -DHAS_SX1262 -DHAS_AXP2101 -DHAS_BT_CLASSIC + -DHAS_GPS_CTRL lib_deps = ${common.lib_deps} lewisxhe/XPowersLib @ 0.2.4 @@ -102,6 +105,7 @@ build_flags = -DHAS_SX1278 -DHAS_AXP192 -DHAS_BT_CLASSIC + -DHAS_GPS_CTRL lib_deps = ${common.lib_deps} lewisxhe/XPowersLib @ 0.2.4 @@ -118,6 +122,7 @@ build_flags = -DHAS_SX1276 -DHAS_AXP192 -DHAS_BT_CLASSIC + -DHAS_GPS_CTRL lib_deps = ${common.lib_deps} lewisxhe/XPowersLib @ 0.2.4 @@ -135,6 +140,7 @@ build_flags = -DHAS_SX1268 -DHAS_AXP192 -DHAS_BT_CLASSIC + -DHAS_GPS_CTRL lib_deps = ${common.lib_deps} lewisxhe/XPowersLib @ 0.2.4 diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index 6d20564..80730fc 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -95,7 +95,6 @@ APRSPacket lastReceivedPacket; logging::Logger logger; //#define DEBUG -bool gpsSleepActive = true; // currentBeacon->gpsEcoMode // true! extern bool gpsIsActive; void setup() { diff --git a/src/configuration.cpp b/src/configuration.cpp index 74fdf05..8d7e7f0 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -27,21 +27,22 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) { for (int i = 0; i < BeaconsArray.size(); i++) { Beacon bcn; - bcn.callsign = BeaconsArray[i]["callsign"].as(); + bcn.callsign = BeaconsArray[i]["callsign"].as(); bcn.callsign.toUpperCase(); - bcn.symbol = BeaconsArray[i]["symbol"].as(); - bcn.overlay = BeaconsArray[i]["overlay"].as(); - bcn.micE = BeaconsArray[i]["micE"].as(); - bcn.comment = BeaconsArray[i]["comment"].as(); - bcn.smartBeaconState = BeaconsArray[i]["smartBeacon"]["active"].as(); - bcn.slowRate = BeaconsArray[i]["smartBeacon"]["slowRate"].as(); - bcn.slowSpeed = BeaconsArray[i]["smartBeacon"]["slowSpeed"].as(); - bcn.fastRate = BeaconsArray[i]["smartBeacon"]["fastRate"].as(); - bcn.fastSpeed = BeaconsArray[i]["smartBeacon"]["fastSpeed"].as(); - bcn.minTxDist = BeaconsArray[i]["smartBeacon"]["minTxDist"].as(); - bcn.minDeltaBeacon = BeaconsArray[i]["smartBeacon"]["minDeltaBeacon"].as(); - bcn.turnMinDeg = BeaconsArray[i]["smartBeacon"]["turnMinDeg"].as(); - bcn.turnSlope = BeaconsArray[i]["smartBeacon"]["turnSlope"].as(); + bcn.gpsEcoMode = BeaconsArray[i]["gpsEcoMode"].as(); + bcn.symbol = BeaconsArray[i]["symbol"].as(); + bcn.overlay = BeaconsArray[i]["overlay"].as(); + bcn.micE = BeaconsArray[i]["micE"].as(); + bcn.comment = BeaconsArray[i]["comment"].as(); + bcn.smartBeaconState = BeaconsArray[i]["smartBeacon"]["active"].as(); + bcn.slowRate = BeaconsArray[i]["smartBeacon"]["slowRate"].as(); + bcn.slowSpeed = BeaconsArray[i]["smartBeacon"]["slowSpeed"].as(); + bcn.fastRate = BeaconsArray[i]["smartBeacon"]["fastRate"].as(); + bcn.fastSpeed = BeaconsArray[i]["smartBeacon"]["fastSpeed"].as(); + bcn.minTxDist = BeaconsArray[i]["smartBeacon"]["minTxDist"].as(); + bcn.minDeltaBeacon = BeaconsArray[i]["smartBeacon"]["minDeltaBeacon"].as(); + bcn.turnMinDeg = BeaconsArray[i]["smartBeacon"]["turnMinDeg"].as(); + bcn.turnSlope = BeaconsArray[i]["smartBeacon"]["turnSlope"].as(); beacons.push_back(bcn); } diff --git a/src/configuration.h b/src/configuration.h index 124f1f6..664d862 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -7,20 +7,21 @@ class Beacon { public: - String callsign; - String symbol; - String overlay; - String micE; - String comment; - bool smartBeaconState; - int slowRate; - int slowSpeed; - int fastRate; - int fastSpeed; - int minTxDist; - int minDeltaBeacon; - int turnMinDeg; - int turnSlope; + String callsign; + bool gpsEcoMode; + String symbol; + String overlay; + String micE; + String comment; + bool smartBeaconState; + int slowRate; + int slowSpeed; + int fastRate; + int fastSpeed; + int minTxDist; + int minDeltaBeacon; + int turnMinDeg; + int turnSlope; }; class Display { diff --git a/src/display.cpp b/src/display.cpp index d7aba89..4fefcd8 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -327,7 +327,7 @@ void startupScreen(uint8_t index, const String& version) { case 1: workingFreq += "PL]"; break; case 2: workingFreq += "UK]"; break; } - show_display(" LoRa APRS", " (TRACKER)", workingFreq, "", "", " CA2RXU / " + version, 4000); + show_display(" LoRa APRS", " (TRACKER)", workingFreq, "", "", " CA2RXU " + version, 4000); #ifdef HAS_TFT cleanTFT(); #endif diff --git a/src/gps_utils.cpp b/src/gps_utils.cpp index b5634fb..bbd07c6 100644 --- a/src/gps_utils.cpp +++ b/src/gps_utils.cpp @@ -76,13 +76,14 @@ namespace GPS_Utils { sendUpdate = true; sendStandingUpdate = false; } else { - - // - Serial.print("minTxDistance not achieved : "); - Serial.println(lastTxDistance); - // + if (currentBeacon->gpsEcoMode) { + // + Serial.print("minTxDistance not achieved : "); + Serial.println(lastTxDistance); + // - SLEEP_Utils::gpsSleep(); + SLEEP_Utils::gpsSleep(); + } } } } diff --git a/src/keyboard_utils.cpp b/src/keyboard_utils.cpp index 2624fd5..9e53fd5 100644 --- a/src/keyboard_utils.cpp +++ b/src/keyboard_utils.cpp @@ -6,8 +6,9 @@ #include "winlink_utils.h" #include "station_utils.h" #include "configuration.h" -#include "power_utils.h" #include "boards_pinout.h" +#include "power_utils.h" +#include "sleep_utils.h" #include "msg_utils.h" #include "display.h" @@ -50,6 +51,7 @@ extern String winlinkBody; extern String winlinkAlias; extern String winlinkAliasComplete; extern bool winlinkCommentState; +extern bool gpsIsActive; extern std::vector outputMessagesBuffer; @@ -160,6 +162,7 @@ namespace KEYBOARD_Utils { if (menuDisplay == 0) { if (displayState) { sendUpdate = true; + if (!gpsIsActive) SLEEP_Utils::gpsWakeUp(); } else { display_toggle(true); displayTime = millis(); diff --git a/src/menu_utils.cpp b/src/menu_utils.cpp index 1ddba8a..f254dcb 100644 --- a/src/menu_utils.cpp +++ b/src/menu_utils.cpp @@ -593,7 +593,7 @@ namespace MENU_Utils { fourthRowMainMenu += " ***"; } if (!gpsIsActive) { - fourthRowMainMenu = "*** GPS SLEEPING ***"; + fourthRowMainMenu = "*** GPS SLEEPING ***"; } } diff --git a/src/sleep_utils.cpp b/src/sleep_utils.cpp index 7713d26..c7f8809 100644 --- a/src/sleep_utils.cpp +++ b/src/sleep_utils.cpp @@ -1,33 +1,36 @@ +#include "configuration.h" #include "sleep_utils.h" #include "power_utils.h" -extern bool gpsSleepActive; // currentBeacon->gpsEcoMode // true! -extern uint32_t lastGPSTime; -extern bool gpsIsActive; +extern Beacon *currentBeacon; +extern uint32_t lastGPSTime; +extern bool gpsIsActive; namespace SLEEP_Utils { void gpsSleep() { - if (gpsSleepActive && gpsIsActive) { - POWER_Utils::deactivateGPS(); - lastGPSTime = millis(); - // - Serial.println("GPS SLEEPING"); - // - } - + #ifdef HAS_GPS_CTRL + if (currentBeacon->gpsEcoMode && gpsIsActive) { + POWER_Utils::deactivateGPS(); + lastGPSTime = millis(); + // + Serial.println("GPS SLEEPING"); + // + } + #endif } void gpsWakeUp() { - if (gpsSleepActive && !gpsIsActive) { - POWER_Utils::activateGPS(); - // - Serial.println("GPS WAKEUP"); - // - } - + #ifdef HAS_GPS_CTRL + if (currentBeacon->gpsEcoMode && !gpsIsActive) { + POWER_Utils::activateGPS(); + // + Serial.println("GPS WAKEUP"); + // + } + #endif } } \ No newline at end of file diff --git a/src/station_utils.cpp b/src/station_utils.cpp index 57ab95c..3888565 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -37,7 +37,6 @@ extern uint8_t winlinkStatus; extern bool winlinkCommentState; extern int wxModuleType; -extern bool gpsSleepActive; // currentBeacon->gpsEcoMode // true! extern bool gpsIsActive; bool sendStandingUpdate = false; @@ -284,7 +283,7 @@ namespace STATION_Utils { #ifdef HAS_TFT cleanTFT(); #endif - if (gpsSleepActive) { // currentBeacon->gpsEcoMode // true! + if (currentBeacon->gpsEcoMode) { // currentBeacon->gpsEcoMode // true! SLEEP_Utils::gpsSleep(); } }