Skip to content

Commit ac5464c

Browse files
committed
πŸ§‘β€πŸ’» More direct encoder spin
1 parent a121c80 commit ac5464c

File tree

3 files changed

+16
-23
lines changed

3 files changed

+16
-23
lines changed

β€ŽMarlin/src/lcd/buttons.h

-7
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@
3838
#define HAS_SLOW_BUTTONS 1
3939
#endif
4040

41-
#if HAS_ENCODER_WHEEL
42-
#define ENCODER_PHASE_0 0
43-
#define ENCODER_PHASE_1 2
44-
#define ENCODER_PHASE_2 3
45-
#define ENCODER_PHASE_3 1
46-
#endif
47-
4841
#if EITHER(HAS_DIGITAL_BUTTONS, HAS_DWIN_E3V2)
4942
// Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes)
5043
#define BLEN_A 0

β€ŽMarlin/src/lcd/e3v2/common/encoder.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,21 @@ EncoderState Encoder_ReceiveAnalyze() {
9696
}
9797
if (newbutton != lastEncoderBits) {
9898
switch (newbutton) {
99-
case ENCODER_PHASE_0:
100-
if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++;
101-
else if (lastEncoderBits == ENCODER_PHASE_1) temp_diff--;
99+
case 0:
100+
if (lastEncoderBits == 1) temp_diff++;
101+
else if (lastEncoderBits == 2) temp_diff--;
102102
break;
103-
case ENCODER_PHASE_1:
104-
if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++;
105-
else if (lastEncoderBits == ENCODER_PHASE_2) temp_diff--;
103+
case 2:
104+
if (lastEncoderBits == 0) temp_diff++;
105+
else if (lastEncoderBits == 3) temp_diff--;
106106
break;
107-
case ENCODER_PHASE_2:
108-
if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++;
109-
else if (lastEncoderBits == ENCODER_PHASE_3) temp_diff--;
107+
case 3:
108+
if (lastEncoderBits == 2) temp_diff++;
109+
else if (lastEncoderBits == 1) temp_diff--;
110110
break;
111-
case ENCODER_PHASE_3:
112-
if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++;
113-
else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--;
111+
case 1:
112+
if (lastEncoderBits == 3) temp_diff++;
113+
else if (lastEncoderBits == 0) temp_diff--;
114114
break;
115115
}
116116
lastEncoderBits = newbutton;

β€ŽMarlin/src/lcd/marlinui.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1382,10 +1382,10 @@ void MarlinUI::init() {
13821382
if (buttons & EN_B) enc |= B10;
13831383
if (enc != lastEncoderBits) {
13841384
switch (enc) {
1385-
case ENCODER_PHASE_0: ENCODER_SPIN(ENCODER_PHASE_3, ENCODER_PHASE_1); break;
1386-
case ENCODER_PHASE_1: ENCODER_SPIN(ENCODER_PHASE_0, ENCODER_PHASE_2); break;
1387-
case ENCODER_PHASE_2: ENCODER_SPIN(ENCODER_PHASE_1, ENCODER_PHASE_3); break;
1388-
case ENCODER_PHASE_3: ENCODER_SPIN(ENCODER_PHASE_2, ENCODER_PHASE_0); break;
1385+
case 0: ENCODER_SPIN(1, 2); break;
1386+
case 2: ENCODER_SPIN(0, 3); break;
1387+
case 3: ENCODER_SPIN(2, 1); break;
1388+
case 1: ENCODER_SPIN(3, 0); break;
13891389
}
13901390
#if BOTH(HAS_MARLINUI_MENU, AUTO_BED_LEVELING_UBL)
13911391
external_encoder();

0 commit comments

Comments
Β (0)