mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
draw delta frequency of two markers
This commit is contained in:
parent
95b3ac2a4b
commit
c121731b04
|
|
@ -275,6 +275,8 @@ extern int16_t lastsaveid;
|
||||||
extern properties_t *active_props;
|
extern properties_t *active_props;
|
||||||
extern properties_t current_props;
|
extern properties_t current_props;
|
||||||
|
|
||||||
|
extern uint8_t previous_marker;
|
||||||
|
|
||||||
#define frequency0 current_props._frequency0
|
#define frequency0 current_props._frequency0
|
||||||
#define frequency1 current_props._frequency1
|
#define frequency1 current_props._frequency1
|
||||||
#define sweep_points current_props._sweep_points
|
#define sweep_points current_props._sweep_points
|
||||||
|
|
|
||||||
55
plot.c
55
plot.c
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
void cell_draw_marker_info(int m, int n, int w, int h);
|
void cell_draw_marker_info(int m, int n, int w, int h);
|
||||||
void draw_frequencies(void);
|
void draw_frequencies(void);
|
||||||
void frequency_string(char *buf, size_t len, uint32_t freq);
|
void frequency_string(char *buf, size_t len, int32_t freq);
|
||||||
void markmap_all_markers(void);
|
void markmap_all_markers(void);
|
||||||
|
|
||||||
//#define GRID_COLOR 0x0863
|
//#define GRID_COLOR 0x0863
|
||||||
|
|
@ -1266,15 +1266,40 @@ cell_draw_marker_info(int m, int n, int w, int h)
|
||||||
xpos += 16;
|
xpos += 16;
|
||||||
frequency_string(buf, sizeof buf, frequencies[idx]);
|
frequency_string(buf, sizeof buf, frequencies[idx]);
|
||||||
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
|
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
|
||||||
|
|
||||||
|
if (active_marker != previous_marker && markers[previous_marker].enabled) {
|
||||||
|
int idx0 = markers[previous_marker].index;
|
||||||
|
xpos = 192;
|
||||||
|
xpos -= m * CELLWIDTH -CELLOFFSETX;
|
||||||
|
ypos += 7;
|
||||||
|
chsnprintf(buf, sizeof buf, "\001%d:", previous_marker+1);
|
||||||
|
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
|
||||||
|
xpos += 16;
|
||||||
|
frequency_string(buf, sizeof buf, frequencies[idx] - frequencies[idx0]);
|
||||||
|
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
frequency_string(char *buf, size_t len, uint32_t freq)
|
frequency_string(char *buf, size_t len, int32_t freq)
|
||||||
{
|
{
|
||||||
chsnprintf(buf, len, "%d.%03d %03d MHz",
|
if (freq < 0) {
|
||||||
|
freq = -freq;
|
||||||
|
*buf++ = '-';
|
||||||
|
len -= 1;
|
||||||
|
}
|
||||||
|
if (freq < 1000) {
|
||||||
|
chsnprintf(buf, len, "%d Hz", (int)freq);
|
||||||
|
} else if (freq < 1000000) {
|
||||||
|
chsnprintf(buf, len, "%d.%03d kHz",
|
||||||
|
(int)(freq / 1000),
|
||||||
|
(int)(freq % 1000));
|
||||||
|
} else {
|
||||||
|
chsnprintf(buf, len, "%d.%03d %03d MHz",
|
||||||
(int)(freq / 1000000),
|
(int)(freq / 1000000),
|
||||||
(int)((freq / 1000) % 1000),
|
(int)((freq / 1000) % 1000),
|
||||||
(int)(freq % 1000));
|
(int)(freq % 1000));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -1284,28 +1309,20 @@ draw_frequencies(void)
|
||||||
if (frequency1 > 0) {
|
if (frequency1 > 0) {
|
||||||
int start = frequency0;
|
int start = frequency0;
|
||||||
int stop = frequency1;
|
int stop = frequency1;
|
||||||
chsnprintf(buf, 24, "START %d.%03d %03d MHz ",
|
strcpy(buf, "START ");
|
||||||
(int)(start / 1000000),
|
frequency_string(buf+6, 24-6, start);
|
||||||
(int)((start / 1000) % 1000),
|
|
||||||
(int)(start % 1000));
|
|
||||||
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
|
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
|
||||||
chsnprintf(buf, 24, "STOP %d.%03d %03d MHz",
|
strcpy(buf, "STOP ");
|
||||||
(int)(stop / 1000000),
|
frequency_string(buf+5, 24-5, stop);
|
||||||
(int)((stop / 1000) % 1000),
|
|
||||||
(int)(stop % 1000));
|
|
||||||
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
|
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
|
||||||
} else if (frequency1 < 0) {
|
} else if (frequency1 < 0) {
|
||||||
int fcenter = frequency0;
|
int fcenter = frequency0;
|
||||||
int fspan = -frequency1;
|
int fspan = -frequency1;
|
||||||
chsnprintf(buf, 24, "CENTER %d.%03d %03d MHz ",
|
strcpy(buf, "CENTER ");
|
||||||
(int)(fcenter / 1000000),
|
frequency_string(buf+7, 24-7, fcenter);
|
||||||
(int)((fcenter / 1000) % 1000),
|
|
||||||
(int)(fcenter % 1000));
|
|
||||||
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
|
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
|
||||||
chsnprintf(buf, 24, "SPAN %d.%03d %03d MHz",
|
strcpy(buf, "SPAN ");
|
||||||
(int)(fspan / 1000000),
|
frequency_string(buf+5, 24-5, fspan);
|
||||||
(int)((fspan / 1000) % 1000),
|
|
||||||
(int)(fspan % 1000));
|
|
||||||
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
|
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
|
||||||
} else {
|
} else {
|
||||||
int fcenter = frequency0;
|
int fcenter = frequency0;
|
||||||
|
|
|
||||||
8
ui.c
8
ui.c
|
|
@ -60,6 +60,8 @@ static uint32_t last_button_repeat_ticks;
|
||||||
enum { OP_NONE = 0, OP_LEVER, OP_TOUCH };
|
enum { OP_NONE = 0, OP_LEVER, OP_TOUCH };
|
||||||
uint8_t operation_requested = OP_NONE;
|
uint8_t operation_requested = OP_NONE;
|
||||||
|
|
||||||
|
uint8_t previous_marker = 0;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
UI_NORMAL, UI_MENU, UI_KEYPAD
|
UI_NORMAL, UI_MENU, UI_KEYPAD
|
||||||
};
|
};
|
||||||
|
|
@ -630,8 +632,11 @@ menu_marker_sel_cb(int item)
|
||||||
if (item >= 0 && item < 4) {
|
if (item >= 0 && item < 4) {
|
||||||
if (active_marker == item) {
|
if (active_marker == item) {
|
||||||
markers[active_marker].enabled = FALSE;
|
markers[active_marker].enabled = FALSE;
|
||||||
choose_active_marker();
|
active_marker = previous_marker;
|
||||||
|
previous_marker = 0;
|
||||||
|
//choose_active_marker();
|
||||||
} else {
|
} else {
|
||||||
|
previous_marker = active_marker;
|
||||||
active_marker = item;
|
active_marker = item;
|
||||||
markers[active_marker].enabled = TRUE;
|
markers[active_marker].enabled = TRUE;
|
||||||
}
|
}
|
||||||
|
|
@ -641,6 +646,7 @@ menu_marker_sel_cb(int item)
|
||||||
markers[1].enabled = FALSE;
|
markers[1].enabled = FALSE;
|
||||||
markers[2].enabled = FALSE;
|
markers[2].enabled = FALSE;
|
||||||
markers[3].enabled = FALSE;
|
markers[3].enabled = FALSE;
|
||||||
|
previous_marker = 0;
|
||||||
active_marker = -1;
|
active_marker = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue