diff --git a/nanovna.h b/nanovna.h index e20b8bd..f77140e 100644 --- a/nanovna.h +++ b/nanovna.h @@ -679,6 +679,7 @@ typedef struct setting int step_delay_mode; int offset_delay; int fast_speedup; + float normalize_level; // Level to set normalize to, zero if not doing anything uint32_t checksum; }setting_t; diff --git a/sa_core.c b/sa_core.c index 16121bc..7d12181 100644 --- a/sa_core.c +++ b/sa_core.c @@ -79,6 +79,7 @@ void reset_settings(int m) setting.show_stored = 0; setting.auto_attenuation = false; setting.subtract_stored = 0; + setting.normalize_level = 0.0; setting.drive=13; setting.atten_step = 0; // Only used in low output mode setting.agc = S_AUTO_ON; @@ -455,6 +456,7 @@ void set_subtract_storage(void) if (!setting.show_stored) set_storage(); setting.subtract_stored = true; + setting.normalize_level = 0.0; // setting.auto_attenuation = false; } else { setting.subtract_stored = false; @@ -470,6 +472,7 @@ void toggle_normalize(void) stored_t[i] = actual_t[i]; setting.subtract_stored = true; setting.auto_attenuation = false; // Otherwise noise level may move leading to strange measurements + setting.normalize_level = 0.0; } else { setting.subtract_stored = false; } @@ -1630,7 +1633,7 @@ pureRSSI_t perform(bool break_on_operation, int i, uint32_t f, int tracking) local_IF = spur_alternate_IF; #ifdef __SPUR__ } else if (setting.mode== M_LOW && setting.spur){ // If in low input mode and spur reduction is on - if (S_IS_AUTO(setting.below_IF) /* && lf < 150000000 */ ) // if below 150MHz and auto_below_IF <-------------------TODO --------------------- + if (S_IS_AUTO(setting.below_IF) && (lf < local_IF / 2 || lf > local_IF) ) // if below 150MHz and auto_below_IF <-------------------TODO --------------------- { // else low/above IF if (setting.spur == 1) setting.below_IF = S_AUTO_ON; // use below IF in first pass @@ -1928,7 +1931,7 @@ sweep_again: // stay in sweep loop when output mo if (setting.average != AV_OFF) temp_t[i] = RSSI; if (setting.subtract_stored) { - RSSI = RSSI - stored_t[i] ; + RSSI = RSSI - stored_t[i] + setting.normalize_level; } #ifdef __DEBUG_AGC__ // For debugging the AGC control stored_t[i] = (SI4432_Read_Byte(0x69) & 0x0f) * 3.0 - 90.0; // Display the AGC value in the stored trace diff --git a/si4432.c b/si4432.c index 0669f58..05180de 100644 --- a/si4432.c +++ b/si4432.c @@ -984,10 +984,12 @@ void ADF4351_enable_output(void) ADF4351_Set(0); } -void ADF4351_set_frequency(int channel, unsigned long freq, int drive) // freq / 10Hz +void ADF4351_set_frequency(int channel, uint32_t freq, int drive) // freq / 10Hz { - freq -= 71000; - ADF4351_prep_frequency(channel,freq, drive); +// freq -= 71000; + + uint32_t offs = ((freq / 1000)* 39) / 1000; + ADF4351_prep_frequency(channel,freq + offs, drive); //START_PROFILE; ADF4351_Set(channel); //STOP_PROFILE; @@ -1463,11 +1465,11 @@ void setState(si446x_state_t newState) int16_t Si446x_RSSI(void) { -// Si446x_getInfo(&SI4463_info); + +// int s = Si446x_getInfo(&SI4463_info); // if (s != SI446X_STATE_RX) -// SI4463_start_rx(90); -// SI4463_start_rx(90); +// SI4463_start_rx(0); uint8_t data[3] = { SI446X_CMD_GET_MODEM_STATUS, @@ -1715,7 +1717,9 @@ void SI4463_set_freq(uint32_t freq, uint32_t step_size) { int Odiv; int D; - float RFout=freq/1000000.0; // To MHz + uint32_t offs = ((freq / 1000)* 195) / 1000; + + float RFout=(freq+offs)/1000000.0; // To MHz if (RFout >= 820) { // till 1140MHz Odiv = 8; D = 2; diff --git a/ui_sa.c b/ui_sa.c index 0d8156b..3aa37b8 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -894,6 +894,12 @@ static UI_FUNCTION_ADV_CALLBACK(menu_storage_acb) break; case 3: toggle_normalize(); + if (setting.subtract_stored) { + kp_help_text = "Ref level"; + ui_mode_keypad(KM_REFLEVEL); + ui_process_keypad(); +// setting.normalize_level = uistat.value; + } break; } ui_mode_normal();