From 8631ac14f15434c65cc6c5c0abad6f218f26cfd5 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sat, 28 Mar 2020 19:52:49 +0100 Subject: [PATCH] Atampt to auto scaling and other UI improvements --- sa_core.c | 31 +++++++++++++++++++++++++------ ui.c | 6 +++--- ui_sa.c | 4 ++-- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/sa_core.c b/sa_core.c index 28c2cec..d839429 100644 --- a/sa_core.c +++ b/sa_core.c @@ -354,6 +354,7 @@ void SetMode(int m) float peakLevel; +float min_level; uint32_t peakFreq; int peakIndex; float temppeakLevel; @@ -486,15 +487,20 @@ static const int spur_table[] = 830000, 880000, 949000, + 1390000, 1468000, 1830000, 1900000, + 2770000, 2840000, 2880000, + 4710000, 4780000, 4800000, 4880000, - 6510000 + 6510000, + 6750000, + 6790000, 6860000, 7340000, 8100000, @@ -630,7 +636,8 @@ static bool sweep(bool break_on_operation) float RSSI; palClearPad(GPIOC, GPIOC_LED); temppeakLevel = -150; -// spur_old_stepdelay = 0; + float temp_min_level = 100; + // spur_old_stepdelay = 0; again: for (int i = 0; i < sweep_points; i++) { RSSI = perform(break_on_operation, i, frequencies[i], extraVFO); @@ -666,10 +673,8 @@ again: temppeakLevel = actual_t[i]; } } - if (i == sweep_points -1) { - - - } + if (temp_min_level > actual_t[i]) + temp_min_level = actual_t[i]; } if (settingSpur == 1) { settingSpur = -1; @@ -684,6 +689,20 @@ again: peakIndex = temppeakIndex; peakLevel = actual_t[peakIndex]; peakFreq = frequencies[peakIndex]; + min_level = temp_min_level; +#if 0 // Auto ref level setting + int scale = get_trace_scale(2); + int rp = (NGRIDY - get_trace_refpos(2)) * scale; + if (scale > 0 && peakLevel > rp && peakLevel - min_level < 8 * scale ) { + SetRefpos((((int)(peakLevel/scale)) + 1) * scale); + } + if (scale > 0 && min_level < rp - 9*scale && peakLevel - min_level < 8 * scale ) { + int new_rp = (((int)((min_level + 9*scale)/scale)) - 1) * scale; + if (new_rp < rp) + SetRefpos(new_rp); + } + +#endif int peak_marker = 0; markers[peak_marker].enabled = true; markers[peak_marker].index = peakIndex; diff --git a/ui.c b/ui.c index 21ce6fe..f89aca6 100644 --- a/ui.c +++ b/ui.c @@ -1052,7 +1052,7 @@ const menuitem_t menu_top[] = { #define MENU_BUTTON_WIDTH 60 #define MENU_BUTTON_START (320-MENU_BUTTON_WIDTH) -#define MENU_FORM_WIDTH 290 +#define MENU_FORM_WIDTH 295 #define MENU_FORM_START (320 - MENU_FORM_WIDTH) #define MENU_BUTTON_HEIGHT 30 #define NUM_INPUT_HEIGHT 30 @@ -1484,8 +1484,8 @@ draw_menu_buttons(const menuitem_t *menu) ili9341_set_foreground(fg); ili9341_set_background(bg); if (menu[i].type & MT_FORM) { - ili9341_fill(active_button_start+3, y+6, active_button_width-6, 2+FONT_GET_HEIGHT*2+2, bg); - ili9341_drawstring_size(text, active_button_start+5, y+8, 2); + ili9341_fill(active_button_start+2, y+2, active_button_width-4, FONT_GET_HEIGHT*2+8, bg); + ili9341_drawstring_size(text, active_button_start+6, y+6, 2); } else { if (menu_is_multiline(menu[i].label, &l1, &l2)) { #define BIG_BUTTON_FONT 1 diff --git a/ui_sa.c b/ui_sa.c index 1e5f44f..ec10d26 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1035,7 +1035,7 @@ static void fetch_numeric_target(void) break; case KM_LOWOUTLEVEL: uistat.value = settingAttenuate; - uistat.value = -10 - uistat.value; // compensation for dB offset during low output mode + uistat.value = -5 - uistat.value; // compensation for dB offset during low output mode plot_printf(uistat.text, sizeof uistat.text, "%ddB", uistat.value); break; case KM_HIGHOUTLEVEL: @@ -1099,7 +1099,7 @@ set_numeric_value(void) SetDrive(uistat.value); break; case KM_LOWOUTLEVEL: - uistat.value = -10 - uistat.value ; // compensation for dB offset during low output mode + uistat.value = -5 - uistat.value ; // compensation for dB offset during low output mode SetAttenuation(uistat.value); break; case KM_HIGHOUTLEVEL: