소스 검색

Rotary encoder cleanup (#20753)

Scott Lahteine 3 년 전
부모
커밋
4a89731025
No account linked to committer's email address
30개의 변경된 파일484개의 추가작업 그리고 438개의 파일을 삭제
  1. 1
    1
      Marlin/src/HAL/LPC1768/inc/SanityCheck.h
  2. 1
    1
      Marlin/src/inc/SanityCheck.h
  3. 4
    7
      Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.h
  4. 234
    0
      Marlin/src/lcd/buttons.h
  5. 73
    71
      Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp
  6. 7
    16
      Marlin/src/lcd/dwin/e3v2/rotary_encoder.h
  7. 4
    14
      Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
  8. 11
    7
      Marlin/src/lcd/lcdprint.h
  9. 46
    84
      Marlin/src/lcd/marlinui.cpp
  10. 4
    138
      Marlin/src/lcd/marlinui.h
  11. 2
    2
      Marlin/src/lcd/touch/touch_buttons.cpp
  12. 7
    7
      Marlin/src/pins/linux/pins_RAMPS_LINUX.h
  13. 7
    7
      Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h
  14. 7
    7
      Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h
  15. 3
    3
      Marlin/src/pins/mega/pins_CNCONTROLS_11.h
  16. 3
    3
      Marlin/src/pins/mega/pins_CNCONTROLS_12.h
  17. 4
    4
      Marlin/src/pins/mega/pins_GT2560_REV_A.h
  18. 4
    4
      Marlin/src/pins/mega/pins_HJC2560C_REV2.h
  19. 4
    4
      Marlin/src/pins/mega/pins_MEGATRONICS_2.h
  20. 4
    4
      Marlin/src/pins/mega/pins_MEGATRONICS_3.h
  21. 8
    8
      Marlin/src/pins/pinsDebug_list.h
  22. 4
    4
      Marlin/src/pins/rambo/pins_RAMBO.h
  23. 7
    7
      Marlin/src/pins/ramps/pins_RAMPS.h
  24. 7
    7
      Marlin/src/pins/ramps/pins_TT_OSCAR.h
  25. 4
    4
      Marlin/src/pins/ramps/pins_ULTIMAKER.h
  26. 4
    4
      Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h
  27. 3
    3
      Marlin/src/pins/ramps/pins_ZRIB_V20.h
  28. 7
    7
      Marlin/src/pins/samd/pins_RAMPS_144.h
  29. 7
    7
      Marlin/src/pins/stm32f1/pins_CHITU3D.h
  30. 3
    3
      Marlin/src/pins/teensy3/pins_TEENSY35_36.h

+ 1
- 1
Marlin/src/HAL/LPC1768/inc/SanityCheck.h 파일 보기

116
   #elif HAS_WIRED_LCD
116
   #elif HAS_WIRED_LCD
117
     #if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
117
     #if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
118
       #error "Serial port pins (1) conflict with Encoder Buttons!"
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
        || 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)
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
       #error "Serial port pins (1) conflict with LCD pins!"
121
       #error "Serial port pins (1) conflict with LCD pins!"
122
     #endif
122
     #endif

+ 1
- 1
Marlin/src/inc/SanityCheck.h 파일 보기

