diff --git a/nanovna.h b/nanovna.h index fd6d19b..2b78a8f 100644 --- a/nanovna.h +++ b/nanovna.h @@ -1072,6 +1072,7 @@ extern const float unit_scale_value[]; extern const char unit_scale_text[]; #ifdef TINYSA4 extern int debug_frequencies; +extern int linear_averaging; #endif #if 1 // Still sufficient flash // Flash save area - flash7 : org = 0x0801B000, len = 20k in *.ld file diff --git a/plot.c b/plot.c index b76a6c4..e4db0ad 100644 --- a/plot.c +++ b/plot.c @@ -310,7 +310,11 @@ marker_to_value(const int i) float v = value(ref_marker_levels[markers[i].index]); if (markers[i].mtype & M_AVER) { int old_unit = setting.unit; - if (markers[i].mtype & M_NOISE) + if (markers[i].mtype & M_NOISE +#ifdef TINYSA4 + && linear_averaging + #endif + ) setting.unit = U_WATT; // Noise averaging should always be done in Watts v = 0; for (int i=0; i 0) + set_R(setting.test_argument); + set_attenuation(0); + int test_case = TEST_POWER; + for (int i=1; i<30; i++) { + set_sweep_points(51); + set_sweep_frequency(ST_CENTER, 30000000 * i); + set_sweep_frequency(ST_SPAN, 3000); + test_acquire(test_case); // Acquire test + test_validate(test_case); + shell_printf("Freq = %8.3fMHz, level = %6.2f\n\r", ((float)peakFreq) / 1000000.0, peakLevel); + } + set_sweep_points(450); + reset_settings(M_LOW); #endif } diff --git a/ui_sa.c b/ui_sa.c index be6287f..6dacaa1 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1157,6 +1157,22 @@ static UI_FUNCTION_ADV_CALLBACK(menu_debug_freq_acb) // menu_move_back(); ui_mode_normal(); } + + +static UI_FUNCTION_ADV_CALLBACK(menu_linear_averaging_acb) +{ + (void)data; + (void)item; + if (b){ + b->icon = linear_averaging == 0 ? BUTTON_ICON_NOCHECK : BUTTON_ICON_CHECK; + return; + } + linear_averaging = ! linear_averaging; + // menu_move_back(); + ui_mode_normal(); +} + + #endif static UI_FUNCTION_CALLBACK(menu_clearconfig_cb) @@ -2556,6 +2572,7 @@ static const menuitem_t menu_settings4[] = #ifdef __HARMONIC__ { MT_SUBMENU,0, "HARMONIC", menu_harmonic}, #endif + { MT_ADV_CALLBACK, 0, "LINEAR\nAVERAGING", menu_linear_averaging_acb}, // { MT_SUBMENU, 0, S_RARROW" MORE", menu_settings3}, { MT_NONE, 0, NULL, menu_back} // next-> menu_back };