mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2026-01-03 15:09:58 +01:00
Add variable sweep point support
This commit is contained in:
parent
11ce58a9af
commit
23475a75c4
25
main.c
25
main.c
|
|
@ -736,7 +736,7 @@ void load_default_properties(void)
|
|||
//current_props.magic = CONFIG_MAGIC;
|
||||
current_props._frequency0 = 50000; // start = 50kHz
|
||||
current_props._frequency1 = 900000000; // end = 900MHz
|
||||
current_props._sweep_points = POINTS_COUNT;
|
||||
current_props._sweep_points = POINTS_SET_101; // Set default 101 points
|
||||
current_props._cal_status = 0;
|
||||
//This data not loaded by default
|
||||
//current_props._cal_data[5][POINTS_COUNT][2];
|
||||
|
|
@ -900,6 +900,17 @@ result:
|
|||
shell_printf("bandwidth %d (%uHz)\r\n", config.bandwidth, get_bandwidth_frequency());
|
||||
}
|
||||
|
||||
void set_sweep_points(uint16_t points){
|
||||
if (points == sweep_points || points > POINTS_COUNT)
|
||||
return;
|
||||
|
||||
sweep_points = points;
|
||||
update_frequencies();
|
||||
|
||||
if (cal_auto_interpolate && (cal_status & CALSTAT_APPLY))
|
||||
cal_interpolate(lastsaveid);
|
||||
}
|
||||
|
||||
VNA_SHELL_FUNCTION(cmd_scan)
|
||||
{
|
||||
uint32_t start, stop;
|
||||
|
|
@ -922,6 +933,7 @@ VNA_SHELL_FUNCTION(cmd_scan)
|
|||
shell_printf("sweep points exceeds range "define_to_STR(POINTS_COUNT)"\r\n");
|
||||
return;
|
||||
}
|
||||
sweep_points = points;
|
||||
}
|
||||
|
||||
set_frequencies(start, stop, points);
|
||||
|
|
@ -1110,8 +1122,10 @@ VNA_SHELL_FUNCTION(cmd_sweep)
|
|||
}
|
||||
uint32_t value0 = 0;
|
||||
uint32_t value1 = 0;
|
||||
uint32_t value2 = 0;
|
||||
if (argc >= 1) value0 = my_atoui(argv[0]);
|
||||
if (argc >= 2) value1 = my_atoui(argv[1]);
|
||||
if (argc >= 3) value2 = my_atoui(argv[2]);
|
||||
#if MAX_FREQ_TYPE != 5
|
||||
#error "Sweep mode possibly changed, check cmd_sweep function"
|
||||
#endif
|
||||
|
|
@ -1130,9 +1144,11 @@ VNA_SHELL_FUNCTION(cmd_sweep)
|
|||
set_sweep_frequency(ST_START, value0);
|
||||
if (value1)
|
||||
set_sweep_frequency(ST_STOP, value1);
|
||||
if (value2)
|
||||
set_sweep_points(value2);
|
||||
return;
|
||||
usage:
|
||||
shell_printf("usage: sweep {start(Hz)} [stop(Hz)]\r\n"\
|
||||
shell_printf("usage: sweep {start(Hz)} [stop(Hz)] [points]\r\n"\
|
||||
"\tsweep {%s} {freq(Hz)}\r\n", sweep_cmd);
|
||||
}
|
||||
|
||||
|
|
@ -1401,6 +1417,11 @@ cal_collect(int type)
|
|||
uint8_t bw = config.bandwidth; // store current setting
|
||||
if (bw < BANDWIDTH_100)
|
||||
config.bandwidth = BANDWIDTH_100;
|
||||
|
||||
// Set MAX settings for sweep_points on calibrate
|
||||
// if (sweep_points != POINTS_COUNT)
|
||||
// set_sweep_points(POINTS_COUNT);
|
||||
|
||||
sweep(false);
|
||||
config.bandwidth = bw; // restore
|
||||
// Copy calibration data
|
||||
|
|
|
|||
2
plot.c
2
plot.c
|
|
@ -1614,7 +1614,7 @@ draw_frequencies(void)
|
|||
buf2[0] = S_SARROW[0];
|
||||
ili9341_drawstring(buf1, FREQUENCIES_XPOS1, FREQUENCIES_YPOS);
|
||||
ili9341_drawstring(buf2, FREQUENCIES_XPOS2, FREQUENCIES_YPOS);
|
||||
plot_printf(buf1, sizeof(buf1), "bw:%uHz", get_bandwidth_frequency());
|
||||
plot_printf(buf1, sizeof(buf1), "bw:%uHz %up", get_bandwidth_frequency(), sweep_points);
|
||||
ili9341_set_foreground(DEFAULT_GRID_COLOR);
|
||||
ili9341_drawstring(buf1, FREQUENCIES_XPOS3, FREQUENCIES_YPOS);
|
||||
}
|
||||
|
|
|
|||
26
ui.c
26
ui.c
|
|
@ -43,8 +43,8 @@ uistat_t uistat = {
|
|||
|
||||
#define BUTTON_DOWN_LONG_TICKS 5000 /* 1sec */
|
||||
#define BUTTON_DOUBLE_TICKS 2500 /* 500ms */
|
||||
#define BUTTON_REPEAT_TICKS 500 /* 100ms */
|
||||
#define BUTTON_DEBOUNCE_TICKS 400 /* 80ms */
|
||||
#define BUTTON_REPEAT_TICKS 200 /* 40ms */
|
||||
#define BUTTON_DEBOUNCE_TICKS 100 /* 20ms */
|
||||
|
||||
/* lever switch assignment */
|
||||
#define BIT_UP1 3
|
||||
|
|
@ -485,7 +485,7 @@ menu_config_cb(int item, uint8_t data)
|
|||
case 1:
|
||||
touch_draw_test();
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
show_version();
|
||||
break;
|
||||
}
|
||||
|
|
@ -628,6 +628,14 @@ menu_bandwidth_cb(int item, uint8_t data)
|
|||
draw_menu();
|
||||
}
|
||||
|
||||
static void
|
||||
menu_points_cb(int item, uint8_t data)
|
||||
{
|
||||
(void)item;
|
||||
set_sweep_points(data);
|
||||
draw_menu();
|
||||
}
|
||||
|
||||
static void
|
||||
choose_active_marker(void)
|
||||
{
|
||||
|
|
@ -946,6 +954,13 @@ const menuitem_t menu_display[] = {
|
|||
{ MT_NONE, 0, NULL, NULL } // sentinel
|
||||
};
|
||||
|
||||
const menuitem_t menu_sweep_points[] = {
|
||||
{ MT_CALLBACK, POINTS_SET_51, " 51 points", menu_points_cb },
|
||||
{ MT_CALLBACK, POINTS_SET_101, "101 points", menu_points_cb },
|
||||
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
||||
{ MT_NONE, 0, NULL, NULL } // sentinel
|
||||
};
|
||||
|
||||
const menuitem_t menu_stimulus[] = {
|
||||
{ MT_CALLBACK, 0, "START", menu_stimulus_cb },
|
||||
{ MT_CALLBACK, 0, "STOP", menu_stimulus_cb },
|
||||
|
|
@ -1383,6 +1398,11 @@ menu_item_modify_attribute(const menuitem_t *menu, int item,
|
|||
*bg = 0x0000;
|
||||
*fg = 0xffff;
|
||||
}
|
||||
} else if (menu == menu_sweep_points) {
|
||||
if (menu_sweep_points[item].data == sweep_points) {
|
||||
*bg = 0x0000;
|
||||
*fg = 0xffff;
|
||||
}
|
||||
} else if (menu == menu_transform) {
|
||||
if ((item == 0 && (domain_mode & DOMAIN_MODE) == DOMAIN_TIME)
|
||||
|| (item == 1 && (domain_mode & TD_FUNC) == TD_FUNC_LOWPASS_IMPULSE)
|
||||
|
|
|
|||
Loading…
Reference in a new issue