From 225135428864c386cb76ac460572fcad48afb61b Mon Sep 17 00:00:00 2001 From: Federico Amedeo Izzo Date: Sun, 6 Dec 2020 21:24:25 +0100 Subject: [PATCH] UI: Add top menu items --- openrtx/include/ui.h | 12 ++++++++++++ openrtx/src/ui.c | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/openrtx/include/ui.h b/openrtx/include/ui.h index d44a7e9a..7703719b 100644 --- a/openrtx/include/ui.h +++ b/openrtx/include/ui.h @@ -26,6 +26,9 @@ #include #include +#define MENU_NUM 6 +#define MENU_LEN 10 + enum uiScreen { MAIN_VFO = 0, @@ -39,6 +42,15 @@ enum uiScreen MENU_SETTINGS }; +const char menuItems[MENU_NUM][MENU_LEN] = { + "Zone", + "Channels", + "Contacts", + "Messages", + "GPS", + "Settings" +}; + /** * This function initialises the User Interface, starting the * Finite State Machine describing the user interaction. diff --git a/openrtx/src/ui.c b/openrtx/src/ui.c index b57450a7..b4ca9cd2 100644 --- a/openrtx/src/ui.c +++ b/openrtx/src/ui.c @@ -75,6 +75,7 @@ typedef struct layout_t { uint16_t top_h; + uint16_t line1_h; uint16_t bottom_h; uint16_t vertical_pad; uint16_t horizontal_pad; @@ -179,6 +180,7 @@ layout_t _ui_calculateLayout() layout_t new_layout = { top_h, + line1_h, bottom_h, vertical_pad, horizontal_pad, @@ -226,14 +228,14 @@ void _ui_drawMiddleVFO(state_t* last_state) { // Print VFO frequencies char freq_buf[20] = ""; - snprintf(freq_buf, sizeof(freq_buf), "Rx: %03d.%05d", + snprintf(freq_buf, sizeof(freq_buf), "Rx: %03u.%05u", last_state->channel.rx_frequency/1000000, last_state->channel.rx_frequency%1000000/10); gfx_print(layout.line2_pos, freq_buf, layout.line1_font, TEXT_ALIGN_CENTER, color_white); - snprintf(freq_buf, sizeof(freq_buf), "Tx: %03d.%05d", + snprintf(freq_buf, sizeof(freq_buf), "Tx: %03u.%05u", last_state->channel.tx_frequency/1000000, last_state->channel.tx_frequency%1000000/10); @@ -280,9 +282,20 @@ bool _ui_drawMenuTop() // Total GUI page redraw if(redraw_needed) { + // Print "menu" on top bar gfx_clearScreen(); gfx_print(layout.top_pos, "Menu", layout.top_font, TEXT_ALIGN_CENTER, color_white); + // Print menu entries + point_t pos = {0, layout.line1_h}; + char entry_buf[MENU_LEN] = ""; + for(int item=0; (item < MENU_NUM) && (pos.y < SCREEN_HEIGHT); item++) + { + snprintf(entry_buf, sizeof(entry_buf), "%s", menuItems[item][0]); + gfx_print(pos, entry_buf, layout.line1_font, + TEXT_ALIGN_LEFT, color_white); + pos.y += layout.line1_h; + } screen_update = true; } return screen_update;