1595
 /**
1595
 /**
1596
  * ULTIPANEL encoder
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
   #error "ULTIPANEL controllers require some kind of encoder."
1599
   #error "ULTIPANEL controllers require some kind of encoder."
1600
 #endif
1600
 #endif
1601
 
1601
 

+ 4
- 7
Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.h 파일 보기

61
 #include "../lcdprint.h"
61
 #include "../lcdprint.h"
62
 
62
 
63
 // Use panel encoder - free old encoder pins
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
 #ifndef EN_C
68
 #ifndef EN_C
72
-  #define EN_C       4 //for click
69
+  #define EN_C       4 // for click
73
 #endif
70
 #endif
74
 
71
 
75
 #endif // IS_TFTGLCD_PANEL
72
 #endif // IS_TFTGLCD_PANEL

+ 234
- 0
Marlin/src/lcd/buttons.h 파일 보기

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 파일 보기

33
 #if ENABLED(DWIN_CREALITY_LCD)
33
 #if ENABLED(DWIN_CREALITY_LCD)
34
 
34
 
35
 #include "rotary_encoder.h"
35
 #include "rotary_encoder.h"
36
+#include "../../buttons.h"
36
 
37
 
37
 #include "../../../MarlinCore.h"
38
 #include "../../../MarlinCore.h"
38
 #include "../../../HAL/shared/Delay.h"
39
 #include "../../../HAL/shared/Delay.h"
43
 
44
 
44
 #include <stdlib.h>
45
 #include <stdlib.h>
45
 
46
 
47
+#ifndef ENCODER_PULSES_PER_STEP
48
+  #define ENCODER_PULSES_PER_STEP 4
49
+#endif
50
+
46
 ENCODER_Rate EncoderRate;
51
 ENCODER_Rate EncoderRate;
47
 
52
 
48
 // Buzzer
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
 // Encoder initialization
62
 // Encoder initialization
56
-void Encoder_Configuration(void) {
63
+void Encoder_Configuration() {
57
   #if BUTTON_EXISTS(EN1)
64
   #if BUTTON_EXISTS(EN1)
58
     SET_INPUT_PULLUP(BTN_EN1);
65
     SET_INPUT_PULLUP(BTN_EN1);
59
   #endif
66
   #endif
63
   #if BUTTON_EXISTS(ENC)
70
   #if BUTTON_EXISTS(ENC)
64
     SET_INPUT_PULLUP(BTN_ENC);
71
     SET_INPUT_PULLUP(BTN_ENC);
65
   #endif
72
   #endif
66
-  #ifdef BEEPER_PIN
73
+  #if PIN_EXISTS(BEEPER)
67
     SET_OUTPUT(BEEPER_PIN);
74
     SET_OUTPUT(BEEPER_PIN);
68
   #endif
75
   #endif
69
 }
76
 }
70
 
77
 
71
 // Analyze encoder value and return state
78
 // Analyze encoder value and return state
72
-ENCODER_DiffState Encoder_ReceiveAnalyze(void) {
79
+ENCODER_DiffState Encoder_ReceiveAnalyze() {
73
   const millis_t now = millis();
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
   static signed char temp_diff = 0;
83
   static signed char temp_diff = 0;
77
 
84
 
78
   ENCODER_DiffState temp_diffState = ENCODER_DIFF_NO;
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
   if (BUTTON_PRESSED(ENC)) {
88
   if (BUTTON_PRESSED(ENC)) {
82
     static millis_t next_click_update_ms;
89
     static millis_t next_click_update_ms;
83
     if (ELAPSED(now, next_click_update_ms)) {
90
     if (ELAPSED(now, next_click_update_ms)) {
94
   }
101
   }
95
   if (newbutton != lastEncoderBits) {
102
   if (newbutton != lastEncoderBits) {
96
     switch (newbutton) {
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
         else if (lastEncoderBits == ENCODER_PHASE_1) temp_diff--;
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
         else if (lastEncoderBits == ENCODER_PHASE_2) temp_diff--;
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
         else if (lastEncoderBits == ENCODER_PHASE_3) temp_diff--;
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
         else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--;
118
         else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--;
112
-      }break;
119
+        break;
113
     }
120
     }
114
     lastEncoderBits = newbutton;
121
     lastEncoderBits = newbutton;
115
   }
122
   }
137
         }
144
         }
138
         EncoderRate.lastEncoderTime = ms;
145
         EncoderRate.lastEncoderTime = ms;
139
       }
146
       }
147
+
140
     #else
148
     #else
149
+
141
       constexpr int32_t encoderMultiplier = 1;
150
       constexpr int32_t encoderMultiplier = 1;
142
-    #endif // ENCODER_RATE_MULTIPLIER
151
+
152
+    #endif
143
 
153
 
144
     // EncoderRate.encoderMoveValue += (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
154
     // EncoderRate.encoderMoveValue += (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
145
     EncoderRate.encoderMoveValue = (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
155
     EncoderRate.encoderMoveValue = (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
153
 #if PIN_EXISTS(LCD_LED)
163
 #if PIN_EXISTS(LCD_LED)
154
 
164
 
155
   // 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
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
   // LED light operation
168
   // LED light operation
159
-  void LED_Action(void) {
169
+  void LED_Action() {
160
     LED_Control(RGB_SCALE_WARM_WHITE,0x0F);
170
     LED_Control(RGB_SCALE_WARM_WHITE,0x0F);
161
     delay(30);
171
     delay(30);
162
     LED_Control(RGB_SCALE_WARM_WHITE,0x00);
172
     LED_Control(RGB_SCALE_WARM_WHITE,0x00);
163
   }
173
   }
164
 
174
 
165
   // LED initialization
175
   // LED initialization
166
-  void LED_Configuration(void) {
176
+  void LED_Configuration() {
167
     SET_OUTPUT(LCD_LED_PIN);
177
     SET_OUTPUT(LCD_LED_PIN);
168
   }
178
   }
169
 
179
 
170
   // LED write data
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
     for (tempCounter_LED = 0; tempCounter_LED < LED_NUM; tempCounter_LED++) {
183
     for (tempCounter_LED = 0; tempCounter_LED < LED_NUM; tempCounter_LED++) {
174
       for (tempCounter_Bit = 0; tempCounter_Bit < 24; tempCounter_Bit++) {
184
       for (tempCounter_Bit = 0; tempCounter_Bit < 24; tempCounter_Bit++) {
175
         if (LED_DataArray[tempCounter_LED] & (0x800000 >> tempCounter_Bit)) {
185
         if (LED_DataArray[tempCounter_LED] & (0x800000 >> tempCounter_Bit)) {
190
   // LED control
200
   // LED control
191
   //  RGB_Scale: RGB color ratio
201
   //  RGB_Scale: RGB color ratio
192
   //  luminance: brightness (0~0xFF)
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
       switch (RGB_Scale) {
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
     LED_WriteData();
212
     LED_WriteData();
207
   //  RGB_Scale: RGB color ratio
216
   //  RGB_Scale: RGB color ratio
208
   //  luminance: brightness (0~0xFF)
217
   //  luminance: brightness (0~0xFF)
209
   //  change_Time: gradient time (ms)
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
       switch (RGB_Scale) {
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 파일 보기

34
 
34
 
35
 /*********************** Encoder Set ***********************/
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
 typedef struct {
37
 typedef struct {
47
   bool enabled = false;
38
   bool enabled = false;
48
   int encoderMoveValue = 0;
39
   int encoderMoveValue = 0;
59
 } ENCODER_DiffState;
50
 } ENCODER_DiffState;
