From a9d4aa08a8a068c101dc3bb3e7c4020e3e1b0f53 Mon Sep 17 00:00:00 2001 From: Federico Amedeo Izzo Date: Sun, 20 Dec 2020 09:24:57 +0100 Subject: [PATCH] UI: Add menu selection --- openrtx/src/ui.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openrtx/src/ui.c b/openrtx/src/ui.c index 4064302b..212868e4 100644 --- a/openrtx/src/ui.c +++ b/openrtx/src/ui.c @@ -290,7 +290,9 @@ void _ui_drawMenuList(point_t pos, const char *entries[], uint8_t selected) snprintf(entry_buf, sizeof(entry_buf), "%s", entries[item]); if(item == selected) { - gfx_drawRect(pos, SCREEN_WIDTH, layout.top_h, color_white, true); + // Draw rectangle under selected item, compensating for text height + point_t rect_pos = {0, pos.y - layout.top_h + 3}; + gfx_drawRect(rect_pos, SCREEN_WIDTH, layout.top_h, color_white, true); gfx_print(pos, entry_buf, layout.top_font, TEXT_ALIGN_LEFT, color_black); } else @@ -442,9 +444,13 @@ void ui_updateFSM(event_t event, bool *sync_rtx) case MENU_TOP: if(msg.keys & KEY_UP) { + if(menu_selected > 0) + menu_selected -= 1; } else if(msg.keys & KEY_DOWN) { + if(menu_selected < MENU_NUM) + menu_selected += 1; } else if(msg.keys & KEY_ESC) // Close Menu