From c4f3f67537c65c446cdc8ecf3a46a7a7a32211de Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 25 Oct 2020 04:19:51 -0500 Subject: [PATCH] Followup for BTN_ENC_EN --- Marlin/src/lcd/marlinui.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 9c456c25c9..0a87965721 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -808,6 +808,14 @@ millis_t next_lcd_update_ms; millis_t MarlinUI::return_to_status_ms = 0; #endif +inline bool can_encode() { + #if BUTTON_EXISTS(ENC_EN) + return !BUTTON_PRESSED(ENC_EN); // Update position only when ENC_EN is HIGH + #else + return true; + #endif +} + void MarlinUI::update() { static uint16_t max_display_update_time = 0; @@ -961,9 +969,7 @@ void MarlinUI::update() { #endif // ENCODER_RATE_MULTIPLIER - // Update position only when ENC_EN is HIGH - if (TERN1(BTN_ENC_EN, !BUTTON_PRESSED(ENC_EN))) - encoderPosition += (encoderDiff * encoderMultiplier) / epps; + if (can_encode()) encoderPosition += (encoderDiff * encoderMultiplier) / epps; encoderDiff = 0; } @@ -1182,8 +1188,7 @@ void MarlinUI::update() { if (BUTTON_PRESSED(EN2)) newbutton |= EN_B; #endif #if BUTTON_EXISTS(ENC) - // Update button only when ENC_EN is HIGH - if (TERN1(BTN_ENC_EN, !BUTTON_PRESSED(ENC_EN)) && BUTTON_PRESSED(ENC)) newbutton |= EN_C; + if (can_encode() && BUTTON_PRESSED(ENC)) newbutton |= EN_C; #endif #if BUTTON_EXISTS(BACK) if (BUTTON_PRESSED(BACK)) newbutton |= EN_D;