From bfa5f164731d2851f97be1f340166f66ce0b2b42 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 20 Apr 2021 08:47:00 +0200 Subject: [PATCH] Output bug solved --- nanovna.h | 8 ++++---- sa_core.c | 14 ++++++++++++-- ui_sa.c | 13 +++++++------ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/nanovna.h b/nanovna.h index 146dc2d..b8f2ff0 100644 --- a/nanovna.h +++ b/nanovna.h @@ -18,7 +18,7 @@ */ #include "ch.h" -//#ifdef TINYSA_F303 +#ifdef TINYSA_F303 #include "adc_F303.h" #ifdef TINYSA_F072 #error "Remove comment for #ifdef TINYSA_F303" @@ -27,16 +27,16 @@ #define TINYSA4 #endif #define TINYSA4_PROTO -//#endif +#endif -#ifdef TINYSA_F072 +//#ifdef TINYSA_F072 #ifdef TINYSA_F303 #error "Remove comment for #ifdef TINYSA_F072" #endif #ifndef TINYSA3 #define TINYSA3 #endif -#endif +//#endif // Need enable HAL_USE_SPI in halconf.h #define __USE_DISPLAY_DMA__ diff --git a/sa_core.c b/sa_core.c index a543edc..c60a703 100644 --- a/sa_core.c +++ b/sa_core.c @@ -2620,7 +2620,10 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / ls -= 0.5; float a = ((int)((setting.level + ((float)i / sweep_points) * ls)*2.0)) / 2.0 /* + get_level_offset() */ ; correct_RSSI_freq = get_frequency_correction(f); - a += PURE_TO_float(correct_RSSI_freq) + 3.0; // Always 3dB in attenuator + a += PURE_TO_float(correct_RSSI_freq); +#ifdef TINYSA4 + a += 3.0; // Always 3dB in attenuator +#endif if (a != old_a) { #ifdef TINYSA4 int very_low_flag = false; @@ -2650,7 +2653,12 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / #else #define LOWEST_LEVEL MIN_DRIVE #endif - int d = MAX_DRIVE-8; // Start in the middle + int d; +#ifdef TINYSA4 + d = MAX_DRIVE-8; // Start in the middle +#else + d = MAX_DRIVE-3; // Start in the middle +#endif while (a - BELOW_MAX_DRIVE(d) > 0 && d < MAX_DRIVE) { // Increase if needed d++; @@ -2666,7 +2674,9 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / #ifdef __SI4463__ SI4463_set_output_level(d); #endif +#ifdef TINYSA4 a -= 3.0; // Always at least 3dB attenuation +#endif if (a > 0) a = 0; if (a < -31.5) diff --git a/ui_sa.c b/ui_sa.c index 9da0f0c..ed47028 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -425,8 +425,8 @@ enum { KM_ATTACK, #ifdef TINYSA4 KM_LPF, - KM_LEVEL, #endif + KM_LEVEL, #ifdef __LIMITS__ KM_LIMIT_FREQ, KM_LIMIT_LEVEL, #endif @@ -477,8 +477,8 @@ static const struct { {keypads_positive , "ATTACK"}, // KM_ATTACK #ifdef TINYSA4 {keypads_freq , "ULTRA\nSTART"}, // KM_LPF - {keypads_plusmin , "LEVEL"}, // KM_LEVEL #endif + {keypads_plusmin , "LEVEL"}, // KM_LEVEL #ifdef __LIMITS__ {keypads_freq , "END\nFREQ"}, // KM_LIMIT_FREQ {keypads_plusmin_unit , "LEVEL"}, // KM_LIMIT_LEVEL @@ -533,7 +533,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_sweep_acb) } menu_push_submenu(menu_sweep); } - +#ifdef TINYSA4 static UI_FUNCTION_ADV_CALLBACK(menu_curve_acb) { (void)item; @@ -568,6 +568,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_curve_acb) } reset_settings(old_m); } +#endif static UI_FUNCTION_ADV_CALLBACK(menu_output_level_acb) { @@ -2239,7 +2240,7 @@ static const menuitem_t menu_settings2[] = { MT_NONE, 0, NULL, NULL } // sentinel }; -//#ifdef TINYSA4 +#ifdef TINYSA4 static const menuitem_t menu_curve3[] = { { MT_FORM | MT_ADV_CALLBACK, 14, "%s", menu_curve_acb }, { MT_FORM | MT_ADV_CALLBACK, 15, "%s", menu_curve_acb }, @@ -2276,7 +2277,7 @@ static const menuitem_t menu_curve[] = { { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel }; -//#endif +#endif static const menuitem_t menu_actual_power[] = { @@ -2830,9 +2831,9 @@ set_numeric_value(void) config_save(); ultra_threshold = config.ultra_threshold; break; +#endif case KM_LEVEL: break; -#endif #ifdef __LIMITS__ case KM_LIMIT_FREQ: setting.limits[active_limit].frequency = uistat.value - (setting.frequency_offset - FREQUENCY_SHIFT);