Skip to content

Commit

Permalink
Removed some floats
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkaashoek committed Feb 26, 2021
1 parent a95ec1d commit 232494b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 35 deletions.
2 changes: 2 additions & 0 deletions ili9341.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include "spi.h"



// Allow enable DMA for read display data
//#define __USE_DISPLAY_DMA_RX__

Expand Down
8 changes: 5 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions nanovna.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion sa_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,8 @@ VNA_SHELL_FUNCTION(cmd_z)

#endif

#ifdef __SINGLE_LETTER__

void sweep_remote(void)
{
uint32_t i;
Expand All @@ -582,7 +584,6 @@ void sweep_remote(void)
sweep_mode = 0;
}

#ifdef __SINGLE_LETTER__
VNA_SHELL_FUNCTION(cmd_m)
{
(void)argc;
Expand Down
55 changes: 26 additions & 29 deletions sa_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2240,7 +2240,7 @@ static bool sweep(bool break_on_operation)
#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 ) {
Expand Down Expand Up @@ -2496,7 +2496,7 @@ static bool sweep(bool break_on_operation)
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
Expand Down Expand Up @@ -2674,10 +2674,11 @@ static bool sweep(bool break_on_operation)
}
} 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 {
Expand Down Expand Up @@ -2832,7 +2833,7 @@ int marker_search_max(void)
return found;
}

#define MINMAX_DELTA 10
#define MINMAX_DELTA_X10 100


int
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 232494b

Please sign in to comment.