Skip to content

Commit

Permalink
Ignore quick direction changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dbuezas committed Dec 7, 2023
1 parent 267662b commit 2fbca22
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "../inc/MarlinConfig.h"

#include "../MarlinCore.h" // for printingIsPaused
#include "src/core/macros.h"

#if LED_POWEROFF_TIMEOUT > 0 || ALL(HAS_WIRED_LCD, PRINTER_EVENT_LEDS) || (defined(LCD_BACKLIGHT_TIMEOUT_MINS) && defined(NEOPIXEL_BKGD_INDEX_FIRST))
#include "../feature/leds/leds.h"
Expand Down Expand Up @@ -1073,6 +1074,15 @@ void MarlinUI::init() {

const int8_t fullSteps = encoderDiff / epps;
if (fullSteps != 0) {
static int8_t lastDir;
int8_t dir = SIGN(fullSteps);
if (encoderMultiplier != 1 && dir != lastDir) {
// Changed direction at high speed.
// This is most likely an artifact of skipped steps, keep previous direction instead.
encoderMultiplier *= -1;
} else {
lastDir = dir;
}
last_encoder_full_step_movement = ms;
encoderDiff -= fullSteps * epps;
if (can_encode() && !lcd_clicked) {
Expand Down

0 comments on commit 2fbca22

Please sign in to comment.