Skip to content

Commit

Permalink
Followup for BTN_ENC_EN
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Oct 25, 2020
1 parent ec23e37 commit c4f3f67
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c4f3f67

Please sign in to comment.