work with keypad

scan_delay_optimize
TT 8 years ago
parent 7228ebd5fa
commit f3a473bffa

@ -676,30 +676,24 @@ set_sweep_frequency(int type, float frequency)
uint32_t uint32_t
get_sweep_frequency(int type) get_sweep_frequency(int type)
{ {
uint32_t result = 0; if (frequency1 >= 0) {
switch (type) { switch (type) {
case ST_START: case ST_START: return frequency0;
freq_mode_startstop(); case ST_STOP: return frequency1;
result = frequency0; case ST_CENTER: return (frequency0 + frequency1)/2;
break; case ST_SPAN: return frequency1 - frequency0;
case ST_STOP: case ST_CW: return (frequency0 + frequency1)/2;
freq_mode_startstop(); }
result = frequency1; } else {
break; switch (type) {
case ST_CENTER: case ST_START: return frequency0 + frequency1/2;
freq_mode_centerspan(); case ST_STOP: return frequency1 - frequency1/2;
result = frequency0; case ST_CENTER: return frequency0;
break; case ST_SPAN: return -frequency1;
case ST_SPAN: case ST_CW: return frequency0;
freq_mode_centerspan(); }
result = -frequency1;
break;
case ST_CW:
freq_mode_centerspan();
result = frequency0;
break;
} }
return result; return 0;
} }

55
ui.c

@ -112,6 +112,7 @@ void draw_menu(void);
void leave_ui_mode(void); void leave_ui_mode(void);
void erase_menu_buttons(void); void erase_menu_buttons(void);
void ui_process_keypad(void); void ui_process_keypad(void);
void ui_process_numeric(void);
static void menu_push_submenu(const menuitem_t *submenu); static void menu_push_submenu(const menuitem_t *submenu);
@ -605,14 +606,21 @@ menu_scale_cb(int item)
static void static void
menu_stimulus_cb(int item) menu_stimulus_cb(int item)
{ {
int status;
switch (item) { switch (item) {
case 0: /* START */ case 0: /* START */
case 1: /* STOP */ case 1: /* STOP */
case 2: /* CENTER */ case 2: /* CENTER */
case 3: /* SPAN */ case 3: /* SPAN */
case 4: /* CW */ case 4: /* CW */
ui_mode_numeric(item); status = btn_wait_release();
ui_process_numeric(); if (status & EVT_BUTTON_DOWN_LONG) {
ui_mode_keypad(item);
ui_process_keypad();
} else {
ui_mode_numeric(item);
ui_process_numeric();
}
break; break;
case 5: /* PAUSE */ case 5: /* PAUSE */
toggle_sweep(); toggle_sweep();
@ -1197,36 +1205,34 @@ leave_ui_mode()
void void
fetch_numeric_target(void) fetch_numeric_target(void)
{ {
uint32_t value;
switch (keypad_mode) { switch (keypad_mode) {
case KM_START: case KM_START:
value = get_sweep_frequency(ST_START); uistat.freq = get_sweep_frequency(ST_START);
break; break;
case KM_STOP: case KM_STOP:
value = get_sweep_frequency(ST_STOP); uistat.freq = get_sweep_frequency(ST_STOP);
break; break;
case KM_CENTER: case KM_CENTER:
value = get_sweep_frequency(ST_CENTER); uistat.freq = get_sweep_frequency(ST_CENTER);
break; break;
case KM_SPAN: case KM_SPAN:
value = get_sweep_frequency(ST_SPAN); uistat.freq = get_sweep_frequency(ST_SPAN);
break; break;
case KM_CW: case KM_CW:
value = get_sweep_frequency(ST_CW); uistat.freq = get_sweep_frequency(ST_CW);
break; break;
#if 0 #if 0
case KM_SCALE: case KM_SCALE:
value = get_trace_scale(uistat.current_trace); uistat.freq = get_trace_scale(uistat.current_trace);
break; break;
case KM_REFPOS: case KM_REFPOS:
value = get_trace_refpos(uistat.current_trace); uistat.freq = get_trace_refpos(uistat.current_trace);
break; break;
case KM_EDELAY: case KM_EDELAY:
value = get_electrical_delay(); uistat.freq = get_electrical_delay();
break; break;
#endif #endif
} }
uistat.freq = value;
} }
void set_numeric_value(void) void set_numeric_value(void)
@ -1322,6 +1328,7 @@ ui_mode_keypad(int _keypad_mode)
area_height = HEIGHT - 32; area_height = HEIGHT - 32;
draw_menu(); draw_menu();
draw_keypad(); draw_keypad();
draw_numeric_area_frame();
draw_numeric_input(""); draw_numeric_input("");
} }
@ -1502,13 +1509,25 @@ ui_process_numeric(void)
} else { } else {
do { do {
if (uistat.digit_mode) { if (uistat.digit_mode) {
if (status & EVT_DOWN && uistat.digit < 8) { if (status & EVT_DOWN) {
uistat.digit++; if (uistat.digit < 8) {
draw_numeric_area(); uistat.digit++;
draw_numeric_area();
} else {
// cancel operation
ui_mode_normal();
break;
}
} }
if (status & EVT_UP && uistat.digit > 0) { if (status & EVT_UP) {
uistat.digit--; if (uistat.digit > 0) {
draw_numeric_area(); uistat.digit--;
draw_numeric_area();
} else {
// cancel operation
ui_mode_normal();
break;
}
} }
} else { } else {
int32_t step = 1; int32_t step = 1;

Loading…
Cancel
Save

Powered by TurnKey Linux.