On-screen battery level when charging

This commit is contained in:
OneOfEleven 2023-09-18 14:31:14 +01:00
parent 1610daaf01
commit c4c7148d61
6 changed files with 42 additions and 13 deletions

View File

@ -72,6 +72,8 @@ To compile directly in windows without the need of a linux virtual machine:
Then you can run 'win_make.bat' from the directory you saved this source code too.
You may need to edit the bat file (path to make.exe) depending on where you installed the above two packages too.
I've left some notes in the win_make.bat file to maybe help with stuff.
# Credits
Many thanks to various people on Telegram for putting up with me during this effort and helping:

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -68,23 +68,29 @@ void BATTERY_GetReadings(bool bDisplayBatteryLevel)
if (gBatteryCurrent < 501)
{
if (gChargingWithTypeC)
gUpdateStatus = true;
gChargingWithTypeC = 0;
{
gUpdateStatus = true;
gUpdateDisplay = true;
}
gChargingWithTypeC = false;
}
else
{
if (!gChargingWithTypeC)
{
gUpdateStatus = true;
gUpdateStatus = true;
gUpdateDisplay = true;
BACKLIGHT_TurnOn();
}
gChargingWithTypeC = 1;
gChargingWithTypeC = true;
}
if (PreviousBatteryLevel != gBatteryDisplayLevel)
{
if (gBatteryDisplayLevel < 2)
{
gLowBattery = true;
}
else
{
gLowBattery = false;

View File

@ -21,6 +21,7 @@
#include "driver/st7565.h"
#include "external/printf/printf.h"
#include "functions.h"
#include "helper/battery.h"
#include "misc.h"
#include "radio.h"
#include "settings.h"
@ -55,7 +56,7 @@ void UI_DisplayMain(void)
// #endif
#ifdef ENABLE_DTMF_DECODER
bool show_dtmf_rx = true;
bool center_line_is_free = true;
#endif
for (vfo_num = 0; vfo_num < 2; vfo_num++)
@ -102,7 +103,7 @@ void UI_DisplayMain(void)
sprintf(String, ">%s", gDTMF_InputBox);
#ifdef ENABLE_DTMF_DECODER
show_dtmf_rx = false;
center_line_is_free = false;
#endif
}
UI_PrintString(String, 2, 0, vfo_num * 3, 8);
@ -123,13 +124,13 @@ void UI_DisplayMain(void)
else
{
#ifdef ENABLE_DTMF_DECODER
show_dtmf_rx = false;
center_line_is_free = false;
#endif
}
UI_PrintString(String, 2, 0, 2 + (vfo_num * 3), 8);
#ifdef ENABLE_DTMF_DECODER
show_dtmf_rx = false;
center_line_is_free = false;
#endif
continue;
@ -239,7 +240,7 @@ void UI_DisplayMain(void)
UI_DisplayFrequency(gInputBox, 31, Line, true, false);
#ifdef ENABLE_DTMF_DECODER
show_dtmf_rx = false;
center_line_is_free = false;
#endif
}
else
@ -453,11 +454,31 @@ void UI_DisplayMain(void)
}
#ifdef ENABLE_DTMF_DECODER
if (show_dtmf_rx && gDTMF_ReceivedSaved[0] >= 32)
{ // show the incoming DTMF live on-screen
UI_PrintStringSmall(gDTMF_ReceivedSaved, 8, 0, 3);
}
if (center_line_is_free)
{
if (gDTMF_ReceivedSaved[0] >= 32)
{ // show the on-screen live DTMF decode
UI_PrintStringSmall(gDTMF_ReceivedSaved, 8, 0, 3);
}
else
#else
if (center_line_is_free)
{
#endif
if (gChargingWithTypeC)
{ // charging .. show the battery state
const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v :
(gBatteryVoltageAverage > gMax_bat_v) ? gMax_bat_v :
gBatteryVoltageAverage;
sprintf(String, "Charge %u.%02uV %u%%",
gBatteryVoltageAverage / 100,
gBatteryVoltageAverage % 100,
(100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v));
UI_PrintStringSmall(String, 2, 0, 3);
}
}
ST7565_BlitFullScreen();
}