From ba756ede939a1730b2ce9e82f18577e28e1537ec Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sun, 5 Jun 2022 17:54:08 +0200 Subject: [PATCH] Clean output switch added --- nanovna.h | 5 +++-- sa_core.c | 4 ++-- ui_sa.c | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/nanovna.h b/nanovna.h index 05dd585..bfb9225 100644 --- a/nanovna.h +++ b/nanovna.h @@ -18,7 +18,7 @@ */ #include "ch.h" -#ifdef TINYSA_F303 +//#ifdef TINYSA_F303 #ifdef TINYSA_F072 #error "Remove comment for #ifdef TINYSA_F303" #endif @@ -26,7 +26,7 @@ #define TINYSA4 #endif #define TINYSA4_PROTO -#endif +//#endif #ifdef TINYSA_F072 #ifdef TINYSA_F303 @@ -1184,6 +1184,7 @@ typedef struct setting int R; // KM_R int32_t exp_aver; bool increased_R; + bool clean_output; #endif int64_t test_argument; // used for tests uint32_t checksum; // must be last and at 4 byte boundary diff --git a/sa_core.c b/sa_core.c index f2a587c..18efb16 100644 --- a/sa_core.c +++ b/sa_core.c @@ -3025,7 +3025,7 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / int modulation_count_iter = 0; int spur_second_pass = false; #ifdef __NEW_SWITCHES__ - int direct = ((setting.mode == M_LOW && config.direct && f > DIRECT_START && f= MINIMUM_DIRECT_FREQ && f < ultra_start) ); + int direct = ((setting.mode == M_LOW && config.direct && f > DIRECT_START && f= MINIMUM_DIRECT_FREQ && f < ultra_start && setting.clean_output) ); #else const int direct = false; #endif @@ -3441,7 +3441,7 @@ modulation_again: #endif } } else if (setting.mode == M_GENLOW) { - if (ultra && f > ultra_start) { // Ultra mode output using both SI and ADF + if (ultra && (f > ultra_start || (!setting.clean_output && f > 800000000))) { // Ultra mode output using both SI and ADF if (!SI4463_is_in_tx_mode()) SI4463_init_tx(); enable_ADF_output(true); diff --git a/ui_sa.c b/ui_sa.c index e66f2ff..2c309d0 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -563,6 +563,7 @@ static const menuitem_t menu_measure_noise_figure[]; #endif static const menuitem_t menu_sweep[]; static const menuitem_t menu_settings[]; +static const menuitem_t menu_lowoutput_settings[]; extern bool dirty; char range_text[20]; @@ -1010,7 +1011,30 @@ static UI_FUNCTION_ADV_CALLBACK(menu_listen_acb) #endif } #endif +#ifdef TINYSA4 +static UI_FUNCTION_ADV_CALLBACK(menu_lowoutput_settings_acb) +{ + (void)item; + if (b){ + if (data == 255) { b->param_1.text = setting.clean_output ? "CLEAN" : "ACCURATE"; return; } + b->icon = data == setting.clean_output ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP; + return; + } + switch(data) { + case 255: + menu_push_submenu(menu_lowoutput_settings); + return; + case 0: + setting.clean_output = false; + break; + case 1: + setting.clean_output = true; + break; + } + menu_move_back(false); +} +#endif // const int menu_modulation_value[]={MO_NONE,MO_AM, MO_NFM, MO_WFM, MO_EXTERNAL}; const char *menu_modulation_text[]={"None", "AM", "NFM", "WFM", "External"}; @@ -2484,6 +2508,14 @@ static const menuitem_t menu_sweep[] = { { MT_FORM | MT_SUBMENU, 0, "SWEEP POINTS", menu_sweep_points_form}, { MT_FORM | MT_NONE, 0, NULL, menu_back} // next-> menu_back }; +#ifdef TINYSA4 +static const menuitem_t menu_lowoutput_settings[] = { + { MT_FORM | MT_ADV_CALLBACK, 1, "OPTIMIZE FOR CLEAN SIGNAL", menu_lowoutput_settings_acb}, + { MT_FORM | MT_ADV_CALLBACK, 0, "OPTIMIZE FOR ACCURATE SIGNAL", menu_lowoutput_settings_acb}, + { MT_FORM | MT_SUBMENU, 255, S_RARROW" Settings", menu_settings}, + { MT_FORM | MT_NONE, 0, NULL, menu_back} // next-> menu_back +}; +#endif char low_level_help_text[12] = "-76..-6"; char center_text[18] = "FREQ: %s"; @@ -2500,7 +2532,7 @@ const menuitem_t menu_lowoutputmode[] = { #endif { MT_FORM | MT_KEYPAD, KM_EXT_GAIN, "EXTERNAL GAIN: %s", "-100..+100"}, #ifdef TINYSA4 - { MT_FORM | MT_SUBMENU, 255, S_RARROW" Settings", menu_settings}, + { MT_FORM | MT_ADV_CALLBACK, 255, "OPTIMIZE: %s", menu_lowoutput_settings_acb}, #endif { MT_FORM | MT_CANCEL, 0, "MODE", NULL }, { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel