From 2a7785b5d4e54500bbdafb3b54cddcaed2bbfae1 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 21 Feb 2023 12:56:54 +0100 Subject: [PATCH] Guards, beeper and lock display --- main.c | 9 +++++++-- nanovna.h | 4 +++- plot.c | 9 +++++++++ sa_core.c | 2 +- ui.c | 32 +++++++++++++++++++++++++++++--- 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index baf70c8..e8efe39 100644 --- a/main.c +++ b/main.c @@ -187,12 +187,13 @@ static THD_FUNCTION(Thread1, arg) if (current_guard > GUARDS_MAX) current_guard = 0; } - if (setting.guards[current_guard].start - setting.guards[current_guard].end > 10000000) { + if (setting.guards[current_guard].end > setting.guards[current_guard].start) { set_sweep_frequency(ST_START, setting.guards[current_guard].start); set_sweep_frequency(ST_STOP, setting.guards[current_guard].end); set_rbw(8000); set_sweep_points((setting.guards[current_guard].end - setting.guards[current_guard].start) / 800000); } + DAC->DHR12R1 = 0; } #endif completed = sweep(true); @@ -1140,8 +1141,12 @@ void load_LCD_properties(void) #endif void set_sweep_points(uint16_t points){ - if (points == sweep_points || points > POINTS_COUNT) + if (points == sweep_points) return; + if (points > POINTS_COUNT) + points = POINTS_COUNT; + if (points < 10) + points = 10; sweep_points = points; update_frequencies(); diff --git a/nanovna.h b/nanovna.h index 96f6fb2..a7582ce 100644 --- a/nanovna.h +++ b/nanovna.h @@ -1200,7 +1200,9 @@ typedef struct setting uint8_t fast_speedup; // 0 - 20 uint8_t _traces; // enabled traces flags uint8_t draw_line; // uses the trigger level setting - +#ifdef TINYSA4 + uint8_t lock_display; +#endif uint16_t repeat; // 1...100 uint16_t linearity_step; // range equal POINTS_COUNT uint16_t _sweep_points; diff --git a/plot.c b/plot.c index 183f688..33bfcee 100644 --- a/plot.c +++ b/plot.c @@ -1116,7 +1116,16 @@ draw_cell(int m, int n) if ((uint32_t)(x + x0 - CELLOFFSETX) <= WIDTH + CELLOFFSETX) cell_buffer[tp * CELLWIDTH + x] = c; } +#ifdef __GUARD__XX + if (setting.measurement == M_GUARD) { + int tp = get_guard_level() - y0; + if (tp>=0 && tp < h) + for (x = 0; x < w; x++) + if ((uint32_t)(x + x0 - CELLOFFSETX) <= WIDTH + CELLOFFSETX) + cell_buffer[tp * CELLWIDTH + x] = c; + } +#endif #if 1 // Only right cells if (m >= (GRID_X_TEXT)/CELLWIDTH) diff --git a/sa_core.c b/sa_core.c index c8f9ae6..45e178c 100644 --- a/sa_core.c +++ b/sa_core.c @@ -5190,7 +5190,7 @@ static volatile int dummy; if (MODE_INPUT(setting.mode)) { #ifdef __GUARD__ if (setting.measurement == M_GUARD && RSSI > setting.guards[current_guard].level) { - // guard_exceeded(); + DAC->DHR12R1 = 4095; } #endif for (int t=0; t menu_back +}; +#endif + static const menuitem_t menu_config2[] = { { MT_ADV_CALLBACK, 0, "PULSE\nHIGH", menu_settings_pulse_acb}, @@ -4660,6 +4683,9 @@ static const menuitem_t menu_display[] = { { MT_SUBMENU, 0, "SWEEP\nPOINTS", menu_sweep_points}, { MT_SUBMENU, 0, "SWEEP\nACCURACY", menu_sweep_speed}, { MT_ADV_CALLBACK,0, "ROTATE\nDISPLAY", menu_flip_acb}, +#ifdef TINYSA4 + { MT_SUBMENU,0, "LOCK\nDISPLAY", menu_lock_display}, +#endif //#ifdef __REMOTE_DESKTOP__ // { MT_ADV_CALLBACK,0, "SEND\nDISPLAY", menu_send_display_acb}, //#endif @@ -4964,7 +4990,7 @@ static void fetch_numeric_target(uint8_t mode) plot_printf(uistat.text, sizeof uistat.text, "%.3QHz", uistat.freq_value); break; case KM_GUARD_END: - uistat.freq_value = setting.guards[active_guard].start; + uistat.freq_value = setting.guards[active_guard].end; plot_printf(uistat.text, sizeof uistat.text, "%.3QHz", uistat.freq_value); break; case KM_GUARD_LEVEL: