From 13250cbf1db701165233fbe4777d73c2b2a8080b Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Wed, 2 Jun 2021 11:35:19 +0200 Subject: [PATCH] Added TRACE AVERAGE marker and always find maximum --- nanovna.h | 4 ++-- plot.c | 2 +- sa_core.c | 20 ++++++++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/nanovna.h b/nanovna.h index 06e3915..112e784 100644 --- a/nanovna.h +++ b/nanovna.h @@ -18,7 +18,7 @@ */ #include "ch.h" -//#ifdef TINYSA_F303 +#ifdef TINYSA_F303 #include "adc_F303.h" #ifdef TINYSA_F072 #error "Remove comment for #ifdef TINYSA_F303" @@ -27,7 +27,7 @@ #define TINYSA4 #endif #define TINYSA4_PROTO -//#endif +#endif #ifdef TINYSA_F072 #ifdef TINYSA_F303 diff --git a/plot.c b/plot.c index 8a42c2b..5ba014f 100644 --- a/plot.c +++ b/plot.c @@ -1488,7 +1488,7 @@ static void trace_print_value_string( // Only used at one place #else if (bold) format++; // Skip small prefix for bold output #endif - cell_printf(xpos, ypos, format, buf2, v, unit_string[unit_index], (mtype & M_NOISE?"/Hz":"")); + cell_printf(xpos, ypos, format, buf2, v, unit_string[unit_index], (mtype & M_NOISE?"/Hz":(mtype & M_AVER?"/T":""))); } static void cell_draw_marker_info(int x0, int y0) diff --git a/sa_core.c b/sa_core.c index 599a2a7..00b7f3e 100644 --- a/sa_core.c +++ b/sa_core.c @@ -4103,6 +4103,11 @@ static volatile int dummy; temppeakLevel = actual_t[0]; max_index[0] = 0; downslope = true; + peakLevel = temppeakLevel; + } + if (cur_max == 0 && peakLevel < actual_t[i]) { + peakIndex = i; + peakLevel = actual_t[i]; } if (downslope) { // If in down slope peak finding if (temppeakLevel > actual_t[i]) { // Follow down @@ -4403,6 +4408,10 @@ static volatile int dummy; // --------------------- set tracking markers from maximum table ----------------- + if (cur_max == 0) { + max_index[0] = peakIndex; + cur_max = 1; + } if (MODE_INPUT(setting.mode)) { // Assign maxima found to tracking markers int i = 0; int m = 0; @@ -4525,8 +4534,11 @@ static volatile int dummy; } #endif - peakIndex = max_index[0]; - peakLevel = actual_t[peakIndex]; + if (cur_max > 0) { + peakIndex = max_index[0]; + peakLevel = actual_t[peakIndex]; + cur_max = 1; + } peakFreq = frequencies[peakIndex]; min_level = temp_min_level; } @@ -5887,7 +5899,9 @@ again: set_refer_output(0); set_sweep_frequency(ST_STOP, 60000000); int test_case = TEST_POWER; +#ifdef TINYSA set_extra_lna(calibrate_lna); +#endif set_average(AV_100); for (int m=1; m<20; m++) { test_acquire(test_case); // Acquire test @@ -5996,7 +6010,9 @@ quit: sweep_mode = SWEEP_ENABLE; // set_refer_output(-1); // reset_settings(M_LOW); +#ifdef TINYSA4 set_extra_lna(false); +#endif set_average(AV_OFF); }