From 4cb93be986e94842db268fc7933188d43aadafa2 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Thu, 3 Jun 2021 19:29:12 +0300 Subject: [PATCH] Implement menu item chain --- ui.c | 249 ++++++++++++++++++++++++++------------------------------ ui_sa.c | 186 ++++++++++++++---------------------------- 2 files changed, 176 insertions(+), 259 deletions(-) diff --git a/ui.c b/ui.c index d87cfb4..88e9569 100644 --- a/ui.c +++ b/ui.c @@ -136,7 +136,6 @@ typedef struct { #define EVT_TOUCH_DOWN 1 #define EVT_TOUCH_PRESSED 2 #define EVT_TOUCH_RELEASED 3 -#define EVT_TOUCH_LONGPRESS 4 #define TOUCH_INTERRUPT_ENABLED 1 static uint8_t touch_status_flag = 0; @@ -599,7 +598,7 @@ select_lever_mode(int mode) // type of menu item enum { MT_NONE, // sentinel menu - MT_BLANK, // blank menu (nothing draw) +// MT_BLANK, // blank menu (nothing draw) MT_SUBMENU, // enter to submenu MT_CALLBACK, // call user function MT_ADV_CALLBACK, // adv call user function @@ -788,16 +787,50 @@ active_marker_select(int item) // used only to select an active marker from the #define MENU_STACK_DEPTH_MAX 7 const menuitem_t *menu_stack[MENU_STACK_DEPTH_MAX] = { - menu_top, NULL, NULL, NULL + menu_top, NULL, NULL, NULL, NULL, NULL, NULL }; +int current_menu_is_form(void) +{ + return menu_stack[menu_current_level]->type & MT_FORM; +} + +static bool menuDisabled(uint8_t type){ + if ((type & MT_LOW) && !MODE_LOW(setting.mode)) + return true; + if ((type & MT_HIGH) && !MODE_HIGH(setting.mode)) + return true; +// if (type == MT_BLANK) +// return true; + return false; +} + +static const menuitem_t *menu_next_item(const menuitem_t *m){ + do{ + m++; + m = MT_MASK(m->type) == MT_NONE ? (menuitem_t *)m->reference : m; + } while(m!=NULL && menuDisabled(m->type)); + return m; +} + +static const menuitem_t *current_menu_item(int i){ + const menuitem_t * m = menu_stack[menu_current_level]; + while (i--) m = menu_next_item(m); + return m; +} + +static int current_menu_get_count(void){ + int i = 0; + const menuitem_t *m = menu_stack[menu_current_level]; + while (m){m = menu_next_item(m); i++;} + return i; +} + 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; i++) - ; + int i = current_menu_get_count(); if (selection < 0) selection = -1; if (selection >= i) selection = i-1; if (MT_MASK(menu[0].type) == MT_TITLE && selection == 0) selection = 1; @@ -814,17 +847,18 @@ menu_move_back(bool leave_ui) if (menu_current_level == 0) return; erase_menu_buttons(); - if ( menu_is_form(menu_stack[menu_current_level ]) && - !menu_is_form(menu_stack[menu_current_level-1])) - redraw_request|=REDRAW_AREA|REDRAW_BATTERY|REDRAW_FREQUENCY|REDRAW_CAL_STATUS; // redraw all if switch from form to normal menu mode + bool form = current_menu_is_form(); menu_current_level--; - selection = -1; - if (leave_ui){ + // redraw all if switch from form to normal menu mode or back + if (form != current_menu_is_form()) + redraw_request|=REDRAW_AREA|REDRAW_BATTERY|REDRAW_FREQUENCY|REDRAW_CAL_STATUS; + + selection = -1; + if (leave_ui) ui_mode_normal(); - return; - } - ui_mode_menu(); + else + ui_mode_menu(); } static void @@ -849,11 +883,6 @@ menu_push_highoutput(void) menu_push_submenu(menu_highoutputmode); } -int current_menu_is_form(void) -{ - return menu_is_form(menu_stack[menu_current_level]); -} - /* static void menu_move_top(void) @@ -870,14 +899,13 @@ menu_move_top(void) static void menu_invoke(int item) { - const menuitem_t *menu = menu_stack[menu_current_level]; - menu = &menu[item]; - + const menuitem_t *menu = current_menu_item(item); + if (menu == NULL) return; switch (MT_MASK(menu->type)) { - case MT_NONE: - case MT_BLANK: - ui_mode_normal(); - break; +// case MT_NONE: +// case MT_BLANK: +// ui_mode_normal(); +// break; case MT_CANCEL: menu_move_back(false); @@ -905,7 +933,7 @@ menu_invoke(int item) case MT_KEYPAD: uistat.auto_center_marker = false; - if (menu->type & MT_FORM) { + if (current_menu_is_form()) { redraw_frame(); // Remove form numbers } kp_help_text = (char *)menu->reference; @@ -1053,21 +1081,6 @@ draw_numeric_area_frame(void) draw_numeric_input(""); } -#ifndef __VNA__ -extern void menu_item_modify_attribute( - const menuitem_t *menu, int item, ui_button_t *button); -#endif - -static bool menuDisabled(uint8_t type){ - if ((type & MT_LOW) && !MODE_LOW(setting.mode)) - return true; - if ((type & MT_HIGH) && !MODE_HIGH(setting.mode)) - return true; - if (type == MT_BLANK) - return true; - return false; -} - #define ICON_WIDTH 16 #define ICON_HEIGHT 11 @@ -1159,24 +1172,15 @@ draw_menu_buttons(const menuitem_t *menu, uint32_t mask) int i = 0; int y = 0; ui_button_t button; - for (i = 0; i < MENU_BUTTON_MAX; i++) { - if (MT_MASK(menu[i].type) == MT_NONE) - break; - if (menuDisabled(menu[i].type)) //not applicable to mode + const menuitem_t *m = menu; + for (i = 0; i < MENU_BUTTON_MAX && m; m = menu_next_item(m), i++, y += menu_button_height) { + if ((mask&(1<type) == MT_TITLE) { button.fg = LCD_FG_COLOR; button.bg = LCD_BG_COLOR; button.border = 0; // no border for title @@ -1196,25 +1200,25 @@ draw_menu_buttons(const menuitem_t *menu, uint32_t mask) menu_item_modify_attribute(menu, i, &button); // before plot_printf to create status text char *text; // MT_ADV_CALLBACK - allow change button data in callback, more easy and correct - if (MT_MASK(menu[i].type) == MT_ADV_CALLBACK){ - menuaction_acb_t cb = (menuaction_acb_t)menu[i].reference; - if (cb) (*cb)(i, menu[i].data, &button); + if (MT_MASK(m->type) == MT_ADV_CALLBACK){ + menuaction_acb_t cb = (menuaction_acb_t)m->reference; + if (cb) (*cb)(i, m->data, &button); // Apply custom text, from button label and - if (menu[i].label != MT_CUSTOM_LABEL) - plot_printf(button.text, sizeof(button.text), menu[i].label, button.param_1.u); + if (m->label != MT_CUSTOM_LABEL) + plot_printf(button.text, sizeof(button.text), m->label, button.param_1.u); text = button.text; } else - text = menu[i].label; + text = m->label; // Only keypad retrieves value - if (MT_MASK(menu[i].type) == MT_KEYPAD) { - fetch_numeric_target(menu[i].data); - plot_printf(button.text, sizeof button.text, menu[i].label, uistat.text); + if (MT_MASK(m->type) == MT_KEYPAD) { + fetch_numeric_target(m->data); + plot_printf(button.text, sizeof button.text, m->label, uistat.text); text = button.text; } int button_height = menu_button_height; - if (menu[i].type & MT_FORM) { + if (current_menu_is_form()) { int button_width = MENU_FORM_WIDTH; int button_start = (LCD_WIDTH - MENU_FORM_WIDTH)/2; // At center of screen draw_button(button_start, y, button_width, button_height, &button); @@ -1224,29 +1228,29 @@ draw_menu_buttons(const menuitem_t *menu, uint32_t mask) text_offs = button_start+6+ICON_WIDTH+1; } #ifdef __ICONS__ - if (menu[i].type & MT_ICON) { + if (m->type & MT_ICON) { ili9341_blitBitmap(button_start+MENU_FORM_WIDTH-2*FORM_ICON_WIDTH-8,y+(button_height-FORM_ICON_HEIGHT)/2,FORM_ICON_WIDTH,FORM_ICON_HEIGHT,& left_icons[((menu[i].data >>4)&0xf)*2*FORM_ICON_HEIGHT]); ili9341_blitBitmap(button_start+MENU_FORM_WIDTH- FORM_ICON_WIDTH-8,y+(button_height-FORM_ICON_HEIGHT)/2,FORM_ICON_WIDTH,FORM_ICON_HEIGHT,&right_icons[((menu[i].data >>0)&0xf)*2*FORM_ICON_HEIGHT]); } #endif int local_text_shift = 0; - if (MT_MASK(menu[i].type) == MT_KEYPAD) { + if (MT_MASK(m->type) == MT_KEYPAD) { int local_slider_positions = 0; - if (menu[i].data == KM_CENTER) { + if (m->data == KM_CENTER) { local_slider_positions = LCD_WIDTH/2+setting.slider_position; lcd_printf(button_start+12 + 0 * MENU_FORM_WIDTH/5, y+button_height-9, "%+3.0FHz", -(float)setting.slider_span); lcd_printf(button_start+12 + 1 * MENU_FORM_WIDTH/5, y+button_height-9, "%+3.0FHz", -(float)setting.slider_span/10); lcd_printf(button_start+12 + 2 * MENU_FORM_WIDTH/5, y+button_height-9, "Set"); lcd_printf(button_start+12 + 3 * MENU_FORM_WIDTH/5, y+button_height-9, "%+3.0FHz", (float)setting.slider_span/10); lcd_printf(button_start+12 + 4 * MENU_FORM_WIDTH/5, y+button_height-9, "%+3.0FHz", (float)setting.slider_span); - } else if (menu[i].data == KM_LOWOUTLEVEL) { + } else if (m->data == KM_LOWOUTLEVEL) { local_slider_positions = ((get_level() - level_min()) * (MENU_FORM_WIDTH-8)) / level_range() + OFFSETX+4; lcd_printf(button_start+12 + 0 * MENU_FORM_WIDTH/5, y+button_height-9, "%+ddB", -10); lcd_printf(button_start+12 + 1 * MENU_FORM_WIDTH/5, y+button_height-9, "%+ddB", -1); lcd_printf(button_start+12 + 2 * MENU_FORM_WIDTH/5, y+button_height-9, "Set"); lcd_printf(button_start+12 + 3 * MENU_FORM_WIDTH/5, y+button_height-9, "%+ddB", 1); lcd_printf(button_start+12 + 4 * MENU_FORM_WIDTH/5, y+button_height-9, "%+ddB", 10); - } else if (menu[i].data == KM_HIGHOUTLEVEL) { + } else if (m->data == KM_HIGHOUTLEVEL) { local_slider_positions = ((get_level() - level_min() ) * (MENU_FORM_WIDTH-8)) / level_range() + OFFSETX+4; } if (local_slider_positions){ @@ -1279,7 +1283,6 @@ draw_menu_buttons(const menuitem_t *menu, uint32_t mask) ili9341_drawstring(text, text_offs, y+(button_height-linesFONT_GET_HEIGHT)/2); #endif } - y += button_height; } // Cleanup other buttons (less flicker) // Erase empty buttons @@ -1287,7 +1290,7 @@ draw_menu_buttons(const menuitem_t *menu, uint32_t mask) ili9341_set_background(LCD_BG_COLOR); ili9341_fill(LCD_WIDTH-MENU_BUTTON_WIDTH, y, MENU_BUTTON_WIDTH, NO_WATERFALL - y); } -// if (menu[i].type & MT_FORM) +// if (current_menu_is_form()) // draw_battery_status(); } @@ -1323,8 +1326,9 @@ menu_select_touch(int i, int pos) selection = i; draw_menu_mask(mask); #if 1 // drag values - const menuitem_t *menu = menu_stack[menu_current_level]; - int keypad = menu[i].data; + const menuitem_t *m = current_menu_item(i); + if (m == NULL) return; + int keypad = m->data; int touch_x, touch_y, prev_touch_x = 0; systime_t dt = 0; int mode = SL_UNKNOWN; @@ -1335,7 +1339,7 @@ menu_select_touch(int i, int pos) if (dt > BUTTON_DOWN_LONG_TICKS) break; } - if (menu_is_form(menu) && MT_MASK(menu[i].type) == MT_KEYPAD && dt >= BUTTON_DOWN_LONG_TICKS){ + if (current_menu_is_form() && MT_MASK(m->type) == MT_KEYPAD && dt >= BUTTON_DOWN_LONG_TICKS){ // Wait release touch and process it while (touch_check() != EVT_TOUCH_NONE){ touch_position(&touch_x, &touch_y); @@ -1421,8 +1425,8 @@ menu_select_touch(int i, int pos) draw_menu_mask(1<type) == MT_KEYPAD){ + bool do_exit = false; long_t step = 0; if (keypad == KM_LOWOUTLEVEL) { switch (pos) { @@ -1471,35 +1475,27 @@ nogo: static void menu_apply_touch(int touch_x, int touch_y) { - const menuitem_t *menu = menu_stack[menu_current_level]; + const menuitem_t *m = menu_stack[menu_current_level]; int i; int y = 0; - for (i = 0; i < MENU_BUTTON_MAX; i++) { - if (MT_MASK(menu[i].type) == MT_NONE) - break; - if (menuDisabled(menu[i].type)) //not applicable to mode - continue; - if (MT_MASK(menu[i].type) == MT_TITLE) { - y += menu_button_height; - continue; - } - int active_button_start; - if (menu[i].type & MT_FORM) { - active_button_start = (LCD_WIDTH - MENU_FORM_WIDTH)/2; -// active_button_stop = LCD_WIDTH - active_button_start; - } else { - active_button_start = LCD_WIDTH - MENU_BUTTON_WIDTH; -// active_button_stop = LCD_WIDTH; - } - if (y < touch_y && touch_y < y+menu_button_height) { - if (touch_x > active_button_start) { + int active_button_start; + if (current_menu_is_form()) { + active_button_start = (LCD_WIDTH - MENU_FORM_WIDTH)/2; +// active_button_stop = LCD_WIDTH - active_button_start; + } else { + active_button_start = LCD_WIDTH - MENU_BUTTON_WIDTH; +// active_button_stop = LCD_WIDTH; + } + for (i = 0; i < MENU_BUTTON_MAX && m; m = menu_next_item(m), i++) { + if (MT_MASK(m->type) != MT_TITLE) { + if (y < touch_y && touch_y < y+menu_button_height && touch_x > active_button_start) { menu_select_touch(i, (( touch_x - active_button_start) * 5 ) / MENU_FORM_WIDTH); return; } } y += menu_button_height; } - if (menu_is_form(menu)) + if (current_menu_is_form()) return; touch_wait_release(); ui_mode_normal(); @@ -1771,43 +1767,26 @@ ui_process_menu_lever(void) // if false user must select some thing const menuitem_t *menu = menu_stack[menu_current_level]; int status = btn_check(); - if (status != 0) { - if (selection >=0 && status & EVT_BUTTON_SINGLE_CLICK) { - menu_invoke(selection); - } else { - do { - uint32_t mask = 1< 0 && menuDisabled(menu[selection-1].type)) - selection--; - // close menu if item is 0, else step down - if (selection > 0) - selection--; - else if (!(menu[0].type & MT_FORM)) // not close if type = form menu - goto menuclose; - } -//activate: - ensure_selection(); - draw_menu_mask(mask|(1<=0 && status & EVT_BUTTON_SINGLE_CLICK) { + menu_invoke(selection); + return; } + uint16_t count = current_menu_get_count(); + do { + uint32_t mask = 1<= count && !(menu[0].type & MT_FORM)){ + ui_mode_normal(); + return; + } + ensure_selection(); + draw_menu_mask(mask|(1< menu_back }; static const menuitem_t menu_load_preset_high[] = @@ -2038,8 +2043,7 @@ static const menuitem_t menu_load_preset_high[] = { MT_ADV_CALLBACK, 7, MT_CUSTOM_LABEL, menu_load_preset_acb}, { MT_ADV_CALLBACK, 8, MT_CUSTOM_LABEL, menu_load_preset_acb}, { MT_SUBMENU, 0, "STORE" , menu_store_preset_high}, - { MT_CANCEL, 255, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL,menu_back} // next-> menu_back }; #endif @@ -2051,8 +2055,7 @@ static const menuitem_t menu_store_preset[] = { MT_ADV_CALLBACK, 3, "STORE %d", menu_store_preset_acb}, { MT_ADV_CALLBACK, 4, "STORE %d", menu_store_preset_acb}, { MT_ADV_CALLBACK, 100,"FACTORY\nDEFAULTS",menu_store_preset_acb}, - { MT_CANCEL, 255, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL,menu_back} // next-> menu_back }; static const menuitem_t menu_load_preset[] = @@ -2063,8 +2066,7 @@ static const menuitem_t menu_load_preset[] = { MT_ADV_CALLBACK, 3, MT_CUSTOM_LABEL, menu_load_preset_acb}, { MT_ADV_CALLBACK, 4, MT_CUSTOM_LABEL, menu_load_preset_acb}, { MT_SUBMENU, 0, "STORE" , menu_store_preset}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #ifdef TINYSA4 static const menuitem_t menu_mixer_drive[] = { @@ -2073,8 +2075,7 @@ static const menuitem_t menu_mixer_drive[] = { { MT_ADV_CALLBACK, 2, "%+ddBm", menu_mixer_drive_acb}, { MT_ADV_CALLBACK, 1, "%+ddBm", menu_mixer_drive_acb}, { MT_ADV_CALLBACK, 0, "%+ddBm", menu_mixer_drive_acb}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #else static const menuitem_t menu_lo_drive[] = { @@ -2082,8 +2083,7 @@ static const menuitem_t menu_lo_drive[] = { { MT_ADV_CALLBACK, 14, "%+ddBm", menu_lo_drive_acb}, { MT_ADV_CALLBACK, 13, "%+ddBm", menu_lo_drive_acb}, { MT_ADV_CALLBACK, 12, "%+ddBm", menu_lo_drive_acb}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #endif @@ -2095,8 +2095,7 @@ static const menuitem_t menu_modulation[] = { { MT_FORM | MT_ADV_CALLBACK, MO_WFM, "Wide FM", menu_modulation_acb}, { MT_FORM | MT_ADV_CALLBACK | MT_LOW, MO_EXTERNAL, "External", menu_modulation_acb}, { MT_FORM | MT_KEYPAD, KM_MODULATION, "FREQ: %s", "50Hz..6kHz"}, - { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL }, - { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_sweep[] = { @@ -2104,8 +2103,7 @@ static const menuitem_t menu_sweep[] = { { MT_FORM | MT_KEYPAD | MT_LOW, KM_LEVELSWEEP,"LEVEL CHANGE: %s", VARIANT("-70..70","-90..90")}, { MT_FORM | MT_KEYPAD, KM_SWEEP_TIME, "SWEEP TIME: %s", "0..600 seconds"}, { MT_FORM | MT_SUBMENU, 0, "SWEEP POINTS", menu_sweep_points_form}, - { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL }, - { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, menu_back} // next-> menu_back }; char low_level_help_text[12] = "-76..-6"; @@ -2159,8 +2157,7 @@ static const menuitem_t menu_average[] = { #ifdef __QUASI_PEAK__ { MT_ADV_CALLBACK, AV_QUASI, "QUASI\nPEAK", menu_average_acb}, #endif - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_rbw[] = { @@ -2175,8 +2172,7 @@ static const menuitem_t menu_rbw[] = { { MT_ADV_CALLBACK, 7, "%sHz", menu_rbw_acb}, { MT_ADV_CALLBACK, 8, "%sHz", menu_rbw_acb}, { MT_ADV_CALLBACK, 9, "%sHz", menu_rbw_acb}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back #else { MT_ADV_CALLBACK, 1, "%4dkHz", menu_rbw_acb}, { MT_ADV_CALLBACK, 2, "%4dkHz", menu_rbw_acb}, @@ -2184,8 +2180,7 @@ static const menuitem_t menu_rbw[] = { { MT_ADV_CALLBACK, 4, "%4dkHz", menu_rbw_acb}, { MT_ADV_CALLBACK, 5, "%4dkHz", menu_rbw_acb}, { MT_ADV_CALLBACK, 6, "%4dkHz", menu_rbw_acb}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back #endif }; @@ -2198,8 +2193,7 @@ static const menuitem_t menu_vbw[] = { { MT_ADV_CALLBACK, 3, "%s RBW", menu_vbw_acb}, { MT_ADV_CALLBACK, 4, "%s RBW", menu_vbw_acb}, { MT_ADV_CALLBACK, 5, "%s RBW", menu_vbw_acb}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #endif @@ -2212,8 +2206,7 @@ static const menuitem_t menu_scale_per2[] = { { MT_ADV_CALLBACK,10, "0.01/", menu_scale_per_acb}, //{ MT_ADV_CALLBACK,11, "0.005/", menu_scale_per_acb}, //{ MT_SUBMENU, 0, S_RARROW" MORE", menu_scale_per2}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_scale_per[] = { @@ -2224,8 +2217,7 @@ static const menuitem_t menu_scale_per[] = { { M_ADVT_CALLBACK, 4, " 1/", menu_scale_per_acb}, { MT_ADV_CALLBACK, 5, "0.5/", menu_scale_per_acb}, { MT_SUBMENU, 0, S_RARROW" MORE", menu_scale_per2}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #endif @@ -2234,8 +2226,7 @@ static const menuitem_t menu_reffer2[] = { { MT_FORM | MT_ADV_CALLBACK, 5, "%s", menu_reffer_acb}, { MT_FORM | MT_ADV_CALLBACK, 6, "%s", menu_reffer_acb}, { MT_FORM | MT_ADV_CALLBACK, 7, "%s", menu_reffer_acb}, - { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #endif @@ -2248,8 +2239,7 @@ static const menuitem_t menu_reffer[] = { { MT_FORM | MT_ADV_CALLBACK, 6, "%s", menu_reffer_acb}, { MT_FORM | MT_ADV_CALLBACK, 7, "%s", menu_reffer_acb}, //{ MT_FORM | MT_SUBMENU, 0, S_RARROW" MORE", menu_reffer2}, - { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_atten[] = { @@ -2257,8 +2247,7 @@ static const menuitem_t menu_atten[] = { { MT_KEYPAD | MT_LOW, KM_ATTENUATION, "MANUAL", "0 - 30dB"}, { MT_ADV_CALLBACK | MT_HIGH,0, "0dB", menu_atten_high_acb}, { MT_ADV_CALLBACK | MT_HIGH,30, "22.5 - 40dB", menu_atten_high_acb}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_reflevel[] = { @@ -2276,8 +2265,7 @@ const menuitem_t menu_marker_search[] = { { MT_CALLBACK, 3, "MAX\n" S_RARROW" RIGHT", menu_marker_search_cb }, { MT_ADV_CALLBACK, 0, "ENTER\n%s", menu_enter_marker_acb}, { MT_ADV_CALLBACK, M_TRACKING, "TRACKING",menu_marker_modify_acb }, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; const menuitem_t menu_marker_modify[] = { @@ -2289,8 +2277,7 @@ const menuitem_t menu_marker_modify[] = { { MT_ADV_CALLBACK, M_AVER, "TRACE\nAVERAGE", menu_marker_modify_acb}, { MT_SUBMENU, 0, "SEARCH", menu_marker_search}, { MT_CALLBACK, M_DELETE, "DELETE", menu_marker_delete_cb}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #ifdef __LIMITS__ @@ -2299,8 +2286,7 @@ static const menuitem_t menu_limit_modify[] = { MT_KEYPAD, KM_LIMIT_FREQ, "END\nFREQUENCY", "End frequency"}, { MT_KEYPAD, KM_LIMIT_LEVEL, "LEVEL", "Limit level"}, { MT_CALLBACK, 0, "DISABLE", menu_limit_disable_cb}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; const menuitem_t menu_limit_select[] = { @@ -2310,8 +2296,7 @@ const menuitem_t menu_limit_select[] = { { MT_ADV_CALLBACK, 4, "LIMIT %d", menu_limit_select_acb }, { MT_ADV_CALLBACK, 5, "LIMIT %d", menu_limit_select_acb }, { MT_ADV_CALLBACK, 6, "LIMIT %d", menu_limit_select_acb }, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #endif @@ -2325,8 +2310,7 @@ const menuitem_t menu_marker_sel[] = { { MT_CALLBACK, 0, "DELTA", menu_marker_sel_cb }, { MT_CALLBACK, 0, "NOISE", menu_marker_sel_cb }, { MT_CALLBACK, 0, "TRACKING", menu_marker_sel_cb }, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #endif @@ -2347,8 +2331,7 @@ const menuitem_t menu_marker_select[] = { #if MARKER_COUNT >= 8 { MT_ADV_CALLBACK, 8, "MARKER %d", menu_marker_select_acb }, #endif - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_marker_ref_select[] = { @@ -2368,8 +2351,7 @@ static const menuitem_t menu_marker_ref_select[] = { #if MARKER_COUNT >= 8 { MT_ADV_CALLBACK, 8, "MARKER %d", menu_marker_ref_select_acb }, #endif - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; const menuitem_t menu_marker_ops[] = { @@ -2378,8 +2360,7 @@ const menuitem_t menu_marker_ops[] = { { MT_CALLBACK, ST_CENTER, S_RARROW" CENTER", menu_marker_op_cb }, { MT_CALLBACK, ST_SPAN, S_RARROW" SPAN", menu_marker_op_cb }, { MT_CALLBACK, 4, S_RARROW" REF LEVEL",menu_marker_op_cb }, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_marker[] = { @@ -2388,15 +2369,13 @@ static const menuitem_t menu_marker[] = { { MT_SUBMENU, 0, "MARKER\nOPS", menu_marker_ops}, { MT_SUBMENU, 0, "SEARCH\nMARKER", menu_marker_search}, { MT_CALLBACK, 0, "RESET\nMARKERS", menu_markers_reset_cb}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #ifndef TINYSA4 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_FORM | MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #endif @@ -2408,8 +2387,7 @@ static const menuitem_t menu_harmonic[] = { MT_ADV_CALLBACK, 3, "3", menu_harmonic_acb}, { MT_ADV_CALLBACK, 4, "4", menu_harmonic_acb}, { MT_ADV_CALLBACK, 5, "5", menu_harmonic_acb}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #endif @@ -2420,10 +2398,9 @@ static const menuitem_t menu_scanning_speed[] = // { MT_ADV_CALLBACK, SD_PRECISE, PRECISE", menu_scanning_speed_acb}, // { MT_ADV_CALLBACK | MT_LOW,SD_FAST, "FAST", menu_scanning_speed_acb}, // { MT_KEYPAD | MT_LOW,KM_FAST_SPEEDUP, "FAST\nSPEEDUP", "2..20"}, - { MT_KEYPAD, KM_SAMPLETIME, "SAMPLE\nDELAY", "250..10000, 0=auto"}, // This must be item 4 to match highlighting - { MT_KEYPAD, KM_OFFSET_DELAY, "OFFSET\nDELAY", "250..10000, 0=auto"}, // This must be item 5 to match highlighting - { MT_CANCEL, 0, "\032 BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_KEYPAD, KM_SAMPLETIME, "SAMPLE\nDELAY", "250..10000, 0=auto"}, // This must be item 4 to match highlighting + { MT_KEYPAD, KM_OFFSET_DELAY, "OFFSET\nDELAY", "250..10000, 0=auto"}, // This must be item 5 to match highlighting + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_sweep_points[] = { @@ -2435,8 +2412,7 @@ static const menuitem_t menu_sweep_points[] = { { MT_ADV_CALLBACK, 4, "%3d point", menu_points_acb }, { MT_ADV_CALLBACK, 5, "%3d point", menu_points_acb }, #endif - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_sweep_points_form[] = { @@ -2448,8 +2424,7 @@ static const menuitem_t menu_sweep_points_form[] = { { MT_FORM | MT_ADV_CALLBACK, 4, "%3d point", menu_points_acb }, { MT_FORM | MT_ADV_CALLBACK, 5, "%3d point", menu_points_acb }, #endif - { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_sweep_speed[] = @@ -2468,8 +2443,7 @@ static const menuitem_t menu_sweep_speed[] = #else { MT_KEYPAD | MT_LOW,KM_FAST_SPEEDUP,"FAST\nSPEEDUP", "2..20, 0=disable"}, #endif - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #ifdef TINYSA4 @@ -2506,9 +2480,8 @@ static const menuitem_t menu_settings3[] = #ifdef __HAM_BAND__ { MT_ADV_CALLBACK, 0, "HAM\nBANDS", menu_settings_ham_bands}, #endif -#endif // TINYSA4 - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel +#endif // TINYSA4 + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #ifdef TINYSA4 static const menuitem_t menu_settings4[] = @@ -2532,8 +2505,7 @@ static const menuitem_t menu_settings4[] = { MT_SUBMENU,0, "HARMONIC", menu_harmonic}, #endif // { MT_SUBMENU, 0, S_RARROW" MORE", menu_settings3}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #endif @@ -2553,8 +2525,7 @@ static const menuitem_t menu_settings2[] = { MT_KEYPAD, KM_30MHZ, "ACTUAL\n30MHz*100", "Enter actual 30MHz * 100"}, #endif { MT_SUBMENU, 0, S_RARROW" MORE", menu_settings3}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #ifdef TINYSA4 @@ -2565,8 +2536,7 @@ static const menuitem_t menu_curve3[] = { { MT_FORM | MT_ADV_CALLBACK, 17, MT_CUSTOM_LABEL, menu_curve_acb }, { MT_FORM | MT_ADV_CALLBACK, 18, MT_CUSTOM_LABEL, menu_curve_acb }, { MT_FORM | MT_ADV_CALLBACK, 19, MT_CUSTOM_LABEL, menu_curve_acb }, - { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_curve2[] = { @@ -2578,8 +2548,7 @@ static const menuitem_t menu_curve2[] = { { MT_FORM | MT_ADV_CALLBACK, 12, MT_CUSTOM_LABEL, menu_curve_acb }, { MT_FORM | MT_ADV_CALLBACK, 13, MT_CUSTOM_LABEL, menu_curve_acb }, { MT_FORM | MT_SUBMENU, 0, S_RARROW" MORE", menu_curve3}, - { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_curve[] = { @@ -2591,8 +2560,7 @@ static const menuitem_t menu_curve[] = { { MT_FORM | MT_ADV_CALLBACK, 5, MT_CUSTOM_LABEL, menu_curve_acb }, { MT_FORM | MT_ADV_CALLBACK, 6, MT_CUSTOM_LABEL, menu_curve_acb }, { MT_FORM | MT_SUBMENU, 0, S_RARROW" MORE", menu_curve2}, - { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_curve_confirm[] = { @@ -2612,8 +2580,7 @@ static const menuitem_t menu_actual_power[] = { MT_CALLBACK, 0, "LNA\nCURVE", menu_lna_curve_prepare_cb}, { MT_CALLBACK, 0, "OUTPUT\nCURVE", menu_output_curve_prepare_cb}, #endif - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; @@ -2636,8 +2603,7 @@ static const menuitem_t menu_settings[] = { MT_SUBMENU | MT_LOW,0, "MIXER\nDRIVE", menu_lo_drive}, #endif { MT_SUBMENU, 0, S_RARROW" MORE", menu_settings2}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_measure2[] = { @@ -2656,8 +2622,7 @@ static const menuitem_t menu_measure2[] = { #ifdef __FFT_DECONV__ { MT_ADV_CALLBACK, M_DECONV, "DECONV", menu_measure_acb}, #endif - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_measure[] = { @@ -2668,8 +2633,7 @@ static const menuitem_t menu_measure[] = { { MT_ADV_CALLBACK, M_SNR, "SNR", menu_measure_acb}, { MT_ADV_CALLBACK, M_PASS_BAND, "-3dB\nWIDTH", menu_measure_acb}, { MT_SUBMENU, 0, S_RARROW" MORE", menu_measure2}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #ifdef __CALIBRATE__ @@ -2678,8 +2642,7 @@ static const menuitem_t menu_calibrate[] = { MT_FORM | MT_TITLE, 0, "Connect HIGH and LOW", NULL}, { 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_FORM | MT_NONE, 0, NULL, NULL } // sentinel + { MT_FORM | MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #endif @@ -2695,24 +2658,21 @@ const menuitem_t menu_serial_speed[] = { { MT_ADV_CALLBACK, 7, "%u", menu_serial_speed_acb }, { MT_ADV_CALLBACK, 8, "%u", menu_serial_speed_acb }, { MT_ADV_CALLBACK, 9, "%u", menu_serial_speed_acb }, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_connection[] = { { MT_ADV_CALLBACK, _MODE_USB, "USB", menu_connection_acb }, { MT_ADV_CALLBACK, _MODE_SERIAL, "SERIAL", menu_connection_acb }, { MT_SUBMENU, 0, "SERIAL\nSPEED", menu_serial_speed }, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #endif const menuitem_t menu_touch[] = { { MT_CALLBACK, CONFIG_MENUITEM_TOUCH_CAL, "TOUCH CAL", menu_config_cb}, { MT_CALLBACK, CONFIG_MENUITEM_TOUCH_TEST, "TOUCH TEST", menu_config_cb}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_config[] = { @@ -2735,8 +2695,7 @@ static const menuitem_t menu_config[] = { #ifdef __LCD_BRIGHTNESS__ { MT_CALLBACK, 0, "BRIGHTNESS", menu_brightness_cb}, #endif - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_storage[] = { @@ -2748,8 +2707,7 @@ static const menuitem_t menu_storage[] = { { MT_ADV_CALLBACK,4, "ACTUAL\n"S_RARROW"SD", menu_storage_acb}, { MT_ADV_CALLBACK,5, "STORED\n"S_RARROW"SD", menu_storage_acb}, #endif - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_display[] = { @@ -2771,9 +2729,7 @@ static const menuitem_t menu_display[] = { // { MT_ADV_CALLBACK,0, "SEND\nDISPLAY", menu_send_display_acb}, //#endif // { MT_KEYPAD, KM_SWEEP_TIME, "SWEEP\nTIME", NULL}, - - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_unit[] = @@ -2785,8 +2741,7 @@ static const menuitem_t menu_unit[] = //{ MT_ADV_CALLBACK,U_UVOLT, S_MICRO"Volt", menu_unit_acb}, { MT_ADV_CALLBACK,U_WATT, "Watt", menu_unit_acb}, //{ MT_ADV_CALLBACK,U_UWATT, S_MICRO"Watt", menu_unit_acb}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_trigger[] = { @@ -2798,8 +2753,7 @@ static const menuitem_t menu_trigger[] = { { MT_ADV_CALLBACK, T_UP, "UP\nEDGE", menu_trigger_acb}, { MT_ADV_CALLBACK, T_DOWN, "DOWN\nEDGE", menu_trigger_acb}, { MT_ADV_CALLBACK, T_MODE, "%s\nTRIGGER", menu_trigger_acb}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_level[] = { @@ -2817,8 +2771,7 @@ static const menuitem_t menu_level[] = { #ifdef __LISTEN__ { MT_ADV_CALLBACK, 0, "LISTEN", menu_listen_acb}, #endif - { MT_CANCEL, 0, S_LARROW" BACK",NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_stimulus[] = { @@ -2830,8 +2783,7 @@ static const menuitem_t menu_stimulus[] = { { MT_KEYPAD, KM_VAR, "JOG STEP\n%s","0 - AUTO"}, { MT_SUBMENU,0, "RBW", menu_rbw}, { MT_ADV_CALLBACK,0, "SHIFT\nFREQ", menu_shift_acb}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; static const menuitem_t menu_mode[] = { @@ -2864,20 +2816,6 @@ static const menuitem_t menu_top[] = { #define ACTIVE_COLOR RGBHEX(0x007FFF) -static bool menu_is_form(const menuitem_t *menu) -{ -#if 1 - // Not good set only one item as form and others as normal - return menu[0].type & MT_FORM; -#else - int i; - for (i = 0; MT_MASK(menu[i].type) != MT_NONE; i++) - if (menu[i].type & MT_FORM) - return (true); - return(false); -#endif -} - static void menu_item_modify_attribute( const menuitem_t *menu, int item, ui_button_t *button) {