Explorar el Código

Rotary encoder cleanup (#20753)

Scott Lahteine hace 3 años
padre
commit
4a89731025
No account linked to committer's email address

+ 1
- 1
Marlin/src/HAL/LPC1768/inc/SanityCheck.h Ver fichero

@@ -116,7 +116,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
116 116
   #elif HAS_WIRED_LCD
117 117
     #if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
118 118
       #error "Serial port pins (1) conflict with Encoder Buttons!"
119
-    #elif ANY_TX(1, SD_SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK) \
119
+    #elif ANY_TX(1, SD_SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK_PIN) \
120 120
        || ANY_RX(1, LCD_SDSS, LCD_PINS_RS, SD_MISO_PIN, DOGLCD_A0, SD_SS_PIN, LCD_SDSS, DOGLCD_CS, LCD_RESET_PIN, LCD_BACKLIGHT_PIN)
121 121
       #error "Serial port pins (1) conflict with LCD pins!"
122 122
     #endif

+ 1
- 1
Marlin/src/inc/SanityCheck.h Ver fichero

@@ -1595,7 +1595,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
1595 1595
 /**
1596 1596
  * ULTIPANEL encoder
1597 1597
  */
1598
-#if IS_ULTIPANEL && NONE(IS_NEWPANEL, SR_LCD_2W_NL) && !defined(SHIFT_CLK)
1598
+#if IS_ULTIPANEL && NONE(IS_NEWPANEL, SR_LCD_2W_NL) && !PIN_EXISTS(SHIFT_CLK)
1599 1599
   #error "ULTIPANEL controllers require some kind of encoder."
1600 1600
 #endif
1601 1601
 

+ 4
- 7
Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.h Ver fichero

@@ -61,15 +61,12 @@ extern TFTGLCD lcd;
61 61
 #include "../lcdprint.h"
62 62
 
63 63
 // Use panel encoder - free old encoder pins
64
-#undef  BTN_EN1
65
-#undef  BTN_EN2
66
-#undef  BTN_ENC
67
-#define BTN_EN1     -1
68
-#define BTN_EN2     -1
69
-#define BTN_ENC     -1
64
+#undef BTN_EN1
65
+#undef BTN_EN2
66
+#undef BTN_ENC
70 67
 
71 68
 #ifndef EN_C
72
-  #define EN_C       4 //for click
69
+  #define EN_C       4 // for click
73 70
 #endif
74 71
 
75 72
 #endif // IS_TFTGLCD_PANEL

+ 234
- 0
Marlin/src/lcd/buttons.h Ver fichero

@@ -0,0 +1,234 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "../inc/MarlinConfig.h"
25
+
26
+#if ((!HAS_ADC_BUTTONS && IS_NEWPANEL) || BUTTONS_EXIST(EN1, EN2)) && !IS_TFTGLCD_PANEL
27
+  #define HAS_ENCODER_WHEEL 1
28
+#endif
29
+#if HAS_ENCODER_WHEEL || ANY_BUTTON(ENC, BACK, UP, DWN, LFT, RT)
30
+  #define HAS_DIGITAL_BUTTONS 1
31
+#endif
32
+#if !HAS_ADC_BUTTONS && (IS_RRW_KEYPAD || (HAS_WIRED_LCD && !IS_NEWPANEL))
33
+  #define HAS_SHIFT_ENCODER 1
34
+#endif
35
+
36
+// I2C buttons must be read in the main thread
37
+#if ANY(LCD_I2C_VIKI, LCD_I2C_PANELOLU2, IS_TFTGLCD_PANEL)
38
+  #define HAS_SLOW_BUTTONS 1
39
+#endif
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
+#if EITHER(HAS_DIGITAL_BUTTONS, DWIN_CREALITY_LCD)
49
+
50
+  // Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes)
51
+  #define BLEN_A 0
52
+  #define BLEN_B 1
53
+
54
+  #define EN_A _BV(BLEN_A)
55
+  #define EN_B _BV(BLEN_B)
56
+
57
+  #define _BUTTON_PRESSED(BN) !READ(BTN_##BN)
58
+
59
+  #if BUTTON_EXISTS(ENC) || HAS_TOUCH_BUTTONS
60
+    #define BLEN_C 2
61
+    #define EN_C _BV(BLEN_C)
62
+  #endif
63
+
64
+  #if ENABLED(LCD_I2C_VIKI)
65
+
66
+    #include <LiquidTWI2.h>
67
+
68
+    #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
69
+
70
+    // button and encoder bit positions within 'buttons'
71
+    #define B_LE (BUTTON_LEFT   << B_I2C_BTN_OFFSET)      // The remaining normalized buttons are all read via I2C
72
+    #define B_UP (BUTTON_UP     << B_I2C_BTN_OFFSET)
73
+    #define B_MI (BUTTON_SELECT << B_I2C_BTN_OFFSET)
74
+    #define B_DW (BUTTON_DOWN   << B_I2C_BTN_OFFSET)
75
+    #define B_RI (BUTTON_RIGHT  << B_I2C_BTN_OFFSET)
76
+
77
+    #if BUTTON_EXISTS(ENC)                                // The pause/stop/restart button is connected to BTN_ENC when used
78
+      #define B_ST (EN_C)                                 // Map the pause/stop/resume button into its normalized functional name
79
+      #define BUTTON_CLICK() (buttons & (B_MI|B_RI|B_ST)) // Pause/stop also acts as click until a proper pause/stop is implemented.
80
+    #else
81
+      #define BUTTON_CLICK() (buttons & (B_MI|B_RI))
82
+    #endif
83
+
84
+    // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
85
+
86
+  #elif ENABLED(LCD_I2C_PANELOLU2)
87
+
88
+    #if !BUTTON_EXISTS(ENC) // Use I2C if not directly connected to a pin
89
+
90
+      #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
91
+
92
+      #define B_MI (PANELOLU2_ENCODER_C << B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
93
+
94
+      #define BUTTON_CLICK() (buttons & B_MI)
95
+
96
+    #endif
97
+
98
+  #endif
99
+
100
+#else
101
+
102
+  #undef BUTTON_EXISTS
103
+  #define BUTTON_EXISTS(...) false
104
+
105
+  // Dummy button, never pressed
106
+  #define _BUTTON_PRESSED(BN) false
107
+
108
+  // Shift register bits correspond to buttons:
109
+  #define BL_LE 7   // Left
110
+  #define BL_UP 6   // Up
111
+  #define BL_MI 5   // Middle
112
+  #define BL_DW 4   // Down
113
+  #define BL_RI 3   // Right
114
+  #define BL_ST 2   // Red Button
115
+  #define B_LE _BV(BL_LE)
116
+  #define B_UP _BV(BL_UP)
117
+  #define B_MI _BV(BL_MI)
118
+  #define B_DW _BV(BL_DW)
119
+  #define B_RI _BV(BL_RI)
120
+  #define B_ST _BV(BL_ST)
121
+
122
+  #ifndef BUTTON_CLICK
123
+    #define BUTTON_CLICK() (buttons & (B_MI|B_ST))
124
+  #endif
125
+
126
+#endif
127
+
128
+#if IS_RRW_KEYPAD
129
+  #define BTN_OFFSET          0 // Bit offset into buttons for shift register values
130
+
131
+  #define BLEN_KEYPAD_F3      0
132
+  #define BLEN_KEYPAD_F2      1
133
+  #define BLEN_KEYPAD_F1      2
134
+  #define BLEN_KEYPAD_DOWN    3
135
+  #define BLEN_KEYPAD_RIGHT   4
136
+  #define BLEN_KEYPAD_MIDDLE  5
137
+  #define BLEN_KEYPAD_UP      6
138
+  #define BLEN_KEYPAD_LEFT    7
139
+
140
+  #define EN_KEYPAD_F1      _BV(BTN_OFFSET + BLEN_KEYPAD_F1)
141
+  #define EN_KEYPAD_F2      _BV(BTN_OFFSET + BLEN_KEYPAD_F2)
142
+  #define EN_KEYPAD_F3      _BV(BTN_OFFSET + BLEN_KEYPAD_F3)
143
+  #define EN_KEYPAD_DOWN    _BV(BTN_OFFSET + BLEN_KEYPAD_DOWN)
144
+  #define EN_KEYPAD_RIGHT   _BV(BTN_OFFSET + BLEN_KEYPAD_RIGHT)
145
+  #define EN_KEYPAD_MIDDLE  _BV(BTN_OFFSET + BLEN_KEYPAD_MIDDLE)
146
+  #define EN_KEYPAD_UP      _BV(BTN_OFFSET + BLEN_KEYPAD_UP)
147
+  #define EN_KEYPAD_LEFT    _BV(BTN_OFFSET + BLEN_KEYPAD_LEFT)
148
+
149
+  #define RRK(B) (keypad_buttons & (B))
150
+
151
+  #ifdef EN_C
152
+    #define BUTTON_CLICK() ((buttons & EN_C) || RRK(EN_KEYPAD_MIDDLE))
153
+  #else
154
+    #define BUTTON_CLICK() RRK(EN_KEYPAD_MIDDLE)
155
+  #endif
156
+#endif
157
+
158
+#ifndef EN_A
159
+  #define EN_A 0
160
+#endif
161
+#ifndef EN_B
162
+  #define EN_B 0
163
+#endif
164
+#ifndef EN_C
165
+  #define EN_C 0
166
+#endif
167
+#if BUTTON_EXISTS(BACK) || EITHER(HAS_TOUCH_BUTTONS, IS_TFTGLCD_PANEL)
168
+  #define BLEN_D 3
169
+  #define EN_D _BV(BLEN_D)
170
+#else
171
+  #define EN_D 0
172
+#endif
173
+
174
+#define BUTTON_PRESSED(BN) (_BUTTON_PRESSED_##BN)
175
+
176
+#if BUTTON_EXISTS(EN1)
177
+  #define _BUTTON_PRESSED_EN1 _BUTTON_PRESSED(EN1)
178
+#else
179
+  #define _BUTTON_PRESSED_EN1 false
180
+#endif
181
+#if BUTTON_EXISTS(EN2)
182
+  #define _BUTTON_PRESSED_EN2 _BUTTON_PRESSED(EN2)
183
+#else
184
+  #define _BUTTON_PRESSED_EN2 false
185
+#endif
186
+#if BUTTON_EXISTS(ENC_EN)
187
+  #define _BUTTON_PRESSED_ENC_EN _BUTTON_PRESSED(ENC_EN)
188
+#else
189
+  #define _BUTTON_PRESSED_ENC_EN false
190
+#endif
191
+#if BUTTON_EXISTS(ENC)
192
+  #define _BUTTON_PRESSED_ENC _BUTTON_PRESSED(ENC)
193
+#else
194
+  #define _BUTTON_PRESSED_ENC false
195
+#endif
196
+#if BUTTON_EXISTS(UP)
197
+  #define _BUTTON_PRESSED_UP _BUTTON_PRESSED(UP)
198
+#else
199
+  #define _BUTTON_PRESSED_UP false
200
+#endif
201
+#if BUTTON_EXISTS(DWN)
202
+  #define _BUTTON_PRESSED_DWN _BUTTON_PRESSED(DWN)
203
+#else
204
+  #define _BUTTON_PRESSED_DWN false
205
+#endif
206
+#if BUTTON_EXISTS(LFT)
207
+  #define _BUTTON_PRESSED_LFT _BUTTON_PRESSED(LFT)
208
+#else
209
+  #define _BUTTON_PRESSED_LFT false
210
+#endif
211
+#if BUTTON_EXISTS(RT)
212
+  #define _BUTTON_PRESSED_RT _BUTTON_PRESSED(RT)
213
+#else
214
+  #define _BUTTON_PRESSED_RT false
215
+#endif
216
+#if BUTTON_EXISTS(BACK)
217
+  #define _BUTTON_PRESSED_BACK _BUTTON_PRESSED(BACK)
218
+#else
219
+  #define _BUTTON_PRESSED_BACK false
220
+#endif
221
+
222
+#ifndef BUTTON_CLICK
223
+  #if EN_C > 0
224
+    #define BUTTON_CLICK() (buttons & EN_C)
225
+  #else
226
+    #define BUTTON_CLICK() false
227
+  #endif
228
+#endif
229
+
230
+#if EN_D > 0
231
+  #define LCD_BACK_CLICKED() (buttons & EN_D)
232
+#else
233
+  #define LCD_BACK_CLICKED() false
234
+#endif

+ 73
- 71
Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp Ver fichero

@@ -33,6 +33,7 @@
33 33
 #if ENABLED(DWIN_CREALITY_LCD)
34 34
 
35 35
 #include "rotary_encoder.h"
36
+#include "../../buttons.h"
36 37
 
37 38
 #include "../../../MarlinCore.h"
38 39
 #include "../../../HAL/shared/Delay.h"
@@ -43,17 +44,23 @@
43 44
 
44 45
 #include <stdlib.h>
45 46
 
47
+#ifndef ENCODER_PULSES_PER_STEP
48
+  #define ENCODER_PULSES_PER_STEP 4
49
+#endif
50
+
46 51
 ENCODER_Rate EncoderRate;
47 52
 
48 53
 // Buzzer
49
-void Encoder_tick(void) {
50
-  WRITE(BEEPER_PIN, 1);
51
-  delay(10);
52
-  WRITE(BEEPER_PIN, 0);
54
+void Encoder_tick() {
55
+  #if PIN_EXISTS(BEEPER)
56
+    WRITE(BEEPER_PIN, HIGH);
57
+    delay(10);
58
+    WRITE(BEEPER_PIN, LOW);
59
+  #endif
53 60
 }
54 61
 
55 62
 // Encoder initialization
56
-void Encoder_Configuration(void) {
63
+void Encoder_Configuration() {
57 64
   #if BUTTON_EXISTS(EN1)
58 65
     SET_INPUT_PULLUP(BTN_EN1);
59 66
   #endif
@@ -63,21 +70,21 @@ void Encoder_Configuration(void) {
63 70
   #if BUTTON_EXISTS(ENC)
64 71
     SET_INPUT_PULLUP(BTN_ENC);
65 72
   #endif
66
-  #ifdef BEEPER_PIN
73
+  #if PIN_EXISTS(BEEPER)
67 74
     SET_OUTPUT(BEEPER_PIN);
68 75
   #endif
69 76
 }
70 77
 
71 78
 // Analyze encoder value and return state
72
-ENCODER_DiffState Encoder_ReceiveAnalyze(void) {
79
+ENCODER_DiffState Encoder_ReceiveAnalyze() {
73 80
   const millis_t now = millis();
74
-  static unsigned char lastEncoderBits;
75
-  unsigned char newbutton = 0;
81
+  static uint8_t lastEncoderBits;
82
+  uint8_t newbutton = 0;
76 83
   static signed char temp_diff = 0;
77 84
 
78 85
   ENCODER_DiffState temp_diffState = ENCODER_DIFF_NO;
79
-  if (BUTTON_PRESSED(EN1)) newbutton |= 0x01;
80
-  if (BUTTON_PRESSED(EN2)) newbutton |= 0x02;
86
+  if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
87
+  if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
81 88
   if (BUTTON_PRESSED(ENC)) {
82 89
     static millis_t next_click_update_ms;
83 90
     if (ELAPSED(now, next_click_update_ms)) {
@@ -94,22 +101,22 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void) {
94 101
   }
95 102
   if (newbutton != lastEncoderBits) {
96 103
     switch (newbutton) {
97
-      case ENCODER_PHASE_0: {
98
-        if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++;
104
+      case ENCODER_PHASE_0:
105
+             if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++;
99 106
         else if (lastEncoderBits == ENCODER_PHASE_1) temp_diff--;
100
-      }break;
101
-      case ENCODER_PHASE_1: {
102
-        if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++;
107
+        break;
108
+      case ENCODER_PHASE_1:
109
+             if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++;
103 110
         else if (lastEncoderBits == ENCODER_PHASE_2) temp_diff--;
104
-      }break;
105
-      case ENCODER_PHASE_2: {
106
-        if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++;
111
+        break;
112
+      case ENCODER_PHASE_2:
113
+             if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++;
107 114
         else if (lastEncoderBits == ENCODER_PHASE_3) temp_diff--;
108
-      }break;
109
-      case ENCODER_PHASE_3: {
110
-        if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++;
115
+        break;
116
+      case ENCODER_PHASE_3:
117
+             if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++;
111 118
         else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--;
112
-      }break;
119
+        break;
113 120
     }
114 121
     lastEncoderBits = newbutton;
115 122
   }
@@ -137,9 +144,12 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void) {
137 144
         }
138 145
         EncoderRate.lastEncoderTime = ms;
139 146
       }
147
+
140 148
     #else
149
+
141 150
       constexpr int32_t encoderMultiplier = 1;
142
-    #endif // ENCODER_RATE_MULTIPLIER
151
+
152
+    #endif
143 153
 
144 154
     // EncoderRate.encoderMoveValue += (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
145 155
     EncoderRate.encoderMoveValue = (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
@@ -153,23 +163,23 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void) {
153 163
 #if PIN_EXISTS(LCD_LED)
154 164
 
155 165
   // Take the low 24 valid bits  24Bit: G7 G6 G5 G4 G3 G2 G1 G0 R7 R6 R5 R4 R3 R2 R1 R0 B7 B6 B5 B4 B3 B2 B1 B0
156
-  unsigned int LED_DataArray[LED_NUM];
166
+  uint16_t LED_DataArray[LED_NUM];
157 167
 
158 168
   // LED light operation
159
-  void LED_Action(void) {
169
+  void LED_Action() {
160 170
     LED_Control(RGB_SCALE_WARM_WHITE,0x0F);
161 171
     delay(30);
162 172
     LED_Control(RGB_SCALE_WARM_WHITE,0x00);
163 173
   }
164 174
 
165 175
   // LED initialization
166
-  void LED_Configuration(void) {
176
+  void LED_Configuration() {
167 177
     SET_OUTPUT(LCD_LED_PIN);
168 178
   }
169 179
 
170 180
   // LED write data
171
-  void LED_WriteData(void) {
172
-    unsigned char tempCounter_LED, tempCounter_Bit;
181
+  void LED_WriteData() {
182
+    uint8_t tempCounter_LED, tempCounter_Bit;
173 183
     for (tempCounter_LED = 0; tempCounter_LED < LED_NUM; tempCounter_LED++) {
174 184
       for (tempCounter_Bit = 0; tempCounter_Bit < 24; tempCounter_Bit++) {
175 185
         if (LED_DataArray[tempCounter_LED] & (0x800000 >> tempCounter_Bit)) {
@@ -190,14 +200,13 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void) {
190 200
   // LED control
191 201
   //  RGB_Scale: RGB color ratio
192 202
   //  luminance: brightness (0~0xFF)
193
-  void LED_Control(unsigned char RGB_Scale, unsigned char luminance) {
194
-    unsigned char temp_Counter;
195
-    for (temp_Counter = 0; temp_Counter < LED_NUM; temp_Counter++) {
196
-      LED_DataArray[temp_Counter] = 0;
203
+  void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance) {
204
+    for (uint8_t i = 0; i < LED_NUM; i++) {
205
+      LED_DataArray[i] = 0;
197 206
       switch (RGB_Scale) {
198
-        case RGB_SCALE_R10_G7_B5: LED_DataArray[temp_Counter] = (luminance*10/10) << 8 | (luminance*7/10) << 16 | luminance*5/10; break;
199
-        case RGB_SCALE_R10_G7_B4: LED_DataArray[temp_Counter] = (luminance*10/10) << 8 | (luminance*7/10) << 16 | luminance*4/10; break;
200
-        case RGB_SCALE_R10_G8_B7: LED_DataArray[temp_Counter] = (luminance*10/10) << 8 | (luminance*8/10) << 16 | luminance*7/10; break;
207
+        case RGB_SCALE_R10_G7_B5: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 7/10) << 16 | luminance * 5/10; break;
208
+        case RGB_SCALE_R10_G7_B4: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 7/10) << 16 | luminance * 4/10; break;
209
+        case RGB_SCALE_R10_G8_B7: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 8/10) << 16 | luminance * 7/10; break;
201 210
       }
202 211
     }
203 212
     LED_WriteData();
@@ -207,45 +216,38 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void) {
207 216
   //  RGB_Scale: RGB color ratio
208 217
   //  luminance: brightness (0~0xFF)
209 218
   //  change_Time: gradient time (ms)
210
-  void LED_GraduallyControl(unsigned char RGB_Scale, unsigned char luminance, unsigned int change_Interval) {
211
-    unsigned char temp_Counter;
212
-    unsigned char LED_R_Data[LED_NUM], LED_G_Data[LED_NUM], LED_B_Data[LED_NUM];
213
-    bool LED_R_Flag = 0, LED_G_Flag = 0, LED_B_Flag = 0;
214
-
215
-    for (temp_Counter = 0; temp_Counter < LED_NUM; temp_Counter++) {
219
+  void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval) {
220
+    struct { uint8_t g, r, b; } led_data[LED_NUM];
221
+    for (uint8_t i = 0; i < LED_NUM; i++) {
216 222
       switch (RGB_Scale) {
217
-        case RGB_SCALE_R10_G7_B5: {
218
-          LED_R_Data[temp_Counter] = luminance*10/10;
219
-          LED_G_Data[temp_Counter] = luminance*7/10;
220
-          LED_B_Data[temp_Counter] = luminance*5/10;
221
-        }break;
222
-        case RGB_SCALE_R10_G7_B4: {
223
-          LED_R_Data[temp_Counter] = luminance*10/10;
224
-          LED_G_Data[temp_Counter] = luminance*7/10;
225
-          LED_B_Data[temp_Counter] = luminance*4/10;
226
-        }break;
227
-        case RGB_SCALE_R10_G8_B7: {
228
-          LED_R_Data[temp_Counter] = luminance*10/10;
229
-          LED_G_Data[temp_Counter] = luminance*8/10;
230
-          LED_B_Data[temp_Counter] = luminance*7/10;
231
-        }break;
223
+        case RGB_SCALE_R10_G7_B5:
224
+          led_data[i] = { luminance * 7/10, luminance * 10/10, luminance * 5/10 };
225
+          break;
226
+        case RGB_SCALE_R10_G7_B4:
227
+          led_data[i] = { luminance * 7/10, luminance * 10/10, luminance * 4/10 };
228
+          break;
229
+        case RGB_SCALE_R10_G8_B7:
230
+          led_data[i] = { luminance * 8/10, luminance * 10/10, luminance * 7/10 };
231
+          break;
232 232
       }
233 233
     }
234
-      for (temp_Counter = 0; temp_Counter < LED_NUM; temp_Counter++) {
235
-        if ((unsigned char)(LED_DataArray[temp_Counter] >> 8) > LED_R_Data[temp_Counter]) LED_DataArray[temp_Counter] -= 0x000100;
236
-        else if ((unsigned char)(LED_DataArray[temp_Counter] >> 8) < LED_R_Data[temp_Counter]) LED_DataArray[temp_Counter] += 0x000100;
237
-    while (1) {
238
-        else LED_R_Flag = 1;
239
-        if ((unsigned char)(LED_DataArray[temp_Counter]>>16) > LED_G_Data[temp_Counter]) LED_DataArray[temp_Counter] -= 0x010000;
240
-        else if ((unsigned char)(LED_DataArray[temp_Counter]>>16) < LED_G_Data[temp_Counter]) LED_DataArray[temp_Counter] += 0x010000;
241
-        else LED_G_Flag = 1;
242
-        if ((unsigned char)LED_DataArray[temp_Counter] > LED_B_Data[temp_Counter]) LED_DataArray[temp_Counter] -= 0x000001;
243
-        else if ((unsigned char)LED_DataArray[temp_Counter] < LED_B_Data[temp_Counter]) LED_DataArray[temp_Counter] += 0x000001;
244
-        else LED_B_Flag = 1;
234
+
235
+    struct { bool g, r, b; } led_flag = { false, false, false };
236
+    for (uint8_t i = 0; i < LED_NUM; i++) {
237
+      while (1) {
238
+        const uint8_t g = uint8_t(LED_DataArray[i] >> 16),
239
+                      r = uint8_t(LED_DataArray[i] >> 8),
240
+                      b = uint8_t(LED_DataArray[i]);
241
+        if (g == led_data[i].g) led_flag.g = true;
242
+        else LED_DataArray[i] += (g > led_data[i].g) ? -0x010000 : 0x010000;
243
+        if (r == led_data[i].r) led_flag.r = true;
244
+        else LED_DataArray[i] += (r > led_data[i].r) ? -0x000100 : 0x000100;
245
+        if (b == led_data[i].b) led_flag.b = true;
246
+        else LED_DataArray[i] += (b > led_data[i].b) ? -0x000001 : 0x000001;
247
+        LED_WriteData();
248
+        if (led_flag.r && led_flag.g && led_flag.b) break;
249
+        delay(change_Interval);
245 250
       }
246
-      LED_WriteData();
247
-      if (LED_R_Flag && LED_G_Flag && LED_B_Flag) break;
248
-      else delay(change_Interval);
249 251
     }
250 252
   }
251 253
 

+ 7
- 16
Marlin/src/lcd/dwin/e3v2/rotary_encoder.h Ver fichero

@@ -34,15 +34,6 @@
34 34
 
35 35
 /*********************** Encoder Set ***********************/
36 36
 
37
-#define ENCODER_PHASE_0  0
38
-#define ENCODER_PHASE_1  2
39
-#define ENCODER_PHASE_2  3
40
-#define ENCODER_PHASE_3  1
41
-
42
-#define ENCODER_PULSES_PER_STEP  4
43
-
44
-#define BUTTON_PRESSED(BN) !READ(BTN_## BN)
45
-
46 37
 typedef struct {
47 38
   bool enabled = false;
48 39
   int encoderMoveValue = 0;
@@ -59,10 +50,10 @@ typedef enum {
59 50
 } ENCODER_DiffState;
60 51
 
61 52
 // Encoder initialization
62
-void Encoder_Configuration(void);
53
+void Encoder_Configuration();
63 54
 
64 55
 // Analyze encoder value and return state
65
-ENCODER_DiffState Encoder_ReceiveAnalyze(void);
56
+ENCODER_DiffState Encoder_ReceiveAnalyze();
66 57
 
67 58
 /*********************** Encoder LED ***********************/
68 59
 
@@ -82,23 +73,23 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void);
82 73
   extern unsigned int LED_DataArray[LED_NUM];
83 74
 
84 75
   // LED light operation
85
-  void LED_Action(void);
76
+  void LED_Action();
86 77
 
87 78
   // LED initialization
88
-  void LED_Configuration(void);
79
+  void LED_Configuration();
89 80
 
90 81
   // LED write data
91
-  void LED_WriteData(void);
82
+  void LED_WriteData();
92 83
 
93 84
   // LED control
94 85
   //  RGB_Scale: RGB color ratio
95 86
   //  luminance: brightness (0~0xFF)
96
-  void LED_Control(unsigned char RGB_Scale, unsigned char luminance);
87
+  void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance);
97 88
 
98 89
   // LED gradient control
99 90
   //  RGB_Scale: RGB color ratio
100 91
   //  luminance: brightness (0~0xFF)
101 92
   //  change_Time: gradient time (ms)
102
-  void LED_GraduallyControl(unsigned char RGB_Scale, unsigned char luminance, unsigned int change_Interval);
93
+  void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval);
103 94
 
104 95
 #endif // LCD_LED

+ 4
- 14
Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp Ver fichero

@@ -468,19 +468,10 @@ void lv_encoder_pin_init() {
468 468
         #if ANY_BUTTON(EN1, EN2, ENC, BACK)
469 469
 
470 470
           uint8_t newbutton = 0;
471
-
472
-          #if BUTTON_EXISTS(EN1)
473
-            if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
474
-          #endif
475
-          #if BUTTON_EXISTS(EN2)
476
-            if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
477
-          #endif
478
-          #if BUTTON_EXISTS(ENC)
479
-            if (BUTTON_PRESSED(ENC)) newbutton |= EN_C;
480
-          #endif
481
-          #if BUTTON_EXISTS(BACK)
482
-            if (BUTTON_PRESSED(BACK)) newbutton |= EN_D;
483
-          #endif
471
+          if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
472
+          if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
473
+          if (BUTTON_PRESSED(ENC)) newbutton |= EN_C;
474
+          if (BUTTON_PRESSED(BACK)) newbutton |= EN_D;
484 475
 
485 476
         #else
486 477
 
@@ -488,7 +479,6 @@ void lv_encoder_pin_init() {
488 479
 
489 480
         #endif
490 481
 
491
-
492 482
         static uint8_t buttons = 0;
493 483
         buttons = newbutton;
494 484
         static uint8_t lastEncoderBits;

+ 11
- 7
Marlin/src/lcd/lcdprint.h Ver fichero

@@ -76,8 +76,8 @@
76 76
   #define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT)
77 77
   #define INFO_FONT_WIDTH   6
78 78
 
79
-  #define SETCURSOR(col, row)    lcd_moveto((col) * (MENU_FONT_WIDTH), ((row) + 1) * (MENU_FONT_HEIGHT))
80
-  #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH), ((row) + 1) * (MENU_FONT_HEIGHT))
79
+  #define LCD_COL_X(col) ((    (col)) * (MENU_FONT_WIDTH))
80
+  #define LCD_ROW_Y(row) ((1 + (row)) * (MENU_FONT_HEIGHT))
81 81
 
82 82
 #else
83 83
 
@@ -94,14 +94,18 @@
94 94
   #define LCD_PIXEL_WIDTH   LCD_WIDTH
95 95
   #define LCD_PIXEL_HEIGHT  LCD_HEIGHT
96 96
 
97
-  #define SETCURSOR(col, row)    lcd_moveto(col, row)
98
-  #define SETCURSOR_RJ(len, row) SETCURSOR(LCD_WIDTH - (len), row)
97
+  #define LCD_COL_X(col) (col)
98
+  #define LCD_ROW_Y(row) (row)
99 99
 
100 100
 #endif
101 101
 
102
-#define SETCURSOR_X(col)    SETCURSOR(col, _lcdLineNr)
103
-#define SETCURSOR_X_RJ(len) SETCURSOR_RJ(len, _lcdLineNr)
104
-#define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U)
102
+#define LCD_COL_X_RJ(len)      (LCD_PIXEL_WIDTH - LCD_COL_X(len))
103
+#define LCD_BOTTOM_ROW         (LCD_PIXEL_HEIGHT - 1)
104
+#define SETCURSOR(col, row)    lcd_moveto(LCD_COL_X(col), LCD_ROW_Y(row))
105
+#define SETCURSOR_RJ(len, row) lcd_moveto(LCD_COL_X_RJ(len), LCD_ROW_Y(row))
106
+#define SETCURSOR_X(col)       SETCURSOR(col, _lcdLineNr)
107
+#define SETCURSOR_X_RJ(len)    SETCURSOR_RJ(len, _lcdLineNr)
108
+#define START_OF_UTF8_CHAR(C)  (((C) & 0xC0u) != 0x80U)
105 109
 
106 110
 int lcd_glyph_height();
107 111
 

+ 46
- 84
Marlin/src/lcd/marlinui.cpp Ver fichero

@@ -342,7 +342,6 @@ void MarlinUI::init() {
342 342
   init_lcd();
343 343
 
344 344
   #if HAS_DIGITAL_BUTTONS
345
-
346 345
     #if BUTTON_EXISTS(EN1)
347 346
       SET_INPUT_PULLUP(BTN_EN1);
348 347
     #endif
@@ -352,15 +351,12 @@ void MarlinUI::init() {
352 351
     #if BUTTON_EXISTS(ENC)
353 352
       SET_INPUT_PULLUP(BTN_ENC);
354 353
     #endif
355
-
356 354
     #if BUTTON_EXISTS(ENC_EN)
357 355
       SET_INPUT_PULLUP(BTN_ENC_EN);
358 356
     #endif
359
-
360 357
     #if BUTTON_EXISTS(BACK)
361 358
       SET_INPUT_PULLUP(BTN_BACK);
362 359
     #endif
363
-
364 360
     #if BUTTON_EXISTS(UP)
365 361
       SET_INPUT(BTN_UP);
366 362
     #endif
@@ -373,8 +369,7 @@ void MarlinUI::init() {
373 369
     #if BUTTON_EXISTS(RT)
374 370
       SET_INPUT(BTN_RT);
375 371
     #endif
376
-
377
-  #endif // !HAS_DIGITAL_BUTTONS
372
+  #endif
378 373
 
379 374
   #if HAS_SHIFT_ENCODER
380 375
 
@@ -383,14 +378,14 @@ void MarlinUI::init() {
383 378
       SET_OUTPUT(SR_DATA_PIN);
384 379
       SET_OUTPUT(SR_CLK_PIN);
385 380
 
386
-    #elif defined(SHIFT_CLK)
381
+    #elif PIN_EXISTS(SHIFT_CLK)
387 382
 
388
-      SET_OUTPUT(SHIFT_CLK);
389
-      OUT_WRITE(SHIFT_LD, HIGH);
390
-      #if defined(SHIFT_EN) && SHIFT_EN >= 0
391
-        OUT_WRITE(SHIFT_EN, LOW);
383
+      SET_OUTPUT(SHIFT_CLK_PIN);
384
+      OUT_WRITE(SHIFT_LD_PIN, HIGH);
385
+      #if PIN_EXISTS(SHIFT_EN)
386
+        OUT_WRITE(SHIFT_EN_PIN, LOW);
392 387
       #endif
393
-      SET_INPUT_PULLUP(SHIFT_OUT);
388
+      SET_INPUT_PULLUP(SHIFT_OUT_PIN);
394 389
 
395 390
     #endif
396 391
 
@@ -830,11 +825,7 @@ millis_t next_lcd_update_ms;
830 825
 #endif
831 826
 
832 827
 inline bool can_encode() {
833
-  #if BUTTON_EXISTS(ENC_EN)
834
-    return !BUTTON_PRESSED(ENC_EN);  // Update position only when ENC_EN is HIGH
835
-  #else
836
-    return true;
837
-  #endif
828
+  return !BUTTON_PRESSED(ENC_EN); // Update encoder only when ENC_EN is not LOW (pressed)
838 829
 }
839 830
 
840 831
 void MarlinUI::update() {
@@ -890,18 +881,17 @@ void MarlinUI::update() {
890 881
         else if (!wait_for_unclick && (buttons & EN_C))   // OK button, if not waiting for a debounce release:
891 882
           do_click();
892 883
       }
893
-      else // keep wait_for_unclick value
894
-
895
-    #endif // HAS_TOUCH_BUTTONS
884
+      // keep wait_for_unclick value
885
+    #endif
896 886
 
897
-      {
898
-        // Integrated LCD click handling via button_pressed
899
-        if (!external_control && button_pressed()) {
900
-          if (!wait_for_unclick) do_click();              // Handle the click
901
-        }
902
-        else
903
-          wait_for_unclick = false;
887
+    if (!touch_buttons) {
888
+      // Integrated LCD click handling via button_pressed
889
+      if (!external_control && button_pressed()) {
890
+        if (!wait_for_unclick) do_click();              // Handle the click
904 891
       }
892
+      else
893
+        wait_for_unclick = false;
894
+    }
905 895
 
906 896
     if (LCD_BACK_CLICKED()) {
907 897
       quick_feedback();
@@ -1198,19 +1188,10 @@ void MarlinUI::update() {
1198 1188
         #if ANY_BUTTON(EN1, EN2, ENC, BACK)
1199 1189
 
1200 1190
           uint8_t newbutton = 0;
1201
-
1202
-          #if BUTTON_EXISTS(EN1)
1203
-            if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
1204
-          #endif
1205
-          #if BUTTON_EXISTS(EN2)
1206
-            if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
1207
-          #endif
1208
-          #if BUTTON_EXISTS(ENC)
1209
-            if (can_encode() && BUTTON_PRESSED(ENC)) newbutton |= EN_C;
1210
-          #endif
1211
-          #if BUTTON_EXISTS(BACK)
1212
-            if (BUTTON_PRESSED(BACK)) newbutton |= EN_D;
1213
-          #endif
1191
+          if (BUTTON_PRESSED(EN1))                 newbutton |= EN_A;
1192
+          if (BUTTON_PRESSED(EN2))                 newbutton |= EN_B;
1193
+          if (can_encode() && BUTTON_PRESSED(ENC)) newbutton |= EN_C;
1194
+          if (BUTTON_PRESSED(BACK))                newbutton |= EN_D;
1214 1195
 
1215 1196
         #else
1216 1197
 
@@ -1225,40 +1206,26 @@ void MarlinUI::update() {
1225 1206
 
1226 1207
           const int8_t pulses = epps * encoderDirection;
1227 1208
 
1228
-          if (false) {
1229
-            // for the else-ifs below
1209
+          if (BUTTON_PRESSED(UP)) {
1210
+            encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * pulses;
1211
+            next_button_update_ms = now + 300;
1212
+          }
1213
+          else if (BUTTON_PRESSED(DWN)) {
1214
+            encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM) * pulses;
1215
+            next_button_update_ms = now + 300;
1216
+          }
1217
+          else if (BUTTON_PRESSED(LFT)) {
1218
+            encoderDiff = -pulses;
1219
+            next_button_update_ms = now + 300;
1220
+          }
1221
+          else if (BUTTON_PRESSED(RT)) {
1222
+            encoderDiff = pulses;
1223
+            next_button_update_ms = now + 300;
1230 1224
           }
1231
-          #if BUTTON_EXISTS(UP)
1232
-            else if (BUTTON_PRESSED(UP)) {
1233
-              encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * pulses;
1234
-              next_button_update_ms = now + 300;
1235
-            }
1236
-          #endif
1237
-          #if BUTTON_EXISTS(DWN)
1238
-            else if (BUTTON_PRESSED(DWN)) {
1239
-              encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM) * pulses;
1240
-              next_button_update_ms = now + 300;
1241
-            }
1242
-          #endif
1243
-          #if BUTTON_EXISTS(LFT)
1244
-            else if (BUTTON_PRESSED(LFT)) {
1245
-              encoderDiff = -pulses;
1246
-              next_button_update_ms = now + 300;
1247
-            }
1248
-          #endif
1249
-          #if BUTTON_EXISTS(RT)
1250
-            else if (BUTTON_PRESSED(RT)) {
1251
-              encoderDiff = pulses;
1252
-              next_button_update_ms = now + 300;
1253
-            }
1254
-          #endif
1255 1225
 
1256 1226
         #endif // UP || DWN || LFT || RT
1257 1227
 
1258
-        buttons = (newbutton
1259
-          #if HAS_SLOW_BUTTONS
1260
-            | slow_buttons
1261
-          #endif
1228
+        buttons = (newbutton | TERN0(HAS_SLOW_BUTTONS, slow_buttons)
1262 1229
           #if BOTH(HAS_TOUCH_BUTTONS, HAS_ENCODER_ACTION)
1263 1230
             | (touch_buttons & TERN(HAS_ENCODER_WHEEL, ~(EN_A | EN_B), 0xFF))
1264 1231
           #endif
@@ -1284,13 +1251,13 @@ void MarlinUI::update() {
1284 1251
          * The rotary encoder part is also independent of the LCD chipset.
1285 1252
          */
1286 1253
         uint8_t val = 0;
1287
-        WRITE(SHIFT_LD, LOW);
1288
-        WRITE(SHIFT_LD, HIGH);
1254
+        WRITE(SHIFT_LD_PIN, LOW);
1255
+        WRITE(SHIFT_LD_PIN, HIGH);
1289 1256
         LOOP_L_N(i, 8) {
1290 1257
           val >>= 1;
1291
-          if (READ(SHIFT_OUT)) SBI(val, 7);
1292
-          WRITE(SHIFT_CLK, HIGH);
1293
-          WRITE(SHIFT_CLK, LOW);
1258
+          if (READ(SHIFT_OUT_PIN)) SBI(val, 7);
1259
+          WRITE(SHIFT_CLK_PIN, HIGH);
1260
+          WRITE(SHIFT_CLK_PIN, LOW);
1294 1261
         }
1295 1262
         TERN(REPRAPWORLD_KEYPAD, keypad_buttons, buttons) = ~val;
1296 1263
       #endif
@@ -1306,11 +1273,6 @@ void MarlinUI::update() {
1306 1273
     #if HAS_ENCODER_WHEEL
1307 1274
       static uint8_t lastEncoderBits;
1308 1275
 
1309
-      #define encrot0 0
1310
-      #define encrot1 2
1311
-      #define encrot2 3
1312
-      #define encrot3 1
1313
-
1314 1276
       // Manage encoder rotation
1315 1277
       #define ENCODER_SPIN(_E1, _E2) switch (lastEncoderBits) { case _E1: encoderDiff += encoderDirection; break; case _E2: encoderDiff -= encoderDirection; }
1316 1278
 
@@ -1319,10 +1281,10 @@ void MarlinUI::update() {
1319 1281
       if (buttons & EN_B) enc |= B10;
1320 1282
       if (enc != lastEncoderBits) {
1321 1283
         switch (enc) {
1322
-          case encrot0: ENCODER_SPIN(encrot3, encrot1); break;
1323
-          case encrot1: ENCODER_SPIN(encrot0, encrot2); break;
1324
-          case encrot2: ENCODER_SPIN(encrot1, encrot3); break;
1325
-          case encrot3: ENCODER_SPIN(encrot2, encrot0); break;
1284
+          case ENCODER_PHASE_0: ENCODER_SPIN(ENCODER_PHASE_3, ENCODER_PHASE_1); break;
1285
+          case ENCODER_PHASE_1: ENCODER_SPIN(ENCODER_PHASE_0, ENCODER_PHASE_2); break;
1286
+          case ENCODER_PHASE_2: ENCODER_SPIN(ENCODER_PHASE_1, ENCODER_PHASE_3); break;
1287
+          case ENCODER_PHASE_3: ENCODER_SPIN(ENCODER_PHASE_2, ENCODER_PHASE_0); break;
1326 1288
         }
1327 1289
         #if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL)
1328 1290
           external_encoder();

+ 4
- 138
Marlin/src/lcd/marlinui.h Ver fichero

@@ -25,6 +25,8 @@
25 25
 
26 26
 #include "../module/motion.h"
27 27
 
28
+#include "buttons.h"
29
+
28 30
 #if HAS_BUZZER
29 31
   #include "../libs/buzzer.h"
30 32
 #endif
@@ -40,20 +42,6 @@
40 42
 #if EITHER(HAS_LCD_MENU, ULTIPANEL_FEEDMULTIPLY)
41 43
   #define HAS_ENCODER_ACTION 1
42 44
 #endif
43
-#if ((!HAS_ADC_BUTTONS && IS_NEWPANEL) || BUTTONS_EXIST(EN1, EN2)) && !IS_TFTGLCD_PANEL
44
-  #define HAS_ENCODER_WHEEL 1
45
-#endif
46
-#if HAS_ENCODER_WHEEL || ANY_BUTTON(ENC, BACK, UP, DWN, LFT, RT)
47
-  #define HAS_DIGITAL_BUTTONS 1
48
-#endif
49
-#if !HAS_ADC_BUTTONS && (IS_RRW_KEYPAD || (HAS_WIRED_LCD && !IS_NEWPANEL))
50
-  #define HAS_SHIFT_ENCODER 1
51
-#endif
52
-
53
-// I2C buttons must be read in the main thread
54
-#if ANY(LCD_I2C_VIKI, LCD_I2C_PANELOLU2, IS_TFTGLCD_PANEL)
55
-  #define HAS_SLOW_BUTTONS 1
56
-#endif
57 45
 
58 46
 #if E_MANUAL > 1
59 47
   #define MULTI_MANUAL 1
@@ -114,130 +102,6 @@
114 102
 
115 103
 #endif // HAS_WIRED_LCD
116 104
 
117
-#if IS_RRW_KEYPAD
118
-  #define BTN_OFFSET          0 // Bit offset into buttons for shift register values
119
-
120
-  #define BLEN_KEYPAD_F3      0
121
-  #define BLEN_KEYPAD_F2      1
122
-  #define BLEN_KEYPAD_F1      2
123
-  #define BLEN_KEYPAD_DOWN    3
124
-  #define BLEN_KEYPAD_RIGHT   4
125
-  #define BLEN_KEYPAD_MIDDLE  5
126
-  #define BLEN_KEYPAD_UP      6
127
-  #define BLEN_KEYPAD_LEFT    7
128
-
129
-  #define EN_KEYPAD_F1      _BV(BTN_OFFSET + BLEN_KEYPAD_F1)
130
-  #define EN_KEYPAD_F2      _BV(BTN_OFFSET + BLEN_KEYPAD_F2)
131
-  #define EN_KEYPAD_F3      _BV(BTN_OFFSET + BLEN_KEYPAD_F3)
132
-  #define EN_KEYPAD_DOWN    _BV(BTN_OFFSET + BLEN_KEYPAD_DOWN)
133
-  #define EN_KEYPAD_RIGHT   _BV(BTN_OFFSET + BLEN_KEYPAD_RIGHT)
134
-  #define EN_KEYPAD_MIDDLE  _BV(BTN_OFFSET + BLEN_KEYPAD_MIDDLE)
135
-  #define EN_KEYPAD_UP      _BV(BTN_OFFSET + BLEN_KEYPAD_UP)
136
-  #define EN_KEYPAD_LEFT    _BV(BTN_OFFSET + BLEN_KEYPAD_LEFT)
137
-
138
-  #define RRK(B) (keypad_buttons & (B))
139
-
140
-  #ifdef EN_C
141
-    #define BUTTON_CLICK() ((buttons & EN_C) || RRK(EN_KEYPAD_MIDDLE))
142
-  #else
143
-    #define BUTTON_CLICK() RRK(EN_KEYPAD_MIDDLE)
144
-  #endif
145
-
146
-#endif // IS_RRW_KEYPAD
147
-
148
-#if HAS_DIGITAL_BUTTONS
149
-
150
-  // Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes)
151
-  #define BLEN_A 0
152
-  #define BLEN_B 1
153
-
154
-  #define EN_A _BV(BLEN_A)
155
-  #define EN_B _BV(BLEN_B)
156
-
157
-  #define BUTTON_PRESSED(BN) !READ(BTN_## BN)
158
-
159
-  #if BUTTON_EXISTS(ENC) || HAS_TOUCH_BUTTONS
160
-    #define BLEN_C 2
161
-    #define EN_C _BV(BLEN_C)
162
-  #endif
163
-
164
-  #if ENABLED(LCD_I2C_VIKI)
165
-
166
-    #include <LiquidTWI2.h>
167
-
168
-    #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
169
-
170
-    // button and encoder bit positions within 'buttons'
171
-    #define B_LE (BUTTON_LEFT   << B_I2C_BTN_OFFSET)      // The remaining normalized buttons are all read via I2C
172
-    #define B_UP (BUTTON_UP     << B_I2C_BTN_OFFSET)
173
-    #define B_MI (BUTTON_SELECT << B_I2C_BTN_OFFSET)
174
-    #define B_DW (BUTTON_DOWN   << B_I2C_BTN_OFFSET)
175
-    #define B_RI (BUTTON_RIGHT  << B_I2C_BTN_OFFSET)
176
-
177
-    #if BUTTON_EXISTS(ENC)                                // The pause/stop/restart button is connected to BTN_ENC when used
178
-      #define B_ST (EN_C)                                 // Map the pause/stop/resume button into its normalized functional name
179
-      #define BUTTON_CLICK() (buttons & (B_MI|B_RI|B_ST)) // Pause/stop also acts as click until a proper pause/stop is implemented.
180
-    #else
181
-      #define BUTTON_CLICK() (buttons & (B_MI|B_RI))
182
-    #endif
183
-
184
-    // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
185
-
186
-  #elif ENABLED(LCD_I2C_PANELOLU2)
187
-
188
-    #if !BUTTON_EXISTS(ENC) // Use I2C if not directly connected to a pin
189
-
190
-      #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
191
-
192
-      #define B_MI (PANELOLU2_ENCODER_C << B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
193
-
194
-      #define BUTTON_CLICK() (buttons & B_MI)
195
-
196
-    #endif
197
-
198
-  #endif
199
-
200
-#else
201
-
202
-  #undef BUTTON_EXISTS
203
-  #define BUTTON_EXISTS(...) false
204
-
205
-  // Shift register bits correspond to buttons:
206
-  #define BL_LE 7   // Left
207
-  #define BL_UP 6   // Up
208
-  #define BL_MI 5   // Middle
209
-  #define BL_DW 4   // Down
210
-  #define BL_RI 3   // Right
211
-  #define BL_ST 2   // Red Button
212
-  #define B_LE _BV(BL_LE)
213
-  #define B_UP _BV(BL_UP)
214
-  #define B_MI _BV(BL_MI)
215
-  #define B_DW _BV(BL_DW)
216
-  #define B_RI _BV(BL_RI)
217
-  #define B_ST _BV(BL_ST)
218
-
219
-  #ifndef BUTTON_CLICK
220
-    #define BUTTON_CLICK() (buttons & (B_MI|B_ST))
221
-  #endif
222
-
223
-#endif
224
-
225
-#if BUTTON_EXISTS(BACK) || EITHER(HAS_TOUCH_BUTTONS, IS_TFTGLCD_PANEL)
226
-  #define BLEN_D 3
227
-  #define EN_D _BV(BLEN_D)
228
-  #define LCD_BACK_CLICKED() (buttons & EN_D)
229
-#else
230
-  #define LCD_BACK_CLICKED() false
231
-#endif
232
-
233
-#ifndef BUTTON_CLICK
234
-  #ifdef EN_C
235
-    #define BUTTON_CLICK() (buttons & EN_C)
236
-  #else
237
-    #define BUTTON_CLICK() false
238
-  #endif
239
-#endif
240
-
241 105
 #if HAS_MARLINUI_U8GLIB
242 106
   enum MarlinFont : uint8_t {
243 107
     FONT_STATUSMENU = 1,
@@ -556,6 +420,8 @@ public:
556 420
     #if HAS_TOUCH_BUTTONS
557 421
       static uint8_t touch_buttons;
558 422
       static uint8_t repeat_delay;
423
+    #else
424
+      static constexpr uint8_t touch_buttons = 0;
559 425
     #endif
560 426
 
561 427
     #if ENABLED(ENCODER_RATE_MULTIPLIER)

+ 2
- 2
Marlin/src/lcd/touch/touch_buttons.cpp Ver fichero

@@ -31,7 +31,8 @@ XPT2046 touchIO;
31 31
   #include "../tft_io/touch_calibration.h"
32 32
 #endif
33 33
 
34
-#include "../marlinui.h" // For EN_C bit mask
34
+#include "../buttons.h" // For EN_C bit mask
35
+#include "../marlinui.h" // For ui.refresh
35 36
 #include "../tft_io/tft_io.h"
36 37
 
37 38
 #define DOGM_AREA_LEFT   TFT_PIXEL_OFFSET_X
@@ -66,7 +67,6 @@ uint8_t TouchButtons::read_buttons() {
66 67
       y = uint16_t((uint32_t(y) * TOUCH_CALIBRATION_Y) >> 16) + TOUCH_OFFSET_Y;
67 68
     #endif
68 69
 
69
-
70 70
     // Touch within the button area simulates an encoder button
71 71
     if (y > BUTTON_AREA_TOP && y < BUTTON_AREA_BOT)
72 72
       return WITHIN(x, BUTTOND_X_LO, BUTTOND_X_HI) ? EN_D

+ 7
- 7
Marlin/src/pins/linux/pins_RAMPS_LINUX.h Ver fichero

@@ -459,10 +459,10 @@
459 459
     #if !IS_NEWPANEL
460 460
       // Buttons attached to a shift register
461 461
       // Not wired yet
462
-      //#define SHIFT_CLK                     38
463
-      //#define SHIFT_LD                      42
464
-      //#define SHIFT_OUT                     40
465
-      //#define SHIFT_EN                      17
462
+      //#define SHIFT_CLK_PIN                 38
463
+      //#define SHIFT_LD_PIN                  42
464
+      //#define SHIFT_OUT_PIN                 40
465
+      //#define SHIFT_EN_PIN                  17
466 466
     #endif
467 467
 
468 468
   #endif
@@ -608,9 +608,9 @@
608 608
 
609 609
       // Buttons are directly attached to AUX-2
610 610
       #if IS_RRW_KEYPAD
611
-        #define SHIFT_OUT                     40
612
-        #define SHIFT_CLK                     44
613
-        #define SHIFT_LD                      42
611
+        #define SHIFT_OUT_PIN                 40
612
+        #define SHIFT_CLK_PIN                 44
613
+        #define SHIFT_LD_PIN                  42
614 614
         #define BTN_EN1                       64
615 615
         #define BTN_EN2                       59
616 616
         #define BTN_ENC                       63

+ 7
- 7
Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h Ver fichero

@@ -354,15 +354,15 @@
354 354
 
355 355
   #if IS_NEWPANEL
356 356
     #if IS_RRW_KEYPAD
357
-      #define SHIFT_OUT                    P0_18  // (51) (MOSI) J3-10 & AUX-3
358
-      #define SHIFT_CLK                    P0_15  // (52) (SCK)  J3-9 & AUX-3
359
-      #define SHIFT_LD                     P1_31  // (49)        J3-1 & AUX-3 (NOT 5V tolerant)
357
+      #define SHIFT_OUT_PIN                P0_18  // (51) (MOSI) J3-10 & AUX-3
358
+      #define SHIFT_CLK_PIN                P0_15  // (52) (SCK)  J3-9 & AUX-3
359
+      #define SHIFT_LD_PIN                 P1_31  // (49)        J3-1 & AUX-3 (NOT 5V tolerant)
360 360
     #endif
361 361
   #else
362
-    //#define SHIFT_CLK                    P3_26  // (31)  J3-2 & AUX-4
363
-    //#define SHIFT_LD                     P3_25  // (33)  J3-4 & AUX-4
364
-    //#define SHIFT_OUT                    P2_11  // (35)  J3-3 & AUX-4
365
-    //#define SHIFT_EN                     P1_22  // (41)  J5-4 & AUX-4
362
+    //#define SHIFT_CLK_PIN                P3_26  // (31)  J3-2 & AUX-4
363
+    //#define SHIFT_LD_PIN                 P3_25  // (33)  J3-4 & AUX-4
364
+    //#define SHIFT_OUT_PIN                P2_11  // (35)  J3-3 & AUX-4
365
+    //#define SHIFT_EN_PIN                 P1_22  // (41)  J5-4 & AUX-4
366 366
   #endif
367 367
 
368 368
   #if ANY(VIKI2, miniVIKI)

+ 7
- 7
Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h Ver fichero

@@ -147,14 +147,14 @@
147 147
     #define DOGLCD_A0                      P2_06  // (59) J3-8 & AUX-2
148 148
 
149 149
     #if IS_RRW_KEYPAD
150
-      #define SHIFT_OUT                    P0_18  // (51)  (MOSI) J3-10 & AUX-3
151
-      #define SHIFT_CLK                    P0_15  // (52)  (SCK)  J3-9 & AUX-3
152
-      #define SHIFT_LD                     P1_31  // (49)  not 5V tolerant   J3-1 & AUX-3
150
+      #define SHIFT_OUT_PIN                P0_18  // (51)  (MOSI) J3-10 & AUX-3
151
+      #define SHIFT_CLK_PIN                P0_15  // (52)  (SCK)  J3-9 & AUX-3
152
+      #define SHIFT_LD_PIN                 P1_31  // (49)  not 5V tolerant   J3-1 & AUX-3
153 153
     #elif !IS_NEWPANEL
154
-      //#define SHIFT_OUT                  P2_11  // (35)  J3-3 & AUX-4
155
-      //#define SHIFT_CLK                  P3_26  // (31)  J3-2 & AUX-4
156
-      //#define SHIFT_LD                   P3_25  // (33)  J3-4 & AUX-4
157
-      //#define SHIFT_EN                   P1_22  // (41)  J5-4 & AUX-4
154
+      //#define SHIFT_OUT_PIN              P2_11  // (35)  J3-3 & AUX-4
155
+      //#define SHIFT_CLK_PIN              P3_26  // (31)  J3-2 & AUX-4
156
+      //#define SHIFT_LD_PIN               P3_25  // (33)  J3-4 & AUX-4
157
+      //#define SHIFT_EN_PIN               P1_22  // (41)  J5-4 & AUX-4
158 158
     #endif
159 159
 
160 160
     #if ANY(VIKI2, miniVIKI)

+ 3
- 3
Marlin/src/pins/mega/pins_CNCONTROLS_11.h Ver fichero

@@ -149,9 +149,9 @@
149 149
 #define BTN_ENC                               27
150 150
 
151 151
 // Hardware buttons for manual movement of XYZ
152
-#define SHIFT_OUT                             19
153
-#define SHIFT_LD                              18
154
-#define SHIFT_CLK                             17
152
+#define SHIFT_OUT_PIN                         19
153
+#define SHIFT_LD_PIN                          18
154
+#define SHIFT_CLK_PIN                         17
155 155
 
156 156
 //#define UI1                                 31
157 157
 //#define UI2                                 22

+ 3
- 3
Marlin/src/pins/mega/pins_CNCONTROLS_12.h Ver fichero

@@ -156,9 +156,9 @@
156 156
 #define BTN_ENC                               38
157 157
 
158 158
 // Hardware buttons for manual movement of XYZ
159
-#define SHIFT_OUT                             42
160
-#define SHIFT_LD                              41
161
-#define SHIFT_CLK                             40
159
+#define SHIFT_OUT_PIN                         42
160
+#define SHIFT_LD_PIN                          41
161
+#define SHIFT_CLK_PIN                         40
162 162
 
163 163
 //#define UI1                                 43
164 164
 //#define UI2                                 37

+ 4
- 4
Marlin/src/pins/mega/pins_GT2560_REV_A.h Ver fichero

@@ -146,10 +146,10 @@
146 146
 
147 147
   #else                                           // !IS_NEWPANEL
148 148
 
149
-    #define SHIFT_CLK                         38
150
-    #define SHIFT_LD                          42
151
-    #define SHIFT_OUT                         40
152
-    #define SHIFT_EN                          17
149
+    #define SHIFT_CLK_PIN                     38
150
+    #define SHIFT_LD_PIN                      42
151
+    #define SHIFT_OUT_PIN                     40
152
+    #define SHIFT_EN_PIN                      17
153 153
 
154 154
     #define LCD_PINS_RS                       16
155 155
     #define LCD_PINS_ENABLE                    5

+ 4
- 4
Marlin/src/pins/mega/pins_HJC2560C_REV2.h Ver fichero

@@ -156,10 +156,10 @@
156 156
   #else
157 157
 
158 158
     // Buttons attached to a shift register
159
-    #define SHIFT_CLK                         38
160
-    #define SHIFT_LD                          42
161
-    #define SHIFT_OUT                         40
162
-    #define SHIFT_EN                          17
159
+    #define SHIFT_CLK_PIN                     38
160
+    #define SHIFT_LD_PIN                      42
161
+    #define SHIFT_OUT_PIN                     40
162
+    #define SHIFT_EN_PIN                      17
163 163
 
164 164
     #define LCD_PINS_RS                       16
165 165
     #define LCD_PINS_ENABLE                    5

+ 4
- 4
Marlin/src/pins/mega/pins_MEGATRONICS_2.h Ver fichero

@@ -146,10 +146,10 @@
146 146
     #define BTN_ENC                           43
147 147
   #else
148 148
     // Buttons attached to shift register of reprapworld keypad v1.1
149
-    #define SHIFT_CLK                         63
150
-    #define SHIFT_LD                          42
151
-    #define SHIFT_OUT                         17
152
-    #define SHIFT_EN                          17
149
+    #define SHIFT_CLK_PIN                     63
150
+    #define SHIFT_LD_PIN                      42
151
+    #define SHIFT_OUT_PIN                     17
152
+    #define SHIFT_EN_PIN                      17
153 153
   #endif
154 154
 
155 155
 #endif // HAS_WIRED_LCD

+ 4
- 4
Marlin/src/pins/mega/pins_MEGATRONICS_3.h Ver fichero

@@ -162,10 +162,10 @@
162 162
   #define LCD_PINS_D6                         39
163 163
   #define LCD_PINS_D7                         15
164 164
 
165
-  #define SHIFT_CLK                           43
166
-  #define SHIFT_LD                            35
167
-  #define SHIFT_OUT                           34
168
-  #define SHIFT_EN                            44
165
+  #define SHIFT_CLK_PIN                       43
166
+  #define SHIFT_LD_PIN                        35
167
+  #define SHIFT_OUT_PIN                       34
168
+  #define SHIFT_EN_PIN                        44
169 169
 
170 170
   #if MB(MEGATRONICS_31, MEGATRONICS_32)
171 171
     #define SD_DETECT_PIN                     56

+ 8
- 8
Marlin/src/pins/pinsDebug_list.h Ver fichero

@@ -833,17 +833,17 @@
833 833
 #if PIN_EXISTS(SERVO3)
834 834
   REPORT_NAME_DIGITAL(__LINE__, SERVO3_PIN)
835 835
 #endif
836
-#if defined(SHIFT_CLK) && SHIFT_CLK >= 0
837
-  REPORT_NAME_DIGITAL(__LINE__, SHIFT_CLK)
836
+#if PIN_EXISTS(SHIFT_CLK)
837
+  REPORT_NAME_DIGITAL(__LINE__, SHIFT_CLK_PIN)
838 838
 #endif
839
-#if defined(SHIFT_EN) && SHIFT_EN >= 0
840
-  REPORT_NAME_DIGITAL(__LINE__, SHIFT_EN)
839
+#if PIN_EXISTS(SHIFT_EN)
840
+  REPORT_NAME_DIGITAL(__LINE__, SHIFT_EN_PIN)
841 841
 #endif
842
-#if defined(SHIFT_LD) && SHIFT_LD >= 0
843
-  REPORT_NAME_DIGITAL(__LINE__, SHIFT_LD)
842
+#if PIN_EXISTS(SHIFT_LD)
843
+  REPORT_NAME_DIGITAL(__LINE__, SHIFT_LD_PIN)
844 844
 #endif
845
-#if defined(SHIFT_OUT) && SHIFT_OUT >= 0
846
-  REPORT_NAME_DIGITAL(__LINE__, SHIFT_OUT)
845
+#if PIN_EXISTS(SHIFT_OUT)
846
+  REPORT_NAME_DIGITAL(__LINE__, SHIFT_OUT_PIN)
847 847
 #endif
848 848
 #if PIN_EXISTS(SLED)
849 849
   REPORT_NAME_DIGITAL(__LINE__, SLED_PIN)

+ 4
- 4
Marlin/src/pins/rambo/pins_RAMBO.h Ver fichero

@@ -239,10 +239,10 @@
239 239
 
240 240
     // Buttons attached to a shift register
241 241
     // Not wired yet
242
-    //#define SHIFT_CLK                       38
243
-    //#define SHIFT_LD                        42
244
-    //#define SHIFT_OUT                       40
245
-    //#define SHIFT_EN                        17
242
+    //#define SHIFT_CLK_PIN                   38
243
+    //#define SHIFT_LD_PIN                    42
244
+    //#define SHIFT_OUT_PIN                   40
245
+    //#define SHIFT_EN_PIN                    17
246 246
 
247 247
     #define LCD_PINS_RS                       75
248 248
     #define LCD_PINS_ENABLE                   17

+ 7
- 7
Marlin/src/pins/ramps/pins_RAMPS.h Ver fichero

@@ -504,10 +504,10 @@
504 504
     #if !IS_NEWPANEL
505 505
       // Buttons attached to a shift register
506 506
       // Not wired yet
507
-      //#define SHIFT_CLK                     38
508
-      //#define SHIFT_LD                      42
509
-      //#define SHIFT_OUT                     40
510
-      //#define SHIFT_EN                      17
507
+      //#define SHIFT_CLK_PIN                 38
508
+      //#define SHIFT_LD_PIN                  42
509
+      //#define SHIFT_OUT_PIN                 40
510
+      //#define SHIFT_EN_PIN                  17
511 511
     #endif
512 512
 
513 513
   #endif
@@ -722,9 +722,9 @@
722 722
 #endif // HAS_WIRED_LCD
723 723
 
724 724
 #if IS_RRW_KEYPAD && !HAS_ADC_BUTTONS
725
-  #define SHIFT_OUT                           40
726
-  #define SHIFT_CLK                           44
727
-  #define SHIFT_LD                            42
725
+  #define SHIFT_OUT_PIN                       40
726
+  #define SHIFT_CLK_PIN                       44
727
+  #define SHIFT_LD_PIN                        42
728 728
   #ifndef BTN_EN1
729 729
     #define BTN_EN1                           64
730 730
   #endif

+ 7
- 7
Marlin/src/pins/ramps/pins_TT_OSCAR.h Ver fichero

@@ -342,10 +342,10 @@
342 342
     #if !IS_NEWPANEL
343 343
       // Buttons attached to a shift register
344 344
       // Not wired yet
345
-      //#define SHIFT_CLK                     38
346
-      //#define SHIFT_LD                      42
347
-      //#define SHIFT_OUT                     40
348
-      //#define SHIFT_EN                      17
345
+      //#define SHIFT_CLK_PIN                 38
346
+      //#define SHIFT_LD_PIN                  42
347
+      //#define SHIFT_OUT_PIN                 40
348
+      //#define SHIFT_EN_PIN                  17
349 349
     #endif
350 350
 
351 351
   #endif
@@ -491,9 +491,9 @@
491 491
 
492 492
       // Buttons are directly attached to AUX-2
493 493
       #if IS_RRW_KEYPAD
494
-        #define SHIFT_OUT                     40
495
-        #define SHIFT_CLK                     44
496
-        #define SHIFT_LD                      42
494
+        #define SHIFT_OUT_PIN                 40
495
+        #define SHIFT_CLK_PIN                 44
496
+        #define SHIFT_LD_PIN                  42
497 497
         #define BTN_EN1                       64
498 498
         #define BTN_EN2                       59
499 499
         #define BTN_ENC                       63

+ 4
- 4
Marlin/src/pins/ramps/pins_ULTIMAKER.h Ver fichero

@@ -142,10 +142,10 @@
142 142
   #else                                           // !IS_NEWPANEL - Old style panel with shift register
143 143
 
144 144
     // Buttons attached to a shift register
145
-    #define SHIFT_CLK                         38
146
-    #define SHIFT_LD                          42
147
-    #define SHIFT_OUT                         40
148
-    #define SHIFT_EN                          17
145
+    #define SHIFT_CLK_PIN                     38
146
+    #define SHIFT_LD_PIN                      42
147
+    #define SHIFT_OUT_PIN                     40
148
+    #define SHIFT_EN_PIN                      17
149 149
 
150 150
     #define LCD_PINS_RS                       16
151 151
     #define LCD_PINS_ENABLE                    5

+ 4
- 4
Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h Ver fichero

@@ -197,10 +197,10 @@
197 197
   #else                                           // !IS_NEWPANEL - Old style panel with shift register
198 198
 
199 199
     // Buttons attached to a shift register
200
-    #define SHIFT_CLK                         38
201
-    #define SHIFT_LD                          42
202
-    #define SHIFT_OUT                         40
203
-    #define SHIFT_EN                          17
200
+    #define SHIFT_CLK_PIN                     38
201
+    #define SHIFT_LD_PIN                      42
202
+    #define SHIFT_OUT_PIN                     40
203
+    #define SHIFT_EN_PIN                      17
204 204
 
205 205
     #define LCD_PINS_RS                       16
206 206
     #define LCD_PINS_ENABLE                    5

+ 3
- 3
Marlin/src/pins/ramps/pins_ZRIB_V20.h Ver fichero

@@ -69,9 +69,9 @@
69 69
   #undef ADC_KEYPAD_PIN
70 70
   #undef BEEPER_PIN
71 71
 
72
-  #undef SHIFT_OUT
73
-  #undef SHIFT_CLK
74
-  #undef SHIFT_LD
72
+  #undef SHIFT_OUT_PIN
73
+  #undef SHIFT_CLK_PIN
74
+  #undef SHIFT_LD_PIN
75 75
   #undef BTN_EN1
76 76
   #undef BTN_EN2
77 77
   #undef BTN_ENC

+ 7
- 7
Marlin/src/pins/samd/pins_RAMPS_144.h Ver fichero

@@ -363,10 +363,10 @@
363 363
     #if !IS_NEWPANEL
364 364
       // Buttons attached to a shift register
365 365
       // Not wired yet
366
-      //#define SHIFT_CLK                     38
367
-      //#define SHIFT_LD                      42
368
-      //#define SHIFT_OUT                     40
369
-      //#define SHIFT_EN                      17
366
+      //#define SHIFT_CLK_PIN                 38
367
+      //#define SHIFT_LD_PIN                  42
368
+      //#define SHIFT_OUT_PIN                 40
369
+      //#define SHIFT_EN_PIN                  17
370 370
     #endif
371 371
 
372 372
   #endif
@@ -567,9 +567,9 @@
567 567
       // Buttons are directly attached to AUX-2
568 568
       #if IS_RRW_KEYPAD
569 569
         // TO TEST
570
-        //#define SHIFT_OUT                   40
571
-        //#define SHIFT_CLK                   44
572
-        //#define SHIFT_LD                    42
570
+        //#define SHIFT_OUT_PIN               40
571
+        //#define SHIFT_CLK_PIN               44
572
+        //#define SHIFT_LD_PIN                42
573 573
         //#define BTN_EN1                     56  // Mega/Due:64 - AGCM4:56
574 574
         //#define BTN_EN2                     72  // Mega/Due:59 - AGCM4:72
575 575
         //#define BTN_ENC                     55  // Mega/Due:63 - AGCM4:55

+ 7
- 7
Marlin/src/pins/stm32f1/pins_CHITU3D.h Ver fichero

@@ -146,10 +146,10 @@
146 146
       #define BEEPER_PIN                    PC1   // 33
147 147
       // Buttons attached to a shift register
148 148
       // Not wired yet
149
-      //#define SHIFT_CLK                   PC6   // 38
150
-      //#define SHIFT_LD                    PC10  // 42
151
-      //#define SHIFT_OUT                   PC8   // 40
152
-      //#define SHIFT_EN                    PA1   // 17
149
+      //#define SHIFT_CLK_PIN               PC6   // 38
150
+      //#define SHIFT_LD_PIN                PC10  // 42
151
+      //#define SHIFT_OUT_PIN               PC8   // 40
152
+      //#define SHIFT_EN_PIN                PA1   // 17
153 153
     #endif
154 154
   #endif
155 155
 
@@ -260,9 +260,9 @@
260 260
         #define BTN_EN1                     PE0   // 64
261 261
         #define BTN_EN2                     PD11  // 59
262 262
         #define BTN_ENC                     PD15  // 63
263
-        #define SHIFT_OUT                   PC8   // 40
264
-        #define SHIFT_CLK                   PC12  // 44
265
-        #define SHIFT_LD                    PC10  // 42
263
+        #define SHIFT_OUT_PIN               PC8   // 40
264
+        #define SHIFT_CLK_PIN               PC12  // 44
265
+        #define SHIFT_LD_PIN                PC10  // 42
266 266
       #elif ENABLED(PANEL_ONE)
267 267
         #define BTN_EN1                     PD11  // 59   // AUX2 PIN 3
268 268
         #define BTN_EN2                     PD15  // 63   // AUX2 PIN 4

+ 3
- 3
Marlin/src/pins/teensy3/pins_TEENSY35_36.h Ver fichero

@@ -146,7 +146,7 @@
146 146
 #endif
147 147
 
148 148
 #if IS_RRW_KEYPAD
149
-  #define SHIFT_OUT                           40
150
-  #define SHIFT_CLK                           44
151
-  #define SHIFT_LD                            42
149
+  #define SHIFT_OUT_PIN                       40
150
+  #define SHIFT_CLK_PIN                       44
151
+  #define SHIFT_LD_PIN                        42
152 152
 #endif

Loading…
Cancelar
Guardar