lowBatteryVoltage protection

This commit is contained in:
richonguzman 2024-10-01 20:22:23 -03:00
parent 337113caff
commit c480bf2bb6
4 changed files with 14 additions and 5 deletions

View File

@ -1,5 +1,6 @@
#include <Arduino.h>
#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();
}
}

View File

@ -8,6 +8,7 @@ namespace BATTERY_Utils {
String generateEncodedTelemetry(float voltage);
String getPercentVoltageBattery(float voltage);
void checkLowVoltageAndSleep(float voltage);
}

View File

@ -52,6 +52,7 @@ extern String winlinkAlias;
extern String winlinkAliasComplete;
extern bool winlinkCommentState;
extern bool gpsIsActive;
extern bool sendStartTelemetry;
extern std::vector<String> 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;

View File

@ -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";