From 924f4fb6d4bd047f759b554360ee580934304f5f Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Fri, 3 Oct 2025 12:42:56 +0200 Subject: [PATCH] Added occupied width --- nanovna.h | 4 ++-- plot.c | 2 +- sa_core.c | 7 +++++-- ui.c | 13 ++++++++++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/nanovna.h b/nanovna.h index 42911d5..fb47599 100644 --- a/nanovna.h +++ b/nanovna.h @@ -1860,9 +1860,9 @@ void interpolate_maximum(int m); void calibrate_modulation(int modulation, int8_t *correction); enum { - M_OFF, M_IMD, M_OIP3, M_PHASE_NOISE, M_SNR, M_PASS_BAND, M_LINEARITY, M_AM, M_FM, M_THD, M_CP, M_NF_TINYSA, M_NF_STORE, M_NF_VALIDATE, M_NF_AMPLIFIER, M_DECONV,M_MAX + M_OFF, M_IMD, M_OIP3, M_PHASE_NOISE, M_SNR, M_PASS_BAND, M_LINEARITY, M_AM, M_FM, M_THD, M_CP, M_NF_TINYSA, M_NF_STORE, M_NF_VALIDATE, M_NF_AMPLIFIER, M_DECONV, M_WIDTH, M_MAX }; -#define MEASUREMENT_TEXT "OFF","HARM","OIP3","PN","SNR","PASS","LIN","AM","FM","THD","CP","NF T","NF S","NF V","NF A", "DECONF" +#define MEASUREMENT_TEXT "OFF","HARM","OIP3","PN","SNR","PASS","LIN","AM","FM","THD","CP","NF T","NF S","NF V","NF A", "DECONF", "WIDTH" enum { T_AUTO, T_NORMAL, T_SINGLE, T_DONE, T_UP, T_DOWN, T_MODE, T_PRE, T_POST, T_MID, T_BEEP, T_AUTO_SAVE, diff --git a/plot.c b/plot.c index 1636e50..b4bd0ab 100644 --- a/plot.c +++ b/plot.c @@ -1701,7 +1701,7 @@ static void cell_draw_marker_info(int x0, int y0) active = 2; for (int i = 0; i < MARKER_COUNT; i++) { if (i == 3) { - if (setting.measurement == M_PASS_BAND) { + if (setting.measurement == M_PASS_BAND||setting.measurement == M_WIDTH) { freq_t f; if (markers[2].frequency>markers[1].frequency) f = markers[2].frequency-markers[1].frequency; diff --git a/sa_core.c b/sa_core.c index a0053df..d81ec3d 100644 --- a/sa_core.c +++ b/sa_core.c @@ -5975,7 +5975,7 @@ static volatile int dummy; } else if (setting.measurement == M_PHASE_NOISE && markers[0].index > 10) { // ------------Phase noise measurement // Position phase noise marker at requested offset set_marker_index(1, markers[0].index + (setting.mode == M_LOW ? WIDTH/4 : -WIDTH/4)); - } else if ((setting.measurement == M_PASS_BAND || setting.measurement == M_FM) && markers[0].index > 10) { // ----------------Pass band measurement + } else if ((setting.measurement == M_PASS_BAND || setting.measurement == M_WIDTH || setting.measurement == M_FM) && markers[0].index > 10) { // ----------------Pass band measurement int t1; int t2; float v = -200; @@ -5987,7 +5987,10 @@ static volatile int dummy; } t1 = 0; t2 = 0; - v = v - (in_selftest ? 6.0 : 3.0); + if (setting.measurement == M_WIDTH) + v = v + uistat.value; + else + v = v - (in_selftest ? 6.0 : 3.0); while (t1 < markers[0].index && actual_t[t1+1] < v) // Find left -3dB point t1++; if (t1< markers[0].index) diff --git a/ui.c b/ui.c index e0d52c7..c879177 100644 --- a/ui.c +++ b/ui.c @@ -3004,6 +3004,16 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb) set_measurement(M_PASS_BAND); // SetAverage(4); + break; + case M_WIDTH: // occupied width measurement +// reset_settings(setting.mode); + markers[1].enabled = M_ENABLED; + markers[2].enabled = M_ENABLED; + kp_help_text = "dBc"; + ui_mode_keypad(KM_LEVEL); + set_measurement(M_WIDTH); +// SetAverage(4); + break; #ifdef __LINEARITY__ case M_LINEARITY: @@ -5019,7 +5029,8 @@ static const menuitem_t menu_measure[] = { { MT_ADV_CALLBACK, M_OIP3, "OIP3", menu_measure_acb}, { MT_ADV_CALLBACK, M_PHASE_NOISE,"PHASE\nNOISE", menu_measure_acb}, { MT_ADV_CALLBACK, M_SNR, "SNR", menu_measure_acb}, - { MT_ADV_CALLBACK, M_PASS_BAND, "-3dB\nWIDTH", menu_measure_acb}, + { MT_ADV_CALLBACK, M_PASS_BAND, "-3dB\nWIDTH", menu_measure_acb}, + { MT_ADV_CALLBACK, M_WIDTH, "OCCUPIED\nWIDTH",menu_measure_acb}, { MT_SUBMENU, 0, S_RARROW" MORE", menu_measure2}, { MT_NONE, 0, NULL, menu_back} // next-> menu_back };