From 8dcf6a6b59a72c4ab032e4b3d882621dfa9c6e1a Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Fri, 27 Mar 2020 13:08:13 +0100 Subject: [PATCH] Force top level menu on screen --- nanovna.h | 1 + plot.c | 2 ++ sa_core.c | 4 +++- ui.c | 39 ++++++++++++++++++++++++++------------- ui_sa.c | 1 + 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/nanovna.h b/nanovna.h index 36a7d06..0638ad0 100644 --- a/nanovna.h +++ b/nanovna.h @@ -525,6 +525,7 @@ void clear_all_config_prop_data(void); */ extern void ui_init(void); extern void ui_process(void); +int current_menu_is_form(void); // Irq operation process set #define OP_NONE 0x00 diff --git a/plot.c b/plot.c index 7cb98a6..719a443 100644 --- a/plot.c +++ b/plot.c @@ -1902,6 +1902,8 @@ draw_frequencies(void) char buf2[32]; buf2[0] = 0; if (MODE_OUTPUT(settingMode)) // No frequencies during output return; + if (current_menu_is_form()) + return; #ifdef __VNA__ if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) { diff --git a/sa_core.c b/sa_core.c index 2349e11..0731ae9 100644 --- a/sa_core.c +++ b/sa_core.c @@ -75,7 +75,7 @@ int settingSpur = 0; int settingAverage = 0; int settingShowStorage = 0; int settingSubtractStorage = 0; -int settingMode = M_LOW; +int settingMode = -1; // Initialize to unknown state int settingDrive=0; // 0-3 , 3=+20dBm int settingAGC = true; int settingLNA = false; @@ -705,6 +705,8 @@ void draw_cal_status(void) if (MODE_OUTPUT(settingMode)) // No cal status during output return; + if (current_menu_is_form()) + return; ili9341_set_background(DEFAULT_BG_COLOR); diff --git a/ui.c b/ui.c index 1d13e0d..b29cf4a 100644 --- a/ui.c +++ b/ui.c @@ -1105,6 +1105,11 @@ menu_push_submenu(const menuitem_t *submenu) draw_menu(); } +int current_menu_is_form(void) +{ + return menu_is_form(menu_stack[menu_current_level]); +} + /* static void menu_move_top(void) @@ -1425,7 +1430,6 @@ static void draw_menu_buttons(const menuitem_t *menu) { int i = 0; - int bw = 320; char text[30]; for (i = 0; i < 7; i++) { const char *l1, *l2; @@ -1449,20 +1453,25 @@ draw_menu_buttons(const menuitem_t *menu) uint16_t old_bg = bg; int active_button_width; + int active_button_start; menu_item_modify_attribute(menu, i, &fg, &bg); // before plot_printf to create status text if (menu[i].type & MT_FORM) { - active_button_width = MENU_FORM_WIDTH; + active_button_start = 320 - MENU_FORM_WIDTH; + active_button_width = MENU_FORM_WIDTH - 30; // Shorten at the right if (MT_MASK(menu[i].type) == MT_CALLBACK) { // Only callback can have value keypad_mode = menu[i].data; fetch_numeric_target(); } plot_printf(text, sizeof text, menu[i].label, uistat.text); } - else + else { active_button_width = MENU_BUTTON_WIDTH; - ili9341_fill(bw-active_button_width, y, active_button_width, MENU_BUTTON_HEIGHT-4, old_bg); // Set button to unmodified background color - + active_button_start = 320 - MENU_BUTTON_WIDTH; + } + ili9341_fill(active_button_start, y, active_button_width, MENU_BUTTON_HEIGHT-4, old_bg); // Set button to unmodified background color +#if 0 // 3D button accent + int bw = 320; if (MT_MASK(menu[i].type) != MT_TITLE) { ili9341_fill(bw-active_button_width, y, 2, MENU_BUTTON_HEIGHT-4, LIGHT_GREY); // Set button to unmodified background color @@ -1470,21 +1479,21 @@ draw_menu_buttons(const menuitem_t *menu) ili9341_fill(bw-2, y, 2, MENU_BUTTON_HEIGHT-4, DARK_GREY); // Set button to unmodified background color ili9341_fill(bw-active_button_width, y+MENU_BUTTON_HEIGHT-4, active_button_width, 2, DARK_GREY); // Set button to unmodified background color } - +#endif ili9341_set_foreground(fg); ili9341_set_background(bg); if (menu[i].type & MT_FORM) { - ili9341_fill(bw-active_button_width+3, y+6, active_button_width-6, 2+FONT_GET_HEIGHT*2+2, bg); - ili9341_drawstring_size(text, bw-active_button_width+5, y+8, 2); + ili9341_fill(active_button_start+3, y+6, active_button_width-6, 2+FONT_GET_HEIGHT*2+2, bg); + ili9341_drawstring_size(text, active_button_start+5, y+8, 2); } else { if (menu_is_multiline(menu[i].label, &l1, &l2)) { - ili9341_fill(bw-active_button_width+3, y+5, active_button_width-6, 2+FONT_GET_HEIGHT+1+FONT_GET_HEIGHT+2, bg); - ili9341_drawstring(l1, bw-active_button_width+5, y+7); - ili9341_drawstring(l2, bw-active_button_width+5, y+7+FONT_GET_HEIGHT+1); + ili9341_fill(active_button_start+3, y+5, active_button_width-6, 2+FONT_GET_HEIGHT+1+FONT_GET_HEIGHT+2, bg); + ili9341_drawstring(l1, active_button_start+5, y+7); + ili9341_drawstring(l2, active_button_start+5, y+7+FONT_GET_HEIGHT+1); } else { - ili9341_fill(bw-active_button_width+3, y+8, active_button_width-6, 2+FONT_GET_HEIGHT+2, bg); - ili9341_drawstring(menu[i].label, bw-active_button_width+5, y+10); + ili9341_fill(active_button_start+3, y+8, active_button_width-6, 2+FONT_GET_HEIGHT+2, bg); + ili9341_drawstring(menu[i].label, active_button_start+5, y+10); } } } @@ -2280,6 +2289,10 @@ void ui_process(void) { int button_state = READ_PORT() & BUTTON_MASK; + if (ui_mode == UI_NORMAL && current_menu_is_form()) { // Force into menu mode + selection = -1; // hide keyboard mode selection + ui_mode_menu(); + } if (operation_requested&OP_LEVER || previous_button_state != button_state) { ui_process_lever(); previous_button_state = button_state; diff --git a/ui_sa.c b/ui_sa.c index 5850067..b5c3f18 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -846,6 +846,7 @@ int menu_is_form(const menuitem_t *menu) return(false); } + static void menu_item_modify_attribute( const menuitem_t *menu, int item, uint16_t *fg, uint16_t *bg) {