From a43c28055bc7ac388a2d8d27f5ea6329e9830f4e Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 27 Apr 2021 15:16:46 +0200 Subject: [PATCH] Added actual_freq command --- main.c | 1 + nanovna.h | 2 +- sa_cmd.c | 11 +++++++++++ sa_core.c | 4 +--- si4468.c | 7 +++++++ 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 707e9d9..d127fd6 100644 --- a/main.c +++ b/main.c @@ -2470,6 +2470,7 @@ static const VNAShellCommand commands[] = { "if1", cmd_if1, 0 }, { "lna2", cmd_lna2, 0 }, { "agc", cmd_agc, 0 }, + { "actual_freq", cmd_actual_freq, CMD_WAIT_MUTEX }, #endif { "attenuate", cmd_attenuate, 0 }, { "level", cmd_level, 0 }, diff --git a/nanovna.h b/nanovna.h index 1ef3568..cdc960a 100644 --- a/nanovna.h +++ b/nanovna.h @@ -1159,7 +1159,7 @@ typedef struct properties { //sizeof(properties_t) == 0x1200 -#define CONFIG_MAGIC 0x434f4e4b /* 'CONF' */ +#define CONFIG_MAGIC 0x434f4e4e /* 'CONF' */ extern int16_t lastsaveid; //extern properties_t *active_props; diff --git a/sa_cmd.c b/sa_cmd.c index cdd3017..6564001 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -446,8 +446,19 @@ VNA_SHELL_FUNCTION(cmd_if1) config_save(); } } + +VNA_SHELL_FUNCTION(cmd_actual_freq) +{ + if (argc != 1) { + shell_printf("%DHz\r\n", config.setting_frequency_30mhz); + return; + } else { + set_30mhz(my_atoui(argv[0])); + } +} #endif + VNA_SHELL_FUNCTION(cmd_trigger) { if (argc == 0) diff --git a/sa_core.c b/sa_core.c index 98006e3..a1e9ea3 100644 --- a/sa_core.c +++ b/sa_core.c @@ -419,8 +419,6 @@ void set_gridlines(int d) update_grid(); } -//int setting_frequency_10mhz = 10000000; - #ifdef TINYSA4 void set_30mhz(freq_t f) { @@ -4157,7 +4155,7 @@ static bool sweep(bool break_on_operation) markers[2].enabled = search_maximum(2, frequencies[markers[0].index]*3, 12); markers[3].enabled = search_maximum(3, frequencies[markers[0].index]*4, 16); #ifdef TINYSA4 - } else if (setting.measurement == M_AM && markers[0].index > 10) { // ----------IOP measurement + } else if (setting.measurement == M_AM && markers[0].index > 10) { // ----------AM measurement int l = markers[1].index; int r = markers[2].index; if (r < l) { diff --git a/si4468.c b/si4468.c index 85fcddb..96100ee 100644 --- a/si4468.c +++ b/si4468.c @@ -1227,6 +1227,9 @@ void Si446x_getInfo(si446x_info_t* info) info->func = data[5]; } +float old_temp = -100; +#define TEMP_HISTERESE 0.5 + float Si446x_get_temp(void) { uint8_t data[8] = { SI446X_CMD_GET_ADC_READING, 0x10, 0 }; @@ -1236,6 +1239,10 @@ float Si446x_get_temp(void) i = 6; float t = (data[i] << 8) + data[i+1]; t = (899.0 * t /4096.0) - 293.0; + if (t > old_temp - TEMP_HISTERESE && t < old_temp + TEMP_HISTERESE) { + return(old_temp); + } + old_temp = t; return t; }