diff --git a/nanovna.h b/nanovna.h index 48cfda2..9e291cd 100644 --- a/nanovna.h +++ b/nanovna.h @@ -517,23 +517,19 @@ extern uint16_t graph_bottom; // Menu Button // Maximum menu buttons count #ifdef TINYSA4 -#define MENU_BUTTON_MAX 12 -#define MENU_BUTTON_HEIGHT (LCD_HEIGHT/ 9-1) -#define MENU_BUTTON_HEIGHT_10 (LCD_HEIGHT/10-1) -#define MENU_BUTTON_HEIGHT_11 (LCD_HEIGHT/11-1) -#define MENU_BUTTON_HEIGHT_12 (LCD_HEIGHT/12-1) +#define MENU_BUTTON_MAX 16 +#define MENU_BUTTON_MIN 9 #else -#define MENU_BUTTON_MAX 12 -#define MENU_BUTTON_HEIGHT (LCD_HEIGHT/ 8-1) -#define MENU_BUTTON_HEIGHT_10 (LCD_HEIGHT/10-1) -#define MENU_BUTTON_HEIGHT_11 (LCD_HEIGHT/11-1) -#define MENU_BUTTON_HEIGHT_12 (LCD_HEIGHT/12-1) +#define MENU_BUTTON_MAX 16 +#define MENU_BUTTON_MIN 8 #endif #define MENU_BUTTON_WIDTH 80 #define MENU_BUTTON_BORDER 1 #define KEYBOARD_BUTTON_BORDER 2 #define FORM_BUTTON_BORDER 2 +#define MENU_BUTTON_HEIGHT_N(n) (LCD_HEIGHT/(n)-1) + // Define message box width #define MESSAGE_BOX_WIDTH 180 diff --git a/ui.c b/ui.c index 68a2e26..be043ba 100644 --- a/ui.c +++ b/ui.c @@ -64,7 +64,7 @@ static uint16_t last_button = 0b0000; static uint32_t last_button_down_ticks; static uint32_t last_button_repeat_ticks; -static uint16_t menu_button_height = MENU_BUTTON_HEIGHT; +static uint16_t menu_button_height = MENU_BUTTON_HEIGHT_N(MENU_BUTTON_MIN); volatile uint8_t operation_requested = OP_NONE; int8_t previous_marker = MARKER_INVALID; @@ -818,9 +818,9 @@ ensure_selection(void) if (selection < 0) selection = -1; if (selection >= i) selection = i-1; if (MT_MASK(menu[0].type) == MT_TITLE && selection == 0) selection = 1; - - static const uint8_t button_h[] = {MENU_BUTTON_HEIGHT, MENU_BUTTON_HEIGHT_10, MENU_BUTTON_HEIGHT_11, MENU_BUTTON_HEIGHT_12}; - menu_button_height = button_h[menu[i].data&3]; + if (i < MENU_BUTTON_MIN) i = MENU_BUTTON_MIN; + if (i >= MENU_BUTTON_MAX) i = MENU_BUTTON_MAX; + menu_button_height = MENU_BUTTON_HEIGHT_N(i); } static void diff --git a/ui_sa.c b/ui_sa.c index 0d35eb6..ae85ce3 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -2090,7 +2090,7 @@ static const menuitem_t menu_rbw[] = { { MT_ADV_CALLBACK, 7, "%sHz", menu_rbw_acb}, { MT_ADV_CALLBACK, 8, "%sHz", menu_rbw_acb}, { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, MENU_BUTTON_HEIGHT_10, NULL, NULL } // sentinel + { MT_NONE, 0, NULL, NULL } // sentinel #else { MT_ADV_CALLBACK, 1, "%4dkHz", menu_rbw_acb}, { MT_ADV_CALLBACK, 2, "%4dkHz", menu_rbw_acb},