diff --git a/src/battery_utils.cpp b/src/battery_utils.cpp index cb995d7..18d0f12 100644 --- a/src/battery_utils.cpp +++ b/src/battery_utils.cpp @@ -1,5 +1,6 @@ #include #include "battery_utils.h" +#include "power_utils.h" int telemetryCounter = random(1,999); @@ -58,4 +59,8 @@ namespace BATTERY_Utils { } } + void checkLowVoltageAndSleep(float voltage) { + if (voltage <= 3.0) POWER_Utils::shutdown(); + } + } \ No newline at end of file diff --git a/src/battery_utils.h b/src/battery_utils.h index 7f2f84a..4f94e83 100644 --- a/src/battery_utils.h +++ b/src/battery_utils.h @@ -8,6 +8,7 @@ namespace BATTERY_Utils { String generateEncodedTelemetry(float voltage); String getPercentVoltageBattery(float voltage); + void checkLowVoltageAndSleep(float voltage); } diff --git a/src/keyboard_utils.cpp b/src/keyboard_utils.cpp index 1a7cb5f..32ecb1e 100644 --- a/src/keyboard_utils.cpp +++ b/src/keyboard_utils.cpp @@ -52,6 +52,7 @@ extern String winlinkAlias; extern String winlinkAliasComplete; extern bool winlinkCommentState; extern bool gpsIsActive; +extern bool sendStartTelemetry; extern std::vector outputMessagesBuffer; @@ -287,6 +288,7 @@ namespace KEYBOARD_Utils { winlinkCommentState = false; displayShow("__ INFO __", "", " CHANGING CALLSIGN!", "", "-----> " + Config.beacons[myBeaconsIndex].callsign, "", 2000); STATION_Utils::saveIndex(0, myBeaconsIndex); + sendStartTelemetry = true; if (menuDisplay == 200) menuDisplay = 20; } else if ((menuDisplay >= 1 && menuDisplay <= 3) || (menuDisplay >= 11 &&menuDisplay <= 13) || (menuDisplay >= 20 && menuDisplay <= 27) || (menuDisplay >= 30 && menuDisplay <= 31)) { menuDisplay = menuDisplay * 10; diff --git a/src/station_utils.cpp b/src/station_utils.cpp index 4a0b8ed..8e32e96 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -239,23 +239,24 @@ namespace STATION_Utils { sendCommentAfterXBeacons = Config.sendCommentAfterXBeacons; } String batteryVoltage = POWER_Utils::getBatteryInfoVoltage(); + #if defined(BATTERY_PIN) && !defined(HAS_AXP192) && !defined(HAS_AXP2101) + BATTERY_Utils::checkLowVoltageAndSleep(batteryVoltage.toFloat()); + #endif if (Config.battery.sendVoltage && !Config.battery.voltageAsTelemetry) { String batteryChargeCurrent = POWER_Utils::getBatteryInfoCurrent(); - #ifdef HAS_AXP192 + #if defined(HAS_AXP192) comment += " Bat="; comment += batteryVoltage; comment += "V ("; comment += batteryChargeCurrent; comment += "mA)"; - #endif - #ifdef HAS_AXP2101 + #elif defined(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) + #elif defined(BATTERY_PIN) && !defined(HAS_AXP192) && !defined(HAS_AXP2101) comment += " Bat="; comment += String(batteryVoltage.toFloat(),2); comment += "V";