added battery percent to heltec WT

This commit is contained in:
richonguzman 2024-10-01 19:41:22 -03:00
parent 98557c3883
commit e365b1b5ce
4 changed files with 19 additions and 2 deletions

View File

@ -47,4 +47,15 @@ namespace BATTERY_Utils {
return telemetry;
}
String getPercentVoltageBattery(float voltage) {
int percent = ((voltage - 3.0) / (4.2 - 3.0)) * 100;
if (percent < 10) {
return " " + String(percent);
} else if (percent >= 10 && percent < 100) {
return " " + String(percent);
} else {
return "100";
}
}
}

View File

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

View File

@ -5,6 +5,7 @@
#include "station_utils.h"
#include "configuration.h"
#include "APRSPacketLib.h"
#include "battery_utils.h"
#include "power_utils.h"
#include "menu_utils.h"
#include "msg_utils.h"
@ -622,9 +623,11 @@ namespace MENU_Utils {
String batteryVoltage = POWER_Utils::getBatteryInfoVoltage();
String batteryCharge = POWER_Utils::getBatteryInfoCurrent();
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_LORA32_V2_1_GPS) || defined(TTGO_T_LORA32_V2_1_GPS_915) || defined(TTGO_T_LORA32_V2_1_TNC) || defined(TTGO_T_LORA32_V2_1_TNC_915) || defined(HELTEC_V3_GPS) || defined(HELTEC_V3_TNC) || defined(HELTEC_WIRELESS_TRACKER) || defined(TTGO_T_DECK_GPS)
sixthRowMainMenu = "Bat: ";
sixthRowMainMenu = "Battery: ";
sixthRowMainMenu += batteryVoltage;
sixthRowMainMenu += "V";
sixthRowMainMenu += "V ";
sixthRowMainMenu += BATTERY_Utils::getPercentVoltageBattery(batteryVoltage.toFloat());
sixthRowMainMenu += "%";
#endif
#ifdef HAS_AXP192
if (batteryCharge.toInt() == 0) {

View File

@ -259,6 +259,8 @@ namespace STATION_Utils {
comment += " Bat=";
comment += String(batteryVoltage.toFloat(),2);
comment += "V";
comment += BATTERY_Utils::getPercentVoltageBattery(batteryVoltage.toFloat());
comment += "%";
#endif
}
if (comment != "" || (Config.battery.sendVoltage && Config.battery.voltageAsTelemetry)) {