From a0b391e0eb59b99275726a1ad3a17437f50d2879 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Wed, 18 Sep 2024 23:04:00 -0300 Subject: [PATCH] Encoded Telemetry Battery Voltage fix --- README.md | 2 +- src/LoRa_APRS_Tracker.cpp | 2 +- src/station_utils.cpp | 57 +++++++++++++++++++-------------------- 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 195b628..67dd1a3 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ ____________________________________________________ ____________________________________________________ ## Timeline (Versions): -- 2024.09.17 Battery Info now as Encoded Telemetry in GPS Beacon. +- 2024.09.17 Battery Voltage now as Encoded Telemetry in GPS Beacon. - 2024.08.26 New reformating of code ahead of WebInstaller: SmartBeacon change. - 2024.08.16 BLE support for Android devices (not APRSDroid yet). - 2024.08.12 Added support for EByte E220 400M30S 1Watt LoRa module for DIY ESP32 Tracker (LLCC68 supports spreading factor only in range of 5 - 11!) diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index 043fb71..e07e932 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -47,7 +47,7 @@ TinyGPSPlus gps; OneButton userButton = OneButton(BUTTON_PIN, true, true); #endif -String versionDate = "2024.09.17"; +String versionDate = "2024.09.18"; uint8_t myBeaconsIndex = 0; int myBeaconsSize = Config.beacons.size(); diff --git a/src/station_utils.cpp b/src/station_utils.cpp index c48a4aa..fb94810 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -41,7 +41,7 @@ extern bool gpsShouldSleep; bool sendStandingUpdate = false; -uint8_t updateCounter = Config.sendCommentAfterXBeacons; +uint8_t updateCounter = 100; bool sendStartTelemetry = true; @@ -238,39 +238,36 @@ namespace STATION_Utils { sendCommentAfterXBeacons = Config.sendCommentAfterXBeacons; } String batteryVoltage = POWER_Utils::getBatteryInfoVoltage(); - if (Config.battery.sendVoltage) { - if (Config.battery.voltageAsTelemetry) { - comment += BATTERY_Utils::generateEncodedTelemetry(batteryVoltage.toFloat()); - } else { - String batteryChargeCurrent = POWER_Utils::getBatteryInfoCurrent(); - #ifdef HAS_AXP192 - comment += " Bat="; - comment += batteryVoltage; - comment += "V ("; - comment += batteryChargeCurrent; - comment += "mA)"; - #endif - #ifdef HAS_AXP2101 - comment += " Bat="; - comment += String(batteryVoltage.toFloat(),2); - comment += "V ("; - comment += batteryChargeCurrent; - comment += "%)"; - #endif - #if defined(HELTEC_V3_GPS) || defined(HELTEC_WIRELESS_TRACKER) || defined(TTGO_T_DECK_GPS) - comment += " Bat="; - comment += String(batteryVoltage.toFloat(),2); - comment += "V"; - #endif - } + if (Config.battery.sendVoltage && !Config.battery.voltageAsTelemetry) { + String batteryChargeCurrent = POWER_Utils::getBatteryInfoCurrent(); + #ifdef HAS_AXP192 + comment += " Bat="; + comment += batteryVoltage; + comment += "V ("; + comment += batteryChargeCurrent; + comment += "mA)"; + #endif + #ifdef HAS_AXP2101 + comment += " Bat="; + comment += String(batteryVoltage.toFloat(),2); + comment += "V ("; + comment += batteryChargeCurrent; + comment += "%)"; + #endif + #if defined(HELTEC_V3_GPS) || defined(HELTEC_WIRELESS_TRACKER) || defined(TTGO_T_DECK_GPS) + comment += " Bat="; + comment += String(batteryVoltage.toFloat(),2); + comment += "V"; + #endif } - if (comment != "") { + if (comment != "" || (Config.battery.sendVoltage && Config.battery.voltageAsTelemetry)) { updateCounter++; if (updateCounter >= sendCommentAfterXBeacons) { - packet += comment; + if (comment != "") packet += comment; + if (Config.battery.sendVoltage && Config.battery.voltageAsTelemetry) packet += BATTERY_Utils::generateEncodedTelemetry(batteryVoltage.toFloat()); updateCounter = 0; - } - } + } + } #ifdef HAS_TFT cleanTFT(); #endif