From 5185435e36059af4b371ec621f0836b74839a78d Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 16 Mar 2021 08:58:29 +0100 Subject: [PATCH] Correct external gain --- plot.c | 4 ++-- sa_core.c | 8 ++++---- ui_sa.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/plot.c b/plot.c index 7fc5b1c..1755880 100644 --- a/plot.c +++ b/plot.c @@ -1449,8 +1449,8 @@ static void cell_draw_marker_info(int x0, int y0) ili9341_set_background(LCD_BG_COLOR); uint16_t color; if ((!setting.subtract_stored) && // Disabled when normalized - ((setting.mode == M_LOW && temppeakLevel - get_attenuation() > -10) || // Ignore external_gain in overload detection - (setting.mode == M_HIGH && temppeakLevel - get_attenuation() > -29) )) + ((setting.mode == M_LOW && temppeakLevel - get_attenuation() + setting.external_gain > -10) || + (setting.mode == M_HIGH && temppeakLevel - get_attenuation()+ setting.external_gain > -29) )) color = LCD_BRIGHT_COLOR_RED; else color = marker_color(markers[i].mtype); diff --git a/sa_core.c b/sa_core.c index fcf5214..06e097f 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1218,7 +1218,7 @@ void set_external_gain(float external_gain) int min,max; min = level_min; max = min + level_range; - plot_printf(low_level_help_text, sizeof low_level_help_text, "%+d..%+d", min + (int)external_gain, max + (int)external_gain); + plot_printf(low_level_help_text, sizeof low_level_help_text, "%+d..%+d", min - (int)external_gain, max - (int)external_gain); redraw_request|=REDRAW_AREA; dirty = true; // No HW update required, only status panel refresh but need to ensure the cached value is updated in the calculation of the RSSI } @@ -3454,7 +3454,7 @@ sweep_again: // stay in sweep loop when output mo setting.atten_step = false; // No step attenuate in low mode auto attenuate int changed = false; int delta = 0; - int actual_max_level = (max_index[0] == 0 ? -100 :(int) (actual_t[max_index[0]] - get_attenuation()) ) - setting.external_gain; // If no max found reduce attenuation + int actual_max_level = (max_index[0] == 0 ? -100 :(int) (actual_t[max_index[0]] - get_attenuation()) ) + setting.external_gain; // If no max found reduce attenuation if (actual_max_level < AUTO_TARGET_LEVEL && setting.attenuate_x2 > 0) { delta = - (AUTO_TARGET_LEVEL - actual_max_level); } else if (actual_max_level > AUTO_TARGET_LEVEL && setting.attenuate_x2 < 60) { @@ -3497,7 +3497,7 @@ sweep_again: // stay in sweep loop when output mo #ifdef __SI4432__ if (!in_selftest && MODE_INPUT(setting.mode)) { if (S_IS_AUTO(setting.agc)) { - int actual_max_level = actual_t[max_index[0]] - get_attenuation() - setting.external_gain; // No need to use float + int actual_max_level = actual_t[max_index[0]] - get_attenuation() + setting.external_gain; // 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 @@ -3693,7 +3693,7 @@ sweep_again: // stay in sweep loop when output mo } else if (setting.measurement == M_AM) { // ----------------AM measurement if (S_IS_AUTO(setting.agc )) { #ifdef __SI4432__ - int actual_level = actual_t[max_index[0]] - get_attenuation() - setting.external_gain; // no need for float + int actual_level = actual_t[max_index[0]] - get_attenuation() + setting.external_gain; // no need for float if (actual_level > -20 ) { setting.agc = S_AUTO_OFF; setting.lna = S_AUTO_OFF; diff --git a/ui_sa.c b/ui_sa.c index 56d8987..097f614 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1677,7 +1677,7 @@ static const menuitem_t menu_lowoutputmode[] = { // { MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", "0..350MHz"}, // { MT_FORM | MT_KEYPAD | MT_LOW, KM_LEVELSWEEP,"LEVEL CHANGE: %s", "-70..70"}, // { MT_FORM | MT_KEYPAD, KM_SWEEP_TIME, "SWEEP TIME: %s", "0..600 seconds"}, - { MT_FORM | MT_KEYPAD, KM_EXT_GAIN, "EXTERNAL AMP: %s", "-100..+100"}, + { MT_FORM | MT_KEYPAD, KM_EXT_GAIN, "EXTERNAL GAIN: %s", "-100..+100"}, { MT_FORM | MT_CANCEL, 0, "MODE", NULL }, { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; @@ -1697,7 +1697,7 @@ static const menuitem_t menu_highoutputmode[] = { { MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", NULL}, { MT_FORM | MT_KEYPAD, KM_SWEEP_TIME,"SWEEP TIME: %s", "0..600 seconds"}, #endif - { MT_FORM | MT_KEYPAD, KM_EXT_GAIN, "EXTERNAL AMP: %s", "-100..+100"}, + { MT_FORM | MT_KEYPAD, KM_EXT_GAIN, "EXTERNAL GAIN: %s", "-100..+100"}, { MT_FORM | MT_CANCEL, 0, "MODE", NULL }, { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; @@ -2200,7 +2200,7 @@ static const menuitem_t menu_level[] = { { MT_SUBMENU, 0, "ATTENUATE", menu_atten}, // { MT_SUBMENU,0, "CALC", menu_average}, { MT_SUBMENU, 0, "UNIT", menu_unit}, - { MT_KEYPAD, KM_EXT_GAIN, "EXTERNAL\nAMP",NULL}, + { MT_KEYPAD, KM_EXT_GAIN, "EXTERNAL\nGAIN",NULL}, #ifdef TINYSA4 { MT_ADV_CALLBACK | MT_LOW ,0,"LNA", menu_extra_lna_acb}, #endif