From 9b1b689f461f17e405b5cde440381560b72f099b Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Thu, 17 Jun 2021 10:28:09 +0200 Subject: [PATCH] Repaired marker command --- main.c | 7 ++++++- sa_cmd.c | 5 ++++- sa_core.c | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index a274035..937a208 100644 --- a/main.c +++ b/main.c @@ -1513,6 +1513,8 @@ VNA_SHELL_FUNCTION(cmd_marker) default: // select active marker and move to index or frequency markers[t].enabled = TRUE; + if (argv[1][0] < '0' || argv[1][0] > '9' ) + goto usage; freq_t value = my_atoui(argv[1]); markers[t].mtype &= ~M_TRACKING; active_marker = t; @@ -1530,9 +1532,12 @@ VNA_SHELL_FUNCTION(cmd_marker) marker_mask = M_NOISE; goto set_mask; case 5: - marker_mask = M_STORED; + marker_mask = M_TRACKING; goto set_mask; case 6: + marker_mask = M_STORED; + goto set_mask; + case 7: marker_mask = M_AVER; set_mask: if (argc == 3) { diff --git a/sa_cmd.c b/sa_cmd.c index cba9359..c6c3708 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -181,7 +181,10 @@ VNA_SHELL_FUNCTION(cmd_load) goto usage; uint16_t a = my_atoui(argv[0]); if (a <= 4) { - caldata_recall(a); + if (caldata_recall(a) == -1) { + if (a == 0) + reset_settings(setting.mode); + } return; } usage: diff --git a/sa_core.c b/sa_core.c index 187f977..a24daf3 100644 --- a/sa_core.c +++ b/sa_core.c @@ -4125,10 +4125,15 @@ static volatile int dummy; #ifdef TINYSA4 if (linear_averaging) { +#if 0 int old_unit = setting.unit; setting.unit = U_WATT; // Power averaging should always be done in Watts actual_t[i] = to_dBm((value(actual_t[i])*(scan_after_dirty-1) + value(RSSI)) / scan_after_dirty ); setting.unit = old_unit; +#else + float v = (expf(actual_t[i]*(logf(10.0)/10.0)) * (scan_after_dirty-1) + expf(RSSI * (logf(10.0)/10.0))) / scan_after_dirty; + actual_t[i] = logf(v)*(10.0/logf(10.0)); +#endif } else actual_t[i] = (actual_t[i]*(scan_after_dirty-1) + RSSI)/ scan_after_dirty;