From ac5464c37c4ea0a728ca76934ba61c46e7f1ba68 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 3 Nov 2022 21:29:22 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20More=20dire?= =?UTF-8?q?ct=20encoder=20spin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/buttons.h | 7 ------- Marlin/src/lcd/e3v2/common/encoder.cpp | 24 ++++++++++++------------ Marlin/src/lcd/marlinui.cpp | 8 ++++---- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/Marlin/src/lcd/buttons.h b/Marlin/src/lcd/buttons.h index 67b7aa3944..58471239bb 100644 --- a/Marlin/src/lcd/buttons.h +++ b/Marlin/src/lcd/buttons.h @@ -38,13 +38,6 @@ #define HAS_SLOW_BUTTONS 1 #endif -#if HAS_ENCODER_WHEEL - #define ENCODER_PHASE_0 0 - #define ENCODER_PHASE_1 2 - #define ENCODER_PHASE_2 3 - #define ENCODER_PHASE_3 1 -#endif - #if EITHER(HAS_DIGITAL_BUTTONS, HAS_DWIN_E3V2) // Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes) #define BLEN_A 0 diff --git a/Marlin/src/lcd/e3v2/common/encoder.cpp b/Marlin/src/lcd/e3v2/common/encoder.cpp index f14d63e7b5..5081e27690 100644 --- a/Marlin/src/lcd/e3v2/common/encoder.cpp +++ b/Marlin/src/lcd/e3v2/common/encoder.cpp @@ -96,21 +96,21 @@ EncoderState Encoder_ReceiveAnalyze() { } if (newbutton != lastEncoderBits) { switch (newbutton) { - case ENCODER_PHASE_0: - if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++; - else if (lastEncoderBits == ENCODER_PHASE_1) temp_diff--; + case 0: + if (lastEncoderBits == 1) temp_diff++; + else if (lastEncoderBits == 2) temp_diff--; break; - case ENCODER_PHASE_1: - if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++; - else if (lastEncoderBits == ENCODER_PHASE_2) temp_diff--; + case 2: + if (lastEncoderBits == 0) temp_diff++; + else if (lastEncoderBits == 3) temp_diff--; break; - case ENCODER_PHASE_2: - if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++; - else if (lastEncoderBits == ENCODER_PHASE_3) temp_diff--; + case 3: + if (lastEncoderBits == 2) temp_diff++; + else if (lastEncoderBits == 1) temp_diff--; break; - case ENCODER_PHASE_3: - if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++; - else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--; + case 1: + if (lastEncoderBits == 3) temp_diff++; + else if (lastEncoderBits == 0) temp_diff--; break; } lastEncoderBits = newbutton; diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 0dfe60d8e4..5991806b7b 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1382,10 +1382,10 @@ void MarlinUI::init() { if (buttons & EN_B) enc |= B10; if (enc != lastEncoderBits) { switch (enc) { - case ENCODER_PHASE_0: ENCODER_SPIN(ENCODER_PHASE_3, ENCODER_PHASE_1); break; - case ENCODER_PHASE_1: ENCODER_SPIN(ENCODER_PHASE_0, ENCODER_PHASE_2); break; - case ENCODER_PHASE_2: ENCODER_SPIN(ENCODER_PHASE_1, ENCODER_PHASE_3); break; - case ENCODER_PHASE_3: ENCODER_SPIN(ENCODER_PHASE_2, ENCODER_PHASE_0); break; + case 0: ENCODER_SPIN(1, 2); break; + case 2: ENCODER_SPIN(0, 3); break; + case 3: ENCODER_SPIN(2, 1); break; + case 1: ENCODER_SPIN(3, 0); break; } #if BOTH(HAS_MARLINUI_MENU, AUTO_BED_LEVELING_UBL) external_encoder();