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

@ -104,6 +104,22 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_
}
}
void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer)
{
size_t i;
const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]);
const unsigned int char_spacing = char_width + 0;
for (i = 0; i < strlen(pString); i++)
{
if (pString[i] >= 32)
{
const unsigned int Index = (unsigned int)pString[i] - 32;
if (Index < ARRAY_SIZE(gFontSmall))
memmove(buffer + (i * char_spacing), &gFontSmall[Index], char_width);
}
}
}
void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag)
{
const unsigned int char_width = 13;

View File

@ -24,6 +24,7 @@ void UI_GenerateChannelString(char *pString, const uint8_t Channel);
void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber);
void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width);
void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer);
void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag);
void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero);
void UI_DisplaySmallDigits(const uint8_t size, const char *str, const uint8_t x, const uint8_t y, const bool display_leading_zeros);

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));