Browse Source

🧑‍💻 More direct encoder spin

Scott Lahteine 2 years ago
parent
commit
c579250294
3 changed files with 16 additions and 23 deletions
  1. 0
    7
      Marlin/src/lcd/buttons.h
  2. 12
    12
      Marlin/src/lcd/e3v2/common/encoder.cpp
  3. 4
    4
      Marlin/src/lcd/marlinui.cpp

+ 0
- 7
Marlin/src/lcd/buttons.h View File

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

+ 12
- 12
Marlin/src/lcd/e3v2/common/encoder.cpp View File

@@ -96,21 +96,21 @@ EncoderState Encoder_ReceiveAnalyze() {
96 96
   }
97 97
   if (newbutton != lastEncoderBits) {
98 98
     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--;
102 102
         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--;
106 106
         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--;
110 110
         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--;
114 114
         break;
115 115
     }
116 116
     lastEncoderBits = newbutton;

+ 4
- 4
Marlin/src/lcd/marlinui.cpp View File

@@ -1382,10 +1382,10 @@ void MarlinUI::init() {
1382 1382
         if (buttons & EN_B) enc |= B10;
1383 1383
         if (enc != lastEncoderBits) {
1384 1384
           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;
1389 1389
           }
1390 1390
           #if BOTH(HAS_MARLINUI_MENU, AUTO_BED_LEVELING_UBL)
1391 1391
             external_encoder();

Loading…
Cancel
Save