diff --git a/main.c b/main.c index 63133702..7d0a0057 100644 --- a/main.c +++ b/main.c @@ -336,12 +336,12 @@ properties_t current_props = { /* cal_status */ 0, /* frequencies */ {}, /* cal_data */ {}, - /* trace[4] */ { - /* enable, type, channel, polar, scale */ + /* trace[4] */ + {/*enable, type, channel, polar, scale*/ { 1, TRC_LOGMAG, 0, 0, 1.0 }, { 1, TRC_LOGMAG, 1, 0, 1.0 }, { 1, TRC_SMITH, 0, 1, 1.0 }, - { 1, TRC_PHASE, 1, 1, 1.0 } + { 1, TRC_PHASE, 1, 0, 1.0 } }, /* markers[4] */ { { 1, 30 }, { 0, 40 }, { 0, 60 }, { 0, 80 } diff --git a/plot.c b/plot.c index 42537d49..63724f42 100644 --- a/plot.c +++ b/plot.c @@ -588,7 +588,10 @@ trace_get_value_string(int t, char *buf, int len, float coeff[2], uint32_t frequ switch (trace[t].type) { case TRC_LOGMAG: v = logmag(coeff); - chsnprintf(buf, len, "%.2fdB", v * 10); + if (v == -INFINITY) + chsnprintf(buf, len, "-INF dB"); + else + chsnprintf(buf, len, "%.2fdB", v * 10); break; case TRC_PHASE: v = phase(coeff); @@ -1002,16 +1005,15 @@ draw_cell(int m, int n) for (t = 0; t < TRACES_MAX; t++) { if (!trace[t].enabled) continue; - if (!trace[t].polar) + + if (trace[t].type == TRC_SMITH) + grid_mode |= GRID_SMITH; + //else if (trace[t].type == TRC_ADMIT) + // grid_mode |= GRID_ADMIT; + else if (trace[t].type == TRC_POLAR) + grid_mode |= GRID_POLAR; + else grid_mode |= GRID_RECTANGULAR; - else { - if (trace[t].type == TRC_SMITH) - grid_mode |= GRID_SMITH; - //else if (trace[t].type == TRC_ADMIT) - // grid_mode |= GRID_ADMIT; - else - grid_mode |= GRID_POLAR; - } } PULSE; @@ -1050,8 +1052,11 @@ draw_cell(int m, int n) #if 1 /* draw rectanglar plot */ for (t = 0; t < TRACES_MAX; t++) { - if (!trace[t].enabled || trace[t].polar) + if (!trace[t].enabled) continue; + if (trace[t].type == TRC_SMITH || trace[t].type == TRC_POLAR) + continue; + if (search_index_x(x0, trace_index[t], &i0, &i1)) { if (i0 > 0) i0--; @@ -1070,8 +1075,11 @@ draw_cell(int m, int n) /* draw polar plot */ for (t = 0; t < TRACES_MAX; t++) { int c = config.trace_color[t]; - if (!trace[t].enabled || !trace[t].polar) + if (!trace[t].enabled) continue; + if (trace[t].type != TRC_SMITH && trace[t].type != TRC_POLAR) + continue; + for (i = 1; i < 101; i++) { //uint32_t index = trace_index[t][i]; //uint32_t pindex = trace_index[t][i-1]; diff --git a/ui.c b/ui.c index e3fe5ab9..74b9a771 100644 --- a/ui.c +++ b/ui.c @@ -412,6 +412,7 @@ menu_trace_cb(int item) { if (item < 0 || item >= 4) return; + trace[item].enabled = TRUE; uistat.current_trace = item; menu_move_back(); } @@ -614,10 +615,10 @@ menu_cal_cb(int item) const menuitem_t menu_trace[] = { - { MT_CALLBACK, "0", menu_trace_cb }, - { MT_CALLBACK, "1", menu_trace_cb }, - { MT_CALLBACK, "2", menu_trace_cb }, - { MT_CALLBACK, "3", menu_trace_cb }, + { MT_CALLBACK, "TRACE 0", menu_trace_cb }, + { MT_CALLBACK, "TRACE 1", menu_trace_cb }, + { MT_CALLBACK, "TRACE 2", menu_trace_cb }, + { MT_CALLBACK, "TRACE 3", menu_trace_cb }, { MT_CALLBACK, "\2SINGLE\0TRACE", menu_single_trace_cb }, { MT_CANCEL, "BACK", NULL }, { MT_NONE, NULL, NULL } // sentinel @@ -643,6 +644,15 @@ const menuitem_t menu_format[] = { { MT_NONE, NULL, NULL } // sentinel }; +const menuitem_t menu_scale[] = { + { MT_CALLBACK, "SCALE/DIV", menu_scale_cb }, + { MT_CALLBACK, "\2REFERENCE\0POSITION", menu_scale_cb }, + { MT_CALLBACK, "\2ELECTRICAL\0DELAY", menu_scale_cb }, + { MT_CANCEL, "BACK", NULL }, + { MT_NONE, NULL, NULL } // sentinel +}; + + const menuitem_t menu_channel[] = { { MT_CALLBACK, "\2CH0\0REFLECT", menu_channel_cb }, { MT_CALLBACK, "\2CH1\0THROUGH", menu_channel_cb }, @@ -653,7 +663,7 @@ const menuitem_t menu_channel[] = { const menuitem_t menu_display[] = { { MT_SUBMENU, "TRACE", menu_trace }, { MT_SUBMENU, "FORMAT", menu_format }, - { MT_CALLBACK, "SCALE", menu_scale_cb }, + { MT_SUBMENU, "SCALE", menu_scale }, { MT_SUBMENU, "CHANNEL", menu_channel }, { MT_CANCEL, "BACK", NULL }, { MT_NONE, NULL, NULL } // sentinel @@ -838,7 +848,7 @@ draw_keypad(void) } const char *keypad_mode_label[] = { - "START", "STOP", "CENTER", "SPAN", "SCALE" + "START", "STOP", "CENTER", "SPAN", "CW FREQ", "SCALE" }; void @@ -875,6 +885,24 @@ menu_is_multiline(const char *label, const char **l1, const char **l2) return TRUE; } +static void +menu_item_modify_attribute(const menuitem_t *menu, int item, + uint16_t *fg, uint16_t *bg) +{ + if (menu == menu_trace && item < 4) { + *bg = config.trace_color[item]; + } else if (menu == menu_calop) { + if (item == 0 && (cal_status & CALSTAT_OPEN) + || item == 1 && (cal_status & CALSTAT_SHORT) + || item == 2 && (cal_status & CALSTAT_LOAD) + || item == 3 && (cal_status & CALSTAT_ISOLN) + || item == 4 && (cal_status & CALSTAT_THRU)) { + *bg = 0x0000; + *fg = 0xffff; + } + } +} + void draw_menu_buttons(const menuitem_t *menu) { @@ -887,15 +915,18 @@ draw_menu_buttons(const menuitem_t *menu) continue; int y = 32*i; uint16_t bg = config.menu_normal_color; + uint16_t fg = 0x0000; // focus only in MENU mode but not in KEYPAD mode if (ui_mode == UI_MENU && i == selection) bg = config.menu_active_color; ili9341_fill(320-60, y, 60, 30, bg); + + menu_item_modify_attribute(menu, i, &fg, &bg); if (menu_is_multiline(menu[i].label, &l1, &l2)) { - ili9341_drawstring_5x7(l1, 320-54, y+8, 0x0000, bg); - ili9341_drawstring_5x7(l2, 320-54, y+15, 0x0000, bg); + ili9341_drawstring_5x7(l1, 320-54, y+8, fg, bg); + ili9341_drawstring_5x7(l2, 320-54, y+15, fg, bg); } else { - ili9341_drawstring_5x7(menu[i].label, 320-54, y+12, 0x0000, bg); + ili9341_drawstring_5x7(menu[i].label, 320-54, y+12, fg, bg); } } }