0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 06:39:49 +03:00

Battery percentage added

This commit is contained in:
OneOfEleven
2023-09-09 10:17:58 +01:00
parent 09482d38b3
commit 9131d75cb5
8 changed files with 34 additions and 5 deletions

View File

@ -89,7 +89,7 @@ static const char MenuList[][7] =
"PONMSG",
"ROGER",
"BATVOL",
"AM",
"MODE",
// 48
#ifndef DISABLE_NOAA
"NOAA_S",
@ -375,6 +375,10 @@ void UI_DisplayMenu(void)
sprintf(String, "%d sec", gSubMenuSelection * 10);
break;
case MENU_AM:
strcpy(String, (gSubMenuSelection == 0) ? "FM" : "AM");
break;
case MENU_BCL:
case MENU_BEEP:
case MENU_AUTOLK:
@ -383,7 +387,6 @@ void UI_DisplayMenu(void)
case MENU_STE:
case MENU_D_ST:
case MENU_D_DCD:
case MENU_AM:
#ifndef DISABLE_NOAA
case MENU_NOAA_S:
#endif
@ -497,7 +500,7 @@ void UI_DisplayMenu(void)
break;
case MENU_VOL:
sprintf(String, "%.3fV", gBatteryVoltageAverage * 0.01); // argh, floating point :(
sprintf(String, "%.2fV", gBatteryVoltageAverage * 0.01); // argh, floating point :(
break;
case MENU_RESET:
@ -511,6 +514,15 @@ void UI_DisplayMenu(void)
UI_PrintString(String, 50, 127, 2, 8, true);
if (gMenuCursor == MENU_VOL)
{ // 2nd text line
const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v :
(gBatteryVoltageAverage > gMax_bat_v) ? gMax_bat_v :
gBatteryVoltageAverage;
sprintf(String, "%u%%", (100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v));
UI_PrintString(String, 50, 127, 4, 8, true);
}
if (gMenuCursor == MENU_OFFSET)
UI_PrintString("MHz", 50, 127, 4, 8, true);

View File

@ -21,6 +21,7 @@
#include "external/printf/printf.h"
#include "helper/battery.h"
#include "settings.h"
#include "misc.h"
#include "ui/helper.h"
#include "ui/welcome.h"
#include "version.h"
@ -44,8 +45,14 @@ void UI_DisplayWelcome(void)
if (gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_VOLTAGE)
{
const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v :
(gBatteryVoltageAverage > gMax_bat_v) ? gMax_bat_v :
gBatteryVoltageAverage;
sprintf(WelcomeString0, "VOLTAGE");
sprintf(WelcomeString1, "%.2fV", gBatteryVoltageAverage * 0.01); // argh, floating point :(
sprintf(WelcomeString1, "%.2fV %u%%",
gBatteryVoltageAverage * 0.01, // argh, floating point :(
(100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v));
}
else
{