From aed244c78f371bd2ef4f0f1798b18ca7a5b51291 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 11 Apr 2023 10:17:45 +0200 Subject: [PATCH] Jog button hang and negative frequencies --- nanovna.h | 2 ++ plot.c | 8 +++++++- ui.c | 9 ++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/nanovna.h b/nanovna.h index 196d103..5bf8c6e 100644 --- a/nanovna.h +++ b/nanovna.h @@ -208,6 +208,7 @@ extern const char * const trc_channel_name[]; #ifdef TINYSA3 typedef uint32_t freq_t; +#define HALF_FREQ 0x8000000UL typedef int32_t long_t; extern bool has_esd; #define CORRECTION_POINTS 10 // Frequency dependent level correction table entries @@ -220,6 +221,7 @@ typedef uint32_t freq_t; #endif #ifdef TINYSA4 typedef uint64_t freq_t; +#define HALF_FREQ 0x800000000000000ULL typedef int64_t long_t; #define CORRECTION_POINTS 20 // Frequency dependent level correction table entries #define CORRECTION_LOW_IN 0 diff --git a/plot.c b/plot.c index bf90ccf..8828a66 100644 --- a/plot.c +++ b/plot.c @@ -1602,11 +1602,17 @@ static void trace_print_value_string( // Only used at one place step = step*10; } } + int negative = (freq > HALF_FREQ); + if (negative) + freq = - freq; #ifdef TINYSA4 if (freq >= 1000000000) digits += 3; #endif - plot_printf(ptr2, sizeof(buf2) - 9, "%9.*QHz", digits, freq); + if (negative) + plot_printf(ptr2, sizeof(buf2) - 9, "-%9.*QHz", digits, freq); + else + plot_printf(ptr2, sizeof(buf2) - 9, "%9.*QHz", digits, freq); } #ifdef __LEVEL_METER__ #ifdef TINYSA4 diff --git a/ui.c b/ui.c index 95af9c2..235ef93 100644 --- a/ui.c +++ b/ui.c @@ -7057,11 +7057,14 @@ ui_process_menu_lever(void) const menuitem_t *menu = menu_stack[menu_current_level]; int status = btn_check(); if (status == 0) return; - if (selection >=0 && status & EVT_BUTTON_SINGLE_CLICK) { - menu_invoke(selection); + uint16_t count = current_menu_get_count(); + if (status & EVT_BUTTON_SINGLE_CLICK) { + if ((uint16_t)selection >= count) + ui_mode_normal(); + else + menu_invoke(selection); return; } - uint16_t count = current_menu_get_count(); do { uint32_t mask = 1<