From e9fb1e41437b1e5e1c3df929b772f376912c3ec7 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 21 Jun 2022 18:06:30 +0200 Subject: [PATCH] Path repairs --- nanovna.h | 2 ++ sa_cmd.c | 1 + sa_core.c | 20 ++++++++++++++------ ui_sa.c | 14 +++++++++++++- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/nanovna.h b/nanovna.h index 6f1d634..31f6cdd 100644 --- a/nanovna.h +++ b/nanovna.h @@ -1636,6 +1636,8 @@ float to_dBm(float); float dBm_to_Watt(float); uint32_t calc_min_sweep_time_us(void); pureRSSI_t perform(bool b, int i, freq_t f, int e); +extern pureRSSI_t get_frequency_correction(freq_t f); + void interpolate_maximum(int m); void calibrate_modulation(int modulation, int8_t *correction); diff --git a/sa_cmd.c b/sa_cmd.c index 2dc8200..ab6ef67 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -1165,6 +1165,7 @@ VNA_SHELL_FUNCTION(cmd_q) test_output_drive = 0; test_output_attenuate = 0; test_path = 0; + dirty = true; return; } int i = 0; diff --git a/sa_core.c b/sa_core.c index feb80d7..cde1a7a 100644 --- a/sa_core.c +++ b/sa_core.c @@ -196,9 +196,10 @@ void set_output_path(freq_t f, float level) PE4302_Write_Byte(test_output_attenuate); goto set_path; } - } else if (setting.mute) + } else if (setting.mute) { signal_path = PATH_OFF; - else if (MODE_HIGH(setting.mode)) + goto set_path; + } else if (MODE_HIGH(setting.mode)) signal_path = PATH_HIGH; else if (setting.mixer_output && (f >= MAX_LOW_OUTPUT_FREQ || (config.ultra_start != ULTRA_AUTO && f > config.ultra_start))) signal_path = PATH_ULTRA; @@ -209,6 +210,8 @@ void set_output_path(freq_t f, float level) else signal_path = PATH_LOW; + level += PURE_TO_float(get_frequency_correction(f)); + switch (signal_path) { case PATH_LEAKAGE: drive_dBm = (float *)adf_drive_dBm; @@ -349,7 +352,9 @@ void set_output_path(freq_t f, float level) void set_input_path(freq_t f) { - if (MODE_HIGH(setting.mode)) + if (test_output) + signal_path = test_path; + else if (MODE_HIGH(setting.mode)) signal_path = PATH_HIGH; else if(config.ultra && ((config.ultra_start == ULTRA_AUTO && f > 700) || (config.ultra_start != ULTRA_AUTO && f >config.ultra_start))) signal_path = PATH_ULTRA; @@ -2098,6 +2103,8 @@ pureRSSI_t get_frequency_correction(freq_t f) // Frequency dependent RSSI c } else if (setting.mode == M_GENLOW){ switch (signal_path) { + case PATH_OFF: + return 0; case PATH_LOW: c = CORRECTION_LOW_OUT; break; @@ -3346,13 +3353,14 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / else if (ls < 0) ls -= 0.5; float a = ((int)((setting.level + ((float)i / sweep_points) * ls)*2.0)) / 2.0 /* + get_level_offset() */ ; +#ifdef TINYSA4 + { + set_output_path(f, a); +#else correct_RSSI_freq = get_frequency_correction(f); a += PURE_TO_float(correct_RSSI_freq); if (a != old_a) { old_a = a; -#ifdef TINYSA4 - set_output_path(f, a); -#else a = a - level_max(); // convert to all settings maximum power output equals a = zero if (a < -SWITCH_ATTENUATION) { a = a + SWITCH_ATTENUATION; diff --git a/ui_sa.c b/ui_sa.c index cec0cc6..569e4e1 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1012,13 +1012,21 @@ static UI_FUNCTION_ADV_CALLBACK(menu_listen_acb) } #endif #ifdef TINYSA4 + +enum {PATH_OFF, PATH_LOW, PATH_DIRECT, PATH_ULTRA, PATH_LEAKAGE, PATH_HIGH}; +const char *path_text[]={"OFF", "LOW", "DIRECT", "ULTRA", "ADF", "High"}; +extern int signal_path; +extern int test_path; +extern int test_output; + static UI_FUNCTION_ADV_CALLBACK(menu_lowoutput_settings_acb) { static char mode_string[26]; (void)item; if (b){ if (data == 255) { - plot_printf(mode_string, sizeof mode_string, "%s %s %s", + plot_printf(mode_string, sizeof mode_string, "%s %s %s %s", + (!test_output ? "" : path_text[test_path]), (get_sweep_frequency(ST_START) < MINIMUM_DIRECT_FREQ ? "SINUS" : "" ), (get_sweep_frequency(ST_STOP) >= MINIMUM_DIRECT_FREQ ? "SQUARE WAVE" : ""), (get_sweep_frequency(ST_STOP) > MAX_LOW_OUTPUT_FREQ && setting.mixer_output ? "MIXER" : "")); @@ -3334,7 +3342,11 @@ static void fetch_numeric_target(uint8_t mode) if (setting.level_sweep != 0) plot_printf(uistat.text, sizeof uistat.text, "%.1f to %.1fdBm", uistat.value, end_level); else +#ifdef TINYSA4 + plot_printf(uistat.text, sizeof uistat.text, "%+.1fdBm %s", uistat.value, (setting.disable_correction?"Uncorrected":"")); +#else plot_printf(uistat.text, sizeof uistat.text, "%+.1fdBm", uistat.value); +#endif break; case KM_HIGHOUTLEVEL: uistat.value = get_level(); // compensation for dB offset during low output mode