From 63e8cee47141b097ad05c3bd8cc79db0f44a481c Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sat, 20 Jun 2020 09:29:15 +0200 Subject: [PATCH] Calculate correct CW sweep time when spur is on --- main.c | 15 +++++++++++---- nanovna.h | 2 +- plot.c | 6 +++++- sa_cmd.c | 8 +++++--- sa_core.c | 10 ++++++---- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/main.c b/main.c index 929a5f3..06ece57 100644 --- a/main.c +++ b/main.c @@ -156,8 +156,12 @@ static THD_FUNCTION(Thread1, arg) shell_function(shell_nargs - 1, &shell_args[1]); shell_function = 0; osalThreadSleepMilliseconds(10); - if (dirty && MODE_OUTPUT(setting.mode)) - draw_menu(); // update screen if in output mode and dirty + if (dirty) { + if (MODE_OUTPUT(setting.mode)) + draw_menu(); // update screen if in output mode and dirty + else + redraw_request |= REDRAW_CAL_STATUS | REDRAW_AREA | REDRAW_FREQUENCY; + } continue; } // Process UI inputs @@ -2438,9 +2442,12 @@ static void VNAShell_executeLine(char *line) } while (shell_function); } else { scp->sc_function(shell_nargs - 1, &shell_args[1]); - if (dirty && MODE_OUTPUT(setting.mode)) { + if (dirty) { operation_requested = true; // ensure output is updated - draw_menu(); + if (MODE_OUTPUT(setting.mode)) + draw_menu(); // update screen if in output mode and dirty + else + redraw_request |= REDRAW_CAL_STATUS | REDRAW_AREA | REDRAW_FREQUENCY; } } return; diff --git a/nanovna.h b/nanovna.h index 1fdcaee..e93c028 100644 --- a/nanovna.h +++ b/nanovna.h @@ -195,7 +195,7 @@ void set_sweep_time(float); //extern int setting.rbw; #ifdef __SPUR__ //extern int setting.spur; -void SetSpur(int v); +void set_spur(int v); #endif void set_average(int); int GetAverage(void); diff --git a/plot.c b/plot.c index bbcba5e..d3da9f9 100644 --- a/plot.c +++ b/plot.c @@ -2154,7 +2154,11 @@ draw_frequencies(void) #endif if (FREQ_IS_CW()) { plot_printf(buf1, sizeof(buf1), " CW %qHz", get_sweep_frequency(ST_CW)); - float t = setting.actual_sweep_time; // in mS + + float t = calc_min_sweep_time(); // Calc minimum sweep time + if (t < setting.sweep_time) + t = setting.sweep_time; + setting.actual_sweep_time = t; ; // in mS if (t>=1000) plot_printf(buf2, sizeof(buf2), " TIME %.2fS",t/1000.0); diff --git a/sa_cmd.c b/sa_cmd.c index 57c4bee..8b3212d 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -80,11 +80,12 @@ VNA_SHELL_FUNCTION(cmd_spur) return; } if (strcmp(argv[0],"on") == 0) { - setting.spur = 1; + set_spur(1); } else if (strcmp(argv[0],"off") == 0) { - setting.spur = 0; + set_spur(0); } else goto usage; + redraw_request |= REDRAW_CAL_STATUS | REDRAW_AREA; } VNA_SHELL_FUNCTION(cmd_output) @@ -133,6 +134,7 @@ VNA_SHELL_FUNCTION(cmd_attenuate) // goto usage; set_attenuation(a); } + redraw_request |= REDRAW_CAL_STATUS | REDRAW_AREA; } VNA_SHELL_FUNCTION(cmd_level) @@ -234,7 +236,7 @@ VNA_SHELL_FUNCTION(cmd_trigger) float t = my_atof(argv[0]); if (setting.trigger == T_AUTO ) set_trigger(T_NORMAL); - set_trigger_level(t); + set_trigger_level(to_dBm(t)); goto update; } static const char cmd_trigger_list[] = "auto|normal|single"; diff --git a/sa_core.c b/sa_core.c index ecdcf04..4ccf95f 100644 --- a/sa_core.c +++ b/sa_core.c @@ -38,6 +38,7 @@ int const reffer_freq[] = {30000000, 15000000, 10000000, 4000000, 3000000, 20000 int in_selftest = false; +#if 0 const char *dummy = "this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available\ this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available\ this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available\ @@ -50,10 +51,11 @@ this is a very long string only used to fill memory so I know when the memory is this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available\ this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available" ; +#endif void reset_settings(int m) { - strcpy((char *)spi_buffer, dummy); +// strcpy((char *)spi_buffer, dummy); setting.mode = m; setting.unit_scale_index = 0; setting.unit_scale = 1; @@ -164,7 +166,7 @@ float calc_min_sweep_time(void) // Calculate minimum sweep time in mS else { if (FREQ_IS_CW()) { a = (float)MINIMUM_SWEEP_TIME / 290.0; // time per step in CW mode - if (setting.repeat != 1 || setting.sweep_time >= 1000) + if (setting.repeat != 1 || setting.sweep_time >= 1000 || setting.spur != 0) a = 15.0 / 290.0; // time per step in CW mode with repeat } t = vbwSteps * sweep_points * (setting.spur ? 2 : 1) * ( (a + (setting.repeat - 1)* REPEAT_TIME/1000.0)); @@ -1360,7 +1362,7 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) skip_LO_setting: #ifdef __FAST_SWEEP__ - if (i == 0 && setting.frequency_step == 0 && setting.trigger == T_AUTO && actualStepDelay == 0 && setting.repeat == 1 && setting.sweep_time < 1000) { + if (i == 0 && setting.frequency_step == 0 && setting.trigger == T_AUTO && setting.spur == 0 && actualStepDelay == 0 && setting.repeat == 1 && setting.sweep_time < 1000) { SI4432_Fill(MODE_SELECT(setting.mode), 0); } #endif @@ -1397,7 +1399,7 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) if (subRSSI < setting.trigger_level) goto wait; #ifdef __FAST_SWEEP__ - if (i == 0 && setting.frequency_step == 0 /* && setting.trigger == T_AUTO */ && old_actual_step_delay == 0 && setting.repeat == 1 && setting.sweep_time < 1000) { + if (i == 0 && setting.frequency_step == 0 /* && setting.trigger == T_AUTO */&& setting.spur == 0 && old_actual_step_delay == 0 && setting.repeat == 1 && setting.sweep_time < 1000) { SI4432_Fill(MODE_SELECT(setting.mode), 1); } #endif