Print battery voltage instead of battery icon for platform without battery

replace/ad2fdf2e76d3ccf55db309cdeea9f9e9bcb49fb2
Federico Amedeo Izzo 2021-04-01 22:37:35 +02:00 zatwierdzone przez Silvano Seva
rodzic 795d8d4451
commit 2d3d932111
2 zmienionych plików z 10 dodań i 4 usunięć

Wyświetl plik

@ -695,6 +695,7 @@ void ui_saveState()
void ui_updateFSM(event_t event, bool *sync_rtx)
{
#ifndef BAT_NONE
// The volume knob has been set to OFF, shutdown the radio
if(state.v_bat <= 0)
{
@ -702,7 +703,7 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
platform_terminate();
return;
}
#endif
// Check if battery has enough charge to operate.
// Check is skipped if there is an ongoing transmission, since the voltage
// drop caused by the RF PA power absorption causes spurious triggers of

Wyświetl plik

@ -39,14 +39,19 @@ void _ui_drawMainTop()
color_white, "%02d:%02d:%02d", last_state.time.hour,
last_state.time.minute, last_state.time.second);
#endif
// Print battery icon on top bar, use 4 px padding
// If the radio has no built-in battery, print input voltage
#ifdef BAT_NONE
char volt_buf[6] = "";
snprintf(volt_buf, sizeof(volt_buf), "%.1fV", last_state.v_bat);
gfx_print(layout.top_pos, volt_buf, layout.top_font, TEXT_ALIGN_RIGHT, color_white);
#else
// Otherwise print battery icon on top bar, use 4 px padding
uint16_t bat_width = SCREEN_WIDTH / 9;
uint16_t bat_height = layout.top_h - (layout.status_v_pad * 2);
point_t bat_pos = {SCREEN_WIDTH - bat_width - layout.horizontal_pad,
layout.status_v_pad};
gfx_drawBattery(bat_pos, bat_width, bat_height, last_state.charge);
#endif
// Print radio mode on top bar
switch(last_state.channel.mode)
{