0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 22:58:04 +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

@ -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
{