From d3ad97c6a92eb36a682f0519b9137a2592a27aa2 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Mon, 3 Aug 2020 11:03:15 +0300 Subject: [PATCH] Update bandwidth string on change --- main.c | 11 ++++++++--- nanovna.h | 1 + ui.c | 3 +-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 8c59fc4..a861aa6 100644 --- a/main.c +++ b/main.c @@ -82,9 +82,9 @@ static volatile vna_shellcmd_t shell_function = 0; // Enable port command, used for debug //#define ENABLE_PORT_COMMAND // Enable si5351 timing command, used for debug -#define ENABLE_SI5351_TIMINGS +//#define ENABLE_SI5351_TIMINGS // Enable i2c timing command, used for debug -#define ENABLE_I2C_TIMINGS +//#define ENABLE_I2C_TIMINGS static void apply_CH0_error_term_at(int i); static void apply_CH1_error_term_at(int i); @@ -933,6 +933,11 @@ bool sweep(bool break_on_operation, uint16_t sweep_mode) return p_sweep == sweep_points; } +void set_bandwidth(uint16_t bw_count){ + config.bandwidth = bw_count&0xFF; + redraw_request|=REDRAW_FREQUENCY; +} + uint32_t get_bandwidth_frequency(uint16_t bw_freq){ return (AUDIO_ADC_FREQ/AUDIO_SAMPLES_COUNT)/(bw_freq+1); } @@ -941,7 +946,7 @@ VNA_SHELL_FUNCTION(cmd_bandwidth) { if (argc != 1) goto result; - config.bandwidth = my_atoui(argv[0])&0xFF; + set_bandwidth(my_atoui(argv[0])); result: shell_printf("bandwidth %d (%uHz)\r\n", config.bandwidth, get_bandwidth_frequency(config.bandwidth)); } diff --git a/nanovna.h b/nanovna.h index 187f447..85e0ba9 100644 --- a/nanovna.h +++ b/nanovna.h @@ -113,6 +113,7 @@ enum stimulus_type { void set_sweep_frequency(int type, uint32_t frequency); uint32_t get_sweep_frequency(int type); +void set_bandwidth(uint16_t bw_count); uint32_t get_bandwidth_frequency(uint16_t bw_freq); double my_atof(const char *p); diff --git a/ui.c b/ui.c index bbde7d6..4cb91ec 100644 --- a/ui.c +++ b/ui.c @@ -754,8 +754,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_bandwidth_acb) b->p1.u = get_bandwidth_frequency(data); return; } - config.bandwidth = data; - draw_frequencies(); + set_bandwidth(data); draw_menu(); }