🧑‍💻 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
#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

View File

@ -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;

View File

@ -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();