From fe7a1ac4deb72547cc80eff0b6a941e754188d2e Mon Sep 17 00:00:00 2001 From: TT Date: Thu, 14 May 2020 06:53:52 +0900 Subject: [PATCH] fix: keep freq mode in each save slot --- main.c | 13 +++++++------ nanovna.h | 9 +++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/main.c b/main.c index 91f475c..2deacf2 100644 --- a/main.c +++ b/main.c @@ -779,7 +779,6 @@ config_t config = { .trace_color = { DEFAULT_TRACE_1_COLOR, DEFAULT_TRACE_2_COLOR, DEFAULT_TRACE_3_COLOR, DEFAULT_TRACE_4_COLOR }, // .touch_cal = { 693, 605, 124, 171 }, // 2.4 inch LCD panel .touch_cal = { 338, 522, 153, 192 }, // 2.8 inch LCD panel - .freq_mode = FREQ_MODE_START_STOP, .harmonic_freq_threshold = 300000000, .vbat_offset = 500 }; @@ -819,6 +818,8 @@ void load_default_properties(void) current_props._active_marker = 0; current_props._domain_mode = 0; current_props._marker_smith_format = MS_RLC; + current_props._freq_mode = FREQ_MODE_START_STOP; + //Checksum add on caldata_save //current_props.checksum = 0; } @@ -1003,7 +1004,7 @@ set_sweep_frequency(int type, uint32_t freq) ensure_edit_config(); switch (type) { case ST_START: - config.freq_mode &= ~FREQ_MODE_CENTER_SPAN; + freq_mode &= ~FREQ_MODE_CENTER_SPAN; if (frequency0 != freq) { frequency0 = freq; // if start > stop then make start = stop @@ -1011,7 +1012,7 @@ set_sweep_frequency(int type, uint32_t freq) } break; case ST_STOP: - config.freq_mode &= ~FREQ_MODE_CENTER_SPAN; + freq_mode &= ~FREQ_MODE_CENTER_SPAN; if (frequency1 != freq) { frequency1 = freq; // if start > stop then make start = stop @@ -1019,7 +1020,7 @@ set_sweep_frequency(int type, uint32_t freq) } break; case ST_CENTER: - config.freq_mode |= FREQ_MODE_CENTER_SPAN; + freq_mode |= FREQ_MODE_CENTER_SPAN; uint32_t center = frequency0 / 2 + frequency1 / 2; if (center != freq) { uint32_t span = frequency1 - frequency0; @@ -1034,7 +1035,7 @@ set_sweep_frequency(int type, uint32_t freq) } break; case ST_SPAN: - config.freq_mode |= FREQ_MODE_CENTER_SPAN; + freq_mode |= FREQ_MODE_CENTER_SPAN; if (frequency1 - frequency0 != freq) { uint32_t center = frequency0 / 2 + frequency1 / 2; if (center < START_MIN + freq / 2) { @@ -1048,7 +1049,7 @@ set_sweep_frequency(int type, uint32_t freq) } break; case ST_CW: - config.freq_mode |= FREQ_MODE_CENTER_SPAN; + freq_mode |= FREQ_MODE_CENTER_SPAN; if (frequency0 != freq || frequency1 != freq) { frequency0 = freq; frequency1 = freq; diff --git a/nanovna.h b/nanovna.h index ec03e18..79a6b15 100644 --- a/nanovna.h +++ b/nanovna.h @@ -230,7 +230,6 @@ typedef struct config { uint16_t menu_active_color; uint16_t trace_color[TRACES_MAX]; int16_t touch_cal[4]; - int8_t freq_mode; uint32_t harmonic_freq_threshold; uint16_t vbat_offset; uint8_t _reserved[22]; @@ -380,7 +379,8 @@ typedef struct properties { uint8_t _domain_mode; /* 0bxxxxxffm : where ff: TD_FUNC m: DOMAIN_MODE */ uint8_t _marker_smith_format; uint8_t _bandwidth; - uint8_t _reserved[50]; + int8_t _freq_mode; + uint8_t _reserved[49]; uint32_t checksum; } properties_t; @@ -407,9 +407,10 @@ extern properties_t current_props; #define velocity_factor current_props._velocity_factor #define marker_smith_format current_props._marker_smith_format #define bandwidth current_props._bandwidth +#define freq_mode current_props._freq_mode -#define FREQ_IS_STARTSTOP() (!(config.freq_mode&FREQ_MODE_CENTER_SPAN)) -#define FREQ_IS_CENTERSPAN() (config.freq_mode&FREQ_MODE_CENTER_SPAN) +#define FREQ_IS_STARTSTOP() (!(freq_mode & FREQ_MODE_CENTER_SPAN)) +#define FREQ_IS_CENTERSPAN() (freq_mode & FREQ_MODE_CENTER_SPAN) #define FREQ_IS_CW() (frequency0 == frequency1) int caldata_save(int id);