diff --git a/main.c b/main.c index b9307c5..a274035 100644 --- a/main.c +++ b/main.c @@ -1472,7 +1472,7 @@ VNA_SHELL_FUNCTION(cmd_marker) if (argc == 0) { for (t = 0; t < MARKERS_MAX; t++) { if (markers[t].enabled) { - shell_printf("%d %d %D %f\r\n", t+1, markers[t].index, markers[t].frequency, marker_to_value(t)); + shell_printf("%d %d %D %.2f\r\n", t+1, markers[t].index, markers[t].frequency, marker_to_value(t)); } } return; @@ -1495,7 +1495,13 @@ VNA_SHELL_FUNCTION(cmd_marker) markers[t].enabled = TRUE; return; } +#ifdef TINYSA4 + static const char cmd_marker_list[] = "on|off|peak|delta|noise|tracking|stored|trace_aver"; +#else static const char cmd_marker_list[] = "on|off|peak"; +#endif + static const char cmd_marker_on_off[] = "off|on"; + int marker_mask = 0; switch (get_str_index(argv[1], cmd_marker_list)) { case 0: markers[t].enabled = TRUE; active_marker = t; return; case 1: markers[t].enabled =FALSE; if (active_marker == t) active_marker = MARKER_INVALID; return; @@ -1515,9 +1521,35 @@ VNA_SHELL_FUNCTION(cmd_marker) else set_marker_index(t, value); return; +#ifdef TINYSA4 + // M_NORMAL=0,M_REFERENCE=1, M_DELTA=2, M_NOISE=4, M_STORED=8, M_AVER=16, M_TRACKING=32, M_DELETE=64 // Tracking must be last. + case 3: + marker_mask = M_DELTA; + goto set_mask; + case 4: + marker_mask = M_NOISE; + goto set_mask; + case 5: + marker_mask = M_STORED; + goto set_mask; + case 6: + marker_mask = M_AVER; + set_mask: + if (argc == 3) { + switch (get_str_index(argv[2],cmd_marker_on_off)) { + default: goto usage; + case 0: markers[t].mtype &= ~marker_mask; return; + case 1: markers[t].mtype |= marker_mask; return; + } + } +#endif } - usage: +usage: +#ifdef TINYSA4 + shell_printf("marker [n] [%s|{freq}|{index}] [on|off]\r\n", cmd_marker_list); +#else shell_printf("marker [n] [%s|{freq}|{index}]\r\n", cmd_marker_list); +#endif } VNA_SHELL_FUNCTION(cmd_touchcal) @@ -1797,7 +1829,7 @@ static const VNAShellCommand commands[] = {"recall" , cmd_recall , CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD}, {"trace" , cmd_trace , CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD}, {"trigger" , cmd_trigger , CMD_RUN_IN_LOAD}, - {"marker" , cmd_marker , CMD_RUN_IN_LOAD}, + {"marker" , cmd_marker , CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD}, #ifdef ENABLE_USART_COMMAND {"usart" , cmd_usart , CMD_WAIT_MUTEX}, {"usart_cfg" , cmd_usart_cfg , CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD}, @@ -1819,27 +1851,27 @@ static const VNAShellCommand commands[] = #ifdef ENABLE_COLOR_COMMAND {"color" , cmd_color , CMD_RUN_IN_LOAD}, #endif - { "if", cmd_if, CMD_RUN_IN_LOAD }, + { "if", cmd_if, CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD }, #ifdef TINYSA4 { "if1", cmd_if1, CMD_RUN_IN_LOAD }, { "lna2", cmd_lna2, CMD_RUN_IN_LOAD }, { "agc", cmd_agc, CMD_RUN_IN_LOAD }, #endif { "actual_freq", cmd_actual_freq, CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD }, - { "attenuate", cmd_attenuate, CMD_RUN_IN_LOAD }, - { "level", cmd_level, CMD_RUN_IN_LOAD }, - { "sweeptime", cmd_sweeptime, CMD_RUN_IN_LOAD }, + { "attenuate", cmd_attenuate, CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD }, + { "level", cmd_level, CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD }, + { "sweeptime", cmd_sweeptime, CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD }, { "leveloffset", cmd_leveloffset, CMD_RUN_IN_LOAD }, { "levelchange", cmd_levelchange, CMD_RUN_IN_LOAD }, { "modulation", cmd_modulation, CMD_RUN_IN_LOAD }, - { "rbw", cmd_rbw, CMD_RUN_IN_LOAD }, + { "rbw", cmd_rbw, CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD }, { "mode", cmd_mode, CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD}, #ifdef __SPUR__ - { "spur", cmd_spur, CMD_RUN_IN_LOAD }, + { "spur", cmd_spur, CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD }, #endif #ifdef TINYSA4 - { "lna", cmd_lna, CMD_RUN_IN_LOAD }, - { "ultra", cmd_ultra, CMD_RUN_IN_LOAD }, + { "lna", cmd_lna, CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD }, + { "ultra", cmd_ultra, CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD }, { "ultra_start", cmd_ultra_start, CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD }, #endif { "load", cmd_load, CMD_RUN_IN_LOAD }, @@ -1848,7 +1880,7 @@ static const VNAShellCommand commands[] = { "deviceid", cmd_deviceid, CMD_RUN_IN_LOAD }, { "selftest", cmd_selftest, 0 }, { "correction", cmd_correction, CMD_RUN_IN_LOAD }, - { "calc", cmd_calc, CMD_RUN_IN_LOAD}, + { "calc", cmd_calc, CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD}, #ifdef ENABLE_SD_CARD_CMD { "sd_list", cmd_sd_list, CMD_WAIT_MUTEX }, { "sd_read", cmd_sd_read, CMD_WAIT_MUTEX }, diff --git a/sa_cmd.c b/sa_cmd.c index 59b9836..cba9359 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -397,7 +397,7 @@ VNA_SHELL_FUNCTION(cmd_rbw) if (argc != 1) { usage: #ifdef TINYSA4 - shell_printf("usage: rbw 0.3..600|auto\r\n"); + shell_printf("usage: rbw 0.3..850|auto\r\n"); #else shell_printf("usage: rbw 2..600|auto\r\n"); #endif @@ -408,7 +408,13 @@ VNA_SHELL_FUNCTION(cmd_rbw) set_RBW(0); } else { float a = my_atof(argv[0]); - if (a < 0.2 || a>600) + if (a < 0.2 || +#ifdef TINYSA4 + a>850 +#else + a>600 +#endif + ) goto usage; if (setting.rbw_x10 != a*10) set_RBW((int) ( a*10)); diff --git a/sa_core.c b/sa_core.c index 70a6eaa..187f977 100644 --- a/sa_core.c +++ b/sa_core.c @@ -72,7 +72,7 @@ uint32_t old_CFGR; uint32_t orig_CFGR; int debug_frequencies = false; -int linear_averaging = false; +int linear_averaging = true; static freq_t old_freq[5] = { 0, 0, 0, 0,0}; static freq_t real_old_freq[5] = { 0, 0, 0, 0,0}; @@ -5823,7 +5823,7 @@ abort: setting.R = 0; switch_SI4463_RSSI_correction(true); reset_settings(M_LOW); - } if (test == 8) { // RBW level test + } else if (test == 8) { // RBW level test in_selftest = true; ui_mode_normal(); // set_scale(2); @@ -5841,19 +5841,17 @@ abort: setting.extra_lna = true; osalThreadSleepMilliseconds(200); set_average(AV_100); - test_acquire(TC_LEVEL); // Acquire test - test_acquire(TC_LEVEL); // Acquire test - test_acquire(TC_LEVEL); // Acquire test - test_acquire(TC_LEVEL); // Acquire test - test_acquire(TC_LEVEL); // Acquire test + for (int w=0; w<50; w++) { + test_acquire(TC_LEVEL); // Acquire test + } test_validate(TEST_NOISE); // Validate test peakLevel += - logf(actual_rbw_x10*100.0) * (10.0/logf(10.0)) #ifdef TINYSA4 + SI4463_noise_correction_x10/10.0 #endif ; - // if (j == SI4432_RBW_count-1) - // first_level = peakLevel; + if (j == SI4432_RBW_count-1) + first_level = peakLevel; shell_printf("RBW = %7.1fk, level = %6.2f, corr = %6.2f\n\r",actual_rbw_x10/10.0 , peakLevel, (first_level - peakLevel)*10.0 ); if (setting.test_argument != 0) break; @@ -5893,6 +5891,7 @@ abort: break; if (operation_requested) goto abort; } + if (operation_requested) break; } #endif shell_printf("\n\r"); @@ -5911,8 +5910,9 @@ abort: test_acquire(TEST_LEVEL); // Acquire test test_validate(TEST_LEVEL); // Validate test shell_printf("Temp = %4.1f, level = %6.2f, delta = %6.2f\n\r",Si446x_get_temp() , peakLevel, (first_level - peakLevel)*10.0 ); + if (operation_requested) break; } - } else if (test == 10) { + } else if (test == 10) { // Test 30MHz spurs // reset_settings(M_LOW); set_refer_output(-1); if (setting.test_argument > 0) @@ -5929,6 +5929,7 @@ abort: test_acquire(test_case); // Acquire test test_validate(test_case); shell_printf("Freq = %8.3fMHz, level = %6.2f\n\r", ((float)peakFreq) / 1000000.0, peakLevel); + if (operation_requested) break; } set_sweep_points(450); reset_settings(M_LOW);