From a42955399d2e095b3b63fead9a9698f2f57df07d Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sun, 28 Aug 2022 09:22:14 +0200 Subject: [PATCH] Output mode settings menu to config --- sa_core.c | 23 ++++++++++++++++------- ui_sa.c | 13 +++++++------ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/sa_core.c b/sa_core.c index 4e248bb..2be549a 100644 --- a/sa_core.c +++ b/sa_core.c @@ -112,7 +112,8 @@ int actual_drive = -1; #ifdef TINYSA4 const float si_drive_dBm [] = {-44.1, -30, -21.6, -17, -14, -11.7, -9.9, -8.4, -7.1, -6, -5, -4.2, -3.4, -2.7 , -2.1, -1.5, -1, -0.47, 0}; -const float adf_drive_dBm[] = {-13,-7.5,-4.2, 0}; +//const float adf_drive_dBm[] = {-13,-7.5,-4.2, 0}; +const float adf_drive_dBm[] = {-9, -4, 0, 0}; const uint8_t drive_register[] = {0, 1, 2, 3, 4, 5, 6, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}; float *drive_dBm = (float *) si_drive_dBm; const int min_drive = 0; @@ -236,21 +237,29 @@ void set_output_path(freq_t f, float level) if (signal_path == PATH_HIGH) { return; //TODO setup high path } - float ATTENUATION_RESERVE = 3.0; - if (setting.modulation == MO_AM) - ATTENUATION_RESERVE = 6.0; -// if (signal_path != PATH_LEAKAGE) - level += ATTENUATION_RESERVE; + float ATTENUATION_RESERVE = 3.0; + if (signal_path == PATH_LEAKAGE) { + ATTENUATION_RESERVE = 0; + } + else { + if (setting.modulation == MO_AM) + ATTENUATION_RESERVE = 6.0; + } + level += ATTENUATION_RESERVE; float switch_atten = SWITCH_ATTENUATION; if (signal_path == PATH_LEAKAGE) #if 0 switch_atten = 44.0; +#else +#ifdef TINYSA4 + switch_atten = 32.0; #else switch_atten = 31.0; +#endif #endif float a = level - level_max(); // convert to all settings maximum power output equals a = zero - if (a < -28 + BELOW_MAX_DRIVE(0)) { // Switch needed + if (a < -switch_atten + BELOW_MAX_DRIVE(0)) { // Switch needed a = a + switch_atten; setting.atten_step = true; } else diff --git a/ui_sa.c b/ui_sa.c index a4921e5..1767615 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -786,7 +786,12 @@ static UI_FUNCTION_ADV_CALLBACK(menu_output_level_acb) } int old_m = setting.mode; reset_settings(M_GENLOW); - set_level(-25); +#ifdef TINYSA4 +#define TEST_LEVEL -30 +#else +#define TEST_LEVEL -25 +#endif + set_level(TEST_LEVEL); set_sweep_frequency(ST_CW, 30000000); setting.mute = false; perform(false, 0, 30000000, false); @@ -797,11 +802,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_output_level_acb) if (kp_buf[0] != 0) { float old_offset = config.low_level_output_offset; if (old_offset == 100) old_offset = 0; -#ifdef TINYSA4 - float new_offset = uistat.value - (-25.0) + old_offset; // calculate offset based on difference between measured peak level and known peak level -#else - float new_offset = uistat.value - (-25.0) + old_offset; // calculate offset based on difference between measured peak level and known peak level -#endif + float new_offset = uistat.value - (TEST_LEVEL) + old_offset; // calculate offset based on difference between measured peak level and known peak level if (uistat.value == 100) new_offset = 100; if ((new_offset > -10 && new_offset < 10) || new_offset == 100) { config.low_level_output_offset = new_offset;