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