From a8bffcf92cee5f10cd37cae480dbce91bcfb1902 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Fri, 6 Jan 2023 09:57:48 +0100 Subject: [PATCH] Added trigger interval --- NANOVNA_STM32_F072/mcuconf.h | 2 +- nanovna.h | 2 ++ sa_core.c | 19 +++++++++++++------ ui.c | 12 ++++++++++++ 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/NANOVNA_STM32_F072/mcuconf.h b/NANOVNA_STM32_F072/mcuconf.h index 241b42d..83b96f1 100644 --- a/NANOVNA_STM32_F072/mcuconf.h +++ b/NANOVNA_STM32_F072/mcuconf.h @@ -101,7 +101,7 @@ /* * GPT driver system settings. */ -#define STM32_GPT_USE_TIM1 FALSE +#define STM32_GPT_USE_TIM1 TRUE #define STM32_GPT_USE_TIM2 FALSE #define STM32_GPT_USE_TIM3 TRUE #define STM32_GPT_USE_TIM14 TRUE diff --git a/nanovna.h b/nanovna.h index c603e78..98b021f 100644 --- a/nanovna.h +++ b/nanovna.h @@ -1235,6 +1235,8 @@ typedef struct setting systime_t actual_sweep_time_us; systime_t additional_step_delay_us; + uint32_t trigger_grid; + // freq_t *correction_frequency; // float *correction_value; diff --git a/sa_core.c b/sa_core.c index 115fd3f..c2e8319 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1079,14 +1079,16 @@ void set_depth(int d) void set_modulation_frequency(int f) { - if (50 <= f && f <= 10000) { + if (f < 50) + f = 50; + if (f > 10000) + f = 10000; #ifdef TINYSA4 - if (setting.modulation == MO_WFM && f > 2000) - f = 2000; + if (setting.modulation == MO_WFM && f > 2000) + f = 2000; #endif - setting.modulation_frequency = f; - dirty = true; - } + setting.modulation_frequency = f; + dirty = true; } void set_repeat(int r) @@ -4852,6 +4854,11 @@ static bool sweep(bool break_on_operation) sweep_again: // stay in sweep loop when output mode and modulation on. + if (setting.trigger_grid) { // for start of sweep in time grid + while ((chVTGetSystemTimeX() % (setting.trigger_grid+2)) == 0); + while ((chVTGetSystemTimeX() % (setting.trigger_grid+2)) != 0); + } + #ifdef __ULTRA__ if (config.ultra_start == ULTRA_AUTO) { if (setting.mode == M_LOW){ diff --git a/ui.c b/ui.c index 14815b5..8ac9009 100644 --- a/ui.c +++ b/ui.c @@ -1333,6 +1333,7 @@ enum { #ifdef __USE_SD_CARD__ KM_FILENAME, #endif + KM_TRIGGER_GRID, KM_NONE // always at enum end }; @@ -1411,6 +1412,7 @@ static const struct { #ifdef __USE_SD_CARD__ [KM_FILENAME] = {keypads_text , "NAME"}, // filename #endif +[KM_TRIGGER_GRID] = {keypads_time , "INTERVAL"}, // KM_CODE }; #if 0 // Not used @@ -4434,6 +4436,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_KEYPAD, KM_TRIGGER_GRID, "INTERVAL\n\b%ss", NULL}, { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; @@ -4744,6 +4747,11 @@ static void fetch_numeric_target(uint8_t mode) format = "%.1f%s"; plot_printf(uistat.text, sizeof uistat.text, format, uistat.value,unit_string[setting.unit]); break; + case KM_TRIGGER_GRID: + uistat.value = ((float)ST2US(setting.trigger_grid))/1000000.0; + plot_printf(uistat.text, sizeof uistat.text, "%.3F", uistat.value); + break; + case KM_MARKER: if (active_marker >=0) { uistat.freq_value = markers[active_marker].frequency; @@ -4949,6 +4957,10 @@ set_numeric_value(void) set_trigger_level(to_dBm(uistat.value)); completed = true; break; + case KM_TRIGGER_GRID: + setting.trigger_grid = US2ST(uistat.value*1000000.0) ; + completed = true; + break; case KM_GRIDLINES: set_gridlines(uistat.value); break;