60
 
51
 
61
 // Encoder initialization
52
 // Encoder initialization
62
-void Encoder_Configuration(void);
53
+void Encoder_Configuration();
63
 
54
 
64
 // Analyze encoder value and return state
55
 // Analyze encoder value and return state
65
-ENCODER_DiffState Encoder_ReceiveAnalyze(void);
56
+ENCODER_DiffState Encoder_ReceiveAnalyze();
66
 
57
 
67
 /*********************** Encoder LED ***********************/
58
 /*********************** Encoder LED ***********************/
68
 
59
 
82
   extern unsigned int LED_DataArray[LED_NUM];
73
   extern unsigned int LED_DataArray[LED_NUM];
83
 
74
 
84
   // LED light operation
75
   // LED light operation
85
-  void LED_Action(void);
76
+  void LED_Action();
86
 
77
 
87
   // LED initialization
78
   // LED initialization
88
-  void LED_Configuration(void);
79
+  void LED_Configuration();
89
 
80
 
90
   // LED write data
81
   // LED write data
91
-  void LED_WriteData(void);
82
+  void LED_WriteData();
92
 
83
 
93
   // LED control
84
   // LED control
94
   //  RGB_Scale: RGB color ratio
85
   //  RGB_Scale: RGB color ratio
95
   //  luminance: brightness (0~0xFF)
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
   // LED gradient control
89
   // LED gradient control
99
   //  RGB_Scale: RGB color ratio
90
   //  RGB_Scale: RGB color ratio
100
   //  luminance: brightness (0~0xFF)
91
   //  luminance: brightness (0~0xFF)
101
   //  change_Time: gradient time (ms)
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
 #endif // LCD_LED
95
 #endif // LCD_LED

+ 4
- 14
Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp 파일 보기

468
         #if ANY_BUTTON(EN1, EN2, ENC, BACK)
468
         #if ANY_BUTTON(EN1, EN2, ENC, BACK)
