From 8562d8b41ce1ec01de9e7b2475f36c259d2b40c6 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Fri, 9 Jul 2021 18:07:48 +0200 Subject: [PATCH] trace command updated --- main.c | 51 +++++++++++++++++++++++++++++++-------------------- nanovna.h | 1 + plot.c | 2 +- sa_core.c | 26 ++++++++++++++++---------- ui_sa.c | 28 ++++++++++++++++------------ 5 files changed, 65 insertions(+), 43 deletions(-) diff --git a/main.c b/main.c index 44d2edc..1a679db 100644 --- a/main.c +++ b/main.c @@ -1366,6 +1366,8 @@ VNA_SHELL_FUNCTION(cmd_trace) { int t = 0; bool do_one = false; + if (argc==1 && argv[0][0] == '?') + goto usage; if (argc == 0) { for (t = 0; t < TRACES_MAX; t++) { show_one: @@ -1402,20 +1404,6 @@ show_one: set_unit(type); goto update; } -// goto usage; - } - static const char cmd_store_list[] = "value"; - process: - if (argc == 1) { - int type = get_str_index(argv[next_arg], cmd_store_list); - if (type >= 0) { - switch(type) { - case 0: - for (int i=0;i= 0) { + switch(type) { + case 0: + for (int i=0;i= 2) { switch (get_str_index(argv[next_arg++], cmd_load_list)) { case 0: - store_trace(t, my_atoi(argv[next_arg++])); + store_trace(t, my_atoi(argv[next_arg++])-1); // copy {trace} goto update; case 1: - setting.stored[t]= true;; + setting.stored[t]= (get_str_index(argv[next_arg++], "off|on") == 1); // freeze {off|on} goto update; case 2: - subtract_trace(t,my_atoi(argv[next_arg++])); + subtract_trace(t,my_atoi(argv[next_arg++])-1); + goto update; + case 3: + if (get_str_index(argv[next_arg++], "off|on") == 1) + { TRACE_ENABLE(1< -10) || (setting.mode == M_HIGH && level > -29) || (setting.mode == M_LOW && (markers[i].mtype & M_NOISE) && vbwSteps > 1)) //MAXPEAK increases noise marker, should reduce span. diff --git a/sa_core.c b/sa_core.c index 5ec2518..6fdb280 100644 --- a/sa_core.c +++ b/sa_core.c @@ -241,6 +241,7 @@ void reset_settings(int m) setting.average[t] = 0; setting.stored[t] = false; setting.subtract[t] = 0; // Disabled + setting.normalized[t] = false; // Disabled } for (int l=0;lbg = LCD_TRACE_1_COLOR+data; return; } - current_trace = data; + if (setting.normalized_trace != -1 && data == TRACE_TEMP) { + drawMessageBox("Error", "Disable normalization first", 2000); + redraw_request|= REDRAW_AREA; + } else + current_trace = data; menu_move_back(false); } @@ -1591,7 +1595,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_traces_acb) } else if (data == 2) // freeze b->icon = setting.stored[current_trace] ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK; - else if (data == 3) { + else if (data == 5) { if (setting.subtract[current_trace]) plot_printf(b->text, sizeof(b->text), "SUBTRACT\nTRACE %d", setting.subtract[current_trace]); else @@ -1601,8 +1605,8 @@ static UI_FUNCTION_ADV_CALLBACK(menu_traces_acb) if (current_trace == TRACES_MAX-1) b->fg = LCD_DARK_GREY; else - b->icon = setting.normalized_trace == current_trace ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK; - } else if (data == 5) { + b->icon = setting.normalized[current_trace] ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK; + } else if (data == 3) { plot_printf(b->text, sizeof(b->text), "CALC\n%s", averageText[setting.average[0]]); b->icon = setting.average[current_trace] ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK; } @@ -1630,22 +1634,22 @@ static UI_FUNCTION_ADV_CALLBACK(menu_traces_acb) case 2: // Freeze setting.stored[current_trace] = !setting.stored[current_trace]; break; - case 3: + case 5: menu_push_submenu(menu_subtract_trace); return; break; case 4: if (current_trace < TRACES_MAX-1) { toggle_normalize(current_trace); - if (setting.subtract[current_trace]) { - kp_help_text = "Ref level"; - ui_mode_keypad(KM_REFLEVEL); -// setting.normalize_level = uistat.value; + if (setting.normalized[current_trace]) { +// kp_help_text = "Ref level"; +// ui_mode_keypad(KM_REFLEVEL); +// setting.normalize_level = 20.0; // uistat.value; } else set_auto_reflevel(true); } break; - case 5: + case 3: menu_push_submenu(menu_average); return; break; @@ -2839,9 +2843,9 @@ static const menuitem_t menu_traces[] = { MT_ADV_CALLBACK,0, "TRACE %d", menu_traces_acb}, { MT_ADV_CALLBACK,1, "ENABLE", menu_traces_acb}, { MT_ADV_CALLBACK,2, "FREEZE", menu_traces_acb}, - { MT_ADV_CALLBACK,3, MT_CUSTOM_LABEL, menu_traces_acb}, + { MT_ADV_CALLBACK,3, MT_CUSTOM_LABEL, menu_traces_acb}, // Calc { MT_ADV_CALLBACK,4, "NORMALIZE", menu_traces_acb}, - { MT_ADV_CALLBACK,5, MT_CUSTOM_LABEL, menu_traces_acb}, + { MT_ADV_CALLBACK,5, MT_CUSTOM_LABEL, menu_traces_acb}, // Trace Math { 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},