diff --git a/ili9341.c b/ili9341.c index a22bee6..d2c1a95 100644 --- a/ili9341.c +++ b/ili9341.c @@ -23,6 +23,8 @@ #include "spi.h" + + // Allow enable DMA for read display data //#define __USE_DISPLAY_DMA_RX__ diff --git a/main.c b/main.c index b0903f0..e1eeaac 100644 --- a/main.c +++ b/main.c @@ -146,9 +146,11 @@ static THD_FUNCTION(Thread1, arg) // call from lowest level to save stack space self_test(setting.test); // sweep_mode = SWEEP_ENABLE; - } else if (sweep_mode & SWEEP_REMOTE) { +#ifdef __SINGLE_LETTER__ + } else if (sweep_mode & SWEEP_REMOTE) { sweep_remote(); - } else if (sweep_mode & SWEEP_CALIBRATE) { +#endif + } else if (sweep_mode & SWEEP_CALIBRATE) { // call from lowest level to save stack space calibrate(); sweep_mode = SWEEP_ENABLE; @@ -3021,7 +3023,7 @@ void HardFault_Handler(void) void hard_fault_handler_c(uint32_t *sp) { -#if 1 +#if 0 uint32_t r0 = sp[0]; uint32_t r1 = sp[1]; uint32_t r2 = sp[2]; diff --git a/nanovna.h b/nanovna.h index 63a6118..31dca08 100644 --- a/nanovna.h +++ b/nanovna.h @@ -51,9 +51,9 @@ #define __SPUR__ // Does spur reduction by shifting IF //#define __USE_SERIAL_CONSOLE__ // Enable serial I/O connection (need enable HAL_USE_SERIAL as TRUE in halconf.h) #define __SINGLE_LETTER__ -//#define __NICE_BIG_FONT__ +#define __NICE_BIG_FONT__ #define __QUASI_PEAK__ -#define __REMOTE_DESKTOP__ +//#define __REMOTE_DESKTOP__ #ifdef TINYSA3 #define DEFAULT_IF 433800000 diff --git a/sa_cmd.c b/sa_cmd.c index f2dc797..e17e06b 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -556,6 +556,8 @@ VNA_SHELL_FUNCTION(cmd_z) #endif +#ifdef __SINGLE_LETTER__ + void sweep_remote(void) { uint32_t i; @@ -582,7 +584,6 @@ void sweep_remote(void) sweep_mode = 0; } -#ifdef __SINGLE_LETTER__ VNA_SHELL_FUNCTION(cmd_m) { (void)argc; diff --git a/sa_core.c b/sa_core.c index 165912b..674a40f 100644 --- a/sa_core.c +++ b/sa_core.c @@ -2240,7 +2240,7 @@ sweep_again: // stay in sweep loop when output mo #endif if (check_for_AM) { - int AGC_value = (SI4432_Read_Byte(0x69) & 0x01f) * 3.0 - 90.0; + int AGC_value = (SI4432_Read_Byte(0x69) & 0x01f) * 3 - 90; if (AGC_value < last_AGC_value && last_AGC_direction_up ) { AGC_flip_count++; } else if (AGC_value > last_AGC_value && !last_AGC_direction_up ) { @@ -2496,7 +2496,7 @@ sweep_again: // stay in sweep loop when output mo if (!in_selftest && MODE_INPUT(setting.mode)) { #ifdef __SI4432__ if (S_IS_AUTO(setting.agc)) { - float actual_max_level = actual_t[max_index[0]] - get_attenuation(); + int actual_max_level = actual_t[max_index[0]] - get_attenuation(); // No need to use float if (UNIT_IS_LINEAR(setting.unit)) { // Auto AGC in linear mode if (actual_max_level > - 45) auto_set_AGC_LNA(false, 0); // Strong signal, no AGC and no LNA @@ -2674,10 +2674,11 @@ sweep_again: // stay in sweep loop when output mo } } else if (setting.measurement == M_AM) { // ----------------AM measurement if (S_IS_AUTO(setting.agc )) { - if (actual_t[max_index[0]] - get_attenuation() > -20 ) { + int actual_level = actual_t[max_index[0]] - get_attenuation(); // no need for float + if (actual_level > -20 ) { setting.agc = S_AUTO_OFF; setting.lna = S_AUTO_OFF; - } else if (actual_t[max_index[0]] - get_attenuation() < -45 ) { + } else if (actual_level < -45 ) { setting.agc = S_AUTO_ON; setting.lna = S_AUTO_ON; } else { @@ -2832,7 +2833,7 @@ int marker_search_max(void) return found; } -#define MINMAX_DELTA 10 +#define MINMAX_DELTA_X10 100 int @@ -2843,22 +2844,22 @@ marker_search_left_min(int from) if (uistat.current_trace == -1) return -1; - float value = actual_t[from]; + int value_x10 = actual_t[from]*10; for (i = from - 1; i >= 0; i--) { - float new_value = actual_t[i]; - if (new_value > value) { - value = new_value; // follow up + int new_value_x10 = actual_t[i]*10; + if (new_value_x10 > value_x10) { + value_x10 = new_value_x10; // follow up // found = i; - } else if (new_value < value - MINMAX_DELTA ) + } else if (new_value_x10 < value_x10 - MINMAX_DELTA_X10 ) break; // past the maximum } for (; i >= 0; i--) { - float new_value = actual_t[i]; - if (new_value < value) { - value = new_value; // follow down + int new_value_x10 = actual_t[i]*10; + if (new_value_x10 < value_x10) { + value_x10 = new_value_x10; // follow down found = i; - } else if (new_value > value + MINMAX_DELTA ) + } else if (new_value_x10 > value_x10 + MINMAX_DELTA_X10 ) break; } return found; @@ -2872,21 +2873,21 @@ marker_search_right_min(int from) if (uistat.current_trace == -1) return -1; - float value = actual_t[from]; + int value_x10 = actual_t[from]*10; for (i = from + 1; i < sweep_points; i++) { - float new_value = actual_t[i]; - if (new_value > value) { // follow up - value = new_value; + int new_value_x10 = actual_t[i]*10; + if (new_value_x10 > value_x10) { // follow up + value_x10 = new_value_x10; // found = i; - } else if (new_value < value - MINMAX_DELTA) // less then largest value - noise + } else if (new_value_x10 < value_x10 - MINMAX_DELTA_X10) // less then largest value_x10 - noise break; // past the maximum } for (; i < sweep_points; i++) { - float new_value = actual_t[i]; - if (new_value < value) { // follow down - value = new_value; + int new_value_x10 = actual_t[i]*10; + if (new_value_x10 < value_x10) { // follow down + value_x10 = new_value_x10; found = i; - } else if (new_value > value + MINMAX_DELTA) // larger then smallest value + noise + } else if (new_value_x10 > value_x10 + MINMAX_DELTA_X10) // larger then smallest value_x10 + noise break; } return found; @@ -3112,8 +3113,7 @@ int validate_atten(int i) { if (j == 0) reference_peak_level = summed_peak_level; else { -// shell_printf("Attenuation %.2fdB, measured level %.2fdBm, delta %.2fdB\n\r",((float)j)/2.0, summed_peak_level, summed_peak_level - reference_peak_level); - if (SDU1.config->usbp->state == USB_ACTIVE) shell_printf("Attenuation %.2fdB, measured level %.2fdBm, delta %.2fdB\n\r",a, summed_peak_level, summed_peak_level - reference_peak_level); +// if (SDU1.config->usbp->state == USB_ACTIVE) shell_printf("Attenuation %.2fdB, measured level %.2fdBm, delta %.2fdB\n\r",a, summed_peak_level, summed_peak_level - reference_peak_level); #define ATTEN_TEST_CRITERIA 1 if (summed_peak_level - reference_peak_level <= -ATTEN_TEST_CRITERIA || summed_peak_level - reference_peak_level >= ATTEN_TEST_CRITERIA) { status = TS_FAIL; @@ -3582,8 +3582,6 @@ void self_test(int test) set_sweep_frequency(ST_SPAN, 0); break; } - } -#endif } else if (test == 6) { in_selftest = true; // Spur search reset_settings(M_LOW); @@ -3598,9 +3596,8 @@ void self_test(int test) test_acquire(TEST_SPUR); // Acquire test shell_printf("%d: %9.3q\n\r",i, peakFreq); test_validate(TEST_SPUR); // Validate test - } - +#endif } show_test_info = FALSE;