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
Firmware
|
@ -686,7 +686,11 @@ LongTimer lcd_timeoutToStatus;
|
||||||
uint8_t lcd_clicked(void)
|
uint8_t lcd_clicked(void)
|
||||||
{
|
{
|
||||||
bool clicked = LCD_CLICKED;
|
bool clicked = LCD_CLICKED;
|
||||||
if(clicked) lcd_button_pressed = 0;
|
if(clicked)
|
||||||
|
{
|
||||||
|
lcd_button_pressed = 0;
|
||||||
|
lcd_buttons &= 0xff^EN_C;
|
||||||
|
}
|
||||||
return clicked;
|
return clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -766,8 +770,7 @@ void lcd_buttons_update(void)
|
||||||
uint8_t newbutton = 0;
|
uint8_t newbutton = 0;
|
||||||
if (READ(BTN_EN1) == 0) newbutton |= EN_A;
|
if (READ(BTN_EN1) == 0) newbutton |= EN_A;
|
||||||
if (READ(BTN_EN2) == 0) newbutton |= EN_B;
|
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)
|
if (READ(BTN_ENC) == 0)
|
||||||
{ //button is pressed
|
{ //button is pressed
|
||||||
lcd_timeoutToStatus.start();
|
lcd_timeoutToStatus.start();
|
||||||
|
@ -776,12 +779,11 @@ void lcd_buttons_update(void)
|
||||||
safetyTimer.start();
|
safetyTimer.start();
|
||||||
if ((lcd_button_pressed == 0) && (lcd_long_press_active == 0))
|
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;
|
lcd_button_pressed = 1;
|
||||||
}
|
}
|
||||||
else
|
else if (longPressTimer.expired(LONG_PRESS_TIME))
|
||||||
{
|
|
||||||
if (longPressTimer.expired(LONG_PRESS_TIME))
|
|
||||||
{
|
{
|
||||||
lcd_long_press_active = 1;
|
lcd_long_press_active = 1;
|
||||||
if (lcd_longpress_func)
|
if (lcd_longpress_func)
|
||||||
|
@ -789,7 +791,6 @@ void lcd_buttons_update(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{ //button not pressed
|
{ //button not pressed
|
||||||
if (lcd_button_pressed)
|
if (lcd_button_pressed)
|
||||||
|
@ -805,12 +806,6 @@ void lcd_buttons_update(void)
|
||||||
else
|
else
|
||||||
lcd_long_press_active = 0;
|
lcd_long_press_active = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{ //we are in modal mode
|
|
||||||
if (READ(BTN_ENC) == 0)
|
|
||||||
newbutton |= EN_C;
|
|
||||||
}
|
|
||||||
|
|
||||||
lcd_buttons = newbutton;
|
lcd_buttons = newbutton;
|
||||||
//manage encoder rotation
|
//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))
|
if (menu_clicked && (lcd_encoder == menu_item))
|
||||||
{
|
{
|
||||||
menu_clicked = false;
|
menu_clicked = false;
|
||||||
|
lcd_button_pressed = 0;
|
||||||
|
lcd_buttons &= 0xff^EN_C;
|
||||||
lcd_update_enabled = 0;
|
lcd_update_enabled = 0;
|
||||||
if (func) func();
|
if (func) func();
|
||||||
lcd_update_enabled = 1;
|
lcd_update_enabled = 1;
|
||||||
|
|
|
@ -463,6 +463,8 @@ static uint8_t menu_item_sdfile(const char*
|
||||||
}
|
}
|
||||||
if (menu_clicked && (lcd_encoder == menu_item))
|
if (menu_clicked && (lcd_encoder == menu_item))
|
||||||
{
|
{
|
||||||
|
lcd_button_pressed = 0;
|
||||||
|
lcd_buttons &= 0xff^EN_C;
|
||||||
menu_action_sdfile(str_fn);
|
menu_action_sdfile(str_fn);
|
||||||
return menu_item_ret();
|
return menu_item_ret();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue