From ca687ea11be15a8f334df717cba3d540adbac010 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Thu, 2 Apr 2020 08:52:04 +0200 Subject: [PATCH] Intermediate commit on UI change --- nanovna.h | 4 ++-- sa_core.c | 2 +- ui.c | 24 +++++++++++++++--------- ui_sa.c | 22 +++++++++++----------- 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/nanovna.h b/nanovna.h index 82d5efa..a299dd5 100644 --- a/nanovna.h +++ b/nanovna.h @@ -199,8 +199,8 @@ extern int _height; #define CELLWIDTH (32) #define CELLHEIGHT (32) -#define NGRIDY 10 -//#define NGRIDY 9 +//#define NGRIDY 10 +#define NGRIDY 9 #define FREQUENCIES_XPOS1 OFFSETX #define FREQUENCIES_XPOS2 200 diff --git a/sa_core.c b/sa_core.c index 3c370ea..2396f5c 100644 --- a/sa_core.c +++ b/sa_core.c @@ -742,7 +742,7 @@ static bool sweep(bool break_on_operation) } -const char *averageText[] = { "OFF", "MIN", "MAX", "2", "4", "8"}; +const char *averageText[] = { "OFF", "MIN", "MAX", "MAXD", "4", "16"}; const char *dBText[] = { "1dB/", "2dB/", "5dB/", "10dB/", "20dB/"}; const int refMHz[] = { 30, 15, 10, 4, 3, 2, 1 }; diff --git a/ui.c b/ui.c index 6fc675c..2542794 100644 --- a/ui.c +++ b/ui.c @@ -1090,8 +1090,12 @@ static void ensure_selection(void) { const menuitem_t *menu = menu_stack[menu_current_level]; - int i; - for (i = 0; MT_MASK(menu[i].type) != MT_NONE && MT_MASK(menu[i].type) != MT_TITLE ; i++) + int i=0; + if (MT_MASK(menu[0].type) == MT_TITLE && selection == 0) { + selection = 1; + return; + } + for (i = 0; MT_MASK(menu[i].type) != MT_NONE ; i++) ; if (selection >= i) selection = i-1; @@ -1943,13 +1947,14 @@ ui_process_menu(void) // close menu if next item is sentinel if (menu_stack[menu_current_level][selection+1].type == MT_NONE) goto menuclose; - selection++; + if (!(menu_stack[menu_current_level][selection+1].type == MT_FORM | MT_NONE)) + selection++; } if (status & EVT_DOWN) { - if (selection == 0) - goto menuclose; - selection--; + if (! ( selection == 0 && menu_stack[menu_current_level][0].type & MT_FORM)) + selection--; } + ensure_selection(); draw_menu(); status = btn_wait_release(); } while (status != 0); @@ -2203,9 +2208,11 @@ ui_process_keypad(void) } redraw_frame(); - if (menu_is_form(menu_stack[menu_current_level])) + if (menu_is_form(menu_stack[menu_current_level])) { ui_mode_menu(); //Reactivate menu after keypad - else { + selection = 0; + ensure_selection(); + } else { ui_mode_normal(); request_to_redraw_grid(); } @@ -2360,7 +2367,6 @@ 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 - ensure_selection(); ui_mode_menu(); } if (operation_requested&OP_LEVER || previous_button_state != button_state) { diff --git a/ui_sa.c b/ui_sa.c index 58875ca..b67489e 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -528,7 +528,7 @@ static const menuitem_t menu_drive_wide[] = { { MT_FORM | MT_CALLBACK, 2, " 15dBm", menu_drive_cb}, { MT_FORM | MT_CALLBACK, 3, " 20dBm", menu_drive_cb}, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_modulation[] = { @@ -538,7 +538,7 @@ const menuitem_t menu_modulation[] = { { MT_FORM | MT_CALLBACK, 2, "NARROW FM", menu_modulation_cb}, { MT_FORM | MT_CALLBACK, 3, "WIDE FM", menu_modulation_cb}, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_lowoutputmode[] = { @@ -547,7 +547,7 @@ const menuitem_t menu_lowoutputmode[] = { { MT_FORM | MT_KEYPAD, KM_LOWOUTLEVEL, "LEVEL: %s", NULL}, { MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation}, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_highoutputmode[] = { @@ -556,7 +556,7 @@ const menuitem_t menu_highoutputmode[] = { { MT_FORM | MT_SUBMENU, 0, "LEVEL: %s", menu_drive_wide}, { MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation}, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; static const menuitem_t menu_average[] = { @@ -607,7 +607,7 @@ static const menuitem_t menu_reffer2[] = { { MT_FORM | MT_CALLBACK, 6, "2MHz" , menu_reffer_cb}, { MT_FORM | MT_CALLBACK, 7, "1MHz" , menu_reffer_cb}, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; static const menuitem_t menu_reffer[] = { @@ -618,7 +618,7 @@ static const menuitem_t menu_reffer[] = { { MT_FORM | MT_CALLBACK, 4, "4MHz" , menu_reffer_cb}, { MT_FORM | MT_SUBMENU, 0, S_RARROW" MORE", menu_reffer2}, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; static const menuitem_t menu_acquire[] = { @@ -627,7 +627,7 @@ static const menuitem_t menu_acquire[] = { { MT_SUBMENU,0, "RBW", menu_rbw}, { MT_SUBMENU,0, "AVERAGE", menu_average}, { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; static const menuitem_t menu_acquirehigh[] = { @@ -730,7 +730,7 @@ static const menuitem_t menu_marker[] = { static const menuitem_t menu_dfu[] = { { MT_FORM | MT_CALLBACK, 0, "ENTER DFU", menu_dfu_cb}, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; static const menuitem_t menu_settings2[] = @@ -783,7 +783,7 @@ static const menuitem_t menu_calibrate[] = { MT_FORM | MT_CALLBACK, 0, "CALIBRATE", menu_calibrate_cb}, { MT_FORM | MT_CALLBACK, 0, "RESET CALBRATION", menu_calibrate_cb}, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; static const menuitem_t menu_config[] = { @@ -796,7 +796,7 @@ static const menuitem_t menu_config[] = { // { MT_SUBMENU, 0, "RBW", menu_rbw}, { MT_FORM | MT_SUBMENU, 0, S_RARROW"DFU", menu_dfu}, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; static const menuitem_t menu_mode[] = { @@ -808,7 +808,7 @@ static const menuitem_t menu_mode[] = { { MT_FORM | MT_SUBMENU, 0, "CAL OUTPUT: %s", menu_reffer}, { MT_FORM | MT_SUBMENU, 0, "CONFIG", menu_config}, // { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; #if 1 const menuitem_t menu_top[] = {