mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
add channel menu, narrow and ensure selection, reverse marker moving direction
This commit is contained in:
parent
4e55ca4f70
commit
d84a212a3b
2
Makefile
2
Makefile
|
|
@ -66,7 +66,7 @@ endif
|
||||||
# Stack size to the allocated to the Cortex-M main/exceptions stack. This
|
# Stack size to the allocated to the Cortex-M main/exceptions stack. This
|
||||||
# stack is used for processing interrupts and exceptions.
|
# stack is used for processing interrupts and exceptions.
|
||||||
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
|
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
|
||||||
USE_EXCEPTIONS_STACKSIZE = 0x280
|
USE_EXCEPTIONS_STACKSIZE = 0x200
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
||||||
16
main.c
16
main.c
|
|
@ -46,7 +46,7 @@ void scan_lcd(void);
|
||||||
static MUTEX_DECL(mutex);
|
static MUTEX_DECL(mutex);
|
||||||
|
|
||||||
|
|
||||||
static THD_WORKING_AREA(waThread1, 400);
|
static THD_WORKING_AREA(waThread1, 440);
|
||||||
static THD_FUNCTION(Thread1, arg)
|
static THD_FUNCTION(Thread1, arg)
|
||||||
{
|
{
|
||||||
(void)arg;
|
(void)arg;
|
||||||
|
|
@ -513,7 +513,7 @@ eterm_copy(int dst, int src)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct open_model {
|
const struct open_model {
|
||||||
float c0;
|
float c0;
|
||||||
float c1;
|
float c1;
|
||||||
float c2;
|
float c2;
|
||||||
|
|
@ -829,7 +829,7 @@ const char *trc_type_name[] = {
|
||||||
"LOGMAG", "PHASE", "SMITH", "ADMIT", "POLAR", "LINEAR", "SWR"
|
"LOGMAG", "PHASE", "SMITH", "ADMIT", "POLAR", "LINEAR", "SWR"
|
||||||
};
|
};
|
||||||
const char *trc_channel_name[] = {
|
const char *trc_channel_name[] = {
|
||||||
"S11", "S21"
|
"CH0", "CH1"
|
||||||
};
|
};
|
||||||
|
|
||||||
void set_trace_type(int t, int type)
|
void set_trace_type(int t, int type)
|
||||||
|
|
@ -856,6 +856,14 @@ void set_trace_type(int t, int type)
|
||||||
force_set_markmap();
|
force_set_markmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_trace_channel(int t, int channel)
|
||||||
|
{
|
||||||
|
if (trace[t].channel != channel) {
|
||||||
|
trace[t].channel = channel;
|
||||||
|
force_set_markmap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static float
|
static float
|
||||||
my_atof(const char *p)
|
my_atof(const char *p)
|
||||||
{
|
{
|
||||||
|
|
@ -1109,7 +1117,7 @@ static void cmd_stat(BaseSequentialStream *chp, int argc, char *argv[])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(400)
|
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(440)
|
||||||
static THD_WORKING_AREA(waThread2, SHELL_WA_SIZE);
|
static THD_WORKING_AREA(waThread2, SHELL_WA_SIZE);
|
||||||
|
|
||||||
static const ShellCommand commands[] =
|
static const ShellCommand commands[] =
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,7 @@ typedef struct {
|
||||||
//extern trace_t trace[TRACES_MAX];
|
//extern trace_t trace[TRACES_MAX];
|
||||||
|
|
||||||
void set_trace_type(int t, int type);
|
void set_trace_type(int t, int type);
|
||||||
|
void set_trace_channel(int t, int channel);
|
||||||
|
|
||||||
// marker
|
// marker
|
||||||
|
|
||||||
|
|
|
||||||
44
ui.c
44
ui.c
|
|
@ -245,6 +245,18 @@ static void
|
||||||
menu_format2_cb(int item)
|
menu_format2_cb(int item)
|
||||||
{
|
{
|
||||||
menu_format_cb(item + 5);
|
menu_format_cb(item + 5);
|
||||||
|
ui_status = FALSE;
|
||||||
|
ui_hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
menu_channel_cb(int item)
|
||||||
|
{
|
||||||
|
if (item < 0 || item >= 2)
|
||||||
|
return;
|
||||||
|
set_trace_channel(uistat.current_trace, item);
|
||||||
|
ui_status = FALSE;
|
||||||
|
ui_hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -324,10 +336,18 @@ const menuitem_t menu_format[] = {
|
||||||
{ MT_NONE, NULL, NULL } // sentinel
|
{ MT_NONE, NULL, NULL } // sentinel
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const menuitem_t menu_channel[] = {
|
||||||
|
{ MT_CALLBACK, "0", menu_channel_cb },
|
||||||
|
{ MT_CALLBACK, "1", menu_channel_cb },
|
||||||
|
{ MT_CANCEL, "BACK", NULL },
|
||||||
|
{ MT_NONE, NULL, NULL } // sentinel
|
||||||
|
};
|
||||||
|
|
||||||
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_SUBMENU, "SCALE", menu_format },
|
{ MT_SUBMENU, "SCALE", menu_format },
|
||||||
|
{ MT_SUBMENU, "CHANNEL", menu_channel },
|
||||||
{ MT_CANCEL, "BACK", NULL },
|
{ MT_CANCEL, "BACK", NULL },
|
||||||
{ MT_NONE, NULL, NULL } // sentinel
|
{ MT_NONE, NULL, NULL } // sentinel
|
||||||
};
|
};
|
||||||
|
|
@ -366,11 +386,23 @@ const menuitem_t *menu_stack[4] = {
|
||||||
menu_top, NULL, NULL, NULL
|
menu_top, NULL, NULL, NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
ensure_selection(void)
|
||||||
|
{
|
||||||
|
const menuitem_t *menu = menu_stack[menu_current_level];
|
||||||
|
int i;
|
||||||
|
for (i = 0; menu[i].type != MT_NONE; i++)
|
||||||
|
;
|
||||||
|
if (selection >= i)
|
||||||
|
selection = i-1;
|
||||||
|
}
|
||||||
|
|
||||||
static void menu_move_back(void)
|
static void menu_move_back(void)
|
||||||
{
|
{
|
||||||
if (menu_current_level == 0)
|
if (menu_current_level == 0)
|
||||||
return;
|
return;
|
||||||
menu_current_level--;
|
menu_current_level--;
|
||||||
|
ensure_selection();
|
||||||
erase_buttons();
|
erase_buttons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -379,6 +411,7 @@ static void menu_move_top(void)
|
||||||
if (menu_current_level == 0)
|
if (menu_current_level == 0)
|
||||||
return;
|
return;
|
||||||
menu_current_level = 0;
|
menu_current_level = 0;
|
||||||
|
ensure_selection();
|
||||||
erase_buttons();
|
erase_buttons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -412,6 +445,7 @@ void menu_invoke(int selection)
|
||||||
break;
|
break;
|
||||||
menu_current_level++;
|
menu_current_level++;
|
||||||
menu_stack[menu_current_level] = (const menuitem_t*)menu->reference;
|
menu_stack[menu_current_level] = (const menuitem_t*)menu->reference;
|
||||||
|
erase_buttons();
|
||||||
selection = 0;
|
selection = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -503,22 +537,24 @@ ui_process(void)
|
||||||
ui_show();
|
ui_show();
|
||||||
} else {
|
} else {
|
||||||
if (ui_status) {
|
if (ui_status) {
|
||||||
if (status & EVT_UP) {
|
if (status & EVT_UP
|
||||||
|
&& menu_stack[menu_current_level][selection+1].type != MT_NONE) {
|
||||||
selection++;
|
selection++;
|
||||||
draw_buttons();
|
draw_buttons();
|
||||||
}
|
}
|
||||||
if (status & EVT_DOWN) {
|
if (status & EVT_DOWN
|
||||||
|
&& selection > 0) {
|
||||||
selection--;
|
selection--;
|
||||||
draw_buttons();
|
draw_buttons();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
if (active_marker >= 0 && markers[active_marker].enabled) {
|
if (active_marker >= 0 && markers[active_marker].enabled) {
|
||||||
if ((status & EVT_UP) && markers[active_marker].index > 0) {
|
if ((status & EVT_DOWN) && markers[active_marker].index > 0) {
|
||||||
markers[active_marker].index--;
|
markers[active_marker].index--;
|
||||||
redraw_marker(active_marker, FALSE);
|
redraw_marker(active_marker, FALSE);
|
||||||
}
|
}
|
||||||
if ((status & EVT_DOWN) && markers[active_marker].index < 100) {
|
if ((status & EVT_UP) && markers[active_marker].index < 100) {
|
||||||
markers[active_marker].index++;
|
markers[active_marker].index++;
|
||||||
redraw_marker(active_marker, FALSE);
|
redraw_marker(active_marker, FALSE);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue