From 0e1d9b090f54c520677f24de7a4e1845e5eb4622 Mon Sep 17 00:00:00 2001 From: Federico Amedeo Izzo Date: Mon, 7 Dec 2020 18:43:54 +0100 Subject: [PATCH] UI: Add current mode print on status bar --- openrtx/include/state.h | 19 +++++++++++++++++-- openrtx/src/ui.c | 25 ++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/openrtx/include/state.h b/openrtx/include/state.h index eb71fe14..e66635bd 100644 --- a/openrtx/include/state.h +++ b/openrtx/include/state.h @@ -38,8 +38,8 @@ typedef struct float v_bat; uint8_t ui_screen; - //enum tuner_mode; - //enum radio_mode; + uint8_t tuner_mode; + uint8_t radio_mode; //time_t rx_status_tv; //bool rx_status; @@ -55,6 +55,21 @@ typedef struct } state_t; +enum TunerMode +{ + VFO = 0, + CH, + SCAN, + CHSCAN +}; + +enum RadioMode +{ + MODE_FM = 0, + MODE_NFM, + MODE_DMR, +}; + enum RtxStatus { RTX_OFF = 0, diff --git a/openrtx/src/ui.c b/openrtx/src/ui.c index 2fdc7a15..3582f38d 100644 --- a/openrtx/src/ui.c +++ b/openrtx/src/ui.c @@ -71,6 +71,7 @@ #include #include #include +#include const char *menuItems[MENU_NUM] = { @@ -102,12 +103,13 @@ typedef struct layout_t fontSize_t bottom_font; } layout_t; +const color_t color_white = {255, 255, 255}; +const color_t color_grey = {60, 60, 60}; +const color_t yellow_fab413 = {250, 180, 19}; + layout_t layout; bool layout_ready = false; bool redraw_needed = true; -color_t color_white = {255, 255, 255}; -color_t color_grey = {60, 60, 60}; -color_t yellow_fab413 = {250, 180, 19}; layout_t _ui_calculateLayout() { @@ -233,6 +235,23 @@ void _ui_drawTopBar(state_t* last_state) point_t bat_pos = {SCREEN_WIDTH - bat_width - layout.horizontal_pad, layout.vertical_pad / 2}; gfx_drawBattery(bat_pos, bat_width, bat_height, percentage); + + // Print radio mode on top bar + char mode[4] = ""; + switch(last_state->radio_mode) + { + case MODE_FM: + strcpy(mode, "FM"); + break; + case MODE_NFM: + strcpy(mode, "NFM"); + break; + case MODE_DMR: + strcpy(mode, "DMR"); + break; + } + gfx_print(layout.top_pos, mode, layout.top_font, TEXT_ALIGN_LEFT, + color_white); } void _ui_drawMiddleVFO(state_t* last_state)