mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
update marker position on sweep frequency change
This commit is contained in:
parent
a20f3770da
commit
5a441edc6b
|
|
@ -27,7 +27,7 @@ Otherwise, use toolchains included inside LPCxpresso. Like this.
|
|||
|
||||
$ PATH=$PATH:/Applications/lpcxpresso_7.8.0_426/lpcxpresso/tools/bin
|
||||
|
||||
## Build the firmware
|
||||
## Build firmware
|
||||
|
||||
Fetch ChibiOS submodule into tree.
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ Just make in the top directory.
|
|||
|
||||
$ make
|
||||
|
||||
## Burn the firmware
|
||||
## Flash firmware
|
||||
|
||||
Boot MCU in DFU mode. To do this, jumper BOOT0 pin at powering device.
|
||||
Then, burn firmware using dfu-util via USB.
|
||||
|
|
|
|||
41
main.c
41
main.c
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
static void apply_error_term(void);
|
||||
static void apply_error_term_at(int i);
|
||||
static void cal_interpolate(int s);
|
||||
|
||||
void sweep(void);
|
||||
|
||||
|
|
@ -400,7 +401,7 @@ properties_t current_props = {
|
|||
{ 1, TRC_PHASE, 1, 0, 1.0, 4.0 }
|
||||
},
|
||||
/* markers[4] */ {
|
||||
{ 1, 30 }, { 0, 40 }, { 0, 60 }, { 0, 80 }
|
||||
{ 1, 30, 0 }, { 0, 40, 0 }, { 0, 60, 0 }, { 0, 80, 0 }
|
||||
},
|
||||
/* active_marker */ 0,
|
||||
/* checksum */ 0
|
||||
|
|
@ -495,6 +496,37 @@ void sweep(void)
|
|||
// apply_error_term();
|
||||
}
|
||||
|
||||
static void
|
||||
update_marker_index(void)
|
||||
{
|
||||
int m;
|
||||
int i;
|
||||
for (m = 0; m < 4; m++) {
|
||||
if (!markers[m].enabled)
|
||||
continue;
|
||||
uint32_t f = markers[m].frequency;
|
||||
if (f < frequencies[0]) {
|
||||
markers[m].index = 0;
|
||||
markers[m].frequency = frequencies[0];
|
||||
} else if (f >= frequencies[sweep_points-1]) {
|
||||
markers[m].index = sweep_points-1;
|
||||
markers[m].frequency = frequencies[sweep_points-1];
|
||||
} else {
|
||||
for (i = 0; i < sweep_points-1; i++) {
|
||||
if (frequencies[i] <= f && f < frequencies[i+1]) {
|
||||
uint32_t mid = (frequencies[i] + frequencies[i+1])/2;
|
||||
if (f < mid) {
|
||||
markers[m].index = i;
|
||||
} else {
|
||||
markers[m].index = i + 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
update_frequencies(void)
|
||||
{
|
||||
|
|
@ -517,6 +549,8 @@ update_frequencies(void)
|
|||
if (cal_auto_interpolate)
|
||||
cal_interpolate(0);
|
||||
|
||||
update_marker_index();
|
||||
|
||||
frequency_updated = TRUE;
|
||||
// set grid layout
|
||||
update_grid();
|
||||
|
|
@ -1287,7 +1321,7 @@ static void cmd_marker(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
if (argc == 0) {
|
||||
for (t = 0; t < 4; t++) {
|
||||
if (markers[t].enabled) {
|
||||
chprintf(chp, "%d %d\r\n", t+1, markers[t].index);
|
||||
chprintf(chp, "%d %d %d\r\n", t+1, markers[t].index, markers[t].frequency);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
@ -1303,7 +1337,7 @@ static void cmd_marker(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
if (t < 0 || t >= 4)
|
||||
goto usage;
|
||||
if (argc == 1) {
|
||||
chprintf(chp, "%d %d\r\n", t+1, markers[t].index);
|
||||
chprintf(chp, "%d %d %d\r\n", t+1, markers[t].index, frequency);
|
||||
active_marker = t;
|
||||
markers[t].enabled = TRUE;
|
||||
return;
|
||||
|
|
@ -1320,6 +1354,7 @@ static void cmd_marker(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
markers[t].enabled = TRUE;
|
||||
int index = atoi(argv[1]);
|
||||
markers[t].index = index;
|
||||
markers[t].frequency = frequencies[index];
|
||||
active_marker = t;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,9 +195,9 @@ void set_trace_refpos(int t, float refpos);
|
|||
// marker
|
||||
|
||||
typedef struct {
|
||||
int enabled;
|
||||
//uint32_t frequency;
|
||||
int index;
|
||||
int8_t enabled;
|
||||
int16_t index;
|
||||
uint32_t frequency;
|
||||
} marker_t;
|
||||
|
||||
//extern marker_t markers[4];
|
||||
|
|
|
|||
14
ui.c
14
ui.c
|
|
@ -645,6 +645,7 @@ menu_marker_op_cb(int item)
|
|||
break;
|
||||
}
|
||||
ui_mode_normal();
|
||||
draw_cal_status();
|
||||
//redraw_all();
|
||||
}
|
||||
|
||||
|
|
@ -702,7 +703,6 @@ const menuitem_t menu_cal[] = {
|
|||
{ MT_SUBMENU, "CALIBRATE", menu_calop },
|
||||
{ MT_CALLBACK, "RESET", menu_cal2_cb },
|
||||
{ MT_CALLBACK, "CORRECTION", menu_cal2_cb },
|
||||
{ MT_SUBMENU, "SAVE", menu_save },
|
||||
{ MT_CANCEL, "BACK", NULL },
|
||||
{ MT_NONE, NULL, NULL } // sentinel
|
||||
};
|
||||
|
|
@ -805,6 +805,12 @@ const menuitem_t menu_recall[] = {
|
|||
{ MT_CALLBACK, "RECALL 2", menu_recall_cb },
|
||||
{ MT_CALLBACK, "RECALL 3", menu_recall_cb },
|
||||
{ MT_CALLBACK, "RECALL 4", menu_recall_cb },
|
||||
{ MT_CANCEL, "BACK", NULL },
|
||||
{ MT_NONE, NULL, NULL } // sentinel
|
||||
};
|
||||
|
||||
const menuitem_t menu_recall_save[] = {
|
||||
{ MT_SUBMENU, "RECALL", menu_recall },
|
||||
{ MT_SUBMENU, "SAVE", menu_save },
|
||||
{ MT_CANCEL, "BACK", NULL },
|
||||
{ MT_NONE, NULL, NULL } // sentinel
|
||||
|
|
@ -815,7 +821,7 @@ const menuitem_t menu_top[] = {
|
|||
{ MT_SUBMENU, "MARKER", menu_marker },
|
||||
{ MT_SUBMENU, "STIMULUS", menu_stimulus },
|
||||
{ MT_SUBMENU, "CAL", menu_cal },
|
||||
{ MT_SUBMENU, "\2RECALL\0/SAVE", menu_recall },
|
||||
{ MT_SUBMENU, "\2RECALL\0SAVE", menu_recall_save },
|
||||
{ MT_CLOSE, "CLOSE", NULL },
|
||||
{ MT_NONE, NULL, NULL } // sentinel
|
||||
};
|
||||
|
|
@ -1176,10 +1182,12 @@ ui_process_normal(void)
|
|||
if (active_marker >= 0 && markers[active_marker].enabled) {
|
||||
if ((status & EVT_DOWN) && markers[active_marker].index > 0) {
|
||||
markers[active_marker].index--;
|
||||
markers[active_marker].frequency = frequencies[markers[active_marker].index];
|
||||
redraw_marker(active_marker, FALSE);
|
||||
}
|
||||
if ((status & EVT_UP) && markers[active_marker].index < 100) {
|
||||
markers[active_marker].index++;
|
||||
markers[active_marker].frequency = frequencies[markers[active_marker].index];
|
||||
redraw_marker(active_marker, FALSE);
|
||||
}
|
||||
}
|
||||
|
|
@ -1384,6 +1392,7 @@ void drag_marker(int t, int m)
|
|||
index = search_nearest_index(touch_x, touch_y, t);
|
||||
if (index >= 0) {
|
||||
markers[m].index = index;
|
||||
markers[m].frequency = frequencies[index];
|
||||
redraw_marker(m, TRUE);
|
||||
}
|
||||
|
||||
|
|
@ -1419,6 +1428,7 @@ touch_pickup_marker(void)
|
|||
|
||||
if (sq_distance(x - touch_x, y - touch_y) < 400) {
|
||||
if (active_marker != m) {
|
||||
previous_marker = active_marker;
|
||||
active_marker = m;
|
||||
redraw_marker(active_marker, TRUE);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue