From 6596a9fa8caf5caad1c1e0927f84ff60c13d4ddc Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sat, 3 Jul 2021 12:53:01 +0200 Subject: [PATCH] Bugs repaired --- .cproject | 1 + .settings/language.settings.xml | 4 +- sa_core.c | 42 ++++++---- ui_sa.c | 144 ++++++++++++++++++-------------- 4 files changed, 109 insertions(+), 82 deletions(-) diff --git a/.cproject b/.cproject index 906db46..2b62475 100644 --- a/.cproject +++ b/.cproject @@ -113,4 +113,5 @@ + diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 240010c..c335b92 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/sa_core.c b/sa_core.c index f8aa920..75efd3f 100644 --- a/sa_core.c +++ b/sa_core.c @@ -240,7 +240,7 @@ void reset_settings(int m) for (int t=0;t RSSI) trace_data[i] = RSSI; break; - case AV_MAX_HOLD: if (trace_data[i] < RSSI) trace_data[i] = RSSI; break; + case AV_MIN: if (trace_data[i] > RSSI_calc) trace_data[i] = RSSI_calc; break; + case AV_MAX_HOLD: if (trace_data[i] < RSSI_calc) trace_data[i] = RSSI_calc; break; case AV_MAX_DECAY: - if (trace_data[i] < RSSI) { + if (trace_data[i] < RSSI_calc) { age[i] = 0; - trace_data[i] = RSSI; + trace_data[i] = RSSI_calc; } else { if (age[i] > setting.decay) trace_data[i] -= 0.5; @@ -4131,8 +4137,8 @@ static volatile int dummy; age[i] += 1; } break; - case AV_4: trace_data[i] = (trace_data[i]*3.0 + RSSI) / 4.0; break; - case AV_16: trace_data[i] = (trace_data[i]*15.0 + RSSI) / 16.0; break; + case AV_4: trace_data[i] = (trace_data[i]*3.0 + RSSI_calc) / 4.0; break; + case AV_16: trace_data[i] = (trace_data[i]*15.0 + RSSI_calc) / 16.0; break; case AV_100: #ifdef TINYSA4 if (linear_averaging) @@ -4140,29 +4146,29 @@ static volatile int dummy; #if 0 int old_unit = setting.unit; setting.unit = U_WATT; // Power averaging should always be done in Watts - trace_data[i] = to_dBm((value(trace_data[i])*(scan_after_dirty-1) + value(RSSI)) / scan_after_dirty ); + trace_data[i] = to_dBm((value(trace_data[i])*(scan_after_dirty-1) + value(RSSI_calc)) / scan_after_dirty ); setting.unit = old_unit; #else - float v = (expf(trace_data[i]*(logf(10.0)/10.0)) * (scan_after_dirty-1) + expf(RSSI * (logf(10.0)/10.0))) / scan_after_dirty; + float v = (expf(trace_data[i]*(logf(10.0)/10.0)) * (scan_after_dirty-1) + expf(RSSI_calc * (logf(10.0)/10.0))) / scan_after_dirty; trace_data[i] = logf(v)*(10.0/logf(10.0)); #endif } else - trace_data[i] = (trace_data[i]*(scan_after_dirty-1) + RSSI)/ scan_after_dirty; + trace_data[i] = (trace_data[i]*(scan_after_dirty-1) + RSSI_calc)/ scan_after_dirty; #else - trace_data[i] = (trace_data[i]*(scan_after_dirty-1) + RSSI)/ scan_after_dirty; + trace_data[i] = (trace_data[i]*(scan_after_dirty-1) + RSSI_calc)/ scan_after_dirty; #endif break; #ifdef __QUASI_PEAK__ case AV_QUASI: { static float old_RSSI = -150.0; if (i == 0) old_RSSI = trace_data[sweep_points-1]; - if (RSSI > old_RSSI && setting.attack > 1) - old_RSSI += (RSSI - old_RSSI)/setting.attack; - else if (RSSI < old_RSSI && setting.decay > 1) - old_RSSI += (RSSI - old_RSSI)/setting.decay; + if (RSSI_calc > old_RSSI && setting.attack > 1) + old_RSSI += (RSSI_calc - old_RSSI)/setting.attack; + else if (RSSI_calc < old_RSSI && setting.decay > 1) + old_RSSI += (RSSI_calc - old_RSSI)/setting.decay; else - old_RSSI = RSSI; + old_RSSI = RSSI_calc; trace_data[i] = old_RSSI; } break; diff --git a/ui_sa.c b/ui_sa.c index 1d549cb..87bac0b 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -516,6 +516,7 @@ static const menuitem_t menu_highoutputmode[]; static const menuitem_t menu_modulation[]; static const menuitem_t menu_top[]; static const menuitem_t menu_trace[]; +static const menuitem_t menu_marker_trace[]; static const menuitem_t menu_subtract_trace[]; static const menuitem_t menu_reffer[]; static const menuitem_t menu_sweep_points[]; @@ -1525,23 +1526,37 @@ static UI_FUNCTION_ADV_CALLBACK(menu_trace_acb) if(b){ b->param_1.i = data+1; b->icon = (data == current_trace) ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP; + b->bg = LCD_TRACE_1_COLOR+data; return; } current_trace = data; menu_move_back(false); } +static UI_FUNCTION_ADV_CALLBACK(menu_marker_trace_acb) +{ + (void)item; + if(b){ + b->param_1.i = data+1; + b->icon = (data == markers[active_marker].trace) ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP; + b->bg = LCD_TRACE_1_COLOR+data; + return; + } + markers[active_marker].trace = data; + menu_move_back(false); +} + static UI_FUNCTION_ADV_CALLBACK(menu_store_trace_acb) { (void)item; if(b){ - if (data == current_trace) - plot_printf(b->text, sizeof(b->text), "", data); - else - plot_printf(b->text, sizeof(b->text), S_RARROW"TRACE %d", data+1); + plot_printf(b->text, sizeof(b->text), S_RARROW"TRACE %d", data+1); + b->bg = LCD_TRACE_1_COLOR+data; + if (current_trace == data) + b->fg = LCD_DARK_GREY; return; } - if (data != current_trace) store_trace(current_trace,data); + store_trace(current_trace,data); menu_move_back(false); } @@ -1550,11 +1565,15 @@ static UI_FUNCTION_ADV_CALLBACK(menu_subtract_trace_acb) { (void)item; if(b){ - if (data) + if (data) { plot_printf(b->text, sizeof(b->text), "SUBTRACT\nTRACE %d", data); + b->bg = LCD_TRACE_1_COLOR+data-1; + } else plot_printf(b->text, sizeof(b->text), "SUBTRACT\nDISABLED"); b->icon = (data == setting.subtract[current_trace]) ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP; + if (data - 1 == current_trace) + b->fg = LCD_DARK_GREY; return; } subtract_trace(current_trace,data); @@ -1566,15 +1585,20 @@ static UI_FUNCTION_ADV_CALLBACK(menu_traces_acb) { (void)item; if(b){ - if (data == 0) { + if (data == 0) { // Select trace b->param_1.i = current_trace+1; - } else if (data == 1) - b->icon = IS_TRACE_ENABLE(current_trace) ? BUTTON_ICON_NOCHECK : BUTTON_ICON_CHECK ; - else if (data == 2) + b->bg = LCD_TRACE_1_COLOR+current_trace; + } else if (data == 1) { // View + if (current_trace) + b->icon = IS_TRACE_ENABLE(current_trace) ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK; + else + b->fg = LCD_DARK_GREY; + } + else if (data == 2) // freeze b->icon = setting.stored[current_trace] ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK; else if (data == 3) { - if (setting.stored[current_trace]) - plot_printf(b->text, sizeof(b->text), "SUBTRACT\nTRACE %d", setting.stored[current_trace]); + if (setting.subtract[current_trace]) + plot_printf(b->text, sizeof(b->text), "SUBTRACT\nTRACE %d", setting.subtract[current_trace]); else plot_printf(b->text, sizeof(b->text), "SUBTRACT\nDISABLED"); } @@ -1586,12 +1610,13 @@ static UI_FUNCTION_ADV_CALLBACK(menu_traces_acb) return; case 1: if (IS_TRACE_ENABLE(current_trace)) { - TRACE_DISABLE(1<icon = BUTTON_ICON_NOCHECK; - if (data & markers[active_marker].mtype) - b->icon = BUTTON_ICON_CHECK; - else if (data==markers[active_marker].mtype) // This catches the M_NORMAL case + if (markers[active_marker].mtype & data) b->icon = BUTTON_ICON_CHECK; - if ((markers[active_marker].mtype & M_DELTA)) + if (markers[active_marker].mtype & M_DELTA) uistat.text[0] = markers[active_marker].ref+'1'; - else - uistat.text[0] = 0; - uistat.text[1] = 0; - b->param_1.text = uistat.text; + break; + case M_STORED: + uistat.text[0] = markers[active_marker].trace+'1'; + b->bg = LCD_TRACE_1_COLOR+markers[active_marker].trace; + break; } + b->param_1.text = uistat.text; return; } - if (markers[active_marker].enabled == M_ENABLED) - { - if (data == M_NORMAL) { - markers[active_marker].mtype = M_NORMAL; - } -#if 0 - if (data == M_REFERENCE) { - for (int i = 0; i menu_back }; +static const menuitem_t menu_marker_trace[] = +{ + { MT_ADV_CALLBACK,0, "TRACE %d", menu_marker_trace_acb}, + { MT_ADV_CALLBACK,1, "TRACE %d", menu_marker_trace_acb}, + { MT_ADV_CALLBACK,2, "TRACE %d", menu_marker_trace_acb}, +#if TRACES_MAX > 3 + { MT_ADV_CALLBACK,3, "TRACE %d", menu_marker_trace_acb}, +#endif + { MT_NONE, 0, NULL, menu_back} // next-> menu_back +}; + static const menuitem_t menu_store_trace[] = { { MT_ADV_CALLBACK,0, MT_CUSTOM_LABEL, menu_store_trace_acb}, @@ -2975,11 +2995,11 @@ static const menuitem_t menu_subtract_trace[] = static const menuitem_t menu_traces[] = { { MT_ADV_CALLBACK,0, "TRACE %d", menu_traces_acb}, - { MT_ADV_CALLBACK,1, "HIDDEN", menu_traces_acb}, - { MT_ADV_CALLBACK,2, "STORED", menu_traces_acb}, + { MT_ADV_CALLBACK,1, "VIEW", menu_traces_acb}, + { MT_ADV_CALLBACK,2, "FREEZE", menu_traces_acb}, { MT_ADV_CALLBACK,3, MT_CUSTOM_LABEL, menu_traces_acb}, { MT_SUBMENU, 0, "CALC", menu_average}, - { MT_SUBMENU, 0, "STORE\n"S_RARROW"TRACE", menu_store_trace}, + { MT_SUBMENU, 0, "COPY\n"S_RARROW"TRACE", menu_store_trace}, #ifdef TINYSA4 { MT_ADV_CALLBACK,6, "WRITE\n"S_RARROW"SD", menu_traces_acb}, #endif