Use Timer class for button blanking. Save 74B FLASH and 1B RAM.

This commit is contained in:
Marek Bel 2018-06-15 20:24:05 +02:00
parent 9ba49affc6
commit 29e045f502

View file

@ -190,7 +190,7 @@ float pid_temp = DEFAULT_PID_TEMP;
bool long_press_active = false; bool long_press_active = false;
static ShortTimer longPressTimer; static ShortTimer longPressTimer;
unsigned long button_blanking_time = millis(); static ShortTimer buttonBlanking;
bool button_pressed = false; bool button_pressed = false;
bool menuExiting = false; bool menuExiting = false;
@ -7548,8 +7548,8 @@ void lcd_buttons_update()
if (lcd_update_enabled == true) { //if we are in non-modal mode, long press can be used and short press triggers with button release if (lcd_update_enabled == true) { //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 if (READ(BTN_ENC) == 0) { //button is pressed
lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
if (millis() > button_blanking_time) { if (!buttonBlanking.running() || buttonBlanking.expired(BUTTON_BLANKING_TIME)) {
button_blanking_time = millis() + BUTTON_BLANKING_TIME; buttonBlanking.start();
if (button_pressed == false && long_press_active == false) { if (button_pressed == false && long_press_active == false) {
longPressTimer.start(); longPressTimer.start();
button_pressed = true; button_pressed = true;
@ -7565,7 +7565,7 @@ void lcd_buttons_update()
} }
else { //button not pressed else { //button not pressed
if (button_pressed) { //button was released if (button_pressed) { //button was released
button_blanking_time = millis() + BUTTON_BLANKING_TIME; buttonBlanking.start();
if (long_press_active == false) { //button released before long press gets activated if (long_press_active == false) { //button released before long press gets activated
newbutton |= EN_C; newbutton |= EN_C;