mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
add CW, mod freq from limits
This commit is contained in:
parent
52dce51f31
commit
aa91bc23fc
40
main.c
40
main.c
|
|
@ -494,6 +494,9 @@ freq_mode_centerspan(void)
|
|||
}
|
||||
|
||||
|
||||
#define START_MIN 500000
|
||||
#define STOP_MAX 300000000
|
||||
|
||||
void
|
||||
set_sweep_frequency(int type, int frequency)
|
||||
{
|
||||
|
|
@ -501,6 +504,8 @@ set_sweep_frequency(int type, int frequency)
|
|||
case ST_START:
|
||||
ensure_edit_config();
|
||||
freq_mode_startstop();
|
||||
if (frequency < START_MIN)
|
||||
frequency = START_MIN;
|
||||
if (freq_start != frequency) {
|
||||
freq_start = frequency;
|
||||
update_frequencies();
|
||||
|
|
@ -509,6 +514,8 @@ set_sweep_frequency(int type, int frequency)
|
|||
case ST_STOP:
|
||||
ensure_edit_config();
|
||||
freq_mode_startstop();
|
||||
if (frequency > STOP_MAX)
|
||||
frequency = STOP_MAX;
|
||||
if (freq_stop != frequency) {
|
||||
freq_stop = frequency;
|
||||
update_frequencies();
|
||||
|
|
@ -519,6 +526,16 @@ set_sweep_frequency(int type, int frequency)
|
|||
freq_mode_centerspan();
|
||||
if (freq_start != frequency) {
|
||||
freq_start = frequency;
|
||||
int center = freq_start;
|
||||
int span = -freq_stop;
|
||||
if (center-span/2 < START_MIN) {
|
||||
span = (center - START_MIN) * 2;
|
||||
freq_stop = -span;
|
||||
}
|
||||
if (center+span/2 > STOP_MAX) {
|
||||
span = (STOP_MAX - center) * 2;
|
||||
freq_stop = -span;
|
||||
}
|
||||
update_frequencies();
|
||||
}
|
||||
break;
|
||||
|
|
@ -527,6 +544,25 @@ set_sweep_frequency(int type, int frequency)
|
|||
freq_mode_centerspan();
|
||||
if (freq_stop != -frequency) {
|
||||
freq_stop = -frequency;
|
||||
int center = freq_start;
|
||||
int span = -freq_stop;
|
||||
if (center-span/2 < START_MIN) {
|
||||
center = START_MIN + span/2;
|
||||
freq_start = center;
|
||||
}
|
||||
if (center+span/2 > STOP_MAX) {
|
||||
center = STOP_MAX - span/2;
|
||||
freq_start = center;
|
||||
}
|
||||
update_frequencies();
|
||||
}
|
||||
break;
|
||||
case ST_CW:
|
||||
ensure_edit_config();
|
||||
freq_mode_centerspan();
|
||||
if (freq_start != frequency || freq_stop != 0) {
|
||||
freq_start = frequency;
|
||||
freq_stop = 0;
|
||||
update_frequencies();
|
||||
}
|
||||
break;
|
||||
|
|
@ -559,6 +595,10 @@ static void cmd_sweep(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
int32_t value = atoi(argv[1]);
|
||||
set_sweep_frequency(ST_SPAN, value);
|
||||
return;
|
||||
} else if (strcmp(argv[0], "cw") == 0) {
|
||||
int32_t value = atoi(argv[1]);
|
||||
set_sweep_frequency(ST_CW, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ void cal_collect(int type);
|
|||
void cal_done(void);
|
||||
|
||||
enum {
|
||||
ST_START, ST_STOP, ST_CENTER, ST_SPAN
|
||||
ST_START, ST_STOP, ST_CENTER, ST_SPAN, ST_CW
|
||||
};
|
||||
|
||||
void set_sweep_frequency(int type, int frequency);
|
||||
|
|
|
|||
11
plot.c
11
plot.c
|
|
@ -1251,7 +1251,7 @@ draw_frequencies(void)
|
|||
(int)((fstop / 1000) % 1000),
|
||||
(int)(fstop % 1000));
|
||||
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
|
||||
} else {
|
||||
} else if (fstop < 0) {
|
||||
int fcenter = fstart;
|
||||
int fspan = -fstop;
|
||||
chsnprintf(buf, 24, "CENTER %d.%03d %03d MHz ",
|
||||
|
|
@ -1264,6 +1264,15 @@ draw_frequencies(void)
|
|||
(int)((fspan / 1000) % 1000),
|
||||
(int)(fspan % 1000));
|
||||
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
|
||||
} else {
|
||||
int fcenter = fstart;
|
||||
chsnprintf(buf, 24, "CW %d.%03d %03d MHz ",
|
||||
(int)(fcenter / 1000000),
|
||||
(int)((fcenter / 1000) % 1000),
|
||||
(int)(fcenter % 1000));
|
||||
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
|
||||
chsnprintf(buf, 24, " ");
|
||||
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
7
ui.c
7
ui.c
|
|
@ -60,7 +60,7 @@ enum {
|
|||
};
|
||||
|
||||
enum {
|
||||
KM_START, KM_STOP, KM_CENTER, KM_SPAN, KM_SCALE
|
||||
KM_START, KM_STOP, KM_CENTER, KM_SPAN, KM_CW, KM_SCALE
|
||||
};
|
||||
|
||||
uint8_t ui_mode = UI_NORMAL;
|
||||
|
|
@ -305,6 +305,7 @@ menu_stimulus_cb(int item)
|
|||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
ui_mode_keypad(item);
|
||||
ui_process_keypad();
|
||||
break;
|
||||
|
|
@ -410,6 +411,7 @@ const menuitem_t menu_stimulus[] = {
|
|||
{ MT_CALLBACK, "STOP", menu_stimulus_cb },
|
||||
{ MT_CALLBACK, "CENTER", menu_stimulus_cb },
|
||||
{ MT_CALLBACK, "SPAN", menu_stimulus_cb },
|
||||
{ MT_CALLBACK, "CW", menu_stimulus_cb },
|
||||
{ MT_CANCEL, "BACK", NULL },
|
||||
{ MT_NONE, NULL, NULL } // sentinel
|
||||
};
|
||||
|
|
@ -805,6 +807,9 @@ ui_process_keypad(void)
|
|||
case KM_SPAN:
|
||||
set_sweep_frequency(ST_SPAN, value);
|
||||
break;
|
||||
case KM_CW:
|
||||
set_sweep_frequency(ST_CW, value);
|
||||
break;
|
||||
case KM_SCALE:
|
||||
set_trace_scale(uistat.current_trace, value);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in a new issue