diff --git a/src/battery_utils.cpp b/src/battery_utils.cpp index 07caff8..cb995d7 100644 --- a/src/battery_utils.cpp +++ b/src/battery_utils.cpp @@ -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"; + } + } + } \ No newline at end of file diff --git a/src/battery_utils.h b/src/battery_utils.h index da3448d..7f2f84a 100644 --- a/src/battery_utils.h +++ b/src/battery_utils.h @@ -7,6 +7,7 @@ namespace BATTERY_Utils { String generateEncodedTelemetry(float voltage); + String getPercentVoltageBattery(float voltage); } diff --git a/src/menu_utils.cpp b/src/menu_utils.cpp index 85e642f..9d7a997 100644 --- a/src/menu_utils.cpp +++ b/src/menu_utils.cpp @@ -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) { diff --git a/src/station_utils.cpp b/src/station_utils.cpp index ee40855..4a0b8ed 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -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)) {