469
 
469
 
470
           uint8_t newbutton = 0;
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
         #else
476
         #else
486
 
477
 
488
 
479
 
489
         #endif
480
         #endif
490
 
481
 
491
-
492
         static uint8_t buttons = 0;
482
         static uint8_t buttons = 0;
493
         buttons = newbutton;
483
         buttons = newbutton;
494
         static uint8_t lastEncoderBits;
484
         static uint8_t lastEncoderBits;

+ 11
- 7
Marlin/src/lcd/lcdprint.h 파일 보기

76
   #define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT)
76
   #define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT)
77
   #define INFO_FONT_WIDTH   6
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
 #else
82
 #else
83
 
83
 
94
   #define LCD_PIXEL_WIDTH   LCD_WIDTH
94
   #define LCD_PIXEL_WIDTH   LCD_WIDTH
95
   #define LCD_PIXEL_HEIGHT  LCD_HEIGHT
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
 #endif
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
 int lcd_glyph_height();
110
 int lcd_glyph_height();
107
 
111
 

+ 46
- 84
Marlin/src/lcd/marlinui.cpp 파일 보기

342
   init_lcd();
342
   init_lcd();
343
 
343
 
344
   #if HAS_DIGITAL_BUTTONS
344
   #if HAS_DIGITAL_BUTTONS
345
-
346
     #if BUTTON_EXISTS(EN1)
345
     #if BUTTON_EXISTS(EN1)
347
       SET_INPUT_PULLUP(BTN_EN1);
346
       SET_INPUT_PULLUP(BTN_EN1);
348
     #endif
347
     #endif
352
     #if BUTTON_EXISTS(ENC)
351
     #if BUTTON_EXISTS(ENC)
353
       SET_INPUT_PULLUP(BTN_ENC);
352
       SET_INPUT_PULLUP(BTN_ENC);
354
     #endif
353
     #endif
355
-
356
     #if BUTTON_EXISTS(ENC_EN)
354
     #if BUTTON_EXISTS(ENC_EN)
357
       SET_INPUT_PULLUP(BTN_ENC_EN);
355
       SET_INPUT_PULLUP(BTN_ENC_EN);
358
     #endif
356
     #endif
359
-
360
     #if BUTTON_EXISTS(BACK)
357
     #if BUTTON_EXISTS(BACK)
361
       SET_INPUT_PULLUP(BTN_BACK);
358
       SET_INPUT_PULLUP(BTN_BACK);
362
     #endif
359
     #endif
363
-
364
     #if BUTTON_EXISTS(UP)
360
     #if BUTTON_EXISTS(UP)
365
       SET_INPUT(BTN_UP);
361
       SET_INPUT(BTN_UP);
366
     #endif
362
     #endif
373
     #if BUTTON_EXISTS(RT)
369
     #if BUTTON_EXISTS(RT)
374
       SET_INPUT(BTN_RT);
370
       SET_INPUT(BTN_RT);
375
     #endif
371
     #endif
376
-
377
-  #endif // !HAS_DIGITAL_BUTTONS
372
+  #endif
378
 
373
 
379
   #if HAS_SHIFT_ENCODER
374
   #if HAS_SHIFT_ENCODER
380
 
375
 
383
       SET_OUTPUT(SR_DATA_PIN);
378
       SET_OUTPUT(SR_DATA_PIN);
384
       SET_OUTPUT(SR_CLK_PIN);
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
       #endif
387
       #endif
393
-      SET_INPUT_PULLUP(SHIFT_OUT);
388
+      SET_INPUT_PULLUP(SHIFT_OUT_PIN);
394
 
389
 
395
     #endif
390
     #endif
396
 
391
 
830
 #endif
825
 #endif
831
 
826
 
