Commit 4a611a58 authored by Pavel Semerad's avatar Pavel Semerad
Browse files

trims - longer beep at reset_value and short pause ignoring buttons

parent 082a9422
......@@ -2,6 +2,7 @@
*0.3.0 ()
added globally settable key long-press delay
when using trims, longer beep at value reset and short pause ignoring keys
*0.2.0 (9 Jun 2011)
......
......@@ -43,9 +43,11 @@ Buttons:
key press), values are saved to EEPROm automatically when it disappears
> when autorepeat disabled on trims (default), reset trim to 0
by pressing both trim keys together for long
(eg. TRIM_LEFT-long + TRIM_RIGHT-long and similar for channel 2)
(eg. TRIM_LEFT-long + TRIM_RIGHT-long and similar for channel 2 trim)
> while value is showed, it is possible to change it with rotate
encoder also
> when value set to reset_value (usualy 0), longer beep sounds to
attention to it and short pause is intruduced to ignore keys
Standard menu:
......
trims
longer beep at centre
short pause at centre, ignore the same key for some time
2-state keys
add possibility of set value/return to previous value
add DIG as key function, also for SWItch allow set reverse
......
......@@ -44,6 +44,9 @@
// delay in seconds of popup menu (trim, dualrate, ...)
#define POPUP_DELAY 5
// pause in 5ms when reset value is reached during trim popup
#define RESET_VALUE_DELAY (500 / 5)
......
......@@ -168,7 +168,7 @@ const u8 steps_map[STEPS_MAP_SIZE] = {
// if another key pressed, return
#define AVAL(x) *(s8 *)etf->aval = (s8)(x)
static u8 menu_popup_et(u8 trim_id) {
u16 to_time;
u16 delay_time;
s16 val;
u8 step;
u16 buttons_state_last;
......@@ -222,6 +222,8 @@ static u8 menu_popup_et(u8 trim_id) {
lcd_7seg(etf->channel);
while (1) {
u8 val_set_to_reset = 0;
// check value left/right
if (btnl_all(btn_lr)) {
key_beep();
......@@ -269,6 +271,7 @@ static u8 menu_popup_et(u8 trim_id) {
if ((ck.momentary & opposite_reset) &&
val < etf->reset) val = etf->reset;
}
if (val == etf->reset) val_set_to_reset = 1;
}
}
AVAL(val);
......@@ -277,12 +280,20 @@ static u8 menu_popup_et(u8 trim_id) {
else btnr_nolong(btn_lr); // keep long-presses for testing-both
}
else if (btn(BTN_ROT_ALL)) {
s16 val2 = val;
val = menu_change_val(val, etf->min, etf->max, etf->rot_fast_step,
0);
// if encoder skipped reset value, set it to reset value
if (val2 < etf->reset && val > etf->reset ||
val2 > etf->reset && val < etf->reset) val = etf->reset;
if (val == etf->reset) val_set_to_reset = 1;
AVAL(val);
}
btnr(BTN_ROT_ALL);
// longer beep at value reset value
if (val_set_to_reset) buzzer_on(3, 0, 1);
// if another button was pressed, leave this screen
if (buttons) break;
if ((buttons_state & ~btn_lr) != buttons_state_last) break;
......@@ -292,11 +303,21 @@ static u8 menu_popup_et(u8 trim_id) {
else lcd_char_num3(val);
lcd_update();
// if reset value was reached, ignore rotate/btn_lr for some time
delay_time = POPUP_DELAY * 200;
if (val_set_to_reset) {
u8 delay = RESET_VALUE_DELAY;
while (delay && !(buttons & ~(btn_lr | BTN_ROT_ALL)) &&
((buttons_state & ~btn_lr) == buttons_state_last))
delay = (u8)delay_menu(delay);
btnr(BTN_ROT_ALL | btn_lr);
delay_time -= RESET_VALUE_DELAY;
}
// sleep 5s, and if no button was changed during, end this screen
to_time = time_sec + POPUP_DELAY;
while (time_sec < to_time && !buttons &&
while (delay_time && !buttons &&
((buttons_state & ~btn_lr) == buttons_state_last))
delay_menu((to_time - time_sec) * 200);
delay_time = delay_menu(delay_time);
if (!buttons) break; // timeouted without button press
}
......@@ -477,7 +498,7 @@ u8 menu_key_function_2state(u8 n) {
// change val, temporary show new value (not always)
// end when another key pressed
static u8 menu_popup_key(u8 key_id) {
u16 to_time;
u16 delay_time;
u16 buttons_state_last;
u16 btnx;
config_key_map_s *km = &ck.key_map[key_id];
......@@ -549,10 +570,10 @@ static u8 menu_popup_key(u8 key_id) {
if ((buttons_state & ~btnx) != buttons_state_last) break;
// sleep 5s, and if no button was changed during, end this screen
to_time = time_sec + POPUP_DELAY;
while (time_sec < to_time && !buttons &&
delay_time = POPUP_DELAY * 200;
while (delay_time && !buttons &&
((buttons_state & ~btnx) == buttons_state_last))
delay_menu((to_time - time_sec) * 200);
delay_time = delay_menu(delay_time);
if (!buttons) break; // timeouted without button press
if (is_long) {
......
......@@ -123,16 +123,20 @@ static u16 menu_delay; // timer for delay in MENU task
// delay in task MENU - will be interrupted by buttons/ADC
void delay_menu(u16 len_5ms) {
u16 delay_menu(u16 len_5ms) {
u16 rest;
menu_delay = len_5ms;
stop();
rest = menu_delay;
menu_delay = 0; // MENU task can be awaked from input also, so set no delay for sure
return rest;
}
void delay_menu_always(u8 len_s) {
u16 to_time = time_sec + len_s;
while (time_sec < to_time)
delay_menu((to_time - time_sec) * 200);
u16 delay_time = len_s * 200;
while (delay_time)
delay_time = delay_menu(delay_time);
}
......
......@@ -30,7 +30,7 @@ extern volatile u8 time_5ms;
// delay in task MENU - will be interrupted by buttons/ADC
extern void delay_menu(u16 len_5ms);
extern u16 delay_menu(u16 len_5ms);
extern void delay_menu_always(u8 len_s);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment