Made the status bar bat volt adaptive

This commit is contained in:
OneOfEleven 2023-09-19 18:03:45 +01:00
parent 737e5ac8e2
commit 93f6866c87
5 changed files with 10 additions and 7 deletions

View File

@ -19,7 +19,7 @@ ENABLE_BOOT_BEEPS := 0
ENABLE_COMPANDER := 1
ENABLE_SHOW_CHARGE_LEVEL := 0
ENABLE_REVERSE_BAT_SYMBOL := 1
ENABLE_STATUSBAR_VOLTAGE := 0
ENABLE_STATUSBAR_VOLTAGE := 1
ENABLE_STATUSBAR_PERCENTAGE := 1
#ENABLE_SINGLE_VFO_CHAN := 1
#ENABLE_BAND_SCOPE := 1

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -115,20 +115,23 @@ void UI_DisplayStatus(const bool test_display)
else
if (!gChargingWithTypeC)
{ // battery voltage or percentage
char s[8];
#ifdef ENABLE_STATUSBAR_VOLTAGE
char s[6];
sprintf(s, "%u.%02u", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100);
UI_PrintStringSmallBuffer(s, line);
//line += 8 * 4;
const char *fmt[] = {"%u.%02u", "%2u.%02uV"};
unsigned int i = gEeprom.VOX_SWITCH ? 0 : 1; // add a 'V' and shift the text left a bit if the VOX is not showing
sprintf(s, fmt[i], gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100);
UI_PrintStringSmallBuffer(s, line - (i ? 20 : 0));
#elif defined(ENABLE_STATUSBAR_PERCENTAGE)
const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v : gBatteryVoltageAverage;
const uint16_t percent = (100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v);
const unsigned int x = (percent >= 100) ? 0 : 4; // move to the right a bit
char s[8];
sprintf(s, "%u%%", percent);
UI_PrintStringSmallBuffer(s, line + x);
//line += 8 * 4;
#endif
}