diff --git a/main.c b/main.c index bf16e1b..1b867f1 100644 --- a/main.c +++ b/main.c @@ -109,7 +109,8 @@ volatile uint8_t redraw_request = 0; // contains REDRAW_XXX flags // Version text, displayed in Config->Version menu, also send by info command const char *info_about[]={ BOARD_NAME, - "2016-2020 Copyright @Erik Kaashoek", + "2019-2020 Copyright @Erik Kaashoek", + "2016-2020 Copyright @edy555", "SW licensed under GPL. See: https://github.com/erikkaashoek/tinySA", "Version: " VERSION, "Build Time: " __DATE__ " - " __TIME__, @@ -713,7 +714,7 @@ VNA_SHELL_FUNCTION(cmd_data) if (sel >= 0 || sel <= MAX_DATA) { for (i = 0; i < sweep_points; i++) - shell_printf("%f %f\r\n", measured[sel][i], 0.0); + shell_printf("%f\r\n", measured[sel][i]); return; } shell_printf("usage: data [array]\r\n"); @@ -948,7 +949,7 @@ VNA_SHELL_FUNCTION(cmd_scan) start = my_atoui(argv[0]); stop = my_atoui(argv[1]); - if (start == 0 || stop == 0 || start > stop) { + if (start > stop) { shell_printf("frequency range is invalid\r\n"); return; } @@ -973,9 +974,9 @@ VNA_SHELL_FUNCTION(cmd_scan) if (mask) { for (i = 0; i < points; i++) { if (mask & 1) shell_printf("%u ", frequencies[i]); - if (mask & 2) shell_printf("%f %f ", measured[0][i]); - if (mask & 4) shell_printf("%f %f ", measured[1][i]); - if (mask & 8) shell_printf("%f %f ", measured[2][i]); + if (mask & 2) shell_printf("%f ", measured[0][i]); + if (mask & 4) shell_printf("%f ", measured[1][i]); + if (mask & 8) shell_printf("%f ", measured[2][i]); shell_printf("\r\n"); } } @@ -2181,229 +2182,8 @@ VNA_SHELL_FUNCTION(cmd_threads) } #endif +#include "sa_cmd.c" -extern volatile int SI4432_Sel; // currently selected SI4432 -void SI4432_Write_Byte(byte ADR, byte DATA ); -byte SI4432_Read_Byte( byte ADR ); -int VFO = 0; -int points = 101; // For 's' and 'm' commands - -VNA_SHELL_FUNCTION(cmd_v) - - -{ - if (argc != 1) { - shell_printf("%d\r\n", SI4432_Sel); - return; - } - VFO = my_atoi(argv[0]); - shell_printf("VFO %d\r\n", VFO); -} - -int xtoi(char *t) -{ - - int v=0; - while (*t) { - if ('0' <= *t && *t <= '9') - v = v*16 + *t - '0'; - else if ('a' <= *t && *t <= 'f') - v = v*16 + *t - 'a' + 10; - else if ('A' <= *t && *t <= 'F') - v = v*16 + *t - 'A' + 10; - else - return v; - t++; - } - return v; -} - -VNA_SHELL_FUNCTION(cmd_y) -{ - int rvalue; - int lvalue = 0; - if (argc != 1 && argc != 2) { - shell_printf("usage: x {addr(0-95)} [value(0-FF)]\r\n"); - return; - } - rvalue = xtoi(argv[0]); - SI4432_Sel = VFO; - if (argc == 2){ - lvalue = xtoi(argv[1]); - SI4432_Write_Byte(rvalue, lvalue); - } else { - lvalue = SI4432_Read_Byte(rvalue); - shell_printf("%x\r\n", lvalue); - } -} - -VNA_SHELL_FUNCTION(cmd_selftest) -{ - if (argc != 1) { - shell_printf("usage: selftest (1-3)\r\n"); - return; - } - setting.test = my_atoi(argv[0]); - sweep_mode = SWEEP_SELFTEST; -} - - -VNA_SHELL_FUNCTION(cmd_x) -{ - uint32_t reg; - - - if (argc != 1) { - shell_printf("usage: x value(0-FFFFFFFF)\r\n"); - return; - } - reg = xtoi(argv[0]); - - if ((reg & 7) == 5) { - if (reg & (1<<22)) - VFO = 1; - else - VFO = 0; - reg &= ~0xc00000; // Force led to show lock - reg |= 0x400000; - } -#ifdef __ULTRA_SA__ - ADF4351_WriteRegister32(VFO, reg); -#endif - shell_printf("x=%x\r\n", reg); -} - - -VNA_SHELL_FUNCTION(cmd_i) -{ - int rvalue; -return; // Don't use!!!! - SI4432_Init(); - shell_printf("SI4432 init done\r\n"); - if (argc == 1) { - rvalue = xtoi(argv[0]); - set_switches(rvalue); - set_mode(rvalue); - shell_printf("SI4432 mode %d set\r\n", rvalue); - } -} -VNA_SHELL_FUNCTION(cmd_o) -{ - (void) argc; - return; - uint32_t value = my_atoi(argv[0]); -// if (VFO == 0) -// setting.frequency_IF = value; - set_freq(VFO, value); -} - -VNA_SHELL_FUNCTION(cmd_d) -{ - (void) argc; - int32_t a = my_atoi(argv[0]); - setting.drive = a; -} - - -VNA_SHELL_FUNCTION(cmd_a) -{ - (void)argc; - int32_t value = my_atoi(argv[0]); - frequencyStart = value; -} - -VNA_SHELL_FUNCTION(cmd_b) -{ - (void)argc; - int32_t value = my_atoi(argv[0]); - frequencyStop = value; -} - -VNA_SHELL_FUNCTION(cmd_t) -{ - (void)argc; - (void)argv; -} - -VNA_SHELL_FUNCTION(cmd_e) -{ - (void)argc; - setting.tracking = my_atoi(argv[0]); - if (setting.tracking == -1) - setting.tracking = false; - else - setting.tracking = true; - - if (argc >1) - frequencyExtra = my_atoi(argv[1]); -} - -VNA_SHELL_FUNCTION(cmd_s) -{ - (void)argc; - points = my_atoi(argv[0]); -} - -VNA_SHELL_FUNCTION(cmd_m) -{ - (void)argc; - (void)argv; - - set_mode(0); - setting.tracking = false; //Default test setup - setting.step_atten = false; - set_attenuation(0); - set_reflevel(-10); - set_sweep_frequency(ST_START,frequencyStart - setting.frequency_IF ); - set_sweep_frequency(ST_STOP, frequencyStop - setting.frequency_IF); - draw_cal_status(); - - pause_sweep(); - int32_t f_step = (frequencyStop-frequencyStart)/ points; - palClearPad(GPIOB, GPIOB_LED); // disable led and wait for voltage stabilization - int old_step = setting.frequency_step; - setting.frequency_step = f_step; - update_rbw(); - chThdSleepMilliseconds(10); - streamPut(shell_stream, '{'); - dirty = true; - for (int i = 0; i>8) & 0xFF)); - // enable led - } - streamPut(shell_stream, '}'); - setting.frequency_step = old_step; - update_rbw(); - resume_sweep(); - palSetPad(GPIOB, GPIOB_LED); -} - -VNA_SHELL_FUNCTION(cmd_p) -{ - (void)argc; -return; - int p = my_atoi(argv[0]); - int a = my_atoi(argv[1]); - if (p==5) - set_attenuation(-a); - if (p==6) - set_mode(a); - if (p==1) - if (get_refer_output() != a) - set_refer_output(a); -} - -VNA_SHELL_FUNCTION(cmd_w) -{ - (void)argc; - int p = my_atoi(argv[0]); -return; - set_RBW(p); -} //============================================================================= VNA_SHELL_FUNCTION(cmd_help); @@ -2477,6 +2257,10 @@ static const VNAShellCommand commands[] = #ifdef ENABLE_COLOR_COMMAND {"color" , cmd_color , 0}, #endif + { "if", cmd_if, 0 }, + { "attenuate", cmd_attenuate, 0 }, + { "rbw", cmd_rbw, 0 }, + { "mode", cmd_mode, 0 }, { "selftest", cmd_selftest, 0 }, { "x", cmd_x, 0 }, { "i", cmd_i, 0 }, diff --git a/nanovna.h b/nanovna.h index 66ad520..da0c0e7 100644 --- a/nanovna.h +++ b/nanovna.h @@ -158,6 +158,63 @@ enum { extern int8_t sweep_mode; extern const char *info_about[]; +// ------------------------------- sa_core.c ---------------------------------- +void reset_settings(int); +//void ui_process_touch(void); +void SetPowerGrid(int); +void SetRefLevel(int); +void set_refer_output(int); +void toggle_below_IF(void); +int get_refer_output(void); +void set_attenuation(int); +int get_attenuation(void); +void set_harmonic(int); +//extern int setting.harmonic; +int search_is_greater(void); +void set_auto_attenuation(void); +void set_auto_reflevel(void); +int is_paused(void); +void set_power_level(int); +void SetGenerate(int); +void set_RBW(int); +void set_drive(int d); +void set_IF(int f); +void set_step_delay(int t); +void set_repeat(int); +//extern int setting.repeat; +//extern int setting.rbw; +#ifdef __SPUR__ +//extern int setting.spur; +void SetSpur(int v); +#endif +void set_average(int); +int GetAverage(void); +//extern int setting.average; +void set_storage(void); +void set_clear_storage(void); +void set_subtract_storage(void); +void toggle_waterfall(void); +void set_mode(int); +int GetMode(void); +void set_reflevel(int); +void set_scale(int); +void AllDirty(void); +void MenuDirty(void); +void toggle_LNA(void); +void toggle_AGC(void); +void redrawHisto(void); +void self_test(int); +void set_decay(int); +void set_noise(int); +void toggle_tracking_output(void); +extern int32_t frequencyExtra; +void set_10mhz(int); +void set_modulation(int); +//extern int setting.modulation; +void set_measurement(int); +// extern int settingSpeed; +//extern int setting.step_delay; + #ifdef __VNA__ /* * dsp.c diff --git a/sa_cmd.c b/sa_cmd.c new file mode 100644 index 0000000..3156a02 --- /dev/null +++ b/sa_cmd.c @@ -0,0 +1,299 @@ + +extern volatile int SI4432_Sel; // currently selected SI4432 +void SI4432_Write_Byte(byte ADR, byte DATA ); +byte SI4432_Read_Byte( byte ADR ); +int VFO = 0; +int points = 101; // For 's' and 'm' commands + + +VNA_SHELL_FUNCTION(cmd_mode) +{ + if (argc != 2) { + usage: + shell_printf("usage: mode low|high input|output\r\n"); + return; + } + if (strcmp(argv[0],"low") == 0) { + if (strcmp(argv[1],"input") == 0) + set_mode(M_LOW); + else if(strcmp(argv[1],"output") == 0) + set_mode(M_GENLOW); + else + goto usage; + } else if (strcmp(argv[0],"high") == 0) { + if (strcmp(argv[1],"input") == 0) + set_mode(M_HIGH); + else if(strcmp(argv[1],"output") == 0) + set_mode(M_GENHIGH); + else + goto usage; + } else + goto usage; +} + +VNA_SHELL_FUNCTION(cmd_attenuate) +{ + if (argc != 1) { + usage: + shell_printf("usage: attenuate 0..31|auto\r\n"); + return; + } + if (strcmp(argv[0],"auto") == 0) { + set_auto_attenuation(); + } else { + int a = my_atoi(argv[0]); + if (a < 0 || a>31) + goto usage; + set_attenuation(a); + } +} + +VNA_SHELL_FUNCTION(cmd_rbw) +{ + if (argc != 1) { + usage: + shell_printf("usage: rbw 2..600|auto\r\n"); + return; + } + if (strcmp(argv[0],"auto") == 0) { + set_RBW(0); + } else { + int a = my_atoi(argv[0]); + if (a < 2 || a>600) + goto usage; + set_RBW(a); + } +} + +VNA_SHELL_FUNCTION(cmd_if) +{ + if (argc != 1) { + usage: + shell_printf("usage: if {freq}\r\n"); + return; + } else { + int a = my_atoi(argv[0]); + if (a < 433000000 || a>435000000) + goto usage; + set_IF(a); + } +} + + +VNA_SHELL_FUNCTION(cmd_v) + + +{ + if (argc != 1) { + shell_printf("%d\r\n", SI4432_Sel); + return; + } + VFO = my_atoi(argv[0]); + shell_printf("VFO %d\r\n", VFO); +} + +int xtoi(char *t) +{ + + int v=0; + while (*t) { + if ('0' <= *t && *t <= '9') + v = v*16 + *t - '0'; + else if ('a' <= *t && *t <= 'f') + v = v*16 + *t - 'a' + 10; + else if ('A' <= *t && *t <= 'F') + v = v*16 + *t - 'A' + 10; + else + return v; + t++; + } + return v; +} + +VNA_SHELL_FUNCTION(cmd_y) +{ + int rvalue; + int lvalue = 0; + if (argc != 1 && argc != 2) { + shell_printf("usage: x {addr(0-95)} [value(0-FF)]\r\n"); + return; + } + rvalue = xtoi(argv[0]); + SI4432_Sel = VFO; + if (argc == 2){ + lvalue = xtoi(argv[1]); + SI4432_Write_Byte(rvalue, lvalue); + } else { + lvalue = SI4432_Read_Byte(rvalue); + shell_printf("%x\r\n", lvalue); + } +} + +VNA_SHELL_FUNCTION(cmd_selftest) +{ + if (argc != 1) { + shell_printf("usage: selftest (1-3)\r\n"); + return; + } + setting.test = my_atoi(argv[0]); + sweep_mode = SWEEP_SELFTEST; +} + + +VNA_SHELL_FUNCTION(cmd_x) +{ + uint32_t reg; + + + if (argc != 1) { + shell_printf("usage: x value(0-FFFFFFFF)\r\n"); + return; + } + reg = xtoi(argv[0]); + + if ((reg & 7) == 5) { + if (reg & (1<<22)) + VFO = 1; + else + VFO = 0; + reg &= ~0xc00000; // Force led to show lock + reg |= 0x400000; + } +#ifdef __ULTRA_SA__ + ADF4351_WriteRegister32(VFO, reg); +#endif + shell_printf("x=%x\r\n", reg); +} + + +VNA_SHELL_FUNCTION(cmd_i) +{ + int rvalue; +return; // Don't use!!!! + SI4432_Init(); + shell_printf("SI4432 init done\r\n"); + if (argc == 1) { + rvalue = xtoi(argv[0]); + set_switches(rvalue); + set_mode(rvalue); + shell_printf("SI4432 mode %d set\r\n", rvalue); + } +} + +VNA_SHELL_FUNCTION(cmd_o) +{ + (void) argc; + return; + uint32_t value = my_atoi(argv[0]); +// if (VFO == 0) +// setting.frequency_IF = value; + set_freq(VFO, value); +} + +VNA_SHELL_FUNCTION(cmd_d) +{ + (void) argc; + int32_t a = my_atoi(argv[0]); + setting.drive = a; +} + + +VNA_SHELL_FUNCTION(cmd_a) +{ + (void)argc; + int32_t value = my_atoi(argv[0]); + frequencyStart = value; +} + +VNA_SHELL_FUNCTION(cmd_b) +{ + (void)argc; + int32_t value = my_atoi(argv[0]); + frequencyStop = value; +} + +VNA_SHELL_FUNCTION(cmd_t) +{ + (void)argc; + (void)argv; +} + +VNA_SHELL_FUNCTION(cmd_e) +{ + (void)argc; + setting.tracking = my_atoi(argv[0]); + if (setting.tracking == -1) + setting.tracking = false; + else + setting.tracking = true; + + if (argc >1) + frequencyExtra = my_atoi(argv[1]); +} + +VNA_SHELL_FUNCTION(cmd_s) +{ + (void)argc; + points = my_atoi(argv[0]); +} + +VNA_SHELL_FUNCTION(cmd_m) +{ + (void)argc; + (void)argv; + + set_mode(0); + setting.tracking = false; //Default test setup + setting.step_atten = false; + set_attenuation(0); + set_reflevel(-10); + set_sweep_frequency(ST_START,frequencyStart - setting.frequency_IF ); + set_sweep_frequency(ST_STOP, frequencyStop - setting.frequency_IF); + draw_cal_status(); + + pause_sweep(); + int32_t f_step = (frequencyStop-frequencyStart)/ points; + palClearPad(GPIOB, GPIOB_LED); // disable led and wait for voltage stabilization + int old_step = setting.frequency_step; + setting.frequency_step = f_step; + update_rbw(); + chThdSleepMilliseconds(10); + streamPut(shell_stream, '{'); + dirty = true; + for (int i = 0; i>8) & 0xFF)); + // enable led + } + streamPut(shell_stream, '}'); + setting.frequency_step = old_step; + update_rbw(); + resume_sweep(); + palSetPad(GPIOB, GPIOB_LED); +} + +VNA_SHELL_FUNCTION(cmd_p) +{ + (void)argc; +return; + int p = my_atoi(argv[0]); + int a = my_atoi(argv[1]); + if (p==5) + set_attenuation(-a); + if (p==6) + set_mode(a); + if (p==1) + if (get_refer_output() != a) + set_refer_output(a); +} + +VNA_SHELL_FUNCTION(cmd_w) +{ + (void)argc; + int p = my_atoi(argv[0]); +return; + set_RBW(p); +} diff --git a/sa_core.c b/sa_core.c index 713f5b2..c729f78 100644 --- a/sa_core.c +++ b/sa_core.c @@ -489,7 +489,7 @@ void apply_settings(void) set_switches(setting.mode); SI4432_SetReference(setting.refer); update_rbw(); - if (setting.step_delay == 0){ + if (setting.step_delay < 2){ if (actual_rbw > 90.0) actualStepDelay = 400; else if (actual_rbw > 75.0) actualStepDelay = 550; else if (actual_rbw > 56.0) actualStepDelay = 650; @@ -498,6 +498,8 @@ void apply_settings(void) else if (actual_rbw > 9.0) actualStepDelay = 2000; else if (actual_rbw > 5.0) actualStepDelay = 3500; else actualStepDelay = 6000; + if (setting.step_delay == 1) + actualStepDelay *= 2; } else actualStepDelay = setting.step_delay; } @@ -689,8 +691,8 @@ search_maximum(int m, int center, int span) int max_index[4]; if (from<0) from = 0; - if (to > POINTS_COUNT-1) - to = POINTS_COUNT-1; + if (to > setting._sweep_points-1) + to = setting._sweep_points-1; temppeakIndex = 0; temppeakLevel = actual_t[from]; max_index[cur_max] = from; @@ -887,7 +889,7 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) } float RSSI = -150.0; int t = 0; - do { + do { // ------------- Acquisition loop ---------- int offs = (int)((t * 500 - vbwSteps * 250) * actual_rbw); // if (-offs > (uint32_t)f) // Ensure lf >0 0 // offs = -(uint32_t)(f + offs); @@ -904,7 +906,15 @@ again: local_IF = spur_alternate_IF; #ifdef __SPUR__ } else if (setting.mode== M_LOW && setting.spur){ - local_IF = setting.frequency_IF + (int)(actual_rbw < 350.0 ? setting.spur*300000 : 0 ); + if (lf > 150000000) // if above 150MHz use IF shift + local_IF = setting.frequency_IF + (int)(actual_rbw < 350.0 ? setting.spur*300000 : 0 ); + else { + local_IF = setting.frequency_IF; + if (setting.spur == 1) + setting.below_IF = true; + else + setting.below_IF = false; + } #endif } else { // local_IF = setting.frequency_IF ; @@ -1177,7 +1187,7 @@ static bool sweep(bool break_on_operation) markers[1].index = marker_search_left_min(markers[0].index); if (markers[1].index < 0) markers[1].index = 0; markers[2].index = marker_search_right_min(markers[0].index); - if (markers[2].index < 0) markers[1].index = POINTS_COUNT - 1; + if (markers[2].index < 0) markers[1].index = setting._sweep_points - 1; } else if (setting.measurement == M_PASS_BAND && markers[0].index > 10) { int t = markers[0].index; float v = actual_t[t]; @@ -1186,9 +1196,9 @@ static bool sweep(bool break_on_operation) if (t > 0) markers[1].index = t; t = markers[0].index; - while (t < POINTS_COUNT - 1 && actual_t[t] > v - 3.0) + while (t < setting._sweep_points - 1 && actual_t[t] > v - 3.0) t ++; - if (t < POINTS_COUNT - 1 ) + if (t < setting._sweep_points - 1 ) markers[2].index = t; } #endif @@ -1662,16 +1672,18 @@ int validate_below(int tc, int from, int to) { int validate_flatness(int i) { volatile int j; test_fail_cause[i] = "Passband "; - for (j = peakIndex; j < POINTS_COUNT; j++) { - if (actual_t[j] < peakLevel - 3) // Search right -3dB + for (j = peakIndex; j < setting._sweep_points; j++) { + if (actual_t[j] < peakLevel - 6) // Search right -3dB break; } + shell_printf("\n\rRight width %d\n\r", j - peakIndex ); if (j - peakIndex < test_case[i].width) return(TS_FAIL); for (j = peakIndex; j > 0; j--) { - if (actual_t[j] < peakLevel - 3) // Search left -3dB + if (actual_t[j] < peakLevel - 6) // Search left -3dB break; } + shell_printf("Left width %d\n\r", j - peakIndex ); if (peakIndex - j < test_case[i].width) return(TS_FAIL); test_fail_cause[i] = ""; @@ -1680,7 +1692,7 @@ int validate_flatness(int i) { int validate_above(int tc) { int status = TS_PASS; - for (int j = 0; j < POINTS_COUNT; j++) { + for (int j = 0; j < setting._sweep_points; j++) { if (actual_t[j] < stored_t[j] + 5) status = TS_CRITICAL; else if (actual_t[j] < stored_t[j]) { @@ -1710,9 +1722,9 @@ int test_validate(int i) case TC_SIGNAL: // Validate signal common: current_test_status = validate_signal_within(i, 5.0); if (current_test_status == TS_PASS) { // Validate noise floor - current_test_status = validate_below(i, 0, POINTS_COUNT/2 - test_case[i].width); + current_test_status = validate_below(i, 0, setting._sweep_points/2 - test_case[i].width); if (current_test_status == TS_PASS) { - current_test_status = validate_below(i, POINTS_COUNT/2 + test_case[i].width, POINTS_COUNT); + current_test_status = validate_below(i, setting._sweep_points/2 + test_case[i].width, setting._sweep_points); } if (current_test_status != TS_PASS) test_fail_cause[i] = "Stopband "; @@ -1726,7 +1738,7 @@ int test_validate(int i) current_test_status = validate_above(i); break; case TC_BELOW: // Validate signal below curve - current_test_status = validate_below(i, 0, POINTS_COUNT); + current_test_status = validate_below(i, 0, setting._sweep_points); break; case TC_FLAT: // Validate passband flatness current_test_status = validate_flatness(i); @@ -1759,7 +1771,7 @@ void test_prepare(int i) set_mode(M_LOW); common_silent: set_refer_output(-1); - for (int j = 0; j < POINTS_COUNT; j++) + for (int j = 0; j < setting._sweep_points; j++) stored_t[j] = test_case[i].pass; break; case TP_10MHZ_SWITCH: @@ -1778,11 +1790,11 @@ common_silent: set_refer_output(2); common: - for (int j = 0; j < POINTS_COUNT/2 - test_case[i].width; j++) + for (int j = 0; j < setting._sweep_points/2 - test_case[i].width; j++) stored_t[j] = test_case[i].stop; - for (int j = POINTS_COUNT/2 + test_case[i].width; j < POINTS_COUNT; j++) + for (int j = setting._sweep_points/2 + test_case[i].width; j < setting._sweep_points; j++) stored_t[j] = test_case[i].stop; - for (int j = POINTS_COUNT/2 - test_case[i].width; j < POINTS_COUNT/2 + test_case[i].width; j++) + for (int j = setting._sweep_points/2 - test_case[i].width; j < setting._sweep_points/2 + test_case[i].width; j++) stored_t[j] = test_case[i].pass; break; case TP_30MHZ: diff --git a/ui_sa.c b/ui_sa.c index d0d57a4..bc964ae 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -4,75 +4,6 @@ extern const menuitem_t menu_marker_modify[]; void set_sweep_frequency(int type, uint32_t frequency); uint32_t get_sweep_frequency(int type); void clearDisplay(void); -void reset_settings(int); -//void ui_process_touch(void); -void SetPowerGrid(int); -void SetRefLevel(int); -void set_refer_output(int); -void toggle_below_IF(void); -int get_refer_output(void); -void set_attenuation(int); -int get_attenuation(void); -void set_harmonic(int); -//extern int setting.harmonic; -int search_is_greater(void); -void set_auto_attenuation(void); -void set_auto_reflevel(void); -int is_paused(void); -void set_power_level(int); -void SetGenerate(int); -void set_RBW(int); -void set_drive(int d); -void set_IF(int f); -void set_step_delay(int t); -void set_repeat(int); -//extern int setting.repeat; -//extern int setting.rbw; -#ifdef __SPUR__ -//extern int setting.spur; -void SetSpur(int v); -#endif -void set_average(int); -int GetAverage(void); -//extern int setting.average; -void set_storage(void); -void set_clear_storage(void); -void set_subtract_storage(void); -void toggle_waterfall(void); -void set_mode(int); -int GetMode(void); -void set_reflevel(int); -void set_scale(int); -void AllDirty(void); -void MenuDirty(void); -void toggle_LNA(void); -void toggle_AGC(void); -void redrawHisto(void); -void self_test(int); -void set_decay(int); -void set_noise(int); -void toggle_tracking_output(void); -extern int32_t frequencyExtra; -#if 0 -extern int setting.tracking; -extern int setting.tracking_output; -extern int setting.drive; -extern int setting.lna; -extern int setting.agc; -extern int setting.decay; -extern int setting.noise; -extern int setting.auto_reflevel; -extern int setting.auto_attenuation; -extern int setting.reflevel; -extern int setting.scale; -extern int setting.10mhz; -#endif -void set_10mhz(int); -void set_modulation(int); -//extern int setting.modulation; -void set_measurement(int); -// extern int settingSpeed; -//extern int setting.step_delay; void blit16BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t *bitmap); @@ -580,6 +511,14 @@ static void menu_calibrate_cb(int item, uint8_t data) } } +static void menu_scanning_speed_cb(int item, uint8_t data) +{ + (void)item; + set_step_delay(data); +// menu_move_back(); + ui_mode_normal(); +} + static void menu_config_cb(int item, uint8_t data) { (void)data; @@ -1279,12 +1218,22 @@ static const menuitem_t menu_settings2[] = { MT_NONE, 0, NULL, NULL } // sentinel }; +static const menuitem_t menu_scanning_speed[] = +{ + { MT_CALLBACK, 0, "FAST", menu_scanning_speed_cb}, + { MT_CALLBACK, 1, "PRECISE", menu_scanning_speed_cb}, + { MT_KEYPAD, KM_SAMPLETIME, "\2POINT\0TIME", NULL}, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel +}; + + static const menuitem_t menu_settings[] = { { MT_CALLBACK, 3, "\2TRACKING\0OUTPUT",menu_settings2_cb}, { MT_KEYPAD, KM_ACTUALPOWER, "\2ACTUAL\0POWER", NULL}, { MT_KEYPAD, KM_IF, "\2IF\0FREQ", NULL}, - { MT_KEYPAD, KM_SAMPLETIME, "\2SAMPLE\0TIME", NULL}, + { MT_SUBMENU,0, "\2SCAN\0SPEED", menu_scanning_speed}, { MT_KEYPAD, KM_REPEAT, "REPEATS", NULL}, { MT_SUBMENU,0, "\2LO\0DRIVE", menu_drive}, #ifdef __ULTRA__ @@ -1416,6 +1365,9 @@ static const menuitem_t menu_stimulus[] = { { MT_KEYPAD, KM_SPAN, "SPAN", NULL}, { MT_KEYPAD, KM_CW, "\2ZERO\0SPAN", NULL}, { MT_SUBMENU,0, "RBW", menu_rbw}, +#ifdef __SPUR__ + { MT_CALLBACK,0, "\2SPUR\0REMOVAL", menu_spur_cb}, +#endif { MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel }; @@ -1423,7 +1375,7 @@ static const menuitem_t menu_stimulus[] = { static const menuitem_t menu_mode[] = { - { MT_FORM | MT_TITLE, 0, "MODE", NULL}, + { MT_FORM | MT_TITLE, 0, "tinySA MODE", NULL}, { MT_FORM | MT_CALLBACK | MT_ICON, I_LOW_INPUT+I_SA, "LOW INPUT", menu_mode_cb}, { MT_FORM | MT_CALLBACK | MT_ICON, I_HIGH_INPUT+I_SA, "HIGH INPUT", menu_mode_cb}, { MT_FORM | MT_CALLBACK | MT_ICON, I_LOW_OUTPUT+I_SINUS, "LOW OUTPUT", menu_mode_cb}, @@ -1599,6 +1551,10 @@ static void menu_item_modify_attribute( if (item ==0 && setting.tracking_output){ mark = true; } + } else if (menu == menu_scanning_speed) { + if (item == setting.step_delay){ + mark = true; + } #ifdef __ULTRA__ } else if (MT_MASK(menu[item].type) == MT_CALLBACK && menu == menu_harmonic) { if (data == setting.harmonic) @@ -1614,6 +1570,9 @@ static void menu_item_modify_attribute( if (item == 2 && setting.tracking){ // should not happen in high mode mark = true; } + if (item == 3 && setting.below_IF){ // should not happen in high mode + mark = true; + } } else if (menu == menu_marker_modify && active_marker >= 0 && markers[active_marker].enabled == M_ENABLED) { if (data & markers[active_marker].mtype) mark = true;