work with keypad

pull/4/head
TT 8 years ago
parent 7228ebd5fa
commit f3a473bffa

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

43
ui.c

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

Loading…
Cancel
Save

Powered by TurnKey Linux.