0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-20 15:08:37 +03:00

Added bat voltage/percentage statusbar compile option

This commit is contained in:
OneOfEleven
2023-09-19 07:59:06 +01:00
parent 787b5add92
commit 7e7439bcb6
9 changed files with 61 additions and 7 deletions

View File

@ -23,10 +23,12 @@
#include "bitmaps.h"
#include "driver/keyboard.h"
#include "driver/st7565.h"
#include "external/printf/printf.h"
#include "functions.h"
#include "helper/battery.h"
#include "misc.h"
#include "settings.h"
#include "ui/helper.h"
#include "ui/ui.h"
#include "ui/status.h"
@ -100,12 +102,34 @@ void UI_DisplayStatus(const bool test_display)
// KEY-LOCK indicator
if (gEeprom.KEY_LOCK || test_display)
{
memmove(line, BITMAP_KeyLock, sizeof(BITMAP_KeyLock));
line += sizeof(BITMAP_KeyLock);
}
else
if (gWasFKeyPressed)
{
memmove(line, BITMAP_F_Key, sizeof(BITMAP_F_Key));
line += sizeof(BITMAP_F_Key);
line += sizeof(BITMAP_F_Key);
}
else
if (!gChargingWithTypeC)
{ // battery voltage/percentage
#if defined(ENABLE_STATUSBAR_VOLTAGE)
char s[6];
sprintf(s, "%u.%02u", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100);
UI_PrintStringSmallBuffer(s, line);
#elif defined(ENABLE_STATUSBAR_PERCENTAGE)
char s[6];
const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v :
(gBatteryVoltageAverage > gMax_bat_v) ? gMax_bat_v :
gBatteryVoltageAverage;
sprintf(s, "%u%%", (100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v));
UI_PrintStringSmallBuffer(s, line);
#endif
}
// USB-C charge indicator
if (gChargingWithTypeC || test_display)
memmove(line, BITMAP_USB_C, sizeof(BITMAP_USB_C));