mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
feat: change the operations to select lever mode
This commit is contained in:
parent
fb3c9cf82f
commit
93d1233d8b
4
main.c
4
main.c
|
|
@ -914,9 +914,9 @@ set_sweep_frequency(int type, uint32_t freq)
|
|||
break;
|
||||
case ST_CENTER:
|
||||
freq_mode_centerspan();
|
||||
uint32_t center = frequency0/2 + frequency1/2;
|
||||
uint32_t center = FREQ_CENTER();
|
||||
if (center != freq) {
|
||||
uint32_t span = frequency0 - frequency1;
|
||||
uint32_t span = FREQ_SPAN();
|
||||
ensure_edit_config();
|
||||
if (freq < START_MIN + span/2) {
|
||||
span = (freq - START_MIN) * 2;
|
||||
|
|
|
|||
|
|
@ -371,6 +371,14 @@ extern properties_t current_props;
|
|||
#define velocity_factor current_props._velocity_factor
|
||||
#define marker_smith_format current_props._marker_smith_format
|
||||
|
||||
#define FREQ_IS_STARTSTOP() (frequency0 < frequency1)
|
||||
#define FREQ_IS_CENTERSPAN() (frequency0 > frequency1)
|
||||
#define FREQ_IS_CW() (frequency0 == frequency1)
|
||||
#define FREQ_START() (frequency0)
|
||||
#define FREQ_STOP() (frequency1)
|
||||
#define FREQ_CENTER() (frequency0/2 + frequency1/2)
|
||||
#define FREQ_SPAN() (frequency0 - frequency1)
|
||||
|
||||
int caldata_save(int id);
|
||||
int caldata_recall(int id);
|
||||
const properties_t *caldata_ref(int id);
|
||||
|
|
|
|||
12
plot.c
12
plot.c
|
|
@ -1467,7 +1467,9 @@ draw_all_cells(bool flush_markmap)
|
|||
void
|
||||
draw_all(bool flush)
|
||||
{
|
||||
if (redraw_request & REDRAW_CELLS)
|
||||
if (redraw_request & REDRAW_MARKER)
|
||||
markmap_upperarea();
|
||||
if (redraw_request & (REDRAW_CELLS | REDRAW_MARKER))
|
||||
draw_all_cells(flush);
|
||||
if (redraw_request & REDRAW_FREQUENCY)
|
||||
draw_frequencies();
|
||||
|
|
@ -1681,12 +1683,12 @@ draw_frequencies(void)
|
|||
char buf1[32];
|
||||
char buf2[32];buf2[0]=0;
|
||||
if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) {
|
||||
if (frequency0 < frequency1) {
|
||||
if (FREQ_IS_STARTSTOP()) {
|
||||
chsnprintf(buf1, sizeof(buf1), " START %qHz", frequency0);
|
||||
chsnprintf(buf2, sizeof(buf2), " STOP %qHz", frequency1);
|
||||
} else if (frequency0 > frequency1) {
|
||||
chsnprintf(buf1, sizeof(buf1), " CENTER %qHz", frequency0/2 + frequency1/2);
|
||||
chsnprintf(buf2, sizeof(buf2), " SPAN %qHz", frequency0 - frequency1);
|
||||
} else if (FREQ_IS_CENTERSPAN()) {
|
||||
chsnprintf(buf1, sizeof(buf1), " CENTER %qHz", FREQ_CENTER());
|
||||
chsnprintf(buf2, sizeof(buf2), " SPAN %qHz", FREQ_SPAN());
|
||||
} else {
|
||||
chsnprintf(buf1, sizeof(buf1), " CW %qHz", frequency0);
|
||||
}
|
||||
|
|
|
|||
60
ui.c
60
ui.c
|
|
@ -439,6 +439,15 @@ enter_dfu(void)
|
|||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
static void
|
||||
select_lever_mode(int mode)
|
||||
{
|
||||
if (uistat.lever_mode != mode) {
|
||||
uistat.lever_mode = mode;
|
||||
redraw_request |= REDRAW_FREQUENCY | REDRAW_MARKER;
|
||||
}
|
||||
}
|
||||
|
||||
// type of menu item
|
||||
enum {
|
||||
MT_NONE,
|
||||
|
|
@ -625,7 +634,7 @@ menu_transform_cb(int item, uint8_t data)
|
|||
(void)item;
|
||||
(void)data;
|
||||
domain_mode ^= DOMAIN_TIME;
|
||||
uistat.lever_mode = LM_MARKER;
|
||||
select_lever_mode(LM_MARKER);
|
||||
draw_frequencies();
|
||||
ui_mode_normal();
|
||||
}
|
||||
|
|
@ -692,7 +701,6 @@ menu_stimulus_cb(int item, uint8_t data)
|
|||
case 2: /* CENTER */
|
||||
case 3: /* SPAN */
|
||||
case 4: /* CW */
|
||||
uistat.lever_mode = item == 3 ? LM_SPAN : LM_CENTER;
|
||||
status = btn_wait_release();
|
||||
if (status & EVT_BUTTON_DOWN_LONG) {
|
||||
ui_mode_numeric(item);
|
||||
|
|
@ -803,7 +811,7 @@ menu_marker_search_cb(int item, uint8_t data)
|
|||
}
|
||||
draw_menu();
|
||||
redraw_marker(active_marker, TRUE);
|
||||
uistat.lever_mode = LM_SEARCH;
|
||||
select_lever_mode(LM_SEARCH);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -860,7 +868,6 @@ menu_marker_sel_cb(int item, uint8_t data)
|
|||
}
|
||||
redraw_marker(active_marker, TRUE);
|
||||
draw_menu();
|
||||
uistat.lever_mode = LM_MARKER;
|
||||
}
|
||||
|
||||
const menuitem_t menu_calop[] = {
|
||||
|
|
@ -1724,15 +1731,15 @@ lever_zoom_span(int status)
|
|||
}
|
||||
|
||||
static void
|
||||
lever_move_center(int status)
|
||||
lever_move(int status, int mode)
|
||||
{
|
||||
uint32_t center = get_sweep_frequency(ST_CENTER);
|
||||
uint32_t center = get_sweep_frequency(mode);
|
||||
uint32_t span = get_sweep_frequency(ST_SPAN);
|
||||
span = step_round(span / 3);
|
||||
if (status & EVT_UP) {
|
||||
set_sweep_frequency(ST_CENTER, center + span);
|
||||
set_sweep_frequency(mode, center + span);
|
||||
} else if (status & EVT_DOWN) {
|
||||
set_sweep_frequency(ST_CENTER, center - span);
|
||||
set_sweep_frequency(mode, center - span);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1747,8 +1754,15 @@ ui_process_normal(void)
|
|||
switch (uistat.lever_mode) {
|
||||
case LM_MARKER: lever_move_marker(status); break;
|
||||
case LM_SEARCH: lever_search_marker(status); break;
|
||||
case LM_CENTER: lever_move_center(status); break;
|
||||
case LM_SPAN: lever_zoom_span(status); break;
|
||||
case LM_CENTER:
|
||||
lever_move(status, FREQ_IS_STARTSTOP() ? ST_START : ST_CENTER);
|
||||
break;
|
||||
case LM_SPAN:
|
||||
if (FREQ_IS_STARTSTOP())
|
||||
lever_move(status, ST_STOP);
|
||||
else
|
||||
lever_zoom_span(status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2120,6 +2134,7 @@ touch_pickup_marker(void)
|
|||
}
|
||||
// select trace
|
||||
uistat.current_trace = t;
|
||||
select_lever_mode(LM_MARKER);
|
||||
|
||||
// drag marker until release
|
||||
drag_marker(t, m);
|
||||
|
|
@ -2131,6 +2146,27 @@ touch_pickup_marker(void)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
touch_lever_mode_select(void)
|
||||
{
|
||||
int touch_x, touch_y;
|
||||
touch_position(&touch_x, &touch_y);
|
||||
if (touch_y > HEIGHT) {
|
||||
if (touch_x < 160) {
|
||||
select_lever_mode(LM_CENTER);
|
||||
} else {
|
||||
select_lever_mode(LM_SPAN);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (touch_y < 15) {
|
||||
select_lever_mode(LM_MARKER);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static
|
||||
void ui_process_touch(void)
|
||||
|
|
@ -2145,6 +2181,10 @@ void ui_process_touch(void)
|
|||
|
||||
if (touch_pickup_marker()) {
|
||||
break;
|
||||
} else if (touch_lever_mode_select()) {
|
||||
draw_all(FALSE);
|
||||
touch_wait_release();
|
||||
break;
|
||||
}
|
||||
|
||||
touch_wait_release();
|
||||
|
|
|
|||
Loading…
Reference in a new issue