🧑‍💻 More direct encoder spin

This commit is contained in:
Scott Lahteine 2022-11-03 21:29:22 -05:00
parent a121c80e1a
commit ac5464c37c
3 changed files with 16 additions and 23 deletions

View File

@ -38,13 +38,6 @@
#define HAS_SLOW_BUTTONS 1 #define HAS_SLOW_BUTTONS 1
#endif #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) #if EITHER(HAS_DIGITAL_BUTTONS, HAS_DWIN_E3V2)
// Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes) // Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes)
#define BLEN_A 0 #define BLEN_A 0

View File

@ -96,21 +96,21 @@ EncoderState Encoder_ReceiveAnalyze() {
} }
if (newbutton != lastEncoderBits) { if (newbutton != lastEncoderBits) {
switch (newbutton) { switch (newbutton) {
case ENCODER_PHASE_0: case 0:
if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++; if (lastEncoderBits == 1) temp_diff++;
else if (lastEncoderBits == ENCODER_PHASE_1) temp_diff--; else if (lastEncoderBits == 2) temp_diff--;
break; break;
case ENCODER_PHASE_1: case 2:
if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++; if (lastEncoderBits == 0) temp_diff++;
else if (lastEncoderBits == ENCODER_PHASE_2) temp_diff--; else if (lastEncoderBits == 3) temp_diff--;
break; break;
case ENCODER_PHASE_2: case 3:
if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++; if (lastEncoderBits == 2) temp_diff++;
else if (lastEncoderBits == ENCODER_PHASE_3) temp_diff--; else if (lastEncoderBits == 1) temp_diff--;
break; break;
case ENCODER_PHASE_3: case 1:
if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++; if (lastEncoderBits == 3) temp_diff++;
else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--; else if (lastEncoderBits == 0) temp_diff--;
break; break;
} }
lastEncoderBits = newbutton; lastEncoderBits = newbutton;

View File

@ -1382,10 +1382,10 @@ void MarlinUI::init() {
if (buttons & EN_B) enc |= B10; if (buttons & EN_B) enc |= B10;
if (enc != lastEncoderBits) { if (enc != lastEncoderBits) {
switch (enc) { switch (enc) {
case ENCODER_PHASE_0: ENCODER_SPIN(ENCODER_PHASE_3, ENCODER_PHASE_1); break; case 0: ENCODER_SPIN(1, 2); break;
case ENCODER_PHASE_1: ENCODER_SPIN(ENCODER_PHASE_0, ENCODER_PHASE_2); break; case 2: ENCODER_SPIN(0, 3); break;
case ENCODER_PHASE_2: ENCODER_SPIN(ENCODER_PHASE_1, ENCODER_PHASE_3); break; case 3: ENCODER_SPIN(2, 1); break;
case ENCODER_PHASE_3: ENCODER_SPIN(ENCODER_PHASE_2, ENCODER_PHASE_0); break; case 1: ENCODER_SPIN(3, 0); break;
} }
#if BOTH(HAS_MARLINUI_MENU, AUTO_BED_LEVELING_UBL) #if BOTH(HAS_MARLINUI_MENU, AUTO_BED_LEVELING_UBL)
external_encoder(); external_encoder();