832
 inline bool can_encode() {
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
 void MarlinUI::update() {
831
 void MarlinUI::update() {
890
         else if (!wait_for_unclick && (buttons & EN_C))   // OK button, if not waiting for a debounce release:
881
         else if (!wait_for_unclick && (buttons & EN_C))   // OK button, if not waiting for a debounce release:
891
           do_click();
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
     if (LCD_BACK_CLICKED()) {
896
     if (LCD_BACK_CLICKED()) {
907
       quick_feedback();
897
       quick_feedback();
1198
         #if ANY_BUTTON(EN1, EN2, ENC, BACK)
1188
         #if ANY_BUTTON(EN1, EN2, ENC, BACK)
1199
 
1189
 
1200
           uint8_t newbutton = 0;
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
         #else
1196
         #else
1216
 
1197
 
1225
 
1206
 
1226
           const int8_t pulses = epps * encoderDirection;
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
         #endif // UP || DWN || LFT || RT
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
           #if BOTH(HAS_TOUCH_BUTTONS, HAS_ENCODER_ACTION)
1229
           #if BOTH(HAS_TOUCH_BUTTONS, HAS_ENCODER_ACTION)
1263
             | (touch_buttons & TERN(HAS_ENCODER_WHEEL, ~(EN_A | EN_B), 0xFF))
1230
             | (touch_buttons & TERN(HAS_ENCODER_WHEEL, ~(EN_A | EN_B), 0xFF))
1264
           #endif
1231
           #endif
1284
          * The rotary encoder part is also independent of the LCD chipset.
1251
          * The rotary encoder part is also independent of the LCD chipset.
1285
          */
1252
          */
1286
         uint8_t val = 0;
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
         LOOP_L_N(i, 8) {
1256
         LOOP_L_N(i, 8) {
1290
           val >>= 1;
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
         TERN(REPRAPWORLD_KEYPAD, keypad_buttons, buttons) = ~val;
1262
         TERN(REPRAPWORLD_KEYPAD, keypad_buttons, buttons) = ~val;
1296
       #endif
1263
       #endif
1306
     #if HAS_ENCODER_WHEEL
1273
     #if HAS_ENCODER_WHEEL
1307
       static uint8_t lastEncoderBits;
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
       // Manage encoder rotation
1276
       // Manage encoder rotation
1315
       #define ENCODER_SPIN(_E1, _E2) switch (lastEncoderBits) { case _E1: encoderDiff += encoderDirection; break; case _E2: encoderDiff -= encoderDirection; }
1277
       #define ENCODER_SPIN(_E1, _E2) switch (lastEncoderBits) { case _E1: encoderDiff += encoderDirection; break; case _E2: encoderDiff -= encoderDirection; }
1316
 
1278
 
1319
       if (buttons & EN_B) enc |= B10;
1281
       if (buttons & EN_B) enc |= B10;
1320
       if (enc != lastEncoderBits) {
1282
       if (enc != lastEncoderBits) {
1321
         switch (enc) {
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
         #if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL)
1289
         #if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL)
1328
           external_encoder();
1290
           external_encoder();

+ 4
- 138
Marlin/src/lcd/marlinui.h 파일 보기

25
 
25
 
26
 #include "../module/motion.h"
26
 #include "../module/motion.h"
27
 
27
 
28
+#include "buttons.h"
29
+
28
 #if HAS_BUZZER
30
 #if HAS_BUZZER
29
   #include "../libs/buzzer.h"
31
   #include "../libs/buzzer.h"
30
 #endif
32
 #endif
40
 #if EITHER(HAS_LCD_MENU, ULTIPANEL_FEEDMULTIPLY)
42
 #if EITHER(HAS_LCD_MENU, ULTIPANEL_FEEDMULTIPLY)
41
   #define HAS_ENCODER_ACTION 1
43
   #define HAS_ENCODER_ACTION 1
42
 #endif
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
 #if E_MANUAL > 1
46
 #if E_MANUAL > 1
59
   #define MULTI_MANUAL 1
47
   #define MULTI_MANUAL 1
114
 
102
 
115
 #endif // HAS_WIRED_LCD
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
 #if HAS_MARLINUI_U8GLIB
105
 #if HAS_MARLINUI_U8GLIB
242
   enum MarlinFont : uint8_t {
106
   enum MarlinFont : uint8_t {
243
     FONT_STATUSMENU = 1,
107
     FONT_STATUSMENU = 1,
556
     #if HAS_TOUCH_BUTTONS
420
     #if HAS_TOUCH_BUTTONS
557
       static uint8_t touch_buttons;
421
       static uint8_t touch_buttons;
558
       static uint8_t repeat_delay;
422
       static uint8_t repeat_delay;
423
+    #else
424
+      static constexpr uint8_t touch_buttons = 0;
559
     #endif
425
     #endif
560
 
426
 
561
     #if ENABLED(ENCODER_RATE_MULTIPLIER)
427
     #if ENABLED(ENCODER_RATE_MULTIPLIER)

+ 2
- 2
Marlin/src/lcd/touch/touch_buttons.cpp 파일 보기

31
   #include "../tft_io/touch_calibration.h"
31
   #include "../tft_io/touch_calibration.h"
32
 #endif
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
 #include "../tft_io/tft_io.h"
36
 #include "../tft_io/tft_io.h"
36
 
37
 
37
 #define DOGM_AREA_LEFT   TFT_PIXEL_OFFSET_X
38
 #define DOGM_AREA_LEFT   TFT_PIXEL_OFFSET_X
66
       y = uint16_t((uint32_t(y) * TOUCH_CALIBRATION_Y) >> 16) + TOUCH_OFFSET_Y;
67
       y = uint16_t((uint32_t(y) * TOUCH_CALIBRATION_Y) >> 16) + TOUCH_OFFSET_Y;
67
     #endif
68
     #endif
68
 
69
 
69
-
70
     // Touch within the button area simulates an encoder button
70
     // Touch within the button area simulates an encoder button
71
     if (y > BUTTON_AREA_TOP && y < BUTTON_AREA_BOT)
71
     if (y > BUTTON_AREA_TOP && y < BUTTON_AREA_BOT)
72
       return WITHIN(x, BUTTOND_X_LO, BUTTOND_X_HI) ? EN_D
72
       return WITHIN(x, BUTTOND_X_LO, BUTTOND_X_HI) ? EN_D

+ 7
- 7
Marlin/src/pins/linux/pins_RAMPS_LINUX.h 파일 보기

459
     #if !IS_NEWPANEL
459
     #if !IS_NEWPANEL
460
       // Buttons attached to a shift register
460
       // Buttons attached to a shift register
461
       // Not wired yet
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
     #endif
466
     #endif
467
 
467
 
468
   #endif
468
   #endif
608
 
608
 
609
       // Buttons are directly attached to AUX-2
609
       // Buttons are directly attached to AUX-2
610
       #if IS_RRW_KEYPAD
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
         #define BTN_EN1                       64
614
         #define BTN_EN1                       64
615
         #define BTN_EN2                       59
615
         #define BTN_EN2                       59
616
         #define BTN_ENC                       63
616
         #define BTN_ENC                       63

+ 7
- 7
Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h 파일 보기

354
 
354
 
355
   #if IS_NEWPANEL
355
   #if IS_NEWPANEL
356
     #if IS_RRW_KEYPAD
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
     #endif
360
     #endif
361
   #else
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
   #endif
366
   #endif
367
 
367
 
368
   #if ANY(VIKI2, miniVIKI)
368
   #if ANY(VIKI2, miniVIKI)

+ 7
- 7
Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h 파일 보기

147
     #define DOGLCD_A0                      P2_06  // (59) J3-8 & AUX-2
147
     #define DOGLCD_A0                      P2_06  // (59) J3-8 & AUX-2
148
 
148
 
149
     #if IS_RRW_KEYPAD
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
     #elif !IS_NEWPANEL
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
     #endif
158
     #endif
159
 
159
 
160
     #if ANY(VIKI2, miniVIKI)
160
     #if ANY(VIKI2, miniVIKI)

+ 3
- 3
Marlin/src/pins/mega/pins_CNCONTROLS_11.h 파일 보기

149
 #define BTN_ENC                               27
149
 #define BTN_ENC                               27
150
 
150
 
151
 // Hardware buttons for manual movement of XYZ
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
 //#define UI1                                 31
156
 //#define UI1                                 31
157
 //#define UI2                                 22
157
 //#define UI2                                 22

+ 3
- 3
Marlin/src/pins/mega/pins_CNCONTROLS_12.h 파일 보기

156
 #define BTN_ENC                               38
156
 #define BTN_ENC                               38
157
 
157
 
158
 // Hardware buttons for manual movement of XYZ
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
 //#define UI1                                 43
163
 //#define UI1                                 43
164
 //#define UI2                                 37
164
 //#define UI2                                 37

+ 4
- 4
Marlin/src/pins/mega/pins_GT2560_REV_A.h 파일 보기

146
 
146
 
147
   #else                                           // !IS_NEWPANEL
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
     #define LCD_PINS_RS                       16
154
     #define LCD_PINS_RS                       16
155
     #define LCD_PINS_ENABLE                    5
155
     #define LCD_PINS_ENABLE                    5

+ 4
- 4
Marlin/src/pins/mega/pins_HJC2560C_REV2.h 파일 보기

156
   #else
156
   #else
157
 
157
 
158
     // Buttons attached to a shift register
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
     #define LCD_PINS_RS                       16
164
     #define LCD_PINS_RS                       16
165
     #define LCD_PINS_ENABLE                    5
165
     #define LCD_PINS_ENABLE                    5

+ 4
- 4
Marlin/src/pins/mega/pins_MEGATRONICS_2.h 파일 보기

146
     #define BTN_ENC                           43
146
     #define BTN_ENC                           43
147
   #else
147
   #else
148
     // Buttons attached to shift register of reprapworld keypad v1.1
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
   #endif
153
   #endif
154
 
154
 
155
 #endif // HAS_WIRED_LCD
155
 #endif // HAS_WIRED_LCD

+ 4
- 4
Marlin/src/pins/mega/pins_MEGATRONICS_3.h 파일 보기

162
   #define LCD_PINS_D6                         39
162
   #define LCD_PINS_D6                         39
163
   #define LCD_PINS_D7                         15
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
   #if MB(MEGATRONICS_31, MEGATRONICS_32)
170
   #if MB(MEGATRONICS_31, MEGATRONICS_32)
171
     #define SD_DETECT_PIN                     56
171
     #define SD_DETECT_PIN                     56

+ 8
- 8
Marlin/src/pins/pinsDebug_list.h 파일 보기

833
 #if PIN_EXISTS(SERVO3)
833
 #if PIN_EXISTS(SERVO3)
834
   REPORT_NAME_DIGITAL(__LINE__, SERVO3_PIN)
834
   REPORT_NAME_DIGITAL(__LINE__, SERVO3_PIN)
835
 #endif
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
 #endif
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
 #endif
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
 #endif
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
 #endif
847
 #endif
848
 #if PIN_EXISTS(SLED)
848
 #if PIN_EXISTS(SLED)
849
   REPORT_NAME_DIGITAL(__LINE__, SLED_PIN)
849
   REPORT_NAME_DIGITAL(__LINE__, SLED_PIN)

+ 4
- 4
Marlin/src/pins/rambo/pins_RAMBO.h 파일 보기

239
 
239
 
240
     // Buttons attached to a shift register
240
     // Buttons attached to a shift register
241
     // Not wired yet
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
     #define LCD_PINS_RS                       75
247
     #define LCD_PINS_RS                       75
248
     #define LCD_PINS_ENABLE                   17
248
     #define LCD_PINS_ENABLE                   17

+ 7
- 7
Marlin/src/pins/ramps/pins_RAMPS.h 파일 보기

504
     #if !IS_NEWPANEL
504
     #if !IS_NEWPANEL
505
       // Buttons attached to a shift register
505
       // Buttons attached to a shift register
506
       // Not wired yet
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
     #endif
511
     #endif
512
 
512
 
513
   #endif
513
   #endif
722
 #endif // HAS_WIRED_LCD
722
 #endif // HAS_WIRED_LCD
723
 
723
 
724
 #if IS_RRW_KEYPAD && !HAS_ADC_BUTTONS
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
   #ifndef BTN_EN1
728
   #ifndef BTN_EN1
729
     #define BTN_EN1                           64
729
     #define BTN_EN1                           64
730
   #endif
730
   #endif

+ 7
- 7
Marlin/src/pins/ramps/pins_TT_OSCAR.h 파일 보기

342
     #if !IS_NEWPANEL
342
     #if !IS_NEWPANEL
343
       // Buttons attached to a shift register
343
       // Buttons attached to a shift register
344
       // Not wired yet
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
     #endif
349
     #endif
350
 
350
 
351
   #endif
351
   #endif
491
 
491
 
492
       // Buttons are directly attached to AUX-2
492
       // Buttons are directly attached to AUX-2
493
       #if IS_RRW_KEYPAD
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
         #define BTN_EN1                       64
497
         #define BTN_EN1                       64
498
         #define BTN_EN2                       59
498
         #define BTN_EN2                       59
499
         #define BTN_ENC                       63
499
         #define BTN_ENC                       63

+ 4
- 4
Marlin/src/pins/ramps/pins_ULTIMAKER.h 파일 보기

142
   #else                                           // !IS_NEWPANEL - Old style panel with shift register
142
   #else                                           // !IS_NEWPANEL - Old style panel with shift register
143
 
143
 
144
     // Buttons attached to a shift register
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
     #define LCD_PINS_RS                       16
150
     #define LCD_PINS_RS                       16
151
     #define LCD_PINS_ENABLE                    5
151
     #define LCD_PINS_ENABLE                    5

+ 4
- 4
Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h 파일 보기

197
   #else                                           // !IS_NEWPANEL - Old style panel with shift register
197
   #else                                           // !IS_NEWPANEL - Old style panel with shift register
198
 
198
 
199
     // Buttons attached to a shift register
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
     #define LCD_PINS_RS                       16
205
     #define LCD_PINS_RS                       16
206
     #define LCD_PINS_ENABLE                    5
206
     #define LCD_PINS_ENABLE                    5

+ 3
- 3
Marlin/src/pins/ramps/pins_ZRIB_V20.h 파일 보기

69
   #undef ADC_KEYPAD_PIN
69
   #undef ADC_KEYPAD_PIN
70
   #undef BEEPER_PIN
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
   #undef BTN_EN1
75
   #undef BTN_EN1
76
   #undef BTN_EN2
76
   #undef BTN_EN2
77
   #undef BTN_ENC
77
   #undef BTN_ENC

+ 7
- 7
Marlin/src/pins/samd/pins_RAMPS_144.h 파일 보기

363
     #if !IS_NEWPANEL
363
     #if !IS_NEWPANEL
364
       // Buttons attached to a shift register
364
       // Buttons attached to a shift register
365
       // Not wired yet
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
     #endif
370
     #endif
371
 
371
 
372
   #endif
372
   #endif
567
       // Buttons are directly attached to AUX-2
567
       // Buttons are directly attached to AUX-2
568
       #if IS_RRW_KEYPAD
568
       #if IS_RRW_KEYPAD
569
         // TO TEST
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
         //#define BTN_EN1                     56  // Mega/Due:64 - AGCM4:56
573
         //#define BTN_EN1                     56  // Mega/Due:64 - AGCM4:56
574
         //#define BTN_EN2                     72  // Mega/Due:59 - AGCM4:72
574
         //#define BTN_EN2                     72  // Mega/Due:59 - AGCM4:72
575
         //#define BTN_ENC                     55  // Mega/Due:63 - AGCM4:55
575
         //#define BTN_ENC                     55  // Mega/Due:63 - AGCM4:55

+ 7
- 7
Marlin/src/pins/stm32f1/pins_CHITU3D.h 파일 보기

146
       #define BEEPER_PIN                    PC1   // 33
146
       #define BEEPER_PIN                    PC1   // 33
147
       // Buttons attached to a shift register
147
       // Buttons attached to a shift register
148
       // Not wired yet
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
     #endif
153
     #endif
154
   #endif
154
   #endif
155
 
155
 
260
         #define BTN_EN1                     PE0   // 64
260
         #define BTN_EN1                     PE0   // 64
261
         #define BTN_EN2                     PD11  // 59
261
         #define BTN_EN2                     PD11  // 59
262
         #define BTN_ENC                     PD15  // 63
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
       #elif ENABLED(PANEL_ONE)
266
       #elif ENABLED(PANEL_ONE)
267
         #define BTN_EN1                     PD11  // 59   // AUX2 PIN 3
267
         #define BTN_EN1                     PD11  // 59   // AUX2 PIN 3
268
         #define BTN_EN2                     PD15  // 63   // AUX2 PIN 4
268
         #define BTN_EN2                     PD15  // 63   // AUX2 PIN 4

+ 3
- 3
Marlin/src/pins/teensy3/pins_TEENSY35_36.h 파일 보기

146
 #endif
146
 #endif
147
 
147
 
148
 #if IS_RRW_KEYPAD
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
 #endif
152
 #endif

Loading…
취소
저장