Enable button debouncing also in modal mode (!lcd_update_enabled). In lcd_clicked() consume click event immediately.
This commit is contained in:
parent
acff75ac00
commit
90a10a692a
3 changed files with 46 additions and 47 deletions
|
@ -686,7 +686,11 @@ LongTimer lcd_timeoutToStatus;
|
|||
uint8_t lcd_clicked(void)
|
||||
{
|
||||
bool clicked = LCD_CLICKED;
|
||||
if(clicked) lcd_button_pressed = 0;
|
||||
if(clicked)
|
||||
{
|
||||
lcd_button_pressed = 0;
|
||||
lcd_buttons &= 0xff^EN_C;
|
||||
}
|
||||
return clicked;
|
||||
}
|
||||
|
||||
|
@ -766,8 +770,7 @@ void lcd_buttons_update(void)
|
|||
uint8_t newbutton = 0;
|
||||
if (READ(BTN_EN1) == 0) newbutton |= EN_A;
|
||||
if (READ(BTN_EN2) == 0) newbutton |= EN_B;
|
||||
if (lcd_update_enabled)
|
||||
{ //if we are in non-modal mode, long press can be used and short press triggers with button release
|
||||
|
||||
if (READ(BTN_ENC) == 0)
|
||||
{ //button is pressed
|
||||
lcd_timeoutToStatus.start();
|
||||
|
@ -776,12 +779,11 @@ void lcd_buttons_update(void)
|
|||
safetyTimer.start();
|
||||
if ((lcd_button_pressed == 0) && (lcd_long_press_active == 0))
|
||||
{
|
||||
longPressTimer.start();
|
||||
//long press is not possible in modal mode
|
||||
if (lcd_update_enabled) longPressTimer.start();
|
||||
lcd_button_pressed = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (longPressTimer.expired(LONG_PRESS_TIME))
|
||||
else if (longPressTimer.expired(LONG_PRESS_TIME))
|
||||
{
|
||||
lcd_long_press_active = 1;
|
||||
if (lcd_longpress_func)
|
||||
|
@ -789,7 +791,6 @@ void lcd_buttons_update(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //button not pressed
|
||||
if (lcd_button_pressed)
|
||||
|
@ -805,12 +806,6 @@ void lcd_buttons_update(void)
|
|||
else
|
||||
lcd_long_press_active = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //we are in modal mode
|
||||
if (READ(BTN_ENC) == 0)
|
||||
newbutton |= EN_C;
|
||||
}
|
||||
|
||||
lcd_buttons = newbutton;
|
||||
//manage encoder rotation
|
||||
|
|
|
@ -236,6 +236,8 @@ uint8_t menu_item_function_P(const char* str, menu_func_t func)
|
|||
if (menu_clicked && (lcd_encoder == menu_item))
|
||||
{
|
||||
menu_clicked = false;
|
||||
lcd_button_pressed = 0;
|
||||
lcd_buttons &= 0xff^EN_C;
|
||||
lcd_update_enabled = 0;
|
||||
if (func) func();
|
||||
lcd_update_enabled = 1;
|
||||
|
|
|
@ -463,6 +463,8 @@ static uint8_t menu_item_sdfile(const char*
|
|||
}
|
||||
if (menu_clicked && (lcd_encoder == menu_item))
|
||||
{
|
||||
lcd_button_pressed = 0;
|
||||
lcd_buttons &= 0xff^EN_C;
|
||||
menu_action_sdfile(str_fn);
|
||||
return menu_item_ret();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue