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
@ -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;
|
||||
}
|
||||
|
||||
@ -709,7 +713,7 @@ Sound_MakeSound(e_SOUND_TYPE_ButtonEcho);
|
||||
void lcd_quick_feedback(void)
|
||||
{
|
||||
lcd_draw_update = 2;
|
||||
lcd_button_pressed = false;
|
||||
lcd_button_pressed = false;
|
||||
lcd_beeper_quick_feedback();
|
||||
}
|
||||
|
||||
@ -766,51 +770,42 @@ 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();
|
||||
if (!buttonBlanking.running() || buttonBlanking.expired(BUTTON_BLANKING_TIME)) {
|
||||
buttonBlanking.start();
|
||||
safetyTimer.start();
|
||||
if ((lcd_button_pressed == 0) && (lcd_long_press_active == 0))
|
||||
{
|
||||
longPressTimer.start();
|
||||
lcd_button_pressed = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (longPressTimer.expired(LONG_PRESS_TIME))
|
||||
{
|
||||
lcd_long_press_active = 1;
|
||||
if (lcd_longpress_func)
|
||||
lcd_longpress_func();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //button not pressed
|
||||
if (lcd_button_pressed)
|
||||
{ //button was released
|
||||
buttonBlanking.start();
|
||||
if (lcd_long_press_active == 0)
|
||||
{ //button released before long press gets activated
|
||||
newbutton |= EN_C;
|
||||
}
|
||||
//else if (menu_menu == lcd_move_z) lcd_quick_feedback();
|
||||
//lcd_button_pressed is set back to false via lcd_quick_feedback function
|
||||
}
|
||||
else
|
||||
lcd_long_press_active = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //we are in modal mode
|
||||
if (READ(BTN_ENC) == 0)
|
||||
newbutton |= EN_C;
|
||||
}
|
||||
|
||||
if (READ(BTN_ENC) == 0)
|
||||
{ //button is pressed
|
||||
lcd_timeoutToStatus.start();
|
||||
if (!buttonBlanking.running() || buttonBlanking.expired(BUTTON_BLANKING_TIME)) {
|
||||
buttonBlanking.start();
|
||||
safetyTimer.start();
|
||||
if ((lcd_button_pressed == 0) && (lcd_long_press_active == 0))
|
||||
{
|
||||
//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))
|
||||
{
|
||||
lcd_long_press_active = 1;
|
||||
if (lcd_longpress_func)
|
||||
lcd_longpress_func();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //button not pressed
|
||||
if (lcd_button_pressed)
|
||||
{ //button was released
|
||||
buttonBlanking.start();
|
||||
if (lcd_long_press_active == 0)
|
||||
{ //button released before long press gets activated
|
||||
newbutton |= EN_C;
|
||||
}
|
||||
//else if (menu_menu == lcd_move_z) lcd_quick_feedback();
|
||||
//lcd_button_pressed is set back to false via lcd_quick_feedback function
|
||||
}
|
||||
else
|
||||
lcd_long_press_active = 0;
|
||||
}
|
||||
|
||||
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…
Reference in New Issue
Block a user