mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
add marker command
This commit is contained in:
parent
be967b006c
commit
3eb8125086
41
main.c
41
main.c
|
|
@ -774,7 +774,6 @@ const char *trc_channel_name[] = {
|
|||
static void cmd_trace(BaseSequentialStream *chp, int argc, char *argv[])
|
||||
{
|
||||
int t;
|
||||
(void)chp;
|
||||
if (argc == 0) {
|
||||
for (t = 0; t < 4; t++) {
|
||||
if (trace[t].enabled) {
|
||||
|
|
@ -842,6 +841,45 @@ static void cmd_trace(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
chprintf(chp, "trace [n] [logmag|phase|smith|swr] [src]\r\n");
|
||||
}
|
||||
|
||||
static void cmd_marker(BaseSequentialStream *chp, int argc, char *argv[])
|
||||
{
|
||||
int t;
|
||||
if (argc == 0) {
|
||||
for (t = 0; t < 4; t++) {
|
||||
if (markers[t].enabled) {
|
||||
chprintf(chp, "%d %d\r\n", t+1, markers[t].index);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
t = atoi(argv[0])-1;
|
||||
if (t < 0 || t >= 4)
|
||||
goto usage;
|
||||
if (argc == 1) {
|
||||
chprintf(chp, "%d %d\r\n", t+1, markers[t].index);
|
||||
return;
|
||||
}
|
||||
if (argc > 1) {
|
||||
if (strcmp(argv[1], "off") == 0) {
|
||||
markers[t].enabled = FALSE;
|
||||
if (active_marker == t)
|
||||
active_marker = -1;
|
||||
} else if (strcmp(argv[1], "on") == 0) {
|
||||
markers[t].enabled = TRUE;
|
||||
active_marker = t;
|
||||
} else {
|
||||
markers[t].enabled = TRUE;
|
||||
int index = atoi(argv[1]);
|
||||
markers[t].index = index;
|
||||
active_marker = t;
|
||||
}
|
||||
}
|
||||
return;
|
||||
usage:
|
||||
chprintf(chp, "marker [n] [off|{index}]\r\n");
|
||||
}
|
||||
|
||||
|
||||
static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
|
@ -970,6 +1008,7 @@ static const ShellCommand commands[] =
|
|||
{ "save", cmd_save },
|
||||
{ "recall", cmd_recall },
|
||||
{ "trace", cmd_trace },
|
||||
{ "marker", cmd_marker },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -82,6 +82,14 @@ extern float measured[2][101][2];
|
|||
|
||||
void trace_get_info(int t, char *buf, int len);
|
||||
|
||||
typedef struct {
|
||||
int enabled;
|
||||
//uint32_t frequency;
|
||||
int index;
|
||||
} marker_t;
|
||||
|
||||
extern marker_t markers[4];
|
||||
extern int active_marker;
|
||||
|
||||
#define CAL_LOAD 0
|
||||
#define CAL_OPEN 1
|
||||
|
|
|
|||
15
plot.c
15
plot.c
|
|
@ -595,12 +595,6 @@ draw_marker(int w, int h, int x, int y, int c, int ch)
|
|||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int enabled;
|
||||
//uint32_t frequency;
|
||||
int index;
|
||||
} marker_t;
|
||||
|
||||
marker_t markers[4] = {
|
||||
{ 1, 30 }, { 0, 40 }, { 0, 60 }, { 0, 80 }
|
||||
};
|
||||
|
|
@ -623,7 +617,7 @@ cell_draw_markers(int m, int n, int w, int h)
|
|||
int x = CELL_X(index) - x0;
|
||||
int y = CELL_Y(index) - y0;
|
||||
if (x > -6 && x < w+6 && y >= 0 && y < h+12)
|
||||
draw_marker(w, h, x, y, trace[t].color, '1');
|
||||
draw_marker(w, h, x, y, trace[t].color, '1' + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -768,6 +762,8 @@ cell_draw_marker_info(int m, int n, int w, int h)
|
|||
{
|
||||
char buf[24];
|
||||
int t;
|
||||
if (active_marker < 0)
|
||||
return;
|
||||
if (n != 0 || m > 8)
|
||||
return;
|
||||
int idx = markers[active_marker].index;
|
||||
|
|
@ -787,10 +783,13 @@ cell_draw_marker_info(int m, int n, int w, int h)
|
|||
cell_drawstring_5x7(w, h, buf, xpos, ypos, trace[t].color);
|
||||
j++;
|
||||
}
|
||||
int xpos = 208;
|
||||
int xpos = 192;
|
||||
int ypos = 1 + (j/2)*7;
|
||||
xpos -= m * w;
|
||||
ypos -= n * h;
|
||||
chsnprintf(buf, sizeof buf, "%d:", active_marker + 1);
|
||||
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
|
||||
xpos += 16;
|
||||
frequency_string(buf, sizeof buf, frequencies[idx]);
|
||||
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
|
||||
#else
|
||||
|
|
|
|||
Loading…
Reference in a new issue