Load/Store of settings added

tinySA-v0.2
erikkaashoek 6 years ago
parent 2d63ad9aa4
commit 2898c02d36

@ -19,14 +19,14 @@
*/ */
MEMORY MEMORY
{ {
flash0 : org = 0x08000000, len = 104k flash0 : org = 0x08000000, len = 108k
flash1 : org = 0x00000000, len = 0 flash1 : org = 0x00000000, len = 0
flash2 : org = 0x00000000, len = 0 flash2 : org = 0x00000000, len = 0
flash3 : org = 0x00000000, len = 0 flash3 : org = 0x00000000, len = 0
flash4 : org = 0x00000000, len = 0 flash4 : org = 0x00000000, len = 0
flash5 : org = 0x00000000, len = 0 flash5 : org = 0x00000000, len = 0
flash6 : org = 0x00000000, len = 0 flash6 : org = 0x00000000, len = 0
flash7 : org = 0x0801C000, len = 16k flash7 : org = 0x0801B000, len = 20k
ram0 : org = 0x20000000, len = 16k ram0 : org = 0x20000000, len = 16k
ram1 : org = 0x00000000, len = 0 ram1 : org = 0x00000000, len = 0
ram2 : org = 0x00000000, len = 0 ram2 : org = 0x00000000, len = 0

@ -120,48 +120,54 @@ config_recall(void)
return 0; return 0;
} }
const uint32_t saveareas[SAVEAREA_MAX] = { const uint32_t saveareas[SAVEAREA_MAX] =
{
SAVE_PROP_CONFIG_0_ADDR, SAVE_PROP_CONFIG_0_ADDR,
SAVE_PROP_CONFIG_1_ADDR, SAVE_PROP_CONFIG_1_ADDR,
SAVE_PROP_CONFIG_2_ADDR, SAVE_PROP_CONFIG_2_ADDR,
SAVE_PROP_CONFIG_3_ADDR, SAVE_PROP_CONFIG_3_ADDR,
SAVE_PROP_CONFIG_4_ADDR }; SAVE_PROP_CONFIG_4_ADDR,
SAVE_PROP_CONFIG_5_ADDR,
SAVE_PROP_CONFIG_6_ADDR,
SAVE_PROP_CONFIG_7_ADDR,
SAVE_PROP_CONFIG_8_ADDR,
};
int16_t lastsaveid = 0; int16_t lastsaveid = 0;
int int
caldata_save(int id) caldata_save(int id)
{ {
uint16_t *src = (uint16_t*)&current_props; uint16_t *src = (uint16_t*)&setting;
uint16_t *dst; uint16_t *dst;
int count = sizeof(properties_t) / sizeof(uint16_t); int count = sizeof(setting_t) / sizeof(uint16_t);
if (id < 0 || id >= SAVEAREA_MAX) if (id < 0 || id >= SAVEAREA_MAX)
return -1; return -1;
dst = (uint16_t*)saveareas[id]; dst = (uint16_t*)saveareas[id];
current_props.magic = CONFIG_MAGIC; setting.magic = CONFIG_MAGIC;
current_props.checksum = checksum( setting.checksum = checksum(
&current_props, sizeof current_props - sizeof current_props.checksum); &setting, sizeof setting - sizeof setting.checksum);
flash_unlock(); flash_unlock();
/* erase flash pages */ /* erase flash pages */
void *p = dst; void *p = dst;
void *tail = p + sizeof(properties_t); void *tail = p + sizeof(setting_t);
while (p < tail) { while (p < tail) {
flash_erase_page((uint32_t)p); flash_erase_page((uint32_t)p);
p += FLASH_PAGESIZE; p += FLASH_PAGESIZE;
} }
/* write to flahs */ /* write to flash */
while (count-- > 0) { while (count-- > 0) {
flash_program_half_word((uint32_t)dst, *src++); flash_program_half_word((uint32_t)dst, *src++);
dst++; dst++;
} }
/* after saving data, make active configuration points to flash */ /* after saving data, make active configuration points to flash */
active_props = (properties_t*)saveareas[id]; // active_props = (setting_t*)saveareas[id];
lastsaveid = id; lastsaveid = id;
return 0; return 0;
@ -170,14 +176,14 @@ caldata_save(int id)
int int
caldata_recall(int id) caldata_recall(int id)
{ {
properties_t *src; setting_t *src;
void *dst = &current_props; void *dst = &setting;
if (id < 0 || id >= SAVEAREA_MAX) if (id < 0 || id >= SAVEAREA_MAX)
goto load_default; goto load_default;
// point to saved area on the flash memory // point to saved area on the flash memory
src = (properties_t*)saveareas[id]; src = (setting_t*)saveareas[id];
if (src->magic != CONFIG_MAGIC) if (src->magic != CONFIG_MAGIC)
goto load_default; goto load_default;
@ -185,24 +191,27 @@ caldata_recall(int id)
goto load_default; goto load_default;
/* active configuration points to save data on flash memory */ /* active configuration points to save data on flash memory */
active_props = src; // active_props = src;
lastsaveid = id; lastsaveid = id;
/* duplicated saved data onto sram to be able to modify marker/trace */ /* duplicated saved data onto sram to be able to modify marker/trace */
memcpy(dst, src, sizeof(properties_t)); memcpy(dst, src, sizeof(setting_t));
update_frequencies();
SetScale(setting.scale);
SetReflevel(setting.reflevel);
return 0; return 0;
load_default: load_default:
load_default_properties(); load_default_properties();
return -1; return -1;
} }
#if 0
const properties_t * const setting_t *
caldata_ref(int id) caldata_ref(int id)
{ {
const properties_t *src; const setting_t *src;
if (id < 0 || id >= SAVEAREA_MAX) if (id < 0 || id >= SAVEAREA_MAX)
return NULL; return NULL;
src = (const properties_t*)saveareas[id]; src = (const setting_t*)saveareas[id];
if (src->magic != CONFIG_MAGIC) if (src->magic != CONFIG_MAGIC)
return NULL; return NULL;
@ -210,6 +219,7 @@ caldata_ref(int id)
return NULL; return NULL;
return src; return src;
} }
#endif
const uint32_t save_config_prop_area_size = SAVE_CONFIG_AREA_SIZE; const uint32_t save_config_prop_area_size = SAVE_CONFIG_AREA_SIZE;

149
main.c

@ -89,7 +89,7 @@ static void apply_error_term_at(int i);
static void apply_edelay_at(int i); static void apply_edelay_at(int i);
static void cal_interpolate(int s); static void cal_interpolate(int s);
#endif #endif
static void update_frequencies(void); void update_frequencies(void);
static void set_frequencies(uint32_t start, uint32_t stop, uint16_t points); static void set_frequencies(uint32_t start, uint32_t stop, uint16_t points);
static bool sweep(bool break_on_operation); static bool sweep(bool break_on_operation);
#ifdef __VNA__ #ifdef __VNA__
@ -110,7 +110,7 @@ volatile uint8_t redraw_request = 0; // contains REDRAW_XXX flags
const char *info_about[]={ const char *info_about[]={
BOARD_NAME, BOARD_NAME,
"2016-2020 Copyright @Erik Kaashoek", "2016-2020 Copyright @Erik Kaashoek",
"Licensed under GPL. See: https://github.com/erikkaashoek/tinySA", "SW licensed under GPL. See: https://github.com/erikkaashoek/tinySA",
"Version: " VERSION, "Version: " VERSION,
"Build Time: " __DATE__ " - " __TIME__, "Build Time: " __DATE__ " - " __TIME__,
"Kernel: " CH_KERNEL_VERSION, "Kernel: " CH_KERNEL_VERSION,
@ -135,7 +135,7 @@ static THD_FUNCTION(Thread1, arg)
sweep_mode&=~SWEEP_ONCE; sweep_mode&=~SWEEP_ONCE;
} else if (sweep_mode & SWEEP_SELFTEST) { } else if (sweep_mode & SWEEP_SELFTEST) {
// call from lowest level to save stack space // call from lowest level to save stack space
self_test(setting_test); self_test(setting.test);
sweep_mode = SWEEP_ENABLE; sweep_mode = SWEEP_ENABLE;
} else if (sweep_mode & SWEEP_CALIBRATE) { } else if (sweep_mode & SWEEP_CALIBRATE) {
// call from lowest level to save stack space // call from lowest level to save stack space
@ -821,8 +821,8 @@ config_t config = {
.high_level_offset = 100, // Uncalibrated .high_level_offset = 100, // Uncalibrated
}; };
properties_t current_props; //properties_t current_props;
properties_t *active_props = &current_props; //properties_t *active_props = &current_props;
// NanoVNA Default settings // NanoVNA Default settings
static const trace_t def_trace[TRACES_MAX] = {//enable, type, channel, reserved, scale, refpos static const trace_t def_trace[TRACES_MAX] = {//enable, type, channel, reserved, scale, refpos
@ -843,43 +843,44 @@ void load_default_properties(void)
{ {
//Magic add on caldata_save //Magic add on caldata_save
//current_props.magic = CONFIG_MAGIC; //current_props.magic = CONFIG_MAGIC;
current_props._frequency0 = 0; // start = 0Hz // current_props._setting.frequency0 = 0; // start = 0Hz
current_props._frequency1 = 350000000; // end = 350MHz // current_props._setting.frequency1 = 350000000; // end = 350MHz
current_props._frequency_IF= 433800000, // current_props._setting.frequency_IF= 433800000,
current_props._sweep_points = POINTS_COUNT; setting._sweep_points = POINTS_COUNT;
#ifdef VNA__ #ifdef VNA__
current_props._cal_status = 0; setting._cal_status = 0;
//This data not loaded by default //This data not loaded by default
//current_props._frequencies[POINTS_COUNT]; //setting._frequencies[POINTS_COUNT];
//current_props._cal_data[5][POINTS_COUNT][2]; //setting._cal_data[5][POINTS_COUNT][2];
//============================================= //=============================================
current_props._electrical_delay = 0.0; setting._electrical_delay = 0.0;
#endif #endif
memcpy(current_props._trace, def_trace, sizeof(def_trace)); memcpy(setting._trace, def_trace, sizeof(def_trace));
memcpy(current_props._markers, def_markers, sizeof(def_markers)); memcpy(setting._markers, def_markers, sizeof(def_markers));
#ifdef __VNA__ #ifdef __VNA__
current_props._velocity_factor = 0.7; setting._velocity_factor = 0.7;
#endif #endif
current_props._active_marker = 0; setting._active_marker = 0;
#ifdef __VNA__ #ifdef __VNA__
current_props._domain_mode = 0; setting._domain_mode = 0;
current_props._marker_smith_format = MS_RLC; setting._marker_smith_format = MS_RLC;
#endif #endif
reset_settings(-1);
//Checksum add on caldata_save //Checksum add on caldata_save
//current_props.checksum = 0; //setting.checksum = 0;
} }
void void
ensure_edit_config(void) ensure_edit_config(void)
{ {
#ifdef __VNA__
if (active_props == &current_props) if (active_props == &current_props)
return; return;
//memcpy(&current_props, active_props, sizeof(config_t)); //memcpy(&current_props, active_props, sizeof(config_t));
active_props = &current_props; active_props = &current_props;
// move to uncal state // move to uncal state
#ifdef __VNA__
cal_status = 0; cal_status = 0;
#endif #endif
} }
@ -1029,11 +1030,11 @@ set_frequencies(uint32_t start, uint32_t stop, uint16_t points)
// disable at out of sweep range // disable at out of sweep range
for (; i < POINTS_COUNT; i++) for (; i < POINTS_COUNT; i++)
frequencies[i] = 0; frequencies[i] = 0;
setting_frequency_step = delta; setting.frequency_step = delta;
update_rbw(); update_rbw();
} }
static void void
update_frequencies(void) update_frequencies(void)
{ {
uint32_t start, stop; uint32_t start, stop;
@ -1065,55 +1066,55 @@ set_sweep_frequency(int type, uint32_t freq)
ensure_edit_config(); ensure_edit_config();
switch (type) { switch (type) {
case ST_START: case ST_START:
config.freq_mode &= ~FREQ_MODE_CENTER_SPAN; setting.freq_mode &= ~FREQ_MODE_CENTER_SPAN;
if (frequency0 != freq) { if (setting.frequency0 != freq) {
frequency0 = freq; setting.frequency0 = freq;
// if start > stop then make start = stop // if start > stop then make start = stop
if (frequency1 < freq) frequency1 = freq; if (setting.frequency1 < freq) setting.frequency1 = freq;
} }
break; break;
case ST_STOP: case ST_STOP:
config.freq_mode &= ~FREQ_MODE_CENTER_SPAN; setting.freq_mode &= ~FREQ_MODE_CENTER_SPAN;
if (frequency1 != freq) { if (setting.frequency1 != freq) {
frequency1 = freq; setting.frequency1 = freq;
// if start > stop then make start = stop // if start > stop then make start = stop
if (frequency0 > freq) frequency0 = freq; if (setting.frequency0 > freq) setting.frequency0 = freq;
} }
break; break;
case ST_CENTER: case ST_CENTER:
config.freq_mode |= FREQ_MODE_CENTER_SPAN; setting.freq_mode |= FREQ_MODE_CENTER_SPAN;
uint32_t center = frequency0 / 2 + frequency1 / 2; uint32_t center = setting.frequency0 / 2 + setting.frequency1 / 2;
if (center != freq) { if (center != freq) {
uint32_t span = frequency1 - frequency0; uint32_t span = setting.frequency1 - setting.frequency0;
if (freq < START_MIN + span / 2) { if (freq < START_MIN + span / 2) {
span = (freq - START_MIN) * 2; span = (freq - START_MIN) * 2;
} }
if (freq > STOP_MAX - span / 2) { if (freq > STOP_MAX - span / 2) {
span = (STOP_MAX - freq) * 2; span = (STOP_MAX - freq) * 2;
} }
frequency0 = freq - span / 2; setting.frequency0 = freq - span / 2;
frequency1 = freq + span / 2; setting.frequency1 = freq + span / 2;
} }
break; break;
case ST_SPAN: case ST_SPAN:
config.freq_mode |= FREQ_MODE_CENTER_SPAN; setting.freq_mode |= FREQ_MODE_CENTER_SPAN;
if (frequency1 - frequency0 != freq) { if (setting.frequency1 - setting.frequency0 != freq) {
uint32_t center = frequency0 / 2 + frequency1 / 2; uint32_t center = setting.frequency0 / 2 + setting.frequency1 / 2;
if (center < START_MIN + freq / 2) { if (center < START_MIN + freq / 2) {
center = START_MIN + freq / 2; center = START_MIN + freq / 2;
} }
if (center > STOP_MAX - freq / 2) { if (center > STOP_MAX - freq / 2) {
center = STOP_MAX - freq / 2; center = STOP_MAX - freq / 2;
} }
frequency0 = center - freq / 2; setting.frequency0 = center - freq / 2;
frequency1 = center + freq / 2; setting.frequency1 = center + freq / 2;
} }
break; break;
case ST_CW: case ST_CW:
config.freq_mode |= FREQ_MODE_CENTER_SPAN; setting.freq_mode |= FREQ_MODE_CENTER_SPAN;
if (frequency0 != freq || frequency1 != freq) { if (setting.frequency0 != freq || setting.frequency1 != freq) {
frequency0 = freq; setting.frequency0 = freq;
frequency1 = freq; setting.frequency1 = freq;
} }
break; break;
} }
@ -1128,17 +1129,17 @@ uint32_t
get_sweep_frequency(int type) get_sweep_frequency(int type)
{ {
// Obsolete, ensure correct start/stop, start always must be < stop // Obsolete, ensure correct start/stop, start always must be < stop
if (frequency0 > frequency1) { if (setting.frequency0 > setting.frequency1) {
uint32_t t = frequency0; uint32_t t = setting.frequency0;
frequency0 = frequency1; setting.frequency0 = setting.frequency1;
frequency1 = t; setting.frequency1 = t;
} }
switch (type) { switch (type) {
case ST_START: return frequency0; case ST_START: return setting.frequency0;
case ST_STOP: return frequency1; case ST_STOP: return setting.frequency1;
case ST_CENTER: return frequency0/2 + frequency1/2; case ST_CENTER: return setting.frequency0/2 + setting.frequency1/2;
case ST_SPAN: return frequency1 - frequency0; case ST_SPAN: return setting.frequency1 - setting.frequency0;
case ST_CW: return frequency0; case ST_CW: return setting.frequency0;
} }
return 0; return 0;
} }
@ -2242,7 +2243,7 @@ VNA_SHELL_FUNCTION(cmd_selftest)
shell_printf("usage: selftest (1-3)\r\n"); shell_printf("usage: selftest (1-3)\r\n");
return; return;
} }
setting_test = my_atoi(argv[0]); setting.test = my_atoi(argv[0]);
sweep_mode = SWEEP_SELFTEST; sweep_mode = SWEEP_SELFTEST;
} }
@ -2292,7 +2293,7 @@ VNA_SHELL_FUNCTION(cmd_o)
return; return;
uint32_t value = my_atoi(argv[0]); uint32_t value = my_atoi(argv[0]);
// if (VFO == 0) // if (VFO == 0)
// frequency_IF = value; // setting.frequency_IF = value;
setFreq(VFO, value); setFreq(VFO, value);
} }
@ -2300,7 +2301,7 @@ VNA_SHELL_FUNCTION(cmd_d)
{ {
(void) argc; (void) argc;
int32_t a = my_atoi(argv[0]); int32_t a = my_atoi(argv[0]);
setting_drive = a; setting.drive = a;
} }
@ -2327,11 +2328,11 @@ VNA_SHELL_FUNCTION(cmd_t)
VNA_SHELL_FUNCTION(cmd_e) VNA_SHELL_FUNCTION(cmd_e)
{ {
(void)argc; (void)argc;
setting_tracking = my_atoi(argv[0]); setting.tracking = my_atoi(argv[0]);
if (setting_tracking == -1) if (setting.tracking == -1)
setting_tracking = false; setting.tracking = false;
else else
setting_tracking = true; setting.tracking = true;
if (argc >1) if (argc >1)
frequencyExtra = my_atoi(argv[1]); frequencyExtra = my_atoi(argv[1]);
@ -2349,25 +2350,25 @@ VNA_SHELL_FUNCTION(cmd_m)
(void)argv; (void)argv;
SetMode(0); SetMode(0);
setting_tracking = false; //Default test setup setting.tracking = false; //Default test setup
setting_step_atten = false; setting.step_atten = false;
SetAttenuation(0); SetAttenuation(0);
SetReflevel(-10); SetReflevel(-10);
set_sweep_frequency(ST_START,frequencyStart - frequency_IF ); set_sweep_frequency(ST_START,frequencyStart - setting.frequency_IF );
set_sweep_frequency(ST_STOP, frequencyStop - frequency_IF); set_sweep_frequency(ST_STOP, frequencyStop - setting.frequency_IF);
draw_cal_status(); draw_cal_status();
pause_sweep(); pause_sweep();
int32_t f_step = (frequencyStop-frequencyStart)/ points; int32_t f_step = (frequencyStop-frequencyStart)/ points;
palClearPad(GPIOB, GPIOB_LED); // disable led and wait for voltage stabilization palClearPad(GPIOB, GPIOB_LED); // disable led and wait for voltage stabilization
int old_step = setting_frequency_step; int old_step = setting.frequency_step;
setting_frequency_step = f_step; setting.frequency_step = f_step;
update_rbw(); update_rbw();
chThdSleepMilliseconds(10); chThdSleepMilliseconds(10);
streamPut(shell_stream, '{'); streamPut(shell_stream, '{');
dirty = true; dirty = true;
for (int i = 0; i<points; i++) { for (int i = 0; i<points; i++) {
float val = perform(false, i, frequencyStart - frequency_IF + f_step * i, setting_tracking); float val = perform(false, i, frequencyStart - setting.frequency_IF + f_step * i, setting.tracking);
streamPut(shell_stream, 'x'); streamPut(shell_stream, 'x');
int v = val*2 + 256; int v = val*2 + 256;
streamPut(shell_stream, (uint8_t)(v & 0xFF)); streamPut(shell_stream, (uint8_t)(v & 0xFF));
@ -2375,7 +2376,7 @@ VNA_SHELL_FUNCTION(cmd_m)
// enable led // enable led
} }
streamPut(shell_stream, '}'); streamPut(shell_stream, '}');
setting_frequency_step = old_step; setting.frequency_step = old_step;
update_rbw(); update_rbw();
resume_sweep(); resume_sweep();
palSetPad(GPIOB, GPIOB_LED); palSetPad(GPIOB, GPIOB_LED);
@ -2781,8 +2782,10 @@ int main(void)
/* restore config */ /* restore config */
config_recall(); config_recall();
caldata_recall(0); // must be done to setup the scanning stuff if (caldata_recall(0) == -1 || setting.mode == -1) {
setting.mode = -1; // must be done to setup the scanning stuff
setting.refer = -1;
}
/* restore frequencies and calibration 0 slot properties from flash memory */ /* restore frequencies and calibration 0 slot properties from flash memory */
#ifdef __VNA__ #ifdef __VNA__
dac1cfg1.init = config.dac_value; dac1cfg1.init = config.dac_value;
@ -2812,6 +2815,10 @@ int main(void)
//Initialize graph plotting //Initialize graph plotting
plot_init(); plot_init();
if (setting.mode != -1) {
menu_mode_cb(setting.mode+1,0);
ui_mode_normal(); // Do not show menu when autostarting mode
}
redraw_frame(); redraw_frame();
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO-1, Thread1, NULL); chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO-1, Thread1, NULL);

@ -118,6 +118,7 @@ enum stimulus_type {
ST_START=0, ST_STOP, ST_CENTER, ST_SPAN, ST_CW ST_START=0, ST_STOP, ST_CENTER, ST_SPAN, ST_CW
}; };
void update_frequencies(void);
void set_sweep_frequency(int type, uint32_t frequency); void set_sweep_frequency(int type, uint32_t frequency);
uint32_t get_sweep_frequency(int type); uint32_t get_sweep_frequency(int type);
@ -454,18 +455,73 @@ void show_logo(void);
* flash.c * flash.c
*/ */
typedef struct setting
{
uint32_t magic;
// uint32_t _frequency0;
// uint32_t _frequency1;
int mode;
uint16_t _sweep_points;
int attenuate;
int auto_attenuation;
int step_atten;
int rbw;
int below_IF;
int average;
int show_stored;
int subtract_stored;
int drive; // 0-7 , 7=+20dBm, 3dB steps
int agc;
int lna;
int auto_reflevel;
int reflevel;
int scale;
int tracking;
int modulation;
int step_delay;
int frequency_step;
int test;
int harmonic;
int decay;
int noise;
float vbw;
int tracking_output;
int repeat;
uint32_t frequency0;
uint32_t frequency1;
uint32_t frequency_IF;
int freq_mode;
int measurement;
int refer;
trace_t _trace[TRACES_MAX];
marker_t _markers[MARKERS_MAX];
int8_t _active_marker;
uint32_t checksum;
}setting_t;
extern setting_t setting;
extern int setting_frequency_10mhz;
void reset_settings(int m);
extern uint32_t frequencies[POINTS_COUNT];
#if 1 #if 1
#define SAVEAREA_MAX 5 #define SAVEAREA_MAX 9
// Begin addr 0x08018000 // Begin addr 0x08018000
#define SAVE_CONFIG_AREA_SIZE 0x00000800 #define SAVE_CONFIG_AREA_SIZE 0x00000800
// config save area // config save area
#define SAVE_CONFIG_ADDR 0x0801C000 #define SAVE_CONFIG_ADDR 0x0801B000
// properties_t save area // properties_t save area
#define SAVE_PROP_CONFIG_0_ADDR 0x0801C800 #define SAVE_PROP_CONFIG_0_ADDR 0x0801B800
#define SAVE_PROP_CONFIG_1_ADDR 0x0801D000 #define SAVE_PROP_CONFIG_1_ADDR 0x0801C000
#define SAVE_PROP_CONFIG_2_ADDR 0x0801D800 #define SAVE_PROP_CONFIG_2_ADDR 0x0801C800
#define SAVE_PROP_CONFIG_3_ADDR 0x0801E000 #define SAVE_PROP_CONFIG_3_ADDR 0x0801D000
#define SAVE_PROP_CONFIG_4_ADDR 0x0801E800 #define SAVE_PROP_CONFIG_4_ADDR 0x0801D800
#define SAVE_PROP_CONFIG_5_ADDR 0x0801E000
#define SAVE_PROP_CONFIG_6_ADDR 0x0801E800
#define SAVE_PROP_CONFIG_7_ADDR 0x0801F000
#define SAVE_PROP_CONFIG_8_ADDR 0x0801F800
#else #else
#define SAVEAREA_MAX 4 #define SAVEAREA_MAX 4
// Begin addr 0x0801C000 // Begin addr 0x0801C000
@ -479,28 +535,30 @@ void show_logo(void);
#define SAVE_PROP_CONFIG_3_ADDR 0x0801E000 #define SAVE_PROP_CONFIG_3_ADDR 0x0801E000
#define SAVE_PROP_CONFIG_4_ADDR 0x0801e800 #define SAVE_PROP_CONFIG_4_ADDR 0x0801e800
#endif #endif
#if 0
typedef struct properties { typedef struct properties {
uint32_t magic; uint32_t magic;
uint32_t _frequency0; preset_t setting;
uint32_t _frequency1; // uint32_t _frequency0;
// uint32_t _frequency1;
uint16_t _sweep_points; uint16_t _sweep_points;
#ifdef __VNA__ #ifdef __VNA__
uint16_t _cal_status; uint16_t _cal_status;
#endif #endif
#ifdef __SA__ #ifdef __SA__
uint32_t _frequency_IF; //IF frequency // uint32_t _frequency_IF; //IF frequency
#endif #endif
uint32_t _frequencies[POINTS_COUNT]; // uint32_t _frequencies[POINTS_COUNT];
#ifdef __VNA__ #ifdef __VNA__
float _cal_data[5][POINTS_COUNT][2]; float _cal_data[5][POINTS_COUNT][2];
float _electrical_delay; // picoseconds float _electrical_delay; // picoseconds
#endif #endif
trace_t _trace[TRACES_MAX]; trace_t _trace[TRACES_MAX];
marker_t _markers[MARKERS_MAX]; marker_t _markers[MARKERS_MAX];
float _velocity_factor; // %
int8_t _active_marker; int8_t _active_marker;
#ifdef __VNA__ #ifdef __VNA__
float _velocity_factor; // %
uint8_t _domain_mode; /* 0bxxxxxffm : where ff: TD_FUNC m: DOMAIN_MODE */ uint8_t _domain_mode; /* 0bxxxxxffm : where ff: TD_FUNC m: DOMAIN_MODE */
uint8_t _marker_smith_format; uint8_t _marker_smith_format;
uint8_t _bandwidth; uint8_t _bandwidth;
@ -509,31 +567,34 @@ typedef struct properties {
uint32_t checksum; uint32_t checksum;
} properties_t; } properties_t;
#endif
//sizeof(properties_t) == 0x1200 //sizeof(properties_t) == 0x1200
#define CONFIG_MAGIC 0x434f4e45 /* 'CONF' */ #define CONFIG_MAGIC 0x434f4e45 /* 'CONF' */
extern int16_t lastsaveid; extern int16_t lastsaveid;
extern properties_t *active_props; //extern properties_t *active_props;
extern properties_t current_props;
//extern properties_t current_props;
#define frequency0 current_props._frequency0 //#define frequency0 current_props._frequency0
#define frequency1 current_props._frequency1 //#define frequency1 current_props._frequency1
#define sweep_points current_props._sweep_points #define sweep_points setting._sweep_points
#ifdef __VNA__ #ifdef __VNA__
#define cal_status current_props._cal_status #define cal_status current_props._cal_status
#endif #endif
#ifdef __SA__ #ifdef __SA__
#define frequency_IF current_props._frequency_IF //#define frequency_IF current_props._frequency_IF
#endif #endif
#define frequencies current_props._frequencies //#define frequencies current_props._frequencies
#ifdef __VNA__ #ifdef __VNA__
#define cal_data active_props->_cal_data #define cal_data active_props->_cal_data
#define electrical_delay current_props._electrical_delay #define electrical_delay current_props._electrical_delay
#endif #endif
#define trace current_props._trace #define trace setting._trace
#define markers current_props._markers #define markers setting._markers
#define active_marker current_props._active_marker #define active_marker setting._active_marker
#ifdef __VNA__ #ifdef __VNA__
#define domain_mode current_props._domain_mode #define domain_mode current_props._domain_mode
#define velocity_factor current_props._velocity_factor #define velocity_factor current_props._velocity_factor
@ -541,14 +602,12 @@ extern properties_t current_props;
#define bandwidth current_props._bandwidth #define bandwidth current_props._bandwidth
#endif #endif
#define FREQ_IS_STARTSTOP() (!(config.freq_mode&FREQ_MODE_CENTER_SPAN)) #define FREQ_IS_STARTSTOP() (!(setting.freq_mode&FREQ_MODE_CENTER_SPAN))
#define FREQ_IS_CENTERSPAN() (config.freq_mode&FREQ_MODE_CENTER_SPAN) #define FREQ_IS_CENTERSPAN() (setting.freq_mode&FREQ_MODE_CENTER_SPAN)
#define FREQ_IS_CW() (frequency0 == frequency1) #define FREQ_IS_CW() (setting.frequency0 == setting.frequency1)
int caldata_recall(int id); int caldata_recall(int id);
#ifdef __VNA__
int caldata_save(int id); int caldata_save(int id);
const properties_t *caldata_ref(int id); //const properties_t *caldata_ref(int id);
#endif
int config_save(void); int config_save(void);
int config_recall(void); int config_recall(void);
@ -561,6 +620,9 @@ extern void ui_init(void);
extern void ui_process(void); extern void ui_process(void);
int current_menu_is_form(void); int current_menu_is_form(void);
void menu_mode_cb(int, uint8_t);
void ui_mode_normal(void);
// Irq operation process set // Irq operation process set
#define OP_NONE 0x00 #define OP_NONE 0x00
#define OP_LEVER 0x01 #define OP_LEVER 0x01
@ -622,11 +684,11 @@ int16_t adc_vbat_read(void);
*/ */
int plot_printf(char *str, int, const char *fmt, ...); int plot_printf(char *str, int, const char *fmt, ...);
#define PULSE do { palClearPad(GPIOC, GPIOC_LED); palSetPad(GPIOC, GPIOC_LED);} while(0) #define PULSE do { palClearPad(GPIOC, GPIOC_LED); palSetPad(GPIOC, GPIOC_LED);} while(0)
extern int setting_attenuate; //extern int setting_attenuate;
extern int settingPowerCal; //extern int settingPowerCal;
extern int setting_step_delay; //extern int setting_step_delay;
extern int actualStepDelay; //extern int actualStepDelay;
extern int setting_mode; //extern int setting_mode;
void update_rbw(void); void update_rbw(void);
int GetActualRBW(void); int GetActualRBW(void);
@ -660,9 +722,9 @@ void SetReflevel(int);
void SetScale(int); void SetScale(int);
void SetRBW(int); void SetRBW(int);
void SetRX(int); void SetRX(int);
extern int setting_measurement; //extern int setting_measurement;
void self_test(int); void self_test(int);
extern int setting_test; //extern int setting_test;
void wait_user(void); void wait_user(void);
void calibrate(void); void calibrate(void);

@ -1907,7 +1907,7 @@ static void cell_draw_marker_info(int x0, int y0)
} }
} }
for (int i = 0; i < MARKER_COUNT; i++) { for (int i = 0; i < MARKER_COUNT; i++) {
if (i >= 2 && setting_measurement == M_OIP3 && markers[2].enabled && markers[3].enabled) { if (i >= 2 && setting.measurement == M_OIP3 && markers[2].enabled && markers[3].enabled) {
float il = logmag(&(actual_t[markers[2].index])); float il = logmag(&(actual_t[markers[2].index]));
float ir = logmag(&(actual_t[markers[3].index])); float ir = logmag(&(actual_t[markers[3].index]));
float sl = logmag(&(actual_t[markers[0].index])); float sl = logmag(&(actual_t[markers[0].index]));
@ -2031,7 +2031,7 @@ draw_frequencies(void)
{ {
char buf1[32]; char buf1[32];
char buf2[32]; buf2[0] = 0; char buf2[32]; buf2[0] = 0;
if (MODE_OUTPUT(setting_mode)) // No frequencies during output if (MODE_OUTPUT(setting.mode)) // No frequencies during output
return; return;
if (current_menu_is_form() && !in_selftest) if (current_menu_is_form() && !in_selftest)
return; return;

File diff suppressed because it is too large Load Diff

@ -332,11 +332,11 @@ float SI4432_RBW_table(int i){
return(RBW_choices[i*4-1]); return(RBW_choices[i*4-1]);
} }
int setting_10mhz = 10000000; int setting_frequency_10mhz = 10000000;
void set_10mhz(int f) void set_10mhz(int f)
{ {
setting_10mhz = f; setting_frequency_10mhz = f;
} }
void SI4432_Set_Frequency ( long Freq ) { void SI4432_Set_Frequency ( long Freq ) {
@ -349,8 +349,8 @@ void SI4432_Set_Frequency ( long Freq ) {
hbsel = 0; hbsel = 0;
} }
int sbsel = 1; int sbsel = 1;
int N = Freq / setting_10mhz; int N = Freq / setting_frequency_10mhz;
Carrier = ( 4 * ( Freq - N * setting_10mhz )) / 625; Carrier = ( 4 * ( Freq - N * setting_frequency_10mhz )) / 625;
int Freq_Band = ( N - 24 ) | ( hbsel << 5 ) | ( sbsel << 6 ); int Freq_Band = ( N - 24 ) | ( hbsel << 5 ) | ( sbsel << 6 );
#if 0 #if 0
SI4432_Write_Byte ( 0x75, Freq_Band ); SI4432_Write_Byte ( 0x75, Freq_Band );
@ -362,7 +362,7 @@ void SI4432_Set_Frequency ( long Freq ) {
} }
int actualStepDelay = 1500; int actualStepDelay = 1500;
extern int setting_repeat; //extern int setting.repeat;
float SI4432_RSSI(uint32_t i, int s) float SI4432_RSSI(uint32_t i, int s)
{ {
@ -378,12 +378,12 @@ float SI4432_RSSI(uint32_t i, int s)
//START_PROFILE //START_PROFILE
SI4432_Sel = s; SI4432_Sel = s;
chThdSleepMicroseconds(actualStepDelay); chThdSleepMicroseconds(actualStepDelay);
i = setting_repeat; i = setting.repeat;
RSSI_RAW = 0; RSSI_RAW = 0;
while (i-->0) while (i-->0)
RSSI_RAW += (unsigned char)SI4432_Read_Byte( 0x26 ) ; RSSI_RAW += (unsigned char)SI4432_Read_Byte( 0x26 ) ;
RSSI_RAW = RSSI_RAW / setting_repeat; RSSI_RAW = RSSI_RAW / setting.repeat;
// if (MODE_INPUT(setting_mode) && RSSI_RAW == 0) // if (MODE_INPUT(setting.mode) && RSSI_RAW == 0)
// SI4432_Init(); // SI4432_Init();
float dBm = (RSSI_RAW-240)/2.0 - SI4432_RSSI_correction; float dBm = (RSSI_RAW-240)/2.0 - SI4432_RSSI_correction;
#ifdef __SIMULATION__ #ifdef __SIMULATION__

@ -119,7 +119,7 @@ static int16_t last_touch_y;
#define KP_DONE 1 #define KP_DONE 1
#define KP_CANCEL 2 #define KP_CANCEL 2
static void ui_mode_normal(void); void ui_mode_normal(void);
static void ui_mode_menu(void); static void ui_mode_menu(void);
static void ui_mode_numeric(int _keypad_mode); static void ui_mode_numeric(int _keypad_mode);
static void ui_mode_keypad(int _keypad_mode); static void ui_mode_keypad(int _keypad_mode);
@ -1149,6 +1149,7 @@ menu_move_back(void)
static void static void
menu_push_submenu(const menuitem_t *submenu) menu_push_submenu(const menuitem_t *submenu)
{ {
ui_mode = UI_MENU; // Only needed for auto mode setting
erase_menu_buttons(); erase_menu_buttons();
if (menu_current_level < MENU_STACK_DEPTH_MAX-1) if (menu_current_level < MENU_STACK_DEPTH_MAX-1)
menu_current_level++; menu_current_level++;
@ -1849,7 +1850,7 @@ ui_mode_keypad(int _keypad_mode)
draw_numeric_input(""); draw_numeric_input("");
} }
static void void
ui_mode_normal(void) ui_mode_normal(void)
{ {
if (ui_mode == UI_NORMAL) if (ui_mode == UI_NORMAL)

@ -14,7 +14,7 @@ int get_refer_output(void);
void SetAttenuation(int); void SetAttenuation(int);
int GetAttenuation(void); int GetAttenuation(void);
void set_harmonic(int); void set_harmonic(int);
extern int setting_harmonic; //extern int setting.harmonic;
int search_is_greater(void); int search_is_greater(void);
void set_auto_attenuation(void); void set_auto_attenuation(void);
void set_auto_reflevel(void); void set_auto_reflevel(void);
@ -26,15 +26,15 @@ void SetDrive(int d);
void SetIF(int f); void SetIF(int f);
void SetStepDelay(int t); void SetStepDelay(int t);
void set_repeat(int); void set_repeat(int);
extern int setting_repeat; //extern int setting.repeat;
extern int setting_rbw; //extern int setting.rbw;
#ifdef __ULTRA__ #ifdef __ULTRA__
extern int setting_spur; //extern int setting.spur;
void SetSpur(int v); void SetSpur(int v);
#endif #endif
void SetAverage(int); void SetAverage(int);
int GetAverage(void); int GetAverage(void);
extern int setting_average; //extern int setting.average;
void SetStorage(void); void SetStorage(void);
void SetClearStorage(void); void SetClearStorage(void);
void SetSubtractStorage(void); void SetSubtractStorage(void);
@ -51,28 +51,28 @@ void redrawHisto(void);
void self_test(int); void self_test(int);
void set_decay(int); void set_decay(int);
void set_noise(int); void set_noise(int);
void menu_load_preset_cb(int,int);
void menu_store_preset_cb(int,int);
void toggle_tracking_output(void); void toggle_tracking_output(void);
extern int32_t frequencyExtra; extern int32_t frequencyExtra;
extern int setting_tracking; #if 0
extern int setting_tracking_output; extern int setting.tracking;
extern int setting_drive; extern int setting.tracking_output;
extern int setting_lna; extern int setting.drive;
extern int setting_agc; extern int setting.lna;
extern int setting_decay; extern int setting.agc;
extern int setting_noise; extern int setting.decay;
extern int setting_auto_reflevel; extern int setting.noise;
extern int setting_auto_attenuation; extern int setting.auto_reflevel;
extern int setting_reflevel; extern int setting.auto_attenuation;
extern int setting_scale; extern int setting.reflevel;
extern int setting_10mhz; extern int setting.scale;
extern int setting.10mhz;
#endif
void set_10mhz(int); void set_10mhz(int);
void SetModulation(int); void SetModulation(int);
extern int setting_modulation; //extern int setting.modulation;
void set_measurement(int); void set_measurement(int);
// extern int settingSpeed; // extern int settingSpeed;
extern int setting_step_delay; //extern int setting.step_delay;
void blit16BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, void blit16BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
const uint16_t *bitmap); const uint16_t *bitmap);
@ -485,7 +485,7 @@ extern const menuitem_t menu_top[];
extern const menuitem_t menu_tophigh[]; extern const menuitem_t menu_tophigh[];
extern const menuitem_t menu_topultra[]; extern const menuitem_t menu_topultra[];
static void menu_mode_cb(int item, uint8_t data) void menu_mode_cb(int item, uint8_t data)
{ {
(void)data; (void)data;
SetMode(item-1); SetMode(item-1);
@ -512,6 +512,27 @@ static void menu_mode_cb(int item, uint8_t data)
// draw_cal_status(); // draw_cal_status();
} }
void menu_load_preset_cb(int item, uint8_t data)
{
(void)item;
caldata_recall(data);
menu_move_back();
ui_mode_normal();
}
void menu_store_preset_cb(int item, uint8_t data)
{
(void)item;
if (data == 100) {
setting.mode = -1;
data = 0;
}
caldata_save(data);
menu_move_back();
ui_mode_normal();
}
extern int dirty; extern int dirty;
void menu_autosettings_cb(int item, uint8_t data) void menu_autosettings_cb(int item, uint8_t data)
{ {
@ -572,7 +593,7 @@ static void menu_config_cb(int item, uint8_t data)
sweep_mode = 0; // Suspend sweep to save time sweep_mode = 0; // Suspend sweep to save time
menu_move_back(); menu_move_back();
ui_mode_normal(); ui_mode_normal();
setting_test = 0; setting.test = 0;
sweep_mode = SWEEP_SELFTEST; sweep_mode = SWEEP_SELFTEST;
break; break;
case 4: case 4:
@ -636,7 +657,7 @@ static void menu_spur_cb(int item, uint8_t data)
{ {
(void)data; (void)data;
(void)item; (void)item;
if (setting_spur) if (setting.spur)
SetSpur(0); SetSpur(0);
else else
SetSpur(1); // must be 0 or 1 !!!! SetSpur(1); // must be 0 or 1 !!!!
@ -949,19 +970,45 @@ const char *menu_drive_text[]={"-36dBm","-34dBm","-32dBm","-30dBm","-28dBm","-26
// ===[MENU DEFINITION]========================================================= // ===[MENU DEFINITION]=========================================================
static const menuitem_t menu_store_preset_high[] =
{
{ MT_CALLBACK, 0, "\2STORE\0STARTUP",menu_store_preset_cb},
{ MT_CALLBACK, 5, "STORE 5" , menu_store_preset_cb},
{ MT_CALLBACK, 6, "STORE 6" , menu_store_preset_cb},
{ MT_CALLBACK, 7, "STORE 7" , menu_store_preset_cb},
{ MT_CALLBACK, 8, "STORE 8" , menu_store_preset_cb},
{ MT_CALLBACK, 100, "\2ERASE\0STARTUP",menu_store_preset_cb},
{ MT_CANCEL, 255, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_load_preset_high[] =
{
{ MT_CALLBACK, 0, "\2LOAD\0STARTUP",menu_load_preset_cb},
{ MT_CALLBACK, 5, "LOAD 5" , menu_load_preset_cb},
{ MT_CALLBACK, 6, "LOAD 6" , menu_load_preset_cb},
{ MT_CALLBACK, 7, "LOAD 7" , menu_load_preset_cb},
{ MT_CALLBACK, 8, "LOAD 8" , menu_load_preset_cb},
{ MT_SUBMENU, 0, "STORE" , menu_store_preset_high},
{ MT_CANCEL, 255, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_store_preset[] = static const menuitem_t menu_store_preset[] =
{ {
{ MT_CALLBACK, 0, "\2STORE\0STARTUP",menu_store_preset_cb},
{ MT_CALLBACK, 1, "STORE 1" , menu_store_preset_cb}, { MT_CALLBACK, 1, "STORE 1" , menu_store_preset_cb},
{ MT_CALLBACK, 2, "STORE 2" , menu_store_preset_cb}, { MT_CALLBACK, 2, "STORE 2" , menu_store_preset_cb},
{ MT_CALLBACK, 3, "STORE 3" , menu_store_preset_cb}, { MT_CALLBACK, 3, "STORE 3" , menu_store_preset_cb},
{ MT_CALLBACK, 4, "STORE 4" , menu_store_preset_cb}, { MT_CALLBACK, 4, "STORE 4" , menu_store_preset_cb},
{ MT_CALLBACK, 100, "\2ERASE\0STARTUP",menu_store_preset_cb},
{ MT_CANCEL, 255, S_LARROW" BACK", NULL }, { MT_CANCEL, 255, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
static const menuitem_t menu_load_preset[] = static const menuitem_t menu_load_preset[] =
{ {
{ MT_CALLBACK, 0, "DEFAULTS" , menu_load_preset_cb}, { MT_CALLBACK, 0, "\2LOAD\0STARTUP",menu_load_preset_cb},
{ MT_CALLBACK, 1, "LOAD 1" , menu_load_preset_cb}, { MT_CALLBACK, 1, "LOAD 1" , menu_load_preset_cb},
{ MT_CALLBACK, 2, "LOAD 2" , menu_load_preset_cb}, { MT_CALLBACK, 2, "LOAD 2" , menu_load_preset_cb},
{ MT_CALLBACK, 3, "LOAD 3" , menu_load_preset_cb}, { MT_CALLBACK, 3, "LOAD 3" , menu_load_preset_cb},
@ -1388,7 +1435,7 @@ const menuitem_t menu_topultra[] = {
#endif #endif
const menuitem_t menu_top[] = { const menuitem_t menu_top[] = {
{ MT_CALLBACK, 0, "RESET", menu_autosettings_cb}, { MT_SUBMENU, 0, "PRESET", menu_load_preset},
{ MT_SUBMENU, 0, "FREQ", menu_stimulus}, { MT_SUBMENU, 0, "FREQ", menu_stimulus},
{ MT_SUBMENU, 0, "LEVEL", menu_level}, { MT_SUBMENU, 0, "LEVEL", menu_level},
{ MT_SUBMENU, 0, "DISPLAY", menu_display}, { MT_SUBMENU, 0, "DISPLAY", menu_display},
@ -1401,7 +1448,7 @@ const menuitem_t menu_top[] = {
}; };
const menuitem_t menu_tophigh[] = { const menuitem_t menu_tophigh[] = {
{ MT_CALLBACK, 0, "RESET", menu_autosettings_cb}, { MT_SUBMENU, 0, "PRESET", menu_load_preset_high},
{ MT_SUBMENU, 0, "FREQ", menu_stimulus}, { MT_SUBMENU, 0, "FREQ", menu_stimulus},
{ MT_SUBMENU, 0, "LEVEL", menu_levelhigh}, { MT_SUBMENU, 0, "LEVEL", menu_levelhigh},
{ MT_SUBMENU, 0, "DISPLAY", menu_display}, { MT_SUBMENU, 0, "DISPLAY", menu_display},
@ -1469,10 +1516,10 @@ static void menu_item_modify_attribute(
plot_printf(uistat.text, sizeof uistat.text, menu_reffer_text[get_refer_output()+1]); plot_printf(uistat.text, sizeof uistat.text, menu_reffer_text[get_refer_output()+1]);
} }
} else if (menu == menu_highoutputmode && item == 2) { } else if (menu == menu_highoutputmode && item == 2) {
plot_printf(uistat.text, sizeof uistat.text, menu_drive_text[setting_drive]); plot_printf(uistat.text, sizeof uistat.text, menu_drive_text[setting.drive]);
} else if (menu == menu_lowoutputmode || menu == menu_highoutputmode) { } else if (menu == menu_lowoutputmode || menu == menu_highoutputmode) {
if (item == 3) { if (item == 3) {
plot_printf(uistat.text, sizeof uistat.text, menu_modulation_text[setting_modulation]); plot_printf(uistat.text, sizeof uistat.text, menu_modulation_text[setting.modulation]);
} }
} else if (menu == menu_reffer) { } else if (menu == menu_reffer) {
if (item < 5 && item == get_refer_output() + 1){ if (item < 5 && item == get_refer_output() + 1){
@ -1487,7 +1534,7 @@ static void menu_item_modify_attribute(
mark = true; mark = true;
} }
#ifdef __ULTRA__ #ifdef __ULTRA__
if (item == 6 && setting_spur) { if (item == 6 && setting.spur) {
mark = true; mark = true;
} }
#endif #endif
@ -1496,11 +1543,11 @@ static void menu_item_modify_attribute(
mark = true; mark = true;
} }
} else if (menu == menu_dBper) { } else if (menu == menu_dBper) {
if (data == setting_scale){ if (data == setting.scale){
mark = true; mark = true;
} }
} else if (menu == menu_measure && MT_MASK(menu[item].type) == MT_CALLBACK) { } else if (menu == menu_measure && MT_MASK(menu[item].type) == MT_CALLBACK) {
if (data == setting_measurement){ if (data == setting.measurement){
mark = true; mark = true;
} }
} else if (menu == menu_rbw) { } else if (menu == menu_rbw) {
@ -1509,11 +1556,11 @@ static void menu_item_modify_attribute(
} }
} else if (MT_MASK(menu[item].type) == MT_CALLBACK && (menu == menu_drive || menu == menu_drive_wide || menu == menu_drive_wide2|| menu == menu_drive_wide3)) { } else if (MT_MASK(menu[item].type) == MT_CALLBACK && (menu == menu_drive || menu == menu_drive_wide || menu == menu_drive_wide2|| menu == menu_drive_wide3)) {
if (data == setting_drive){ if (data == setting.drive){
mark = true; mark = true;
} }
} else if (menu == menu_modulation && MT_MASK(menu[item].type) == MT_CALLBACK) { } else if (menu == menu_modulation && MT_MASK(menu[item].type) == MT_CALLBACK) {
if (data == setting_modulation){ if (data == setting.modulation){
mark = true; mark = true;
} }
} else if (menu == menu_display) { } else if (menu == menu_display) {
@ -1530,22 +1577,22 @@ static void menu_item_modify_attribute(
mark = true; mark = true;
} }
} else if (menu == menu_settings) { } else if (menu == menu_settings) {
if (item ==0 && setting_tracking_output){ if (item ==0 && setting.tracking_output){
mark = true; mark = true;
} }
#ifdef __ULTRA__ #ifdef __ULTRA__
} else if (MT_MASK(menu[item].type) == MT_CALLBACK && menu == menu_harmonic) { } else if (MT_MASK(menu[item].type) == MT_CALLBACK && menu == menu_harmonic) {
if (data == setting_harmonic) if (data == setting.harmonic)
mark = true; mark = true;
#endif #endif
} else if (menu == menu_settings2 || menu == menu_settingshigh2) { } else if (menu == menu_settings2 || menu == menu_settingshigh2) {
if (item ==0 && setting_agc){ if (item ==0 && setting.agc){
mark = true; mark = true;
} }
if (item == 1 && setting_lna){ if (item == 1 && setting.lna){
mark = true; mark = true;
} }
if (item == 2 && setting_tracking){ // should not happen in high mode if (item == 2 && setting.tracking){ // should not happen in high mode
mark = true; mark = true;
} }
} else if (menu == menu_marker_modify && active_marker >= 0 && markers[active_marker].enabled == M_ENABLED) { } else if (menu == menu_marker_modify && active_marker >= 0 && markers[active_marker].enabled == M_ENABLED) {
@ -1570,10 +1617,10 @@ static void menu_item_modify_attribute(
else if (item == 6 && uistat.marker_tracking) else if (item == 6 && uistat.marker_tracking)
mark = true; mark = true;
} else if (menu == menu_reflevel) { } else if (menu == menu_reflevel) {
if ((item == 0 && setting_auto_reflevel) || (item == 1 && !setting_auto_reflevel)) if ((item == 0 && setting.auto_reflevel) || (item == 1 && !setting.auto_reflevel))
mark = true; mark = true;
} else if (menu == menu_atten) { } else if (menu == menu_atten) {
if ((item == 0 && setting_auto_attenuation ) || (item == 1 && !setting_auto_attenuation)) if ((item == 0 && setting.auto_attenuation ) || (item == 1 && !setting.auto_attenuation))
mark = true; mark = true;
} }
if (mark) { if (mark) {
@ -1615,11 +1662,11 @@ static void fetch_numeric_target(void)
plot_printf(uistat.text, sizeof uistat.text, "%3.3fMHz", uistat.value / 1000000.0); plot_printf(uistat.text, sizeof uistat.text, "%3.3fMHz", uistat.value / 1000000.0);
break; break;
case KM_SCALE: case KM_SCALE:
uistat.value = setting_scale; uistat.value = setting.scale;
plot_printf(uistat.text, sizeof uistat.text, "%ddB/", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%ddB/", ((int32_t)uistat.value));
break; break;
case KM_REFPOS: case KM_REFPOS:
uistat.value = setting_reflevel; uistat.value = setting.reflevel;
plot_printf(uistat.text, sizeof uistat.text, "%ddB", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%ddB", ((int32_t)uistat.value));
break; break;
case KM_ATTENUATION: case KM_ATTENUATION:
@ -1631,19 +1678,19 @@ static void fetch_numeric_target(void)
plot_printf(uistat.text, sizeof uistat.text, "%ddB", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%ddB", ((int32_t)uistat.value));
break; break;
case KM_IF: case KM_IF:
uistat.value = frequency_IF; uistat.value = setting.frequency_IF;
plot_printf(uistat.text, sizeof uistat.text, "%3.3fMHz", uistat.value / 1000000.0); plot_printf(uistat.text, sizeof uistat.text, "%3.3fMHz", uistat.value / 1000000.0);
break; break;
case KM_SAMPLETIME: case KM_SAMPLETIME:
uistat.value = setting_step_delay; uistat.value = setting.step_delay;
plot_printf(uistat.text, sizeof uistat.text, "%3duS", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%3duS", ((int32_t)uistat.value));
break; break;
case KM_REPEAT: case KM_REPEAT:
uistat.value = setting_repeat; uistat.value = setting.repeat;
plot_printf(uistat.text, sizeof uistat.text, "%2d", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%2d", ((int32_t)uistat.value));
break; break;
case KM_DRIVE: case KM_DRIVE:
uistat.value = setting_drive; uistat.value = setting.drive;
plot_printf(uistat.text, sizeof uistat.text, "%3ddB", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%3ddB", ((int32_t)uistat.value));
break; break;
case KM_LOWOUTLEVEL: case KM_LOWOUTLEVEL:
@ -1651,15 +1698,15 @@ static void fetch_numeric_target(void)
plot_printf(uistat.text, sizeof uistat.text, "%ddB", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%ddB", ((int32_t)uistat.value));
break; break;
case KM_DECAY: case KM_DECAY:
uistat.value = setting_decay; uistat.value = setting.decay;
plot_printf(uistat.text, sizeof uistat.text, "%3d", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%3d", ((int32_t)uistat.value));
break; break;
case KM_NOISE: case KM_NOISE:
uistat.value = setting_noise; uistat.value = setting.noise;
plot_printf(uistat.text, sizeof uistat.text, "%3d", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%3d", ((int32_t)uistat.value));
break; break;
case KM_10MHZ: case KM_10MHZ:
uistat.value = setting_10mhz; uistat.value = setting_frequency_10mhz;
plot_printf(uistat.text, sizeof uistat.text, "%3.6fMHz", uistat.value / 1000000.0); plot_printf(uistat.text, sizeof uistat.text, "%3.6fMHz", uistat.value / 1000000.0);
break; break;
@ -1700,11 +1747,11 @@ set_numeric_value(void)
set_trace_scale(2, uistat.value / 1000.0); set_trace_scale(2, uistat.value / 1000.0);
break; break;
case KM_REFPOS: case KM_REFPOS:
setting_auto_reflevel = false; setting.auto_reflevel = false;
SetReflevel(uistat.value); SetReflevel(uistat.value);
break; break;
case KM_ATTENUATION: case KM_ATTENUATION:
setting_auto_attenuation = false; setting.auto_attenuation = false;
SetAttenuation(uistat.value); SetAttenuation(uistat.value);
break; break;
case KM_ACTUALPOWER: case KM_ACTUALPOWER:
@ -1735,7 +1782,7 @@ set_numeric_value(void)
break; break;
case KM_10MHZ: case KM_10MHZ:
if (uistat.value < 9000000) { if (uistat.value < 9000000) {
set_10mhz(setting_10mhz + uistat.value); set_10mhz(setting_frequency_10mhz + uistat.value);
} else } else
set_10mhz(uistat.value); set_10mhz(uistat.value);
dirty = true; dirty = true;

Loading…
Cancel
Save

Powered by TurnKey Linux.