mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
menu attribute change on trace selection and cal operations
This commit is contained in:
parent
5ebb3330ff
commit
ee4576dc33
6
main.c
6
main.c
|
|
@ -336,12 +336,12 @@ properties_t current_props = {
|
||||||
/* cal_status */ 0,
|
/* cal_status */ 0,
|
||||||
/* frequencies */ {},
|
/* frequencies */ {},
|
||||||
/* cal_data */ {},
|
/* cal_data */ {},
|
||||||
/* trace[4] */ {
|
/* trace[4] */
|
||||||
/* enable, type, channel, polar, scale */
|
{/*enable, type, channel, polar, scale*/
|
||||||
{ 1, TRC_LOGMAG, 0, 0, 1.0 },
|
{ 1, TRC_LOGMAG, 0, 0, 1.0 },
|
||||||
{ 1, TRC_LOGMAG, 1, 0, 1.0 },
|
{ 1, TRC_LOGMAG, 1, 0, 1.0 },
|
||||||
{ 1, TRC_SMITH, 0, 1, 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] */ {
|
/* markers[4] */ {
|
||||||
{ 1, 30 }, { 0, 40 }, { 0, 60 }, { 0, 80 }
|
{ 1, 30 }, { 0, 40 }, { 0, 60 }, { 0, 80 }
|
||||||
|
|
|
||||||
22
plot.c
22
plot.c
|
|
@ -588,6 +588,9 @@ trace_get_value_string(int t, char *buf, int len, float coeff[2], uint32_t frequ
|
||||||
switch (trace[t].type) {
|
switch (trace[t].type) {
|
||||||
case TRC_LOGMAG:
|
case TRC_LOGMAG:
|
||||||
v = logmag(coeff);
|
v = logmag(coeff);
|
||||||
|
if (v == -INFINITY)
|
||||||
|
chsnprintf(buf, len, "-INF dB");
|
||||||
|
else
|
||||||
chsnprintf(buf, len, "%.2fdB", v * 10);
|
chsnprintf(buf, len, "%.2fdB", v * 10);
|
||||||
break;
|
break;
|
||||||
case TRC_PHASE:
|
case TRC_PHASE:
|
||||||
|
|
@ -1002,16 +1005,15 @@ draw_cell(int m, int n)
|
||||||
for (t = 0; t < TRACES_MAX; t++) {
|
for (t = 0; t < TRACES_MAX; t++) {
|
||||||
if (!trace[t].enabled)
|
if (!trace[t].enabled)
|
||||||
continue;
|
continue;
|
||||||
if (!trace[t].polar)
|
|
||||||
grid_mode |= GRID_RECTANGULAR;
|
|
||||||
else {
|
|
||||||
if (trace[t].type == TRC_SMITH)
|
if (trace[t].type == TRC_SMITH)
|
||||||
grid_mode |= GRID_SMITH;
|
grid_mode |= GRID_SMITH;
|
||||||
//else if (trace[t].type == TRC_ADMIT)
|
//else if (trace[t].type == TRC_ADMIT)
|
||||||
// grid_mode |= GRID_ADMIT;
|
// grid_mode |= GRID_ADMIT;
|
||||||
else
|
else if (trace[t].type == TRC_POLAR)
|
||||||
grid_mode |= GRID_POLAR;
|
grid_mode |= GRID_POLAR;
|
||||||
}
|
else
|
||||||
|
grid_mode |= GRID_RECTANGULAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
PULSE;
|
PULSE;
|
||||||
|
|
@ -1050,8 +1052,11 @@ draw_cell(int m, int n)
|
||||||
#if 1
|
#if 1
|
||||||
/* draw rectanglar plot */
|
/* draw rectanglar plot */
|
||||||
for (t = 0; t < TRACES_MAX; t++) {
|
for (t = 0; t < TRACES_MAX; t++) {
|
||||||
if (!trace[t].enabled || trace[t].polar)
|
if (!trace[t].enabled)
|
||||||
continue;
|
continue;
|
||||||
|
if (trace[t].type == TRC_SMITH || trace[t].type == TRC_POLAR)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (search_index_x(x0, trace_index[t], &i0, &i1)) {
|
if (search_index_x(x0, trace_index[t], &i0, &i1)) {
|
||||||
if (i0 > 0)
|
if (i0 > 0)
|
||||||
i0--;
|
i0--;
|
||||||
|
|
@ -1070,8 +1075,11 @@ draw_cell(int m, int n)
|
||||||
/* draw polar plot */
|
/* draw polar plot */
|
||||||
for (t = 0; t < TRACES_MAX; t++) {
|
for (t = 0; t < TRACES_MAX; t++) {
|
||||||
int c = config.trace_color[t];
|
int c = config.trace_color[t];
|
||||||
if (!trace[t].enabled || !trace[t].polar)
|
if (!trace[t].enabled)
|
||||||
continue;
|
continue;
|
||||||
|
if (trace[t].type != TRC_SMITH && trace[t].type != TRC_POLAR)
|
||||||
|
continue;
|
||||||
|
|
||||||
for (i = 1; i < 101; i++) {
|
for (i = 1; i < 101; i++) {
|
||||||
//uint32_t index = trace_index[t][i];
|
//uint32_t index = trace_index[t][i];
|
||||||
//uint32_t pindex = trace_index[t][i-1];
|
//uint32_t pindex = trace_index[t][i-1];
|
||||||
|
|
|
||||||
49
ui.c
49
ui.c
|
|
@ -412,6 +412,7 @@ menu_trace_cb(int item)
|
||||||
{
|
{
|
||||||
if (item < 0 || item >= 4)
|
if (item < 0 || item >= 4)
|
||||||
return;
|
return;
|
||||||
|
trace[item].enabled = TRUE;
|
||||||
uistat.current_trace = item;
|
uistat.current_trace = item;
|
||||||
menu_move_back();
|
menu_move_back();
|
||||||
}
|
}
|
||||||
|
|
@ -614,10 +615,10 @@ menu_cal_cb(int item)
|
||||||
|
|
||||||
|
|
||||||
const menuitem_t menu_trace[] = {
|
const menuitem_t menu_trace[] = {
|
||||||
{ MT_CALLBACK, "0", menu_trace_cb },
|
{ MT_CALLBACK, "TRACE 0", menu_trace_cb },
|
||||||
{ MT_CALLBACK, "1", menu_trace_cb },
|
{ MT_CALLBACK, "TRACE 1", menu_trace_cb },
|
||||||
{ MT_CALLBACK, "2", menu_trace_cb },
|
{ MT_CALLBACK, "TRACE 2", menu_trace_cb },
|
||||||
{ MT_CALLBACK, "3", menu_trace_cb },
|
{ MT_CALLBACK, "TRACE 3", menu_trace_cb },
|
||||||
{ MT_CALLBACK, "\2SINGLE\0TRACE", menu_single_trace_cb },
|
{ MT_CALLBACK, "\2SINGLE\0TRACE", menu_single_trace_cb },
|
||||||
{ MT_CANCEL, "BACK", NULL },
|
{ MT_CANCEL, "BACK", NULL },
|
||||||
{ MT_NONE, NULL, NULL } // sentinel
|
{ MT_NONE, NULL, NULL } // sentinel
|
||||||
|
|
@ -643,6 +644,15 @@ const menuitem_t menu_format[] = {
|
||||||
{ MT_NONE, NULL, NULL } // sentinel
|
{ 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[] = {
|
const menuitem_t menu_channel[] = {
|
||||||
{ MT_CALLBACK, "\2CH0\0REFLECT", menu_channel_cb },
|
{ MT_CALLBACK, "\2CH0\0REFLECT", menu_channel_cb },
|
||||||
{ MT_CALLBACK, "\2CH1\0THROUGH", menu_channel_cb },
|
{ MT_CALLBACK, "\2CH1\0THROUGH", menu_channel_cb },
|
||||||
|
|
@ -653,7 +663,7 @@ const menuitem_t menu_channel[] = {
|
||||||
const menuitem_t menu_display[] = {
|
const menuitem_t menu_display[] = {
|
||||||
{ MT_SUBMENU, "TRACE", menu_trace },
|
{ MT_SUBMENU, "TRACE", menu_trace },
|
||||||
{ MT_SUBMENU, "FORMAT", menu_format },
|
{ MT_SUBMENU, "FORMAT", menu_format },
|
||||||
{ MT_CALLBACK, "SCALE", menu_scale_cb },
|
{ MT_SUBMENU, "SCALE", menu_scale },
|
||||||
{ MT_SUBMENU, "CHANNEL", menu_channel },
|
{ MT_SUBMENU, "CHANNEL", menu_channel },
|
||||||
{ MT_CANCEL, "BACK", NULL },
|
{ MT_CANCEL, "BACK", NULL },
|
||||||
{ MT_NONE, NULL, NULL } // sentinel
|
{ MT_NONE, NULL, NULL } // sentinel
|
||||||
|
|
@ -838,7 +848,7 @@ draw_keypad(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *keypad_mode_label[] = {
|
const char *keypad_mode_label[] = {
|
||||||
"START", "STOP", "CENTER", "SPAN", "SCALE"
|
"START", "STOP", "CENTER", "SPAN", "CW FREQ", "SCALE"
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -875,6 +885,24 @@ menu_is_multiline(const char *label, const char **l1, const char **l2)
|
||||||
return TRUE;
|
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
|
void
|
||||||
draw_menu_buttons(const menuitem_t *menu)
|
draw_menu_buttons(const menuitem_t *menu)
|
||||||
{
|
{
|
||||||
|
|
@ -887,15 +915,18 @@ draw_menu_buttons(const menuitem_t *menu)
|
||||||
continue;
|
continue;
|
||||||
int y = 32*i;
|
int y = 32*i;
|
||||||
uint16_t bg = config.menu_normal_color;
|
uint16_t bg = config.menu_normal_color;
|
||||||
|
uint16_t fg = 0x0000;
|
||||||
// focus only in MENU mode but not in KEYPAD mode
|
// focus only in MENU mode but not in KEYPAD mode
|
||||||
if (ui_mode == UI_MENU && i == selection)
|
if (ui_mode == UI_MENU && i == selection)
|
||||||
bg = config.menu_active_color;
|
bg = config.menu_active_color;
|
||||||
ili9341_fill(320-60, y, 60, 30, bg);
|
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)) {
|
if (menu_is_multiline(menu[i].label, &l1, &l2)) {
|
||||||
ili9341_drawstring_5x7(l1, 320-54, y+8, 0x0000, bg);
|
ili9341_drawstring_5x7(l1, 320-54, y+8, fg, bg);
|
||||||
ili9341_drawstring_5x7(l2, 320-54, y+15, 0x0000, bg);
|
ili9341_drawstring_5x7(l2, 320-54, y+15, fg, bg);
|
||||||
} else {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue