From 31eb02efbbe39d35d60a19cc10ce7c592dd9da9f Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Mon, 21 Mar 2022 14:55:53 +0100 Subject: [PATCH] repair my_atoi --- main.c | 4 ++++ nanovna.h | 4 ++-- python/nanovna.py | 2 ++ sa_core.c | 33 +++++++++++++++++++++++++-------- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/main.c b/main.c index 099110d..3574b87 100644 --- a/main.c +++ b/main.c @@ -443,6 +443,10 @@ calculate: case 'M': d += 6; break; case 'G': d += 9; break; } + while (d < 0) { + value /= radix; + d++; + } while (d-->0) value *= radix; return value; diff --git a/nanovna.h b/nanovna.h index 54614c3..5fb9917 100644 --- a/nanovna.h +++ b/nanovna.h @@ -18,7 +18,7 @@ */ #include "ch.h" -#ifdef TINYSA_F303 +//#ifdef TINYSA_F303 #ifdef TINYSA_F072 #error "Remove comment for #ifdef TINYSA_F303" #endif @@ -26,7 +26,7 @@ #define TINYSA4 #endif #define TINYSA4_PROTO -#endif +//#endif #ifdef TINYSA_F072 #ifdef TINYSA_F303 diff --git a/python/nanovna.py b/python/nanovna.py index a2d010d..a47bee0 100755 --- a/python/nanovna.py +++ b/python/nanovna.py @@ -378,6 +378,8 @@ if __name__ == '__main__': if opt.command: for c in opt.command: nv.send_command(c + "\r") + data = nv.fetch_data() + print(data); if opt.capture: print("capturing...") diff --git a/sa_core.c b/sa_core.c index 9444c14..19cf2ae 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1884,6 +1884,9 @@ void setup_sa(void) #ifdef TINYSA4 static int fast_counter = 0; #endif +#ifdef __ULTRA__ +int old_drive = -1; +#endif void set_freq(int V, freq_t freq) // translate the requested frequency into a setting of the SI4432 { @@ -1968,6 +1971,23 @@ void set_freq(int V, freq_t freq) // translate the requested frequency into a } #endif if (freq) { + // ----------------------------- set mixer drive -------------------------------------------- + int target_drive = setting.lo_drive; + if (target_drive & 0x04){ // Automatic mixer drive + if (freq < 100000000ULL) // below 100MHz + target_drive = 0; + else if (freq < 1200000000ULL) // below 1.2GHz + target_drive = 1; + else if (freq < 2000000000ULL) // below 3GHz + target_drive = 2; + else + target_drive = 3; + } + if (old_drive != target_drive) { + ADF4351_drive(target_drive); // Max drive + old_drive = target_drive; + } + real_old_freq[V] = ADF4351_set_frequency(V-ADF4351_LO,freq); } } else if (V==ADF4351_LO2) { @@ -2055,7 +2075,6 @@ case M_LOW: // Mixed into 0 set_AGC_LNA(); #ifdef TINYSA4 ADF4351_enable(true); -// ADF4351_drive(setting.lo_drive); ADF4351_enable_aux_out(setting.tracking_output); ADF4351_enable_out(true); #endif @@ -2143,7 +2162,6 @@ case M_GENLOW: // Mixed output from 0 #endif #ifdef TINYSA4 ADF4351_enable_out(true); -// ADF4351_drive(setting.lo_drive); ADF4351_enable(true); ADF4351_enable_aux_out(setting.tracking_output); @@ -2795,9 +2813,6 @@ void clock_at_48MHz(void) } } -#ifdef __ULTRA__ -int old_drive = -1; -#endif #ifdef TINYSA4 int test_output = false; int test_output_switch = false; @@ -2915,14 +2930,15 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / } } #ifdef TINYSA4 +#if 0 // moved to set_freq // ----------------------------- set mixer drive -------------------------------------------- int target_drive = setting.lo_drive; if (target_drive & 0x04){ // Automatic mixer drive - if (f < 100000000ULL) + if (f < 100000000ULL) // below 100MHz target_drive = 0; - else if (f < 2400000000ULL) + else if (f < 2400000000ULL) // below 2.4GHz target_drive = 1; - else if (f < 3000000000ULL) + else if (f < 3000000000ULL) // below 3GHz target_drive = 2; else target_drive = 3; @@ -2932,6 +2948,7 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / old_drive = target_drive; } #endif +#endif #ifdef TINYSA3 #ifdef __ULTRA__ int target_drive = setting.lo_drive;