From 2d3d932111f65a54d4d061458f2e3a8be188b7c2 Mon Sep 17 00:00:00 2001 From: Federico Amedeo Izzo Date: Thu, 1 Apr 2021 22:37:35 +0200 Subject: [PATCH] Print battery voltage instead of battery icon for platform without battery --- openrtx/src/ui/ui.c | 3 ++- openrtx/src/ui/ui_main.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/openrtx/src/ui/ui.c b/openrtx/src/ui/ui.c index 7b151f82..6ee76b8c 100644 --- a/openrtx/src/ui/ui.c +++ b/openrtx/src/ui/ui.c @@ -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 diff --git a/openrtx/src/ui/ui_main.c b/openrtx/src/ui/ui_main.c index 3404029e..5aa4d9a0 100644 --- a/openrtx/src/ui/ui_main.c +++ b/openrtx/src/ui/ui_main.c @@ -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) {