From 13250cbf1db701165233fbe4777d73c2b2a8080b Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Wed, 2 Jun 2021 11:35:19 +0200 Subject: [PATCH 1/6] Added TRACE AVERAGE marker and always find maximum --- nanovna.h | 4 ++-- plot.c | 2 +- sa_core.c | 20 ++++++++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/nanovna.h b/nanovna.h index 06e3915..112e784 100644 --- a/nanovna.h +++ b/nanovna.h @@ -18,7 +18,7 @@ */ #include "ch.h" -//#ifdef TINYSA_F303 +#ifdef TINYSA_F303 #include "adc_F303.h" #ifdef TINYSA_F072 #error "Remove comment for #ifdef TINYSA_F303" @@ -27,7 +27,7 @@ #define TINYSA4 #endif #define TINYSA4_PROTO -//#endif +#endif #ifdef TINYSA_F072 #ifdef TINYSA_F303 diff --git a/plot.c b/plot.c index 8a42c2b..5ba014f 100644 --- a/plot.c +++ b/plot.c @@ -1488,7 +1488,7 @@ static void trace_print_value_string( // Only used at one place #else if (bold) format++; // Skip small prefix for bold output #endif - cell_printf(xpos, ypos, format, buf2, v, unit_string[unit_index], (mtype & M_NOISE?"/Hz":"")); + cell_printf(xpos, ypos, format, buf2, v, unit_string[unit_index], (mtype & M_NOISE?"/Hz":(mtype & M_AVER?"/T":""))); } static void cell_draw_marker_info(int x0, int y0) diff --git a/sa_core.c b/sa_core.c index 599a2a7..00b7f3e 100644 --- a/sa_core.c +++ b/sa_core.c @@ -4103,6 +4103,11 @@ static volatile int dummy; temppeakLevel = actual_t[0]; max_index[0] = 0; downslope = true; + peakLevel = temppeakLevel; + } + if (cur_max == 0 && peakLevel < actual_t[i]) { + peakIndex = i; + peakLevel = actual_t[i]; } if (downslope) { // If in down slope peak finding if (temppeakLevel > actual_t[i]) { // Follow down @@ -4403,6 +4408,10 @@ static volatile int dummy; // --------------------- set tracking markers from maximum table ----------------- + if (cur_max == 0) { + max_index[0] = peakIndex; + cur_max = 1; + } if (MODE_INPUT(setting.mode)) { // Assign maxima found to tracking markers int i = 0; int m = 0; @@ -4525,8 +4534,11 @@ static volatile int dummy; } #endif - peakIndex = max_index[0]; - peakLevel = actual_t[peakIndex]; + if (cur_max > 0) { + peakIndex = max_index[0]; + peakLevel = actual_t[peakIndex]; + cur_max = 1; + } peakFreq = frequencies[peakIndex]; min_level = temp_min_level; } @@ -5887,7 +5899,9 @@ again: set_refer_output(0); set_sweep_frequency(ST_STOP, 60000000); int test_case = TEST_POWER; +#ifdef TINYSA set_extra_lna(calibrate_lna); +#endif set_average(AV_100); for (int m=1; m<20; m++) { test_acquire(test_case); // Acquire test @@ -5996,7 +6010,9 @@ quit: sweep_mode = SWEEP_ENABLE; // set_refer_output(-1); // reset_settings(M_LOW); +#ifdef TINYSA4 set_extra_lna(false); +#endif set_average(AV_OFF); } From 98f574f296a5f88c77fe3f6a7573138b80b4b104 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Wed, 2 Jun 2021 16:27:12 +0200 Subject: [PATCH 2/6] Tuned noise filter measurements --- nanovna.h | 1 + plot.c | 3 ++- sa_core.c | 13 +++++++++++-- si4468.c | 18 +++++++++--------- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/nanovna.h b/nanovna.h index 112e784..a915f55 100644 --- a/nanovna.h +++ b/nanovna.h @@ -266,6 +266,7 @@ extern float level_range(void); extern float channel_power[3]; extern float channel_power_watt[3]; extern const char * const unit_string[]; +extern uint16_t vbwSteps; #ifdef TINYSA4 extern freq_t ultra_threshold; extern bool ultra; diff --git a/plot.c b/plot.c index 5ba014f..54b8698 100644 --- a/plot.c +++ b/plot.c @@ -1685,7 +1685,8 @@ static void cell_draw_marker_info(int x0, int y0) int level = temppeakLevel - get_attenuation() + setting.external_gain; if ((!setting.subtract_stored) && // Disabled when normalized ((setting.mode == M_LOW && level > -10) || - (setting.mode == M_HIGH && level > -29) )) + (setting.mode == M_HIGH && level > -29) || + (setting.mode == M_LOW && (markers[i].mtype & M_NOISE) && vbwSteps > 1))) //MAXPEAK increases noise marker, should reduce span. color = LCD_BRIGHT_COLOR_RED; else color = marker_color(markers[i].mtype); diff --git a/sa_core.c b/sa_core.c index 00b7f3e..a65e3a2 100644 --- a/sa_core.c +++ b/sa_core.c @@ -4602,6 +4602,11 @@ static volatile int dummy; // palSetLine(LINE_LED); #endif + // Enable traces at sweep complete for redraw + if (enable_after_complete){ + TRACE_ENABLE(enable_after_complete); + enable_after_complete = 0; + } return true; } @@ -5744,9 +5749,11 @@ quit: shell_printf("%6.2f ", (first_level - peakLevel)*10.0 ); if (setting.test_argument != 0) break; + if (operation_requested) goto abort; } } #endif +abort: shell_printf("\n\r"); setting.R = 0; switch_SI4463_RSSI_correction(true); @@ -5764,6 +5771,7 @@ quit: if (setting.test_argument != 0) j = setting.test_argument; test_prepare(TEST_NOISE); + markers[0].mtype = M_NOISE | M_AVER; setting.rbw_x10 = force_rbw(j); setting.extra_lna = true; osalThreadSleepMilliseconds(200); @@ -5798,7 +5806,7 @@ quit: setting.rbw_x10 = force_rbw(j); setting.extra_lna = true; osalThreadSleepMilliseconds(200); - + markers[0].mtype = M_NOISE | M_AVER; set_sweep_frequency(ST_SPAN, (freq_t)(setting.rbw_x10 * (1000 << k))); set_average(AV_100); test_acquire(TC_LEVEL); // Acquire test @@ -5818,6 +5826,7 @@ quit: shell_printf("%6.2f ", (first_level - peakLevel)*10.0 ); if (setting.test_argument != 0) break; + if (operation_requested) goto abort; } } #endif @@ -5899,7 +5908,7 @@ again: set_refer_output(0); set_sweep_frequency(ST_STOP, 60000000); int test_case = TEST_POWER; -#ifdef TINYSA +#ifdef TINYSA4 set_extra_lna(calibrate_lna); #endif set_average(AV_100); diff --git a/si4468.c b/si4468.c index a607564..82422b7 100644 --- a/si4468.c +++ b/si4468.c @@ -1523,15 +1523,15 @@ typedef struct { static const RBW_t RBW_choices[] = { // BW register corr freq - {SI4463_RBW_02kHz, 14,3,22}, - {SI4463_RBW_1kHz, 18,10,9}, - {SI4463_RBW_3kHz, 14,30,8}, - {SI4463_RBW_10kHz, 6,100,6}, - {SI4463_RBW_30kHz, 11,300,2}, - {SI4463_RBW_100kHz, 6,1000,-1}, - {SI4463_RBW_300kHz, 6,3000,-15}, - {SI4463_RBW_600kHz, 6,6000,-21}, - {SI4463_RBW_850kHz,16,8500,-29}, + {SI4463_RBW_02kHz, 21,3, 26}, + {SI4463_RBW_1kHz, 26,10, 10}, + {SI4463_RBW_3kHz, 22,30, 8}, + {SI4463_RBW_10kHz, 12,100, 9}, + {SI4463_RBW_30kHz, 12,300, 12}, + {SI4463_RBW_100kHz, 7,1000, 10}, + {SI4463_RBW_300kHz, 8,3000, 7}, + {SI4463_RBW_600kHz, 8,6000, 15}, + {SI4463_RBW_850kHz,18,8500, 15}, }; const uint8_t SI4432_RBW_count = ((int)(sizeof(RBW_choices)/sizeof(RBW_t))); From 3427a4501a02084eb3e5c971aadbfda9f668d82b Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Thu, 3 Jun 2021 17:14:57 +0200 Subject: [PATCH 3/6] Averaged noise marker caching and improve LF noise floor with large RBW --- nanovna.h | 1 + plot.c | 58 +++++++++++++++++++++++++++++++++---------------------- sa_core.c | 6 ++++-- ui_sa.c | 2 +- 4 files changed, 41 insertions(+), 26 deletions(-) diff --git a/nanovna.h b/nanovna.h index a915f55..9e7dba2 100644 --- a/nanovna.h +++ b/nanovna.h @@ -676,6 +676,7 @@ float get_level_offset(void); extern uint8_t in_selftest; extern int display_test(void); +extern void clear_marker_cache(void); // // Shell config functions and macros diff --git a/plot.c b/plot.c index 54b8698..f93b756 100644 --- a/plot.c +++ b/plot.c @@ -280,9 +280,20 @@ index_to_value(const int i) return(value(actual_t[i])); } #endif + +float marker_cache[MARKERS_MAX]; +bool marker_cache_valid[MARKERS_MAX]; +void +clear_marker_cache(void) +{ + for (int i = 0; i=2 && setting.measurement == M_NF && markers[0].enabled) { float aNP = 0; -#if 1 - for (int i =0; i < sweep_points; i++) { - aNP += actual_t[i]; - } - aNP /= sweep_points; -#else aNP = marker_to_value(0); -#endif - float mNF = aNP - logf(actual_rbw_x10*100.0) * (10.0/logf(10.0)) + 173.93 + SI4463_noise_correction_x10/10.0; // measured noise figure at 20C + float mNF = aNP + 173.93 - nf_gain; // measured noise figure at 20C if (nf_gain != 0) { - float mnf = expf((mNF - nf_gain)/10 * logf(10)); // measure noise factor - float tnf = expf(config.noise_figure/10 * logf(10)); // tinySA noise factor - float amp_gain = expf(nf_gain/10 * logf(10)); + float mnf = expf(mNF/10.0 * logf(10)); // measure noise factor + float tnf = expf(config.noise_figure/10.0 * logf(10.0)); // tinySA noise factor + float amp_gain = expf(nf_gain/10.0 * logf(10.0)); float anf = mnf - (tnf - 1.0)/amp_gain; - mNF = 10*logf(anf)/logf(10); + mNF = 10.0*logf(anf)/logf(10.0); } // powf(10,x) = expf(x * logf(10)) // log10f(x) = logf(x)/logf(10) diff --git a/sa_core.c b/sa_core.c index a65e3a2..8be6432 100644 --- a/sa_core.c +++ b/sa_core.c @@ -3320,7 +3320,7 @@ again: // Spur redu } set_freq(ADF4351_LO, target_f); #if 1 // Compensate frequency ADF4350 error with SI4468 - if (actual_rbw_x10 < 3000 || setting.frequency_step < 100000) { + if (actual_rbw_x10 < 10000 || setting.frequency_step < 100000) { int32_t error_f = 0; if (real_old_freq[ADF4351_LO] > target_f) { error_f = real_old_freq[ADF4351_LO] - target_f; @@ -3588,11 +3588,13 @@ again: // Spur redu my_step_delay = my_step_delay * 2; // if (LO_shifted) // || SI4463_offset_changed) // my_step_delay = my_step_delay * 2; +#if 0 // Always have some delay before measuring RSSI if (old_R < 4 && actual_rbw_x10 >= 1000 && SI4463_frequency_changed && ADF4351_frequency_changed) { my_step_delay -= 200; // compensate for additional delay of setting SI4463 if (my_step_delay < 0) my_step_delay = 0; } +#endif my_microsecond_delay(my_step_delay * (old_R > 5 ? 8 : (old_R > 3 ? 2 : 1))); ADF4351_frequency_changed = false; SI4463_frequency_changed = false; @@ -3738,7 +3740,7 @@ static bool sweep(bool break_on_operation) float vbw_rssi; #endif #endif - + clear_marker_cache(); again: // Waiting for a trigger jumps back to here setting.measure_sweep_time_us = 0; // start measure sweep time // start_of_sweep_timestamp = chVTGetSystemTimeX(); // Will be set in perform diff --git a/ui_sa.c b/ui_sa.c index ba7b1ec..530f399 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1347,7 +1347,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb) case M_NF: // noise figure // reset_settings(setting.mode); markers[0].enabled = M_ENABLED; - markers[0].mtype = M_NOISE; // Not tracking + markers[0].mtype = M_NOISE | M_AVER; // Not tracking set_extra_lna(true); kp_help_text = "Amplifier Gain "; float old_gain = setting.external_gain; From a7ba3c43f4e41b69634ac3fade5154c763c67b8a Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Thu, 3 Jun 2021 18:38:40 +0200 Subject: [PATCH 4/6] Add comment --- sa_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sa_core.c b/sa_core.c index 8be6432..5119438 100644 --- a/sa_core.c +++ b/sa_core.c @@ -3320,7 +3320,7 @@ again: // Spur redu } set_freq(ADF4351_LO, target_f); #if 1 // Compensate frequency ADF4350 error with SI4468 - if (actual_rbw_x10 < 10000 || setting.frequency_step < 100000) { + if (actual_rbw_x10 < 10000 || setting.frequency_step < 100000) { //TODO always compensate for the moment as this eliminates artifacts at larger RBW int32_t error_f = 0; if (real_old_freq[ADF4351_LO] > target_f) { error_f = real_old_freq[ADF4351_LO] - target_f; From ddae6a368248e1a0e94338d0001d929390d1cf0d Mon Sep 17 00:00:00 2001 From: DiSlord Date: Thu, 3 Jun 2021 19:28:01 +0300 Subject: [PATCH 5/6] Move adc code to CPU folder Small cleanup --- Makefile | 6 ++-- adc.c => NANOVNA_STM32_F072/adc.c | 0 adc_F303.c => NANOVNA_STM32_F303/adc.c | 0 adc_F303.h | 41 -------------------------- main.c | 3 -- 5 files changed, 4 insertions(+), 46 deletions(-) rename adc.c => NANOVNA_STM32_F072/adc.c (100%) rename adc_F303.c => NANOVNA_STM32_F303/adc.c (100%) delete mode 100644 adc_F303.h diff --git a/Makefile b/Makefile index be7f79b..2515a8a 100644 --- a/Makefile +++ b/Makefile @@ -159,7 +159,8 @@ CSRC = $(STARTUPSRC) \ FatFs/ff.c \ FatFs/ffunicode.c \ usbcfg.c \ - main.c plot.c ui.c ili9341.c tlv320aic3204.c si5351.c numfont20x22.c Font5x7.c Font10x14.c flash.c adc_F303.c si4468.c Font7x13b.c rtc.c + NANOVNA_STM32_F303/adc.c \ + main.c plot.c ui.c ili9341.c tlv320aic3204.c si5351.c numfont20x22.c Font5x7.c Font10x14.c flash.c si4468.c Font7x13b.c rtc.c else CSRC = $(STARTUPSRC) \ $(KERNSRC) \ @@ -170,7 +171,8 @@ CSRC = $(STARTUPSRC) \ $(BOARDSRC) \ $(STREAMSSRC) \ usbcfg.c \ - main.c plot.c ui.c ili9341.c numfont20x22.c Font5x7.c Font10x14.c flash.c adc.c si4432.c Font7x13b.c + NANOVNA_STM32_F072/adc.c \ + main.c plot.c ui.c ili9341.c numfont20x22.c Font5x7.c Font10x14.c flash.c si4432.c Font7x13b.c endif # C++ sources that can be compiled in ARM or THUMB mode depending on the global diff --git a/adc.c b/NANOVNA_STM32_F072/adc.c similarity index 100% rename from adc.c rename to NANOVNA_STM32_F072/adc.c diff --git a/adc_F303.c b/NANOVNA_STM32_F303/adc.c similarity index 100% rename from adc_F303.c rename to NANOVNA_STM32_F303/adc.c diff --git a/adc_F303.h b/adc_F303.h deleted file mode 100644 index 437b3e7..0000000 --- a/adc_F303.h +++ /dev/null @@ -1,41 +0,0 @@ - -// F303 related ADC defines - - -#define ADC_SMPR_SMP_247P5 6 /**< @brief 260 cycles conversion time. */ -#define ADC_SMPR_SMP_24P5 3 /**< @brief 37 cycles conversion time. */ - - -#define rccEnableWWDG(lp) rccEnableAPB1(RCC_APB1ENR_WWDGEN, lp) -#define ADC_CHSELR_CHSEL6 ADC_CHANNEL_IN3 -#define ADC_CHSELR_CHSEL7 ADC_CHANNEL_IN4 -#define ADC_SMPR_SMP_239P5 7U -#define ADC_SMPR_SMP_28P5 3U /**< @brief 41 cycles conversion time. */ -#define ADC_CFGR_RES_12BIT (0 << 3) -/* -msg_t adcConvert(ADCDriver *adcp, - const ADCConversionGroup *grpp, - adcsample_t *samples, - size_t depth); -*/ -#define ADC_CR1_AWDEN ((uint32_t)0x00800000) /*!< Analog watchdog enable on regular channels */ -//ADC_Common_TypeDef *adcc; -#define ADC_CHSELR_VREFINT ADC_CHANNEL_IN18 -#define ADC_CHSELR_VBAT ADC_CHANNEL_IN17 - -#define ADC_ISR_ADRDY_Pos (0U) -#define ADC_ISR_ADRDY_Msk (0x1U << ADC_ISR_ADRDY_Pos) /*!< 0x00000001 */ -#define ADC_ISR_ADRDY ADC_ISR_ADRDY_Msk /*!< ADC ready flag */ -#define ADC_IER_ADRDYIE_Pos (0U) -#define ADC_IER_ADRDYIE_Msk (0x1U << ADC_IER_ADRDYIE_Pos) /*!< 0x00000001 */ -#define ADC_IER_ADRDYIE ADC_IER_ADRDYIE_Msk /*!< ADC ready interrupt */ -#define ADC_IER_AWD1IE_Pos (7U) -#define ADC_IER_AWD1IE_Msk (0x1U << ADC_IER_AWD1IE_Pos) /*!< 0x00000080 */ -#define ADC_IER_AWD1IE ADC_IER_AWD1IE_Msk /*!< ADC analog watchdog 1 interrupt */ -#define ADC_IER_EOCIE_Pos (2U) -#define ADC_IER_EOCIE_Msk (0x1U << ADC_IER_EOCIE_Pos) /*!< 0x00000004 */ -#define ADC_IER_EOCIE ADC_IER_EOCIE_Msk /*!< ADC group regular end of unitary conversion interrupt */ -#define ADC_IER_EOSMPIE_Pos (1U) -#define ADC_IER_EOSMPIE_Msk (0x1U << ADC_IER_EOSMPIE_Pos) /*!< 0x00000002 */ -#define ADC_IER_EOSMPIE ADC_IER_EOSMPIE_Msk /*!< ADC group regular end of sampling interrupt */ - diff --git a/main.c b/main.c index a322480..cd8f31b 100644 --- a/main.c +++ b/main.c @@ -15,9 +15,6 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ -//#define HAL_USE_SERIAL 1 -//#define STM32_SERIAL_USE_USART1 1 - #include "ch.h" #include "hal.h" From 2957fc289bcb119cc48d06024d0abbbc4357899b Mon Sep 17 00:00:00 2001 From: DiSlord Date: Thu, 3 Jun 2021 19:29:12 +0300 Subject: [PATCH 6/6] 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) {