浏览代码

🎨 Consolidate Ender-3 V2 DWIN common code (#22778)

Scott Lahteine 3 年前
父节点
当前提交
5b5a8798f8
没有帐户链接到提交者的电子邮件
共有 39 个文件被更改,包括 1512 次插入4078 次删除
  1. 9
    9
      Marlin/src/MarlinCore.cpp
  2. 2
    1
      Marlin/src/inc/Conditionals_post.h
  3. 429
    0
      Marlin/src/lcd/e3v2/common/dwin_api.cpp
  4. 265
    0
      Marlin/src/lcd/e3v2/common/dwin_api.h
  5. 44
    0
      Marlin/src/lcd/e3v2/common/dwin_color.h
  6. 38
    0
      Marlin/src/lcd/e3v2/common/dwin_font.h
  7. 138
    0
      Marlin/src/lcd/e3v2/common/dwin_set.h
  8. 15
    19
      Marlin/src/lcd/e3v2/common/encoder.cpp
  9. 3
    3
      Marlin/src/lcd/e3v2/common/encoder.h
  10. 57
    60
      Marlin/src/lcd/e3v2/creality/dwin.cpp
  11. 10
    13
      Marlin/src/lcd/e3v2/creality/dwin.h
  12. 3
    395
      Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp
  13. 5
    318
      Marlin/src/lcd/e3v2/creality/dwin_lcd.h
  14. 0
    263
      Marlin/src/lcd/e3v2/creality/rotary_encoder.cpp
  15. 0
    94
      Marlin/src/lcd/e3v2/creality/rotary_encoder.h
  16. 71
    63
      Marlin/src/lcd/e3v2/enhanced/dwin.cpp
  17. 48
    26
      Marlin/src/lcd/e3v2/enhanced/dwin.h
  18. 37
    447
      Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp
  19. 29
    231
      Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h
  20. 39
    37
      Marlin/src/lcd/e3v2/enhanced/dwinui.cpp
  21. 33
    173
      Marlin/src/lcd/e3v2/enhanced/dwinui.h
  22. 31
    25
      Marlin/src/lcd/e3v2/enhanced/lockscreen.cpp
  23. 25
    15
      Marlin/src/lcd/e3v2/enhanced/lockscreen.h
  24. 0
    263
      Marlin/src/lcd/e3v2/enhanced/rotary_encoder.cpp
  25. 0
    93
      Marlin/src/lcd/e3v2/enhanced/rotary_encoder.h
  26. 131
    140
      Marlin/src/lcd/e3v2/jyersui/dwin.cpp
  27. 10
    131
      Marlin/src/lcd/e3v2/jyersui/dwin.h
  28. 5
    415
      Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp
  29. 4
    185
      Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h
  30. 2
    410
      Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp
  31. 14
    232
      Marlin/src/lcd/e3v2/marlinui/dwin_lcd.h
  32. 2
    3
      Marlin/src/lcd/e3v2/marlinui/dwin_string.h
  33. 3
    3
      Marlin/src/lcd/e3v2/marlinui/ui_common.cpp
  34. 1
    1
      Marlin/src/lcd/marlinui.cpp
  35. 2
    3
      Marlin/src/lcd/marlinui.h
  36. 0
    1
      Marlin/src/sd/SdFile.h
  37. 4
    4
      buildroot/tests/STM32F103RET6_creality
  38. 2
    1
      ini/features.ini
  39. 1
    1
      platformio.ini

+ 9
- 9
Marlin/src/MarlinCore.cpp 查看文件

74
   #include <lvgl.h>
74
   #include <lvgl.h>
75
 #endif
75
 #endif
76
 
76
 
77
-#if ENABLED(DWIN_CREALITY_LCD)
78
-  #include "lcd/e3v2/creality/dwin.h"
79
-  #include "lcd/e3v2/creality/rotary_encoder.h"
80
-#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
81
-  #include "lcd/e3v2/enhanced/dwin.h"
82
-  #include "lcd/e3v2/enhanced/rotary_encoder.h"
83
-#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
84
-  #include "lcd/e3v2/jyersui/dwin.h"
85
-  #include "lcd/e3v2/jyersui/rotary_encoder.h"
77
+#if HAS_DWIN_E3V2
78
+  #include "lcd/e3v2/common/encoder.h"
79
+  #if ENABLED(DWIN_CREALITY_LCD)
80
+    #include "lcd/e3v2/creality/dwin.h"
81
+  #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
82
+    #include "lcd/e3v2/enhanced/dwin.h"
83
+  #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
84
+    #include "lcd/e3v2/jyersui/dwin.h"
85
+  #endif
86
 #endif
86
 #endif
87
 
87
 
88
 #if ENABLED(EXTENSIBLE_UI)
88
 #if ENABLED(EXTENSIBLE_UI)

+ 2
- 1
Marlin/src/inc/Conditionals_post.h 查看文件

421
   #endif
421
   #endif
422
 #endif
422
 #endif
423
 
423
 
424
-#if EITHER(DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI)
424
+#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI)
425
   #define HAS_LCD_BRIGHTNESS 1
425
   #define HAS_LCD_BRIGHTNESS 1
426
+  #define MAX_LCD_BRIGHTNESS 31
426
 #endif
427
 #endif
427
 
428
 
428
 /**
429
 /**

+ 429
- 0
Marlin/src/lcd/e3v2/common/dwin_api.cpp 查看文件

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 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
+#include "../../../inc/MarlinConfigPre.h"
23
+
24
+#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI)
25
+
26
+#include "dwin_api.h"
27
+#include "dwin_set.h"
28
+
29
+#include "../../../inc/MarlinConfig.h"
30
+
31
+#include <string.h> // for memset
32
+
33
+uint8_t DWIN_SendBuf[11 + DWIN_WIDTH / 6 * 2] = { 0xAA };
34
+uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C };
35
+uint8_t databuf[26] = { 0 };
36
+
37
+// Send the data in the buffer plus the packet tail
38
+void DWIN_Send(size_t &i) {
39
+  ++i;
40
+  LOOP_L_N(n, i) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
41
+  LOOP_L_N(n, 4) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); }
42
+}
43
+
44
+/*-------------------------------------- System variable function --------------------------------------*/
45
+
46
+// Handshake (1: Success, 0: Fail)
47
+bool DWIN_Handshake() {
48
+  static int recnum = 0;
49
+  #ifndef LCD_BAUDRATE
50
+    #define LCD_BAUDRATE 115200
51
+  #endif
52
+  LCD_SERIAL.begin(LCD_BAUDRATE);
53
+  const millis_t serial_connect_timeout = millis() + 1000UL;
54
+  while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
55
+
56
+  size_t i = 0;
57
+  DWIN_Byte(i, 0x00);
58
+  DWIN_Send(i);
59
+
60
+  while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) {
61
+    databuf[recnum] = LCD_SERIAL.read();
62
+    // ignore the invalid data
63
+    if (databuf[0] != FHONE) { // prevent the program from running.
64
+      if (recnum > 0) {
65
+        recnum = 0;
66
+        ZERO(databuf);
67
+      }
68
+      continue;
69
+    }
70
+    delay(10);
71
+    recnum++;
72
+  }
73
+
74
+  return ( recnum >= 3
75
+        && databuf[0] == FHONE
76
+        && databuf[1] == '\0'
77
+        && databuf[2] == 'O'
78
+        && databuf[3] == 'K' );
79
+}
80
+
81
+// Set the backlight brightness
82
+//  brightness: (0x00-0x1F)
83
+void DWIN_LCD_Brightness(const uint8_t brightness) {
84
+  size_t i = 0;
85
+  DWIN_Byte(i, 0x30);
86
+  DWIN_Byte(i, _MAX(brightness, 0x1F));
87
+  DWIN_Send(i);
88
+}
89
+
90
+// Set screen display direction
91
+//  dir: 0=0°, 1=90°, 2=180°, 3=270°
92
+void DWIN_Frame_SetDir(uint8_t dir) {
93
+  size_t i = 0;
94
+  DWIN_Byte(i, 0x34);
95
+  DWIN_Byte(i, 0x5A);
96
+  DWIN_Byte(i, 0xA5);
97
+  DWIN_Byte(i, dir);
98
+  DWIN_Send(i);
99
+}
100
+
101
+// Update display
102
+void DWIN_UpdateLCD() {
103
+  size_t i = 0;
104
+  DWIN_Byte(i, 0x3D);
105
+  DWIN_Send(i);
106
+}
107
+
108
+/*---------------------------------------- Drawing functions ----------------------------------------*/
109
+
110
+// Clear screen
111
+//  color: Clear screen color
112
+void DWIN_Frame_Clear(const uint16_t color) {
113
+  size_t i = 0;
114
+  DWIN_Byte(i, 0x01);
115
+  DWIN_Word(i, color);
116
+  DWIN_Send(i);
117
+}
118
+
119
+// Draw a point
120
+//  color: point color
121
+//  width: point width   0x01-0x0F
122
+//  height: point height 0x01-0x0F
123
+//  x,y: upper left point
124
+void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y) {
125
+  size_t i = 0;
126
+  DWIN_Byte(i, 0x02);
127
+  DWIN_Word(i, color);
128
+  DWIN_Byte(i, width);
129
+  DWIN_Byte(i, height);
130
+  DWIN_Word(i, x);
131
+  DWIN_Word(i, y);
132
+  DWIN_Send(i);
133
+}
134
+
135
+// Draw a line
136
+//  color: Line segment color
137
+//  xStart/yStart: Start point
138
+//  xEnd/yEnd: End point
139
+void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
140
+  size_t i = 0;
141
+  DWIN_Byte(i, 0x03);
142
+  DWIN_Word(i, color);
143
+  DWIN_Word(i, xStart);
144
+  DWIN_Word(i, yStart);
145
+  DWIN_Word(i, xEnd);
146
+  DWIN_Word(i, yEnd);
147
+  DWIN_Send(i);
148
+}
149
+
150
+// Draw a rectangle
151
+//  mode: 0=frame, 1=fill, 2=XOR fill
152
+//  color: Rectangle color
153
+//  xStart/yStart: upper left point
154
+//  xEnd/yEnd: lower right point
155
+void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
156
+  size_t i = 0;
157
+  DWIN_Byte(i, 0x05);
158
+  DWIN_Byte(i, mode);
159
+  DWIN_Word(i, color);
160
+  DWIN_Word(i, xStart);
161
+  DWIN_Word(i, yStart);
162
+  DWIN_Word(i, xEnd);
163
+  DWIN_Word(i, yEnd);
164
+  DWIN_Send(i);
165
+}
166
+
167
+// Move a screen area
168
+//  mode: 0, circle shift; 1, translation
169
+//  dir: 0=left, 1=right, 2=up, 3=down
170
+//  dis: Distance
171
+//  color: Fill color
172
+//  xStart/yStart: upper left point
173
+//  xEnd/yEnd: bottom right point
174
+void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
175
+                         uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
176
+  size_t i = 0;
177
+  DWIN_Byte(i, 0x09);
178
+  DWIN_Byte(i, (mode << 7) | dir);
179
+  DWIN_Word(i, dis);
180
+  DWIN_Word(i, color);
181
+  DWIN_Word(i, xStart);
182
+  DWIN_Word(i, yStart);
183
+  DWIN_Word(i, xEnd);
184
+  DWIN_Word(i, yEnd);
185
+  DWIN_Send(i);
186
+}
187
+
188
+/*---------------------------------------- Text related functions ----------------------------------------*/
189
+
190
+// Draw a string
191
+//  widthAdjust: true=self-adjust character width; false=no adjustment
192
+//  bShow: true=display background color; false=don't display background color
193
+//  size: Font size
194
+//  color: Character color
195
+//  bColor: Background color
196
+//  x/y: Upper-left coordinate of the string
197
+//  *string: The string
198
+//  rlimit: To limit the drawn string length
199
+void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit/*=0xFFFF*/) {
200
+  constexpr uint8_t widthAdjust = 0;
201
+  size_t i = 0;
202
+  DWIN_Byte(i, 0x11);
203
+  // Bit 7: widthAdjust
204
+  // Bit 6: bShow
205
+  // Bit 5-4: Unused (0)
206
+  // Bit 3-0: size
207
+  DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size);
208
+  DWIN_Word(i, color);
209
+  DWIN_Word(i, bColor);
210
+  DWIN_Word(i, x);
211
+  DWIN_Word(i, y);
212
+  DWIN_Text(i, string, rlimit);
213
+  DWIN_Send(i);
214
+}
215
+
216
+// Draw a positive integer
217
+//  bShow: true=display background color; false=don't display background color
218
+//  zeroFill: true=zero fill; false=no zero fill
219
+//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
220
+//  size: Font size
221
+//  color: Character color
222
+//  bColor: Background color
223
+//  iNum: Number of digits
224
+//  x/y: Upper-left coordinate
225
+//  value: Integer value
226
+void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
227
+                          uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint32_t value) {
228
+  size_t i = 0;
229
+  DWIN_Byte(i, 0x14);
230
+  // Bit 7: bshow
231
+  // Bit 6: 1 = signed; 0 = unsigned number;
232
+  // Bit 5: zeroFill
233
+  // Bit 4: zeroMode
234
+  // Bit 3-0: size
235
+  DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
236
+  DWIN_Word(i, color);
237
+  DWIN_Word(i, bColor);
238
+  DWIN_Byte(i, iNum);
239
+  DWIN_Byte(i, 0); // fNum
240
+  DWIN_Word(i, x);
241
+  DWIN_Word(i, y);
242
+  #if 0
243
+    for (char count = 0; count < 8; count++) {
244
+      DWIN_Byte(i, value);
245
+      value >>= 8;
246
+      if (!(value & 0xFF)) break;
247
+    }
248
+  #else
249
+    // Write a big-endian 64 bit integer
250
+    const size_t p = i + 1;
251
+    for (char count = 8; count--;) { // 7..0
252
+      ++i;
253
+      DWIN_SendBuf[p + count] = value;
254
+      value >>= 8;
255
+    }
256
+  #endif
257
+
258
+  DWIN_Send(i);
259
+}
260
+
261
+// Draw a floating point number
262
+//  bShow: true=display background color; false=don't display background color
263
+//  zeroFill: true=zero fill; false=no zero fill
264
+//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
265
+//  size: Font size
266
+//  color: Character color
267
+//  bColor: Background color
268
+//  iNum: Number of whole digits
269
+//  fNum: Number of decimal digits
270
+//  x/y: Upper-left point
271
+//  value: Float value
272
+void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
273
+                          uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) {
274
+  //uint8_t *fvalue = (uint8_t*)&value;
275
+  size_t i = 0;
276
+  DWIN_Byte(i, 0x14);
277
+  DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
278
+  DWIN_Word(i, color);
279
+  DWIN_Word(i, bColor);
280
+  DWIN_Byte(i, iNum);
281
+  DWIN_Byte(i, fNum);
282
+  DWIN_Word(i, x);
283
+  DWIN_Word(i, y);
284
+  DWIN_Long(i, value);
285
+  /*
286
+  DWIN_Byte(i, fvalue[3]);
287
+  DWIN_Byte(i, fvalue[2]);
288
+  DWIN_Byte(i, fvalue[1]);
289
+  DWIN_Byte(i, fvalue[0]);
290
+  */
291
+  DWIN_Send(i);
292
+}
293
+
294
+// Draw a floating point number
295
+//  value: positive unscaled float value
296
+void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
297
+                            uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
298
+  const int32_t val = round(value * POW(10, fNum));
299
+  DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, val);
300
+}
301
+
302
+/*---------------------------------------- Picture related functions ----------------------------------------*/
303
+
304
+// Draw JPG and cached in #0 virtual display area
305
+//  id: Picture ID
306
+void DWIN_JPG_ShowAndCache(const uint8_t id) {
307
+  size_t i = 0;
308
+  DWIN_Word(i, 0x2200);
309
+  DWIN_Byte(i, id);
310
+  DWIN_Send(i);     // AA 23 00 00 00 00 08 00 01 02 03 CC 33 C3 3C
311
+}
312
+
313
+// Draw an Icon
314
+//  IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
315
+//  BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
316
+//  BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
317
+//  libID: Icon library ID
318
+//  picID: Icon ID
319
+//  x/y: Upper-left point
320
+void DWIN_ICON_Show(bool IBD, bool BIR, bool BFI, uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
321
+  NOMORE(x, DWIN_WIDTH - 1);
322
+  NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
323
+  size_t i = 0;
324
+  DWIN_Byte(i, 0x23);
325
+  DWIN_Word(i, x);
326
+  DWIN_Word(i, y);
327
+  DWIN_Byte(i, (IBD << 7) | (BIR << 6) | (BFI << 5) | libID);
328
+  DWIN_Byte(i, picID);
329
+  DWIN_Send(i);
330
+}
331
+
332
+// Draw an Icon from SRAM
333
+//  IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
334
+//  BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
335
+//  BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
336
+//  x/y: Upper-left point
337
+//  addr: SRAM address
338
+void DWIN_ICON_Show(bool IBD, bool BIR, bool BFI, uint16_t x, uint16_t y, uint16_t addr) {
339
+  NOMORE(x, DWIN_WIDTH - 1);
340
+  NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
341
+  size_t i = 0;
342
+  DWIN_Byte(i, 0x24);
343
+  DWIN_Word(i, x);
344
+  DWIN_Word(i, y);
345
+  DWIN_Byte(i, (IBD << 7) | (BIR << 6) | (BFI << 5) | 0x00);
346
+  DWIN_Word(i, addr);
347
+  DWIN_Send(i);
348
+}
349
+
350
+// Unzip the JPG picture to a virtual display area
351
+//  n: Cache index
352
+//  id: Picture ID
353
+void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
354
+  size_t i = 0;
355
+  DWIN_Byte(i, 0x25);
356
+  DWIN_Byte(i, n);
357
+  DWIN_Byte(i, id);
358
+  DWIN_Send(i);
359
+}
360
+
361
+// Animate a series of icons
362
+//  animID: Animation ID; 0x00-0x0F
363
+//  animate: true on; false off;
364
+//  libID: Icon library ID
365
+//  picIDs: Icon starting ID
366
+//  picIDe: Icon ending ID
367
+//  x/y: Upper-left point
368
+//  interval: Display time interval, unit 10mS
369
+void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval) {
370
+  NOMORE(x, DWIN_WIDTH - 1);
371
+  NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
372
+  size_t i = 0;
373
+  DWIN_Byte(i, 0x28);
374
+  DWIN_Word(i, x);
375
+  DWIN_Word(i, y);
376
+  // Bit 7: animation on or off
377
+  // Bit 6: start from begin or end
378
+  // Bit 5-4: unused (0)
379
+  // Bit 3-0: animID
380
+  DWIN_Byte(i, (animate * 0x80) | 0x40 | animID);
381
+  DWIN_Byte(i, libID);
382
+  DWIN_Byte(i, picIDs);
383
+  DWIN_Byte(i, picIDe);
384
+  DWIN_Byte(i, interval);
385
+  DWIN_Send(i);
386
+}
387
+
388
+// Animation Control
389
+//  state: 16 bits, each bit is the state of an animation id
390
+void DWIN_ICON_AnimationControl(uint16_t state) {
391
+  size_t i = 0;
392
+  DWIN_Byte(i, 0x29);
393
+  DWIN_Word(i, state);
394
+  DWIN_Send(i);
395
+}
396
+
397
+/*---------------------------------------- Memory functions ----------------------------------------*/
398
+// The LCD has an additional 32KB SRAM and 16KB Flash
399
+// Data can be written to the SRAM and saved to one of the jpeg page files
400
+
401
+// Write Data Memory
402
+//  command 0x31
403
+//  Type: Write memory selection; 0x5A=SRAM; 0xA5=Flash
404
+//  Address: Write data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
405
+//  Data: data
406
+//
407
+//  Flash writing returns 0xA5 0x4F 0x4B
408
+
409
+// Read Data Memory
410
+//  command 0x32
411
+//  Type: Read memory selection; 0x5A=SRAM; 0xA5=Flash
412
+//  Address: Read data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
413
+//  Length: leangth of data to read; 0x01-0xF0
414
+//
415
+//  Response:
416
+//    Type, Address, Length, Data
417
+
418
+// Write Picture Memory
419
+//  Write the contents of the 32KB SRAM data memory into the designated image memory space
420
+//  Issued: 0x5A, 0xA5, PIC_ID
421
+//  Response: 0xA5 0x4F 0x4B
422
+//
423
+//  command 0x33
424
+//  0x5A, 0xA5
425
+//  PicId: Picture Memory location, 0x00-0x0F
426
+//
427
+//  Flash writing returns 0xA5 0x4F 0x4B
428
+
429
+#endif // HAS_DWIN_E3V2 || IS_DWIN_MARLINUI

+ 265
- 0
Marlin/src/lcd/e3v2/common/dwin_api.h 查看文件

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 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 <stddef.h>
25
+#include <stdint.h>
26
+
27
+#include "../../../HAL/shared/Marduino.h"
28
+
29
+#ifndef DWIN_WIDTH
30
+  #define DWIN_WIDTH  272
31
+#endif
32
+#ifndef DWIN_HEIGHT
33
+  #define DWIN_HEIGHT 480
34
+#endif
35
+
36
+#define RECEIVED_NO_DATA         0x00
37
+#define RECEIVED_SHAKE_HAND_ACK  0x01
38
+
39
+#define FHONE                    0xAA
40
+
41
+#define DWIN_SCROLL_UP   2
42
+#define DWIN_SCROLL_DOWN 3
43
+
44
+// Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail.
45
+// Assume the narrowest (6 pixel) font and 2-byte gb2312-encoded characters.
46
+extern uint8_t DWIN_SendBuf[11 + DWIN_WIDTH / 6 * 2];
47
+extern uint8_t DWIN_BufTail[4];
48
+extern uint8_t databuf[26];
49
+
50
+inline void DWIN_Byte(size_t &i, const uint16_t bval) {
51
+  DWIN_SendBuf[++i] = bval;
52
+}
53
+
54
+inline void DWIN_Word(size_t &i, const uint16_t wval) {
55
+  DWIN_SendBuf[++i] = wval >> 8;
56
+  DWIN_SendBuf[++i] = wval & 0xFF;
57
+}
58
+
59
+inline void DWIN_Long(size_t &i, const uint32_t lval) {
60
+  DWIN_SendBuf[++i] = (lval >> 24) & 0xFF;
61
+  DWIN_SendBuf[++i] = (lval >> 16) & 0xFF;
62
+  DWIN_SendBuf[++i] = (lval >>  8) & 0xFF;
63
+  DWIN_SendBuf[++i] = lval & 0xFF;
64
+}
65
+
66
+// Send the data in the buffer plus the packet tail
67
+void DWIN_Send(size_t &i);
68
+
69
+inline void DWIN_Text(size_t &i, const char * const string, uint16_t rlimit=0xFFFF) {
70
+  if (!string) return;
71
+  const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, _MIN(strlen(string), rlimit));
72
+  if (len == 0) return;
73
+  memcpy(&DWIN_SendBuf[i+1], string, len);
74
+  i += len;
75
+}
76
+
77
+inline void DWIN_Text(size_t &i, const __FlashStringHelper * string, uint16_t rlimit=0xFFFF) {
78
+  if (!string) return;
79
+  const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, _MIN(rlimit, strlen_P((PGM_P)string))); // cast to PGM_P (const char*) measure with strlen_P.
80
+  if (len == 0) return;
81
+  memcpy_P(&DWIN_SendBuf[i+1], string, len);
82
+  i += len;
83
+}
84
+
85
+/*-------------------------------------- System variable function --------------------------------------*/
86
+
87
+// Handshake (1: Success, 0: Fail)
88
+bool DWIN_Handshake();
89
+
90
+// DWIN startup
91
+void DWIN_Startup();
92
+
93
+// Set the backlight brightness
94
+//  brightness: (0x00-0xFF)
95
+void DWIN_LCD_Brightness(const uint8_t brightness);
96
+
97
+// Set screen display direction
98
+//  dir: 0=0°, 1=90°, 2=180°, 3=270°
99
+void DWIN_Frame_SetDir(uint8_t dir);
100
+
101
+// Update display
102
+void DWIN_UpdateLCD();
103
+
104
+/*---------------------------------------- Drawing functions ----------------------------------------*/
105
+
106
+// Clear screen
107
+//  color: Clear screen color
108
+void DWIN_Frame_Clear(const uint16_t color);
109
+
110
+// Draw a point
111
+//  color: point color
112
+//  width: point width   0x01-0x0F
113
+//  height: point height 0x01-0x0F
114
+//  x,y: upper left point
115
+void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y);
116
+
117
+// Draw a line
118
+//  color: Line segment color
119
+//  xStart/yStart: Start point
120
+//  xEnd/yEnd: End point
121
+void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
122
+
123
+// Draw a Horizontal line
124
+//  color: Line segment color
125
+//  xStart/yStart: Start point
126
+//  xLength: Line Length
127
+inline void DWIN_Draw_HLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xLength) {
128
+  DWIN_Draw_Line(color, xStart, yStart, xStart + xLength - 1, yStart);
129
+}
130
+
131
+// Draw a Vertical line
132
+//  color: Line segment color
133
+//  xStart/yStart: Start point
134
+//  yLength: Line Length
135
+inline void DWIN_Draw_VLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t yLength) {
136
+  DWIN_Draw_Line(color, xStart, yStart, xStart, yStart + yLength - 1);
137
+}
138
+
139
+// Draw a rectangle
140
+//  mode: 0=frame, 1=fill, 2=XOR fill
141
+//  color: Rectangle color
142
+//  xStart/yStart: upper left point
143
+//  xEnd/yEnd: lower right point
144
+void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
145
+
146
+// Draw a box
147
+//  mode: 0=frame, 1=fill, 2=XOR fill
148
+//  color: Rectangle color
149
+//  xStart/yStart: upper left point
150
+//  xSize/ySize: box size
151
+inline void DWIN_Draw_Box(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xSize, uint16_t ySize) {
152
+  DWIN_Draw_Rectangle(mode, color, xStart, yStart, xStart + xSize - 1, yStart + ySize - 1);
153
+}
154
+
155
+// Move a screen area
156
+//  mode: 0, circle shift; 1, translation
157
+//  dir: 0=left, 1=right, 2=up, 3=down
158
+//  dis: Distance
159
+//  color: Fill color
160
+//  xStart/yStart: upper left point
161
+//  xEnd/yEnd: bottom right point
162
+void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
163
+                         uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
164
+
165
+
166
+/*---------------------------------------- Text related functions ----------------------------------------*/
167
+
168
+// Draw a string
169
+//  bShow: true=display background color; false=don't display background color
170
+//  size: Font size
171
+//  color: Character color
172
+//  bColor: Background color
173
+//  x/y: Upper-left coordinate of the string
174
+//  *string: The string
175
+//  rlimit: For draw less chars than string length use rlimit
176
+void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit=0xFFFF);
177
+
178
+inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
179
+  // Note that this won't work on AVR, only 32-bit systems!
180
+  DWIN_Draw_String(bShow, size, color, bColor, x, y, reinterpret_cast<const char*>(title));
181
+}
182
+
183
+// Draw a positive integer
184
+//  bShow: true=display background color; false=don't display background color
185
+//  zeroFill: true=zero fill; false=no zero fill
186
+//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
187
+//  size: Font size
188
+//  color: Character color
189
+//  bColor: Background color
190
+//  iNum: Number of digits
191
+//  x/y: Upper-left coordinate
192
+//  value: Integer value
193
+void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
194
+                          uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint32_t value);
195
+
196
+// Draw a floating point number
197
+//  bShow: true=display background color; false=don't display background color
198
+//  zeroFill: true=zero fill; false=no zero fill
199
+//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
200
+//  size: Font size
201
+//  color: Character color
202
+//  bColor: Background color
203
+//  iNum: Number of whole digits
204
+//  fNum: Number of decimal digits
205
+//  x/y: Upper-left point
206
+//  value: Float value
207
+void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
208
+                            uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value);
209
+
210
+// Draw a floating point number
211
+//  value: positive unscaled float value
212
+void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
213
+                            uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
214
+
215
+/*---------------------------------------- Picture related functions ----------------------------------------*/
216
+
217
+// Draw JPG and cached in #0 virtual display area
218
+//  id: Picture ID
219
+void DWIN_JPG_ShowAndCache(const uint8_t id);
220
+
221
+// Draw an Icon
222
+//  libID: Icon library ID
223
+//  picID: Icon ID
224
+//  x/y: Upper-left point
225
+void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y);
226
+
227
+// Draw an Icon
228
+//  IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
229
+//  BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
230
+//  BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
231
+//  libID: Icon library ID
232
+//  picID: Icon ID
233
+//  x/y: Upper-left point
234
+void DWIN_ICON_Show(bool IBD, bool BIR, bool BFI, uint8_t libID, uint8_t picID, uint16_t x, uint16_t y);
235
+
236
+// Draw an Icon from SRAM
237
+//  IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
238
+//  BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
239
+//  BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
240
+//  x/y: Upper-left point
241
+//  addr: SRAM address
242
+void DWIN_ICON_Show(bool IBD, bool BIR, bool BFI, uint16_t x, uint16_t y, uint16_t addr);
243
+
244
+// Unzip the JPG picture to a virtual display area
245
+//  n: Cache index
246
+//  id: Picture ID
247
+void DWIN_JPG_CacheToN(uint8_t n, uint8_t id);
248
+
249
+// Unzip the JPG picture to virtual display area #1
250
+//  id: Picture ID
251
+inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); }
252
+
253
+// Animate a series of icons
254
+//  animID: Animation ID  up to 16
255
+//  animate: animation on or off
256
+//  libID: Icon library ID
257
+//  picIDs: Icon starting ID
258
+//  picIDe: Icon ending ID
259
+//  x/y: Upper-left point
260
+//  interval: Display time interval, unit 10mS
261
+void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval);
262
+
263
+// Animation Control
264
+//  state: 16 bits, each bit is the state of an animation id
265
+void DWIN_ICON_AnimationControl(uint16_t state);

+ 44
- 0
Marlin/src/lcd/e3v2/common/dwin_color.h 查看文件

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 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
+// Extended and default UI Colors
25
+#define RGB(R,G,B)  (R << 11) | (G << 5) | (B) // R,B: 0..31; G: 0..63
26
+#define GetRColor(color) ((color >> 11) & 0x1F)
27
+#define GetGColor(color) ((color >>  5) & 0x3F)
28
+#define GetBColor(color) ((color >>  0) & 0x1F)
29
+
30
+#define Color_White         0xFFFF
31
+#define Color_Yellow        RGB(0x1F,0x3F,0x00)
32
+#define Color_Red           RGB(0x1F,0x00,0x00)
33
+#define Color_Error_Red     0xB000  // Error!
34
+#define Color_Bg_Red        0xF00F  // Red background color
35
+#define Color_Bg_Window     0x31E8  // Popup background color
36
+#define Color_Bg_Blue       0x1125  // Dark blue background color
37
+#define Color_Bg_Black      0x0841  // Black background color
38
+#define Color_IconBlue      0x45FA  // Lighter blue that matches icons/accents
39
+#define Popup_Text_Color    0xD6BA  // Popup font background color
40
+#define Line_Color          0x3A6A  // Split line color
41
+#define Rectangle_Color     0xEE2F  // Blue square cursor color
42
+#define Percent_Color       0xFE29  // Percentage color
43
+#define BarFill_Color       0x10E4  // Fill color of progress bar
44
+#define Select_Color        0x33BB  // Selected color

+ 38
- 0
Marlin/src/lcd/e3v2/common/dwin_font.h 查看文件

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 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
+/**
25
+ * 3-.0:The font size, 0x00-0x09, corresponds to the font size below:
26
+ * 0x00=6*12   0x01=8*16   0x02=10*20  0x03=12*24  0x04=14*28
27
+ * 0x05=16*32  0x06=20*40  0x07=24*48  0x08=28*56  0x09=32*64
28
+ */
29
+#define font6x12  0x00
30
+#define font8x16  0x01
31
+#define font10x20 0x02
32
+#define font12x24 0x03
33
+#define font14x28 0x04
34
+#define font16x32 0x05
35
+#define font20x40 0x06
36
+#define font24x48 0x07
37
+#define font28x56 0x08
38
+#define font32x64 0x09

+ 138
- 0
Marlin/src/lcd/e3v2/common/dwin_set.h 查看文件

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 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
+// Picture ID
25
+#define Language_English    1
26
+#define Language_Chinese    2
27
+
28
+#define ICON                7 // Icon set file 7.ICO
29
+
30
+#define ICON_LOGO                0
31
+#define ICON_Print_0             1
32
+#define ICON_Print_1             2
33
+#define ICON_Prepare_0           3
34
+#define ICON_Prepare_1           4
35
+#define ICON_Control_0           5
36
+#define ICON_Control_1           6
37
+#define ICON_Leveling_0          7
38
+#define ICON_Leveling_1          8
39
+#define ICON_HotendTemp          9
40
+#define ICON_BedTemp            10
41
+#define ICON_Speed              11
42
+#define ICON_Zoffset            12
43
+#define ICON_Back               13
44
+#define ICON_File               14
45
+#define ICON_PrintTime          15
46
+#define ICON_RemainTime         16
47
+#define ICON_Setup_0            17
48
+#define ICON_Setup_1            18
49
+#define ICON_Pause_0            19
50
+#define ICON_Pause_1            20
51
+#define ICON_Continue_0         21
52
+#define ICON_Continue_1         22
53
+#define ICON_Stop_0             23
54
+#define ICON_Stop_1             24
55
+#define ICON_Bar                25
56
+#define ICON_More               26
57
+
58
+#define ICON_Axis               27
59
+#define ICON_CloseMotor         28
60
+#define ICON_Homing             29
61
+#define ICON_SetHome            30
62
+#define ICON_PLAPreheat         31
63
+#define ICON_ABSPreheat         32
64
+#define ICON_Cool               33
65
+#define ICON_Language           34
66
+
67
+#define ICON_MoveX              35
68
+#define ICON_MoveY              36
69
+#define ICON_MoveZ              37
70
+#define ICON_Extruder           38
71
+
72
+#define ICON_Temperature        40
73
+#define ICON_Motion             41
74
+#define ICON_WriteEEPROM        42
75
+#define ICON_ReadEEPROM         43
76
+#define ICON_ResumeEEPROM       44
77
+#define ICON_Info               45
78
+
79
+#define ICON_SetEndTemp         46
80
+#define ICON_SetBedTemp         47
81
+#define ICON_FanSpeed           48
82
+#define ICON_SetPLAPreheat      49
83
+#define ICON_SetABSPreheat      50
84
+
85
+#define ICON_MaxSpeed           51
86
+#define ICON_MaxAccelerated     52
87
+#define ICON_MaxJerk            53
88
+#define ICON_Step               54
89
+#define ICON_PrintSize          55
90
+#define ICON_Version            56
91
+#define ICON_Contact            57
92
+#define ICON_StockConfiguration 58
93
+#define ICON_MaxSpeedX          59
94
+#define ICON_MaxSpeedY          60
95
+#define ICON_MaxSpeedZ          61
96
+#define ICON_MaxSpeedE          62
97
+#define ICON_MaxAccX            63
98
+#define ICON_MaxAccY            64
99
+#define ICON_MaxAccZ            65
100
+#define ICON_MaxAccE            66
101
+#define ICON_MaxSpeedJerkX      67
102
+#define ICON_MaxSpeedJerkY      68
103
+#define ICON_MaxSpeedJerkZ      69
104
+#define ICON_MaxSpeedJerkE      70
105
+#define ICON_StepX              71
106
+#define ICON_StepY              72
107
+#define ICON_StepZ              73
108
+#define ICON_StepE              74
109
+#define ICON_Setspeed           75
110
+#define ICON_SetZOffset         76
111
+#define ICON_Rectangle          77
112
+#define ICON_BLTouch            78
113
+#define ICON_TempTooLow         79
114
+#define ICON_AutoLeveling       80
115
+#define ICON_TempTooHigh        81
116
+#define ICON_NoTips_C           82
117
+#define ICON_NoTips_E           83
118
+#define ICON_Continue_C         84
119
+#define ICON_Continue_E         85
120
+#define ICON_Cancel_C           86
121
+#define ICON_Cancel_E           87
122
+#define ICON_Confirm_C          88
123
+#define ICON_Confirm_E          89
124
+#define ICON_Info_0             90
125
+#define ICON_Info_1             91
126
+
127
+#define ICON_Folder       ICON_More
128
+#define ICON_AdvSet       ICON_Language
129
+#define ICON_HomeOffset   ICON_AdvSet
130
+#define ICON_HomeOffsetX  ICON_StepX
131
+#define ICON_HomeOffsetY  ICON_StepY
132
+#define ICON_HomeOffsetZ  ICON_StepZ
133
+#define ICON_ProbeOffset  ICON_AdvSet
134
+#define ICON_ProbeOffsetX ICON_StepX
135
+#define ICON_ProbeOffsetY ICON_StepY
136
+#define ICON_ProbeOffsetZ ICON_StepZ
137
+#define ICON_PIDNozzle    ICON_SetEndTemp
138
+#define ICON_PIDbed       ICON_SetBedTemp

Marlin/src/lcd/e3v2/jyersui/rotary_encoder.cpp → Marlin/src/lcd/e3v2/common/encoder.cpp 查看文件

21
  */
21
  */
22
 
22
 
23
 /*****************************************************************************
23
 /*****************************************************************************
24
- * @file     lcd/e3v2/jyersui/rotary_encoder.cpp
24
+ * @file     lcd/e3v2/common/encoder.cpp
25
  * @brief    Rotary encoder functions
25
  * @brief    Rotary encoder functions
26
  *****************************************************************************/
26
  *****************************************************************************/
27
 
27
 
28
 #include "../../../inc/MarlinConfigPre.h"
28
 #include "../../../inc/MarlinConfigPre.h"
29
 
29
 
30
-#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
30
+#if HAS_DWIN_E3V2
31
 
31
 
32
-#include "rotary_encoder.h"
32
+#include "encoder.h"
33
 #include "../../buttons.h"
33
 #include "../../buttons.h"
34
 
34
 
35
 #include "../../../MarlinCore.h"
35
 #include "../../../MarlinCore.h"
38
 
38
 
39
 #if HAS_BUZZER
39
 #if HAS_BUZZER
40
   #include "../../../libs/buzzer.h"
40
   #include "../../../libs/buzzer.h"
41
-  #include "dwin.h"
42
 #endif
41
 #endif
43
 
42
 
44
 #include <stdlib.h>
43
 #include <stdlib.h>
49
 
48
 
50
 ENCODER_Rate EncoderRate;
49
 ENCODER_Rate EncoderRate;
51
 
50
 
52
-// Buzzer
51
+// TODO: Replace with ui.quick_feedback
53
 void Encoder_tick() {
52
 void Encoder_tick() {
54
   #if PIN_EXISTS(BEEPER)
53
   #if PIN_EXISTS(BEEPER)
55
-    if (CrealityDWIN.eeprom_settings.beeperenable) {
54
+    if (ui.buzzer_enabled) {
56
       WRITE(BEEPER_PIN, HIGH);
55
       WRITE(BEEPER_PIN, HIGH);
57
       delay(10);
56
       delay(10);
58
       WRITE(BEEPER_PIN, LOW);
57
       WRITE(BEEPER_PIN, LOW);
72
     SET_INPUT_PULLUP(BTN_ENC);
71
     SET_INPUT_PULLUP(BTN_ENC);
73
   #endif
72
   #endif
74
   #if PIN_EXISTS(BEEPER)
73
   #if PIN_EXISTS(BEEPER)
75
-    SET_OUTPUT(BEEPER_PIN);
74
+    SET_OUTPUT(BEEPER_PIN);     // TODO: Use buzzer.h which already inits this
76
   #endif
75
   #endif
77
 }
76
 }
78
 
77
 
79
 // Analyze encoder value and return state
78
 // Analyze encoder value and return state
80
-ENCODER_DiffState Encoder_ReceiveAnalyze() {
79
+EncoderState Encoder_ReceiveAnalyze() {
81
   const millis_t now = millis();
80
   const millis_t now = millis();
82
   static uint8_t lastEncoderBits;
81
   static uint8_t lastEncoderBits;
83
   uint8_t newbutton = 0;
82
   uint8_t newbutton = 0;
84
   static signed char temp_diff = 0;
83
   static signed char temp_diff = 0;
85
 
84
 
86
-  ENCODER_DiffState temp_diffState = ENCODER_DIFF_NO;
85
+  EncoderState temp_diffState = ENCODER_DIFF_NO;
87
   if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
86
   if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
88
   if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
87
   if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
89
   if (BUTTON_PRESSED(ENC)) {
88
   if (BUTTON_PRESSED(ENC)) {
94
       #if PIN_EXISTS(LCD_LED)
93
       #if PIN_EXISTS(LCD_LED)
95
         //LED_Action();
94
         //LED_Action();
96
       #endif
95
       #endif
97
-      if (ui.backlight) return ENCODER_DIFF_ENTER;
98
-      ui.refresh_brightness();
96
+      if (!ui.backlight) ui.refresh_brightness();
97
+      const bool was_waiting = wait_for_user;
98
+      wait_for_user = false;
99
+      return was_waiting ? ENCODER_DIFF_NO : ENCODER_DIFF_ENTER;
99
     }
100
     }
100
     else return ENCODER_DIFF_NO;
101
     else return ENCODER_DIFF_NO;
101
   }
102
   }
122
   }
123
   }
123
 
124
 
124
   if (ABS(temp_diff) >= ENCODER_PULSES_PER_STEP) {
125
   if (ABS(temp_diff) >= ENCODER_PULSES_PER_STEP) {
125
-    #if ENABLED(REVERSE_ENCODER_DIRECTION)
126
-      if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CCW;
127
-      else temp_diffState = ENCODER_DIFF_CW;
128
-    #else
129
-      if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CW;
130
-      else temp_diffState = ENCODER_DIFF_CCW;
131
-    #endif
126
+    if (temp_diff > 0) temp_diffState = TERN(REVERSE_ENCODER_DIRECTION, ENCODER_DIFF_CCW, ENCODER_DIFF_CW);
127
+    else temp_diffState = TERN(REVERSE_ENCODER_DIRECTION, ENCODER_DIFF_CW, ENCODER_DIFF_CCW);
132
 
128
 
133
     #if ENABLED(ENCODER_RATE_MULTIPLIER)
129
     #if ENABLED(ENCODER_RATE_MULTIPLIER)
134
 
130
 
260
 
256
 
261
 #endif // LCD_LED
257
 #endif // LCD_LED
262
 
258
 
263
-#endif // DWIN_CREALITY_LCD_JYERSUI
259
+#endif // HAS_DWIN_E3V2

Marlin/src/lcd/e3v2/jyersui/rotary_encoder.h → Marlin/src/lcd/e3v2/common/encoder.h 查看文件

22
 #pragma once
22
 #pragma once
23
 
23
 
24
 /*****************************************************************************
24
 /*****************************************************************************
25
-  * @file     lcd/e3v2/jyersui/rotary_encoder.h
25
+  * @file     lcd/e3v2/common/encoder.h
26
   * @brief    Rotary encoder functions
26
   * @brief    Rotary encoder functions
27
   ****************************************************************************/
27
   ****************************************************************************/
28
 
28
 
43
   ENCODER_DIFF_CW    = 1,  // clockwise rotation
43
   ENCODER_DIFF_CW    = 1,  // clockwise rotation
44
   ENCODER_DIFF_CCW   = 2,  // counterclockwise rotation
44
   ENCODER_DIFF_CCW   = 2,  // counterclockwise rotation
45
   ENCODER_DIFF_ENTER = 3   // click
45
   ENCODER_DIFF_ENTER = 3   // click
46
-} ENCODER_DiffState;
46
+} EncoderState;
47
 
47
 
48
 // Encoder initialization
48
 // Encoder initialization
49
 void Encoder_Configuration();
49
 void Encoder_Configuration();
50
 
50
 
51
 // Analyze encoder value and return state
51
 // Analyze encoder value and return state
52
-ENCODER_DiffState Encoder_ReceiveAnalyze();
52
+EncoderState Encoder_ReceiveAnalyze();
53
 
53
 
54
 /*********************** Encoder LED ***********************/
54
 /*********************** Encoder LED ***********************/
55
 
55
 

+ 57
- 60
Marlin/src/lcd/e3v2/creality/dwin.cpp 查看文件

138
 
138
 
139
 // Value Init
139
 // Value Init
140
 HMI_value_t HMI_ValueStruct;
140
 HMI_value_t HMI_ValueStruct;
141
-HMI_Flag_t HMI_flag{0};
141
+HMI_flag_t HMI_flag{0};
142
 
142
 
143
 millis_t dwin_heat_time = 0;
143
 millis_t dwin_heat_time = 0;
144
 
144
 
470
 }
470
 }
471
 
471
 
472
 template <typename T>
472
 template <typename T>
473
-inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, T &valref) {
473
+inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) {
474
   if (encoder_diffState == ENCODER_DIFF_CW)
474
   if (encoder_diffState == ENCODER_DIFF_CW)
475
     valref += EncoderRate.encoderMoveValue;
475
     valref += EncoderRate.encoderMoveValue;
476
   else if (encoder_diffState == ENCODER_DIFF_CCW)
476
   else if (encoder_diffState == ENCODER_DIFF_CCW)
593
   DWIN_Draw_Label(row, (char*)title);
593
   DWIN_Draw_Label(row, (char*)title);
594
 }
594
 }
595
 
595
 
596
-void DWIN_Draw_Signed_Float(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
596
+void DWIN_Draw_Signed_Float(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) {
597
   DWIN_Draw_String(true, size, Color_White, bColor, x - 8, y, value < 0 ? F("-") : F(" "));
597
   DWIN_Draw_String(true, size, Color_White, bColor, x - 8, y, value < 0 ? F("-") : F(" "));
598
   DWIN_Draw_FloatValue(true, true, 0, size, Color_White, bColor, iNum, fNum, x, y, value < 0 ? -value : value);
598
   DWIN_Draw_FloatValue(true, true, 0, size, Color_White, bColor, iNum, fNum, x, y, value < 0 ? -value : value);
599
 }
599
 }
607
 }
607
 }
608
 
608
 
609
 void Draw_Edit_Float3(const uint8_t row, const uint16_t value, const bool active=false) {
609
 void Draw_Edit_Float3(const uint8_t row, const uint16_t value, const bool active=false) {
610
-  DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, active ? Select_Color : Color_Bg_Black, 3, UNITFDIGITS, 220 - UNITFDIGITS * 8, EBASE(row), value);
610
+  DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, active ? Select_Color : Color_Bg_Black, 3, UNITFDIGITS, 220 - UNITFDIGITS * 8, EBASE(row), (int32_t)value);
611
 }
611
 }
612
 
612
 
613
 void Draw_Edit_Signed_Float2(const uint8_t row, const float value, const bool active=false) {
613
 void Draw_Edit_Signed_Float2(const uint8_t row, const float value, const bool active=false) {
1292
   TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)();
1292
   TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)();
1293
 }
1293
 }
1294
 
1294
 
1295
-inline ENCODER_DiffState get_encoder_state() {
1295
+inline EncoderState get_encoder_state() {
1296
   static millis_t Encoder_ms = 0;
1296
   static millis_t Encoder_ms = 0;
1297
   const millis_t ms = millis();
1297
   const millis_t ms = millis();
1298
   if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
1298
   if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
1299
-  const ENCODER_DiffState state = Encoder_ReceiveAnalyze();
1299
+  const EncoderState state = Encoder_ReceiveAnalyze();
1300
   if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS;
1300
   if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS;
1301
   return state;
1301
   return state;
1302
 }
1302
 }
1317
 }
1317
 }
1318
 
1318
 
1319
 void HMI_Move_X() {
1319
 void HMI_Move_X() {
1320
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1320
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
1321
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1321
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1322
   if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_X_scaled)) {
1322
   if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_X_scaled)) {
1323
     Draw_Edit_Float3(1, HMI_ValueStruct.Move_X_scaled);
1323
     Draw_Edit_Float3(1, HMI_ValueStruct.Move_X_scaled);
1331
 }
1331
 }
1332
 
1332
 
1333
 void HMI_Move_Y() {
1333
 void HMI_Move_Y() {
1334
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1334
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
1335
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1335
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1336
   if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Y_scaled)) {
1336
   if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Y_scaled)) {
1337
     Draw_Edit_Float3(2, HMI_ValueStruct.Move_Y_scaled);
1337
     Draw_Edit_Float3(2, HMI_ValueStruct.Move_Y_scaled);
1345
 }
1345
 }
1346
 
1346
 
1347
 void HMI_Move_Z() {
1347
 void HMI_Move_Z() {
1348
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1348
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
1349
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1349
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1350
   if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Z_scaled)) {
1350
   if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Z_scaled)) {
1351
     Draw_Edit_Float3(3, HMI_ValueStruct.Move_Z_scaled);
1351
     Draw_Edit_Float3(3, HMI_ValueStruct.Move_Z_scaled);
1362
 
1362
 
1363
   void HMI_Move_E() {
1363
   void HMI_Move_E() {
1364
     static float last_E_scaled = 0;
1364
     static float last_E_scaled = 0;
1365
-    ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1365
+    EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
1366
     if (encoder_diffState == ENCODER_DIFF_NO) return;
1366
     if (encoder_diffState == ENCODER_DIFF_NO) return;
1367
     if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_E_scaled)) {
1367
     if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_E_scaled)) {
1368
       last_E_scaled = HMI_ValueStruct.Move_E_scaled;
1368
       last_E_scaled = HMI_ValueStruct.Move_E_scaled;
1383
   bool printer_busy() { return planner.movesplanned() || printingIsActive(); }
1383
   bool printer_busy() { return planner.movesplanned() || printingIsActive(); }
1384
 
1384
 
1385
   void HMI_Zoffset() {
1385
   void HMI_Zoffset() {
1386
-    ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1386
+    EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
1387
     if (encoder_diffState == ENCODER_DIFF_NO) return;
1387
     if (encoder_diffState == ENCODER_DIFF_NO) return;
1388
     uint8_t zoff_line;
1388
     uint8_t zoff_line;
1389
     switch (HMI_ValueStruct.show_mode) {
1389
     switch (HMI_ValueStruct.show_mode) {
1416
 #if HAS_HOTEND
1416
 #if HAS_HOTEND
1417
 
1417
 
1418
   void HMI_ETemp() {
1418
   void HMI_ETemp() {
1419
-    ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1419
+    EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
1420
     if (encoder_diffState == ENCODER_DIFF_NO) return;
1420
     if (encoder_diffState == ENCODER_DIFF_NO) return;
1421
     uint8_t temp_line;
1421
     uint8_t temp_line;
1422
     switch (HMI_ValueStruct.show_mode) {
1422
     switch (HMI_ValueStruct.show_mode) {
1458
 #if HAS_HEATED_BED
1458
 #if HAS_HEATED_BED
1459
 
1459
 
1460
   void HMI_BedTemp() {
1460
   void HMI_BedTemp() {
1461
-    ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1461
+    EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
1462
     if (encoder_diffState == ENCODER_DIFF_NO) return;
1462
     if (encoder_diffState == ENCODER_DIFF_NO) return;
1463
     uint8_t bed_line;
1463
     uint8_t bed_line;
1464
     switch (HMI_ValueStruct.show_mode) {
1464
     switch (HMI_ValueStruct.show_mode) {
1500
 #if HAS_PREHEAT && HAS_FAN
1500
 #if HAS_PREHEAT && HAS_FAN
1501
 
1501
 
1502
   void HMI_FanSpeed() {
1502
   void HMI_FanSpeed() {
1503
-    ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1503
+    EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
1504
     if (encoder_diffState == ENCODER_DIFF_NO) return;
1504
     if (encoder_diffState == ENCODER_DIFF_NO) return;
1505
     uint8_t fan_line;
1505
     uint8_t fan_line;
1506
     switch (HMI_ValueStruct.show_mode) {
1506
     switch (HMI_ValueStruct.show_mode) {
1541
 #endif // HAS_PREHEAT && HAS_FAN
1541
 #endif // HAS_PREHEAT && HAS_FAN
1542
 
1542
 
1543
 void HMI_PrintSpeed() {
1543
 void HMI_PrintSpeed() {
1544
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1544
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
1545
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1545
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1546
   if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.print_speed)) {
1546
   if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.print_speed)) {
1547
     checkkey = Tune;
1547
     checkkey = Tune;
1559
 #define LAST_AXIS TERN(HAS_HOTEND, E_AXIS, Z_AXIS)
1559
 #define LAST_AXIS TERN(HAS_HOTEND, E_AXIS, Z_AXIS)
1560
 
1560
 
1561
 void HMI_MaxFeedspeedXYZE() {
1561
 void HMI_MaxFeedspeedXYZE() {
1562
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1562
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
1563
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1563
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1564
   if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Feedspeed)) {
1564
   if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Feedspeed)) {
1565
     checkkey = MaxSpeed;
1565
     checkkey = MaxSpeed;
1578
 }
1578
 }
1579
 
1579
 
1580
 void HMI_MaxAccelerationXYZE() {
1580
 void HMI_MaxAccelerationXYZE() {
1581
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1581
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
1582
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1582
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1583
   if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Acceleration)) {
1583
   if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Acceleration)) {
1584
     checkkey = MaxAcceleration;
1584
     checkkey = MaxAcceleration;
1599
 #if HAS_CLASSIC_JERK
1599
 #if HAS_CLASSIC_JERK
1600
 
1600
 
1601
   void HMI_MaxJerkXYZE() {
1601
   void HMI_MaxJerkXYZE() {
1602
-    ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1602
+    EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
1603
     if (encoder_diffState == ENCODER_DIFF_NO) return;
1603
     if (encoder_diffState == ENCODER_DIFF_NO) return;
1604
     if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Jerk_scaled)) {
1604
     if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Jerk_scaled)) {
1605
       checkkey = MaxJerk;
1605
       checkkey = MaxJerk;
1620
 #endif // HAS_CLASSIC_JERK
1620
 #endif // HAS_CLASSIC_JERK
1621
 
1621
 
1622
 void HMI_StepXYZE() {
1622
 void HMI_StepXYZE() {
1623
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1623
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
1624
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1624
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1625
   if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Step_scaled)) {
1625
   if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Step_scaled)) {
1626
     checkkey = Step;
1626
     checkkey = Step;
1816
 
1816
 
1817
 void MarlinUI::refresh() { /* Nothing to see here */ }
1817
 void MarlinUI::refresh() { /* Nothing to see here */ }
1818
 
1818
 
1819
-#define ICON_Folder ICON_More
1820
-
1821
 #if ENABLED(SCROLL_LONG_FILENAMES)
1819
 #if ENABLED(SCROLL_LONG_FILENAMES)
1822
 
1820
 
1823
   char shift_name[LONG_FILENAME_LENGTH + 1];
1821
   char shift_name[LONG_FILENAME_LENGTH + 1];
2077
 
2075
 
2078
 // Main Process
2076
 // Main Process
2079
 void HMI_MainMenu() {
2077
 void HMI_MainMenu() {
2080
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
2078
+  EncoderState encoder_diffState = get_encoder_state();
2081
   if (encoder_diffState == ENCODER_DIFF_NO) return;
2079
   if (encoder_diffState == ENCODER_DIFF_NO) return;
2082
 
2080
 
2083
   if (encoder_diffState == ENCODER_DIFF_CW) {
2081
   if (encoder_diffState == ENCODER_DIFF_CW) {
2137
 
2135
 
2138
 // Select (and Print) File
2136
 // Select (and Print) File
2139
 void HMI_SelectFile() {
2137
 void HMI_SelectFile() {
2140
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
2138
+  EncoderState encoder_diffState = get_encoder_state();
2141
 
2139
 
2142
   const uint16_t hasUpDir = !card.flag.workDirIsRoot;
2140
   const uint16_t hasUpDir = !card.flag.workDirIsRoot;
2143
 
2141
 
2257
 
2255
 
2258
 // Printing
2256
 // Printing
2259
 void HMI_Printing() {
2257
 void HMI_Printing() {
2260
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
2258
+  EncoderState encoder_diffState = get_encoder_state();
2261
   if (encoder_diffState == ENCODER_DIFF_NO) return;
2259
   if (encoder_diffState == ENCODER_DIFF_NO) return;
2262
 
2260
 
2263
   if (HMI_flag.done_confirm_flag) {
2261
   if (HMI_flag.done_confirm_flag) {
2335
 
2333
 
2336
 // Pause and Stop window
2334
 // Pause and Stop window
2337
 void HMI_PauseOrStop() {
2335
 void HMI_PauseOrStop() {
2338
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
2336
+  EncoderState encoder_diffState = get_encoder_state();
2339
   if (encoder_diffState == ENCODER_DIFF_NO) return;
2337
   if (encoder_diffState == ENCODER_DIFF_NO) return;
2340
 
2338
 
2341
   if (encoder_diffState == ENCODER_DIFF_CW)
2339
   if (encoder_diffState == ENCODER_DIFF_CW)
2417
       Item_AreaCopy(1,  76, 102,  87, row); // "Set Home Offsets"
2415
       Item_AreaCopy(1,  76, 102,  87, row); // "Set Home Offsets"
2418
     #endif
2416
     #endif
2419
   }
2417
   }
2420
-  Draw_Menu_Line(row, ICON_HomeOff);
2418
+  Draw_Menu_Line(row, ICON_HomeOffset);
2421
   Draw_More_Icon(row);
2419
   Draw_More_Icon(row);
2422
 }
2420
 }
2423
 
2421
 
2434
         say_probe_offs_en(row);
2432
         say_probe_offs_en(row);
2435
       #endif
2433
       #endif
2436
     }
2434
     }
2437
-    Draw_Menu_Line(row, ICON_ProbeOff);
2435
+    Draw_Menu_Line(row, ICON_ProbeOffset);
2438
     Draw_More_Icon(row);
2436
     Draw_More_Icon(row);
2439
   }
2437
   }
2440
 
2438
 
2529
   }
2527
   }
2530
   else {
2528
   else {
2531
     #ifdef USE_STRING_TITLES
2529
     #ifdef USE_STRING_TITLES
2532
-      Draw_Menu_LineF(row, ICON_HomeOffX, GET_TEXT_F(MSG_HOME_OFFSET_X));
2530
+      Draw_Menu_LineF(row, ICON_HomeOffsetX, GET_TEXT_F(MSG_HOME_OFFSET_X));
2533
     #else
2531
     #else
2534
       say_home_offs_en(row); say_x_en(75, row);   // "Home Offset X"
2532
       say_home_offs_en(row); say_x_en(75, row);   // "Home Offset X"
2535
     #endif
2533
     #endif
2536
   }
2534
   }
2537
-  Draw_Menu_Line(row, ICON_HomeOff);
2535
+  Draw_Menu_Line(row, ICON_HomeOffset);
2538
   Draw_Edit_Signed_Float3(row, HMI_ValueStruct.Home_OffX_scaled);
2536
   Draw_Edit_Signed_Float3(row, HMI_ValueStruct.Home_OffX_scaled);
2539
 }
2537
 }
2540
 
2538
 
2544
   }
2542
   }
2545
   else {
2543
   else {
2546
     #ifdef USE_STRING_TITLES
2544
     #ifdef USE_STRING_TITLES
2547
-      Draw_Menu_LineF(row, ICON_HomeOffY, GET_TEXT_F(MSG_HOME_OFFSET_Y));
2545
+      Draw_Menu_LineF(row, ICON_HomeOffsetY, GET_TEXT_F(MSG_HOME_OFFSET_Y));
2548
     #else
2546
     #else
2549
       say_home_offs_en(row); say_y_en(75, row);   // "Home Offset X"
2547
       say_home_offs_en(row); say_y_en(75, row);   // "Home Offset X"
2550
     #endif
2548
     #endif
2551
   }
2549
   }
2552
-  Draw_Menu_Line(row, ICON_HomeOff);
2550
+  Draw_Menu_Line(row, ICON_HomeOffset);
2553
   Draw_Edit_Signed_Float3(row, HMI_ValueStruct.Home_OffY_scaled);
2551
   Draw_Edit_Signed_Float3(row, HMI_ValueStruct.Home_OffY_scaled);
2554
 }
2552
 }
2555
 
2553
 
2559
   }
2557
   }
2560
   else {
2558
   else {
2561
     #ifdef USE_STRING_TITLES
2559
     #ifdef USE_STRING_TITLES
2562
-      Draw_Menu_LineF(row, ICON_HomeOffZ, GET_TEXT_F(MSG_HOME_OFFSET_Z));
2560
+      Draw_Menu_LineF(row, ICON_HomeOffsetZ, GET_TEXT_F(MSG_HOME_OFFSET_Z));
2563
     #else
2561
     #else
2564
       say_home_offs_en(row); say_z_en(75, row);   // "Home Offset Z"
2562
       say_home_offs_en(row); say_z_en(75, row);   // "Home Offset Z"
2565
     #endif
2563
     #endif
2566
   }
2564
   }
2567
-  Draw_Menu_Line(row, ICON_HomeOff);
2565
+  Draw_Menu_Line(row, ICON_HomeOffset);
2568
   Draw_Edit_Signed_Float3(row, HMI_ValueStruct.Home_OffZ_scaled);
2566
   Draw_Edit_Signed_Float3(row, HMI_ValueStruct.Home_OffZ_scaled);
2569
 }
2567
 }
2570
 
2568
 
2602
         DWIN_Frame_TitleCopy(124, 431, 91, 12);                             // "Probe Offsets"
2600
         DWIN_Frame_TitleCopy(124, 431, 91, 12);                             // "Probe Offsets"
2603
       #endif
2601
       #endif
2604
       #ifdef USE_STRING_TITLES
2602
       #ifdef USE_STRING_TITLES
2605
-        Draw_Menu_LineF(1, ICON_ProbeOffX, GET_TEXT_F(MSG_ZPROBE_XOFFSET));  // Probe X Offset
2606
-        Draw_Menu_LineF(2, ICON_ProbeOffY, GET_TEXT_F(MSG_ZPROBE_YOFFSET));  // Probe Y Offset
2603
+        Draw_Menu_LineF(1, ICON_ProbeOffsetX, GET_TEXT_F(MSG_ZPROBE_XOFFSET));  // Probe X Offset
2604
+        Draw_Menu_LineF(2, ICON_ProbeOffsetY, GET_TEXT_F(MSG_ZPROBE_YOFFSET));  // Probe Y Offset
2607
       #else
2605
       #else
2608
         say_probe_offs_en(1); say_x_en(75, 1);  // "Probe Offset X"
2606
         say_probe_offs_en(1); say_x_en(75, 1);  // "Probe Offset X"
2609
         say_probe_offs_en(2); say_y_en(75, 2);  // "Probe Offset Y"
2607
         say_probe_offs_en(2); say_y_en(75, 2);  // "Probe Offset Y"
2615
 
2613
 
2616
     if (select_item.now != CASE_BACK) Draw_Menu_Cursor(select_item.now);
2614
     if (select_item.now != CASE_BACK) Draw_Menu_Cursor(select_item.now);
2617
   }
2615
   }
2616
+
2618
 #endif
2617
 #endif
2619
 
2618
 
2620
 #include "../../../libs/buzzer.h"
2619
 #include "../../../libs/buzzer.h"
2633
 
2632
 
2634
 // Prepare
2633
 // Prepare
2635
 void HMI_Prepare() {
2634
 void HMI_Prepare() {
2636
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
2635
+  EncoderState encoder_diffState = get_encoder_state();
2637
   if (encoder_diffState == ENCODER_DIFF_NO) return;
2636
   if (encoder_diffState == ENCODER_DIFF_NO) return;
2638
 
2637
 
2639
   // Avoid flicker by updating only the previous menu
2638
   // Avoid flicker by updating only the previous menu
2847
 
2846
 
2848
 // Control
2847
 // Control
2849
 void HMI_Control() {
2848
 void HMI_Control() {
2850
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
2849
+  EncoderState encoder_diffState = get_encoder_state();
2851
   if (encoder_diffState == ENCODER_DIFF_NO) return;
2850
   if (encoder_diffState == ENCODER_DIFF_NO) return;
2852
 
2851
 
2853
   // Avoid flicker by updating only the previous menu
2852
   // Avoid flicker by updating only the previous menu
2932
   DWIN_UpdateLCD();
2931
   DWIN_UpdateLCD();
2933
 }
2932
 }
2934
 
2933
 
2935
-
2936
 #if HAS_ONESTEP_LEVELING
2934
 #if HAS_ONESTEP_LEVELING
2937
-
2938
   // Leveling
2935
   // Leveling
2939
   void HMI_Leveling() {
2936
   void HMI_Leveling() {
2940
     Popup_Window_Leveling();
2937
     Popup_Window_Leveling();
2941
     DWIN_UpdateLCD();
2938
     DWIN_UpdateLCD();
2942
     queue.inject_P(PSTR("G28O\nG29"));
2939
     queue.inject_P(PSTR("G28O\nG29"));
2943
   }
2940
   }
2944
-
2945
 #endif
2941
 #endif
2946
 
2942
 
2947
 // Axis Move
2943
 // Axis Move
2948
 void HMI_AxisMove() {
2944
 void HMI_AxisMove() {
2949
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
2945
+  EncoderState encoder_diffState = get_encoder_state();
2950
   if (encoder_diffState == ENCODER_DIFF_NO) return;
2946
   if (encoder_diffState == ENCODER_DIFF_NO) return;
2951
 
2947
 
2952
   #if ENABLED(PREVENT_COLD_EXTRUSION)
2948
   #if ENABLED(PREVENT_COLD_EXTRUSION)
2953
     // popup window resume
2949
     // popup window resume
2954
-    if (HMI_flag.ETempTooLow_flag) {
2950
+    if (HMI_flag.cold_flag) {
2955
       if (encoder_diffState == ENCODER_DIFF_ENTER) {
2951
       if (encoder_diffState == ENCODER_DIFF_ENTER) {
2956
-        HMI_flag.ETempTooLow_flag = false;
2952
+        HMI_flag.cold_flag = false;
2957
         HMI_ValueStruct.Move_E_scaled = current_position.e * MINUNITMULT;
2953
         HMI_ValueStruct.Move_E_scaled = current_position.e * MINUNITMULT;
2958
         Draw_Move_Menu();
2954
         Draw_Move_Menu();
2959
         Draw_Edit_Float3(1, HMI_ValueStruct.Move_X_scaled);
2955
         Draw_Edit_Float3(1, HMI_ValueStruct.Move_X_scaled);
3003
           case 4: // Extruder
2999
           case 4: // Extruder
3004
             #if ENABLED(PREVENT_COLD_EXTRUSION)
3000
             #if ENABLED(PREVENT_COLD_EXTRUSION)
3005
               if (thermalManager.tooColdToExtrude(0)) {
3001
               if (thermalManager.tooColdToExtrude(0)) {
3006
-                HMI_flag.ETempTooLow_flag = true;
3002
+                HMI_flag.cold_flag = true;
3007
                 Popup_Window_ETempTooLow();
3003
                 Popup_Window_ETempTooLow();
3008
                 DWIN_UpdateLCD();
3004
                 DWIN_UpdateLCD();
3009
                 return;
3005
                 return;
3022
 
3018
 
3023
 // TemperatureID
3019
 // TemperatureID
3024
 void HMI_Temperature() {
3020
 void HMI_Temperature() {
3025
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
3021
+  EncoderState encoder_diffState = get_encoder_state();
3026
   if (encoder_diffState == ENCODER_DIFF_NO) return;
3022
   if (encoder_diffState == ENCODER_DIFF_NO) return;
3027
 
3023
 
3028
   // Avoid flicker by updating only the previous menu
3024
   // Avoid flicker by updating only the previous menu
3449
 
3445
 
3450
 // Motion
3446
 // Motion
3451
 void HMI_Motion() {
3447
 void HMI_Motion() {
3452
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
3448
+  EncoderState encoder_diffState = get_encoder_state();
3453
   if (encoder_diffState == ENCODER_DIFF_NO) return;
3449
   if (encoder_diffState == ENCODER_DIFF_NO) return;
3454
 
3450
 
3455
   // Avoid flicker by updating only the previous menu
3451
   // Avoid flicker by updating only the previous menu
3497
 
3493
 
3498
 // Advanced Settings
3494
 // Advanced Settings
3499
 void HMI_AdvSet() {
3495
 void HMI_AdvSet() {
3500
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
3496
+  EncoderState encoder_diffState = get_encoder_state();
3501
   if (encoder_diffState == ENCODER_DIFF_NO) return;
3497
   if (encoder_diffState == ENCODER_DIFF_NO) return;
3502
 
3498
 
3503
   // Avoid flicker by updating only the previous menu
3499
   // Avoid flicker by updating only the previous menu
3594
 
3590
 
3595
   // Home Offset
3591
   // Home Offset
3596
   void HMI_HomeOff() {
3592
   void HMI_HomeOff() {
3597
-    ENCODER_DiffState encoder_diffState = get_encoder_state();
3593
+    EncoderState encoder_diffState = get_encoder_state();
3598
     if (encoder_diffState == ENCODER_DIFF_NO) return;
3594
     if (encoder_diffState == ENCODER_DIFF_NO) return;
3599
 
3595
 
3600
     // Avoid flicker by updating only the previous menu
3596
     // Avoid flicker by updating only the previous menu
3633
   }
3629
   }
3634
 
3630
 
3635
   void HMI_HomeOffN(const AxisEnum axis, float &posScaled, const_float_t lo, const_float_t hi) {
3631
   void HMI_HomeOffN(const AxisEnum axis, float &posScaled, const_float_t lo, const_float_t hi) {
3636
-    ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
3632
+    EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
3637
     if (encoder_diffState == ENCODER_DIFF_NO) return;
3633
     if (encoder_diffState == ENCODER_DIFF_NO) return;
3638
 
3634
 
3639
     if (Apply_Encoder(encoder_diffState, posScaled)) {
3635
     if (Apply_Encoder(encoder_diffState, posScaled)) {
3654
 #endif // HAS_HOME_OFFSET
3650
 #endif // HAS_HOME_OFFSET
3655
 
3651
 
3656
 #if HAS_ONESTEP_LEVELING
3652
 #if HAS_ONESTEP_LEVELING
3653
+
3657
   // Probe Offset
3654
   // Probe Offset
3658
   void HMI_ProbeOff() {
3655
   void HMI_ProbeOff() {
3659
-    ENCODER_DiffState encoder_diffState = get_encoder_state();
3656
+    EncoderState encoder_diffState = get_encoder_state();
3660
     if (encoder_diffState == ENCODER_DIFF_NO) return;
3657
     if (encoder_diffState == ENCODER_DIFF_NO) return;
3661
 
3658
 
3662
     // Avoid flicker by updating only the previous menu
3659
     // Avoid flicker by updating only the previous menu
3689
   }
3686
   }
3690
 
3687
 
3691
   void HMI_ProbeOffN(float &posScaled, float &offset_ref) {
3688
   void HMI_ProbeOffN(float &posScaled, float &offset_ref) {
3692
-    ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
3689
+    EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
3693
     if (encoder_diffState == ENCODER_DIFF_NO) return;
3690
     if (encoder_diffState == ENCODER_DIFF_NO) return;
3694
 
3691
 
3695
     if (Apply_Encoder(encoder_diffState, posScaled)) {
3692
     if (Apply_Encoder(encoder_diffState, posScaled)) {
3710
 
3707
 
3711
 // Info
3708
 // Info
3712
 void HMI_Info() {
3709
 void HMI_Info() {
3713
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
3710
+  EncoderState encoder_diffState = get_encoder_state();
3714
   if (encoder_diffState == ENCODER_DIFF_NO) return;
3711
   if (encoder_diffState == ENCODER_DIFF_NO) return;
3715
   if (encoder_diffState == ENCODER_DIFF_ENTER) {
3712
   if (encoder_diffState == ENCODER_DIFF_ENTER) {
3716
     #if HAS_ONESTEP_LEVELING
3713
     #if HAS_ONESTEP_LEVELING
3727
 
3724
 
3728
 // Tune
3725
 // Tune
3729
 void HMI_Tune() {
3726
 void HMI_Tune() {
3730
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
3727
+  EncoderState encoder_diffState = get_encoder_state();
3731
   if (encoder_diffState == ENCODER_DIFF_NO) return;
3728
   if (encoder_diffState == ENCODER_DIFF_NO) return;
3732
 
3729
 
3733
   // Avoid flicker by updating only the previous menu
3730
   // Avoid flicker by updating only the previous menu
3813
 
3810
 
3814
   // PLA Preheat
3811
   // PLA Preheat
3815
   void HMI_PLAPreheatSetting() {
3812
   void HMI_PLAPreheatSetting() {
3816
-    ENCODER_DiffState encoder_diffState = get_encoder_state();
3813
+    EncoderState encoder_diffState = get_encoder_state();
3817
     if (encoder_diffState == ENCODER_DIFF_NO) return;
3814
     if (encoder_diffState == ENCODER_DIFF_NO) return;
3818
 
3815
 
3819
     // Avoid flicker by updating only the previous menu
3816
     // Avoid flicker by updating only the previous menu
3869
 
3866
 
3870
   // ABS Preheat
3867
   // ABS Preheat
3871
   void HMI_ABSPreheatSetting() {
3868
   void HMI_ABSPreheatSetting() {
3872
-    ENCODER_DiffState encoder_diffState = get_encoder_state();
3869
+    EncoderState encoder_diffState = get_encoder_state();
3873
     if (encoder_diffState == ENCODER_DIFF_NO) return;
3870
     if (encoder_diffState == ENCODER_DIFF_NO) return;
3874
 
3871
 
3875
     // Avoid flicker by updating only the previous menu
3872
     // Avoid flicker by updating only the previous menu
3927
 
3924
 
3928
 // Max Speed
3925
 // Max Speed
3929
 void HMI_MaxSpeed() {
3926
 void HMI_MaxSpeed() {
3930
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
3927
+  EncoderState encoder_diffState = get_encoder_state();
3931
   if (encoder_diffState == ENCODER_DIFF_NO) return;
3928
   if (encoder_diffState == ENCODER_DIFF_NO) return;
3932
 
3929
 
3933
   // Avoid flicker by updating only the previous menu
3930
   // Avoid flicker by updating only the previous menu
3956
 
3953
 
3957
 // Max Acceleration
3954
 // Max Acceleration
3958
 void HMI_MaxAcceleration() {
3955
 void HMI_MaxAcceleration() {
3959
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
3956
+  EncoderState encoder_diffState = get_encoder_state();
3960
   if (encoder_diffState == ENCODER_DIFF_NO) return;
3957
   if (encoder_diffState == ENCODER_DIFF_NO) return;
3961
 
3958
 
3962
   // Avoid flicker by updating only the previous menu
3959
   // Avoid flicker by updating only the previous menu
3986
 #if HAS_CLASSIC_JERK
3983
 #if HAS_CLASSIC_JERK
3987
   // Max Jerk
3984
   // Max Jerk
3988
   void HMI_MaxJerk() {
3985
   void HMI_MaxJerk() {
3989
-    ENCODER_DiffState encoder_diffState = get_encoder_state();
3986
+    EncoderState encoder_diffState = get_encoder_state();
3990
     if (encoder_diffState == ENCODER_DIFF_NO) return;
3987
     if (encoder_diffState == ENCODER_DIFF_NO) return;
3991
 
3988
 
3992
     // Avoid flicker by updating only the previous menu
3989
     // Avoid flicker by updating only the previous menu
4016
 
4013
 
4017
 // Step
4014
 // Step
4018
 void HMI_Step() {
4015
 void HMI_Step() {
4019
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
4016
+  EncoderState encoder_diffState = get_encoder_state();
4020
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4017
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4021
 
4018
 
4022
   // Avoid flicker by updating only the previous menu
4019
   // Avoid flicker by updating only the previous menu
4172
       DWIN_UpdateLCD();
4169
       DWIN_UpdateLCD();
4173
 
4170
 
4174
       while (recovery_flag) {
4171
       while (recovery_flag) {
4175
-        ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
4172
+        EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
4176
         if (encoder_diffState != ENCODER_DIFF_NO) {
4173
         if (encoder_diffState != ENCODER_DIFF_NO) {
4177
           if (encoder_diffState == ENCODER_DIFF_ENTER) {
4174
           if (encoder_diffState == ENCODER_DIFF_ENTER) {
4178
             recovery_flag = false;
4175
             recovery_flag = false;

+ 10
- 13
Marlin/src/lcd/e3v2/creality/dwin.h 查看文件

26
  */
26
  */
27
 
27
 
28
 #include "dwin_lcd.h"
28
 #include "dwin_lcd.h"
29
-#include "rotary_encoder.h"
29
+#include "../common/encoder.h"
30
 #include "../../../libs/BL24CXX.h"
30
 #include "../../../libs/BL24CXX.h"
31
 
31
 
32
 #include "../../../inc/MarlinConfigPre.h"
32
 #include "../../../inc/MarlinConfigPre.h"
144
 
144
 
145
 typedef struct {
145
 typedef struct {
146
   uint8_t language;
146
   uint8_t language;
147
-  bool pause_flag:1;
148
-  bool pause_action:1;
149
-  bool print_finish:1;
147
+  bool pause_flag:1;    // printing is paused
148
+  bool pause_action:1;  // flag a pause action
149
+  bool print_finish:1;  // print was finished
150
+  bool select_flag:1;   // Popup button selected
151
+  bool home_flag:1;     // homing in course
152
+  bool heat_flag:1;     // 0: heating done  1: during heating
150
   bool done_confirm_flag:1;
153
   bool done_confirm_flag:1;
151
-  bool select_flag:1;
152
-  bool home_flag:1;
153
-  bool heat_flag:1;  // 0: heating done  1: during heating
154
   #if ENABLED(PREVENT_COLD_EXTRUSION)
154
   #if ENABLED(PREVENT_COLD_EXTRUSION)
155
-    bool ETempTooLow_flag:1;
156
-  #endif
157
-  #if HAS_LEVELING
158
-    bool leveling_offset_flag:1;
155
+    bool cold_flag:1;
159
   #endif
156
   #endif
160
   AxisEnum feedspeed_axis, acc_axis, jerk_axis, step_axis;
157
   AxisEnum feedspeed_axis, acc_axis, jerk_axis, step_axis;
161
-} HMI_Flag_t;
158
+} HMI_flag_t;
162
 
159
 
163
 extern HMI_value_t HMI_ValueStruct;
160
 extern HMI_value_t HMI_ValueStruct;
164
-extern HMI_Flag_t HMI_flag;
161
+extern HMI_flag_t HMI_flag;
165
 
162
 
166
 #if HAS_HOTEND || HAS_HEATED_BED
163
 #if HAS_HOTEND || HAS_HEATED_BED
167
   // Popup message window
164
   // Popup message window

+ 3
- 395
Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp 查看文件

35
 #include "../../../inc/MarlinConfig.h"
35
 #include "../../../inc/MarlinConfig.h"
36
 
36
 
37
 #include "dwin_lcd.h"
37
 #include "dwin_lcd.h"
38
-#include <string.h> // for memset
39
 
38
 
40
 //#define DEBUG_OUT 1
39
 //#define DEBUG_OUT 1
41
 #include "../../../core/debug_out.h"
40
 #include "../../../core/debug_out.h"
42
 
41
 
43
-// Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail.
44
-// Assume the narrowest (6 pixel) font and 2-byte gb2312-encoded characters.
45
-uint8_t DWIN_SendBuf[11 + DWIN_WIDTH / 6 * 2] = { 0xAA };
46
-uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C };
47
-uint8_t databuf[26] = { 0 };
48
-uint8_t receivedType;
49
-
50
-int recnum = 0;
51
-
52
-inline void DWIN_Byte(size_t &i, const uint16_t bval) {
53
-  DWIN_SendBuf[++i] = bval;
54
-}
55
-
56
-inline void DWIN_Word(size_t &i, const uint16_t wval) {
57
-  DWIN_SendBuf[++i] = wval >> 8;
58
-  DWIN_SendBuf[++i] = wval & 0xFF;
59
-}
60
-
61
-inline void DWIN_Long(size_t &i, const uint32_t lval) {
62
-  DWIN_SendBuf[++i] = (lval >> 24) & 0xFF;
63
-  DWIN_SendBuf[++i] = (lval >> 16) & 0xFF;
64
-  DWIN_SendBuf[++i] = (lval >>  8) & 0xFF;
65
-  DWIN_SendBuf[++i] = lval & 0xFF;
66
-}
67
-
68
-inline void DWIN_String(size_t &i, char * const string) {
69
-  const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, strlen(string));
70
-  memcpy(&DWIN_SendBuf[i+1], string, len);
71
-  i += len;
72
-}
73
-
74
-inline void DWIN_String(size_t &i, const __FlashStringHelper * string) {
75
-  if (!string) return;
76
-  const size_t len = strlen_P((PGM_P)string); // cast it to PGM_P, which is basically const char *, and measure it using the _P version of strlen.
77
-  if (len == 0) return;
78
-  memcpy(&DWIN_SendBuf[i+1], string, len);
79
-  i += len;
80
-}
81
-
82
-// Send the data in the buffer and the packet end
83
-inline void DWIN_Send(size_t &i) {
84
-  ++i;
85
-  LOOP_L_N(n, i) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
86
-  LOOP_L_N(n, 4) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); }
87
-}
88
-
89
 /*-------------------------------------- System variable function --------------------------------------*/
42
 /*-------------------------------------- System variable function --------------------------------------*/
90
 
43
 
91
-// Handshake (1: Success, 0: Fail)
92
-bool DWIN_Handshake(void) {
93
-  #ifndef LCD_BAUDRATE
94
-    #define LCD_BAUDRATE 115200
95
-  #endif
96
-  LCD_SERIAL.begin(LCD_BAUDRATE);
97
-  const millis_t serial_connect_timeout = millis() + 1000UL;
98
-  while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
99
-
100
-  size_t i = 0;
101
-  DWIN_Byte(i, 0x00);
102
-  DWIN_Send(i);
103
-
104
-  while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) {
105
-    databuf[recnum] = LCD_SERIAL.read();
106
-    // ignore the invalid data
107
-    if (databuf[0] != FHONE) { // prevent the program from running.
108
-      if (recnum > 0) {
109
-        recnum = 0;
110
-        ZERO(databuf);
111
-      }
112
-      continue;
113
-    }
114
-    delay(10);
115
-    recnum++;
116
-  }
117
-
118
-  return ( recnum >= 3
119
-        && databuf[0] == FHONE
120
-        && databuf[1] == '\0'
121
-        && databuf[2] == 'O'
122
-        && databuf[3] == 'K' );
123
-}
124
-
125
-void DWIN_Startup(void) {
44
+void DWIN_Startup() {
126
   DEBUG_ECHOPGM("\r\nDWIN handshake ");
45
   DEBUG_ECHOPGM("\r\nDWIN handshake ");
127
   delay(750);   // Delay here or init later in the boot process
46
   delay(750);   // Delay here or init later in the boot process
128
   if (DWIN_Handshake()) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error.");
47
   if (DWIN_Handshake()) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error.");
133
   DWIN_UpdateLCD();
52
   DWIN_UpdateLCD();
134
 }
53
 }
135
 
54
 
136
-// Set the backlight luminance
137
-//  luminance: (0x00-0xFF)
138
-void DWIN_Backlight_SetLuminance(const uint8_t luminance) {
139
-  size_t i = 0;
140
-  DWIN_Byte(i, 0x30);
141
-  DWIN_Byte(i, _MAX(luminance, 0x1F));
142
-  DWIN_Send(i);
143
-}
144
-
145
-// Set screen display direction
146
-//  dir: 0=0°, 1=90°, 2=180°, 3=270°
147
-void DWIN_Frame_SetDir(uint8_t dir) {
148
-  size_t i = 0;
149
-  DWIN_Byte(i, 0x34);
150
-  DWIN_Byte(i, 0x5A);
151
-  DWIN_Byte(i, 0xA5);
152
-  DWIN_Byte(i, dir);
153
-  DWIN_Send(i);
154
-}
155
-
156
-// Update display
157
-void DWIN_UpdateLCD(void) {
158
-  size_t i = 0;
159
-  DWIN_Byte(i, 0x3D);
160
-  DWIN_Send(i);
161
-}
162
-
163
-/*---------------------------------------- Drawing functions ----------------------------------------*/
164
-
165
-// Clear screen
166
-//  color: Clear screen color
167
-void DWIN_Frame_Clear(const uint16_t color) {
168
-  size_t i = 0;
169
-  DWIN_Byte(i, 0x01);
170
-  DWIN_Word(i, color);
171
-  DWIN_Send(i);
172
-}
173
-
174
-// Draw a point
175
-//  width: point width   0x01-0x0F
176
-//  height: point height 0x01-0x0F
177
-//  x,y: upper left point
178
-void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y) {
179
-  size_t i = 0;
180
-  DWIN_Byte(i, 0x02);
181
-  DWIN_Word(i, color);
182
-  DWIN_Byte(i, width);
183
-  DWIN_Byte(i, height);
184
-  DWIN_Word(i, x);
185
-  DWIN_Word(i, y);
186
-  DWIN_Send(i);
187
-}
188
-
189
-// Draw a line
190
-//  color: Line segment color
191
-//  xStart/yStart: Start point
192
-//  xEnd/yEnd: End point
193
-void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
194
-  size_t i = 0;
195
-  DWIN_Byte(i, 0x03);
196
-  DWIN_Word(i, color);
197
-  DWIN_Word(i, xStart);
198
-  DWIN_Word(i, yStart);
199
-  DWIN_Word(i, xEnd);
200
-  DWIN_Word(i, yEnd);
201
-  DWIN_Send(i);
202
-}
203
-
204
-// Draw a rectangle
205
-//  mode: 0=frame, 1=fill, 2=XOR fill
206
-//  color: Rectangle color
207
-//  xStart/yStart: upper left point
208
-//  xEnd/yEnd: lower right point
209
-void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
210
-                         uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
211
-  size_t i = 0;
212
-  DWIN_Byte(i, 0x05);
213
-  DWIN_Byte(i, mode);
214
-  DWIN_Word(i, color);
215
-  DWIN_Word(i, xStart);
216
-  DWIN_Word(i, yStart);
217
-  DWIN_Word(i, xEnd);
218
-  DWIN_Word(i, yEnd);
219
-  DWIN_Send(i);
220
-}
221
-
222
-// Move a screen area
223
-//  mode: 0, circle shift; 1, translation
224
-//  dir: 0=left, 1=right, 2=up, 3=down
225
-//  dis: Distance
226
-//  color: Fill color
227
-//  xStart/yStart: upper left point
228
-//  xEnd/yEnd: bottom right point
229
-void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
230
-                         uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
231
-  size_t i = 0;
232
-  DWIN_Byte(i, 0x09);
233
-  DWIN_Byte(i, (mode << 7) | dir);
234
-  DWIN_Word(i, dis);
235
-  DWIN_Word(i, color);
236
-  DWIN_Word(i, xStart);
237
-  DWIN_Word(i, yStart);
238
-  DWIN_Word(i, xEnd);
239
-  DWIN_Word(i, yEnd);
240
-  DWIN_Send(i);
241
-}
242
-
243
-/*---------------------------------------- Text related functions ----------------------------------------*/
244
-
245
-// Draw a string
246
-//  widthAdjust: true=self-adjust character width; false=no adjustment
247
-//  bShow: true=display background color; false=don't display background color
248
-//  size: Font size
249
-//  color: Character color
250
-//  bColor: Background color
251
-//  x/y: Upper-left coordinate of the string
252
-//  *string: The string
253
-void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string) {
254
-  uint8_t widthAdjust = 0;
255
-  size_t i = 0;
256
-  DWIN_Byte(i, 0x11);
257
-  // Bit 7: widthAdjust
258
-  // Bit 6: bShow
259
-  // Bit 5-4: Unused (0)
260
-  // Bit 3-0: size
261
-  DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size);
262
-  DWIN_Word(i, color);
263
-  DWIN_Word(i, bColor);
264
-  DWIN_Word(i, x);
265
-  DWIN_Word(i, y);
266
-  DWIN_String(i, string);
267
-  DWIN_Send(i);
268
-}
269
-
270
-// Draw a positive integer
271
-//  bShow: true=display background color; false=don't display background color
272
-//  zeroFill: true=zero fill; false=no zero fill
273
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
274
-//  size: Font size
275
-//  color: Character color
276
-//  bColor: Background color
277
-//  iNum: Number of digits
278
-//  x/y: Upper-left coordinate
279
-//  value: Integer value
280
-void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
281
-                          uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value) {
282
-  size_t i = 0;
283
-  DWIN_Byte(i, 0x14);
284
-  // Bit 7: bshow
285
-  // Bit 6: 1 = signed; 0 = unsigned number;
286
-  // Bit 5: zeroFill
287
-  // Bit 4: zeroMode
288
-  // Bit 3-0: size
289
-  DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
290
-  DWIN_Word(i, color);
291
-  DWIN_Word(i, bColor);
292
-  DWIN_Byte(i, iNum);
293
-  DWIN_Byte(i, 0); // fNum
294
-  DWIN_Word(i, x);
295
-  DWIN_Word(i, y);
296
-  #if 0
297
-    for (char count = 0; count < 8; count++) {
298
-      DWIN_Byte(i, value);
299
-      value >>= 8;
300
-      if (!(value & 0xFF)) break;
301
-    }
302
-  #else
303
-    // Write a big-endian 64 bit integer
304
-    const size_t p = i + 1;
305
-    for (char count = 8; count--;) { // 7..0
306
-      ++i;
307
-      DWIN_SendBuf[p + count] = value;
308
-      value >>= 8;
309
-    }
310
-  #endif
311
-
312
-  DWIN_Send(i);
313
-}
314
-
315
-// Draw a floating point number
316
-//  bShow: true=display background color; false=don't display background color
317
-//  zeroFill: true=zero fill; false=no zero fill
318
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
319
-//  size: Font size
320
-//  color: Character color
321
-//  bColor: Background color
322
-//  iNum: Number of whole digits
323
-//  fNum: Number of decimal digits
324
-//  x/y: Upper-left point
325
-//  value: Float value
326
-void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
327
-                            uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
328
-  //uint8_t *fvalue = (uint8_t*)&value;
329
-  size_t i = 0;
330
-  DWIN_Byte(i, 0x14);
331
-  DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
332
-  DWIN_Word(i, color);
333
-  DWIN_Word(i, bColor);
334
-  DWIN_Byte(i, iNum);
335
-  DWIN_Byte(i, fNum);
336
-  DWIN_Word(i, x);
337
-  DWIN_Word(i, y);
338
-  DWIN_Long(i, value);
339
-  /*
340
-  DWIN_Byte(i, fvalue[3]);
341
-  DWIN_Byte(i, fvalue[2]);
342
-  DWIN_Byte(i, fvalue[1]);
343
-  DWIN_Byte(i, fvalue[0]);
344
-  */
345
-  DWIN_Send(i);
346
-}
347
-
348
 /*---------------------------------------- Picture related functions ----------------------------------------*/
55
 /*---------------------------------------- Picture related functions ----------------------------------------*/
349
 
56
 
350
-// Draw JPG and cached in #0 virtual display area
351
-// id: Picture ID
352
-void DWIN_JPG_ShowAndCache(const uint8_t id) {
353
-  size_t i = 0;
354
-  DWIN_Word(i, 0x2200);
355
-  DWIN_Byte(i, id);
356
-  DWIN_Send(i);     // AA 23 00 00 00 00 08 00 01 02 03 CC 33 C3 3C
357
-}
358
-
359
 // Draw an Icon
57
 // Draw an Icon
360
 //  libID: Icon library ID
58
 //  libID: Icon library ID
361
 //  picID: Icon ID
59
 //  picID: Icon ID
362
 //  x/y: Upper-left point
60
 //  x/y: Upper-left point
363
 void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
61
 void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
364
-  NOMORE(x, DWIN_WIDTH - 1);
365
-  NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
366
-  size_t i = 0;
367
-  DWIN_Byte(i, 0x23);
368
-  DWIN_Word(i, x);
369
-  DWIN_Word(i, y);
370
-  DWIN_Byte(i, 0x80 | libID);
371
-  //DWIN_Byte(i, libID);
372
-  DWIN_Byte(i, picID);
373
-  DWIN_Send(i);
374
-}
375
-
376
-// Unzip the JPG picture to a virtual display area
377
-//  n: Cache index
378
-//  id: Picture ID
379
-void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
380
-  size_t i = 0;
381
-  DWIN_Byte(i, 0x25);
382
-  DWIN_Byte(i, n);
383
-  DWIN_Byte(i, id);
384
-  DWIN_Send(i);
62
+  DWIN_ICON_Show(true, false, false, libID, picID, x, y);
385
 }
63
 }
386
 
64
 
387
 // Copy area from virtual display area to current screen
65
 // Copy area from virtual display area to current screen
389
 //  xStart/yStart: Upper-left of virtual area
67
 //  xStart/yStart: Upper-left of virtual area
390
 //  xEnd/yEnd: Lower-right of virtual area
68
 //  xEnd/yEnd: Lower-right of virtual area
391
 //  x/y: Screen paste point
69
 //  x/y: Screen paste point
392
-void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
393
-                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
70
+void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
394
   size_t i = 0;
71
   size_t i = 0;
395
   DWIN_Byte(i, 0x27);
72
   DWIN_Byte(i, 0x27);
396
   DWIN_Byte(i, 0x80 | cacheID);
73
   DWIN_Byte(i, 0x80 | cacheID);
403
   DWIN_Send(i);
80
   DWIN_Send(i);
404
 }
81
 }
405
 
82
 
406
-// Animate a series of icons
407
-//  animID: Animation ID; 0x00-0x0F
408
-//  animate: true on; false off;
409
-//  libID: Icon library ID
410
-//  picIDs: Icon starting ID
411
-//  picIDe: Icon ending ID
412
-//  x/y: Upper-left point
413
-//  interval: Display time interval, unit 10mS
414
-void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval) {
415
-  NOMORE(x, DWIN_WIDTH - 1);
416
-  NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
417
-  size_t i = 0;
418
-  DWIN_Byte(i, 0x28);
419
-  DWIN_Word(i, x);
420
-  DWIN_Word(i, y);
421
-  // Bit 7: animation on or off
422
-  // Bit 6: start from begin or end
423
-  // Bit 5-4: unused (0)
424
-  // Bit 3-0: animID
425
-  DWIN_Byte(i, (animate * 0x80) | 0x40 | animID);
426
-  DWIN_Byte(i, libID);
427
-  DWIN_Byte(i, picIDs);
428
-  DWIN_Byte(i, picIDe);
429
-  DWIN_Byte(i, interval);
430
-  DWIN_Send(i);
431
-}
432
-
433
-// Animation Control
434
-//  state: 16 bits, each bit is the state of an animation id
435
-void DWIN_ICON_AnimationControl(uint16_t state) {
436
-  size_t i = 0;
437
-  DWIN_Byte(i, 0x29);
438
-  DWIN_Word(i, state);
439
-  DWIN_Send(i);
440
-}
441
-
442
-/*---------------------------------------- Memory functions ----------------------------------------*/
443
-// The LCD has an additional 32KB SRAM and 16KB Flash
444
-
445
-// Data can be written to the sram and save to one of the jpeg page files
446
-
447
-// Write Data Memory
448
-//  command 0x31
449
-//  Type: Write memory selection; 0x5A=SRAM; 0xA5=Flash
450
-//  Address: Write data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
451
-//  Data: data
452
-//
453
-//  Flash writing returns 0xA5 0x4F 0x4B
454
-
455
-// Read Data Memory
456
-//  command 0x32
457
-//  Type: Read memory selection; 0x5A=SRAM; 0xA5=Flash
458
-//  Address: Read data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
459
-//  Length: leangth of data to read; 0x01-0xF0
460
-//
461
-//  Response:
462
-//    Type, Address, Length, Data
463
-
464
-// Write Picture Memory
465
-//  Write the contents of the 32KB SRAM data memory into the designated image memory space
466
-//  Issued: 0x5A, 0xA5, PIC_ID
467
-//  Response: 0xA5 0x4F 0x4B
468
-//
469
-//  command 0x33
470
-//  0x5A, 0xA5
471
-//  PicId: Picture Memory location, 0x00-0x0F
472
-//
473
-//  Flash writing returns 0xA5 0x4F 0x4B
474
-
475
 #endif // DWIN_CREALITY_LCD
83
 #endif // DWIN_CREALITY_LCD

+ 5
- 318
Marlin/src/lcd/e3v2/creality/dwin_lcd.h 查看文件

29
  * @brief    迪文屏控制操作函数
29
  * @brief    迪文屏控制操作函数
30
  ********************************************************************************/
30
  ********************************************************************************/
31
 
31
 
32
-#include <stdint.h>
33
-
34
-#define RECEIVED_NO_DATA         0x00
35
-#define RECEIVED_SHAKE_HAND_ACK  0x01
36
-
37
-#define FHONE                    0xAA
38
-
39
-#define DWIN_SCROLL_UP   2
40
-#define DWIN_SCROLL_DOWN 3
41
-
42
 #define DWIN_WIDTH  272
32
 #define DWIN_WIDTH  272
43
 #define DWIN_HEIGHT 480
33
 #define DWIN_HEIGHT 480
44
 
34
 
45
-// Picture ID
46
-#define Language_English    1
47
-#define Language_Chinese    2
48
-
49
-// ICON ID
50
-#define ICON                7 // Icon set file 7.ICO
51
-
52
-#define ICON_LOGO                  0
53
-#define ICON_Print_0               1
54
-#define ICON_Print_1               2
55
-#define ICON_Prepare_0             3
56
-#define ICON_Prepare_1             4
57
-#define ICON_Control_0             5
58
-#define ICON_Control_1             6
59
-#define ICON_Leveling_0            7
60
-#define ICON_Leveling_1            8
61
-#define ICON_HotendTemp            9
62
-#define ICON_BedTemp              10
63
-#define ICON_Speed                11
64
-#define ICON_Zoffset              12
65
-#define ICON_Back                 13
66
-#define ICON_File                 14
67
-#define ICON_PrintTime            15
68
-#define ICON_RemainTime           16
69
-#define ICON_Setup_0              17
70
-#define ICON_Setup_1              18
71
-#define ICON_Pause_0              19
72
-#define ICON_Pause_1              20
73
-#define ICON_Continue_0           21
74
-#define ICON_Continue_1           22
75
-#define ICON_Stop_0               23
76
-#define ICON_Stop_1               24
77
-#define ICON_Bar                  25
78
-#define ICON_More                 26
79
-
80
-#define ICON_Axis                 27
81
-#define ICON_CloseMotor           28
82
-#define ICON_Homing               29
83
-#define ICON_SetHome              30
84
-#define ICON_PLAPreheat           31
85
-#define ICON_ABSPreheat           32
86
-#define ICON_Cool                 33
87
-#define ICON_Language             34
88
-
89
-#define ICON_MoveX                35
90
-#define ICON_MoveY                36
91
-#define ICON_MoveZ                37
92
-#define ICON_Extruder             38
93
-
94
-#define ICON_Temperature          40
95
-#define ICON_Motion               41
96
-#define ICON_WriteEEPROM          42
97
-#define ICON_ReadEEPROM           43
98
-#define ICON_ResumeEEPROM         44
99
-#define ICON_Info                 45
100
-
101
-#define ICON_SetEndTemp           46
102
-#define ICON_SetBedTemp           47
103
-#define ICON_FanSpeed             48
104
-#define ICON_SetPLAPreheat        49
105
-#define ICON_SetABSPreheat        50
106
-
107
-#define ICON_MaxSpeed             51
108
-#define ICON_MaxAccelerated       52
109
-#define ICON_MaxJerk              53
110
-#define ICON_Step                 54
111
-#define ICON_PrintSize            55
112
-#define ICON_Version              56
113
-#define ICON_Contact              57
114
-#define ICON_StockConfiguraton    58
115
-#define ICON_MaxSpeedX            59
116
-#define ICON_MaxSpeedY            60
117
-#define ICON_MaxSpeedZ            61
118
-#define ICON_MaxSpeedE            62
119
-#define ICON_MaxAccX              63
120
-#define ICON_MaxAccY              64
121
-#define ICON_MaxAccZ              65
122
-#define ICON_MaxAccE              66
123
-#define ICON_MaxSpeedJerkX        67
124
-#define ICON_MaxSpeedJerkY        68
125
-#define ICON_MaxSpeedJerkZ        69
126
-#define ICON_MaxSpeedJerkE        70
127
-#define ICON_StepX                71
128
-#define ICON_StepY                72
129
-#define ICON_StepZ                73
130
-#define ICON_StepE                74
131
-#define ICON_Setspeed             75
132
-#define ICON_SetZOffset           76
133
-#define ICON_Rectangle            77
134
-#define ICON_BLTouch              78
135
-#define ICON_TempTooLow           79
136
-#define ICON_AutoLeveling         80
137
-#define ICON_TempTooHigh          81
138
-#define ICON_NoTips_C             82
139
-#define ICON_NoTips_E             83
140
-#define ICON_Continue_C           84
141
-#define ICON_Continue_E           85
142
-#define ICON_Cancel_C             86
143
-#define ICON_Cancel_E             87
144
-#define ICON_Confirm_C            88
145
-#define ICON_Confirm_E            89
146
-#define ICON_Info_0               90
147
-#define ICON_Info_1               91
148
-
149
-#define ICON_AdvSet               ICON_Language
150
-#define ICON_HomeOff              ICON_AdvSet
151
-#define ICON_HomeOffX             ICON_StepX
152
-#define ICON_HomeOffY             ICON_StepY
153
-#define ICON_HomeOffZ             ICON_StepZ
154
-#define ICON_ProbeOff             ICON_AdvSet
155
-#define ICON_ProbeOffX            ICON_StepX
156
-#define ICON_ProbeOffY            ICON_StepY
157
-#define ICON_PIDNozzle            ICON_SetEndTemp
158
-#define ICON_PIDbed               ICON_SetBedTemp
159
-
160
-/**
161
- * 3-.0:The font size, 0x00-0x09, corresponds to the font size below:
162
- * 0x00=6*12   0x01=8*16   0x02=10*20  0x03=12*24  0x04=14*28
163
- * 0x05=16*32  0x06=20*40  0x07=24*48  0x08=28*56  0x09=32*64
164
- */
165
-#define font6x12  0x00
166
-#define font8x16  0x01
167
-#define font10x20 0x02
168
-#define font12x24 0x03
169
-#define font14x28 0x04
170
-#define font16x32 0x05
171
-#define font20x40 0x06
172
-#define font24x48 0x07
173
-#define font28x56 0x08
174
-#define font32x64 0x09
35
+#include "../common/dwin_api.h"
36
+#include "../common/dwin_set.h"
37
+#include "../common/dwin_font.h"
38
+#include "../common/dwin_color.h"
175
 
39
 
176
 #define DWIN_FONT_MENU  font10x20
40
 #define DWIN_FONT_MENU  font10x20
177
 #define DWIN_FONT_STAT  font10x20
41
 #define DWIN_FONT_STAT  font10x20
178
 #define DWIN_FONT_HEAD  font10x20
42
 #define DWIN_FONT_HEAD  font10x20
179
 #define DWIN_FONT_ALERT font14x28
43
 #define DWIN_FONT_ALERT font14x28
180
 
44
 
181
-// Color
182
-#define Color_White       0xFFFF
183
-#define Color_Yellow      0xFF0F
184
-#define Color_Error_Red   0xB000  // Error!
185
-#define Color_Bg_Red      0xF00F  // Red background color
186
-#define Color_Bg_Window   0x31E8  // Popup background color
187
-#define Color_Bg_Blue     0x1125  // Dark blue background color
188
-#define Color_Bg_Black    0x0841  // Black background color
189
-#define Color_IconBlue    0x45FA  // Lighter blue that matches icons/accents
190
-#define Popup_Text_Color  0xD6BA  // Popup font background color
191
-#define Line_Color        0x3A6A  // Split line color
192
-#define Rectangle_Color   0xEE2F  // Blue square cursor color
193
-#define Percent_Color     0xFE29  // Percentage color
194
-#define BarFill_Color     0x10E4  // Fill color of progress bar
195
-#define Select_Color      0x33BB  // Selected color
196
-
197
-/*-------------------------------------- System variable function --------------------------------------*/
198
-
199
-// Handshake (1: Success, 0: Fail)
200
-bool DWIN_Handshake(void);
201
-
202
-// Common DWIN startup
203
-void DWIN_Startup(void);
204
-
205
-// Set the backlight luminance
206
-//  luminance: (0x00-0xFF)
207
-void DWIN_Backlight_SetLuminance(const uint8_t luminance);
208
-
209
-// Set screen display direction
210
-//  dir: 0=0°, 1=90°, 2=180°, 3=270°
211
-void DWIN_Frame_SetDir(uint8_t dir);
212
-
213
-// Update display
214
-void DWIN_UpdateLCD(void);
215
-
216
-/*---------------------------------------- Drawing functions ----------------------------------------*/
217
-
218
-// Clear screen
219
-//  color: Clear screen color
220
-void DWIN_Frame_Clear(const uint16_t color);
221
-
222
-// Draw a point
223
-//  color: point color
224
-//  width: point width   0x01-0x0F
225
-//  height: point height 0x01-0x0F
226
-//  x,y: upper left point
227
-void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y);
228
-
229
-// Draw a line
230
-//  color: Line segment color
231
-//  xStart/yStart: Start point
232
-//  xEnd/yEnd: End point
233
-void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
234
-
235
-// Draw a Horizontal line
236
-//  color: Line segment color
237
-//  xStart/yStart: Start point
238
-//  xLength: Line Length
239
-inline void DWIN_Draw_HLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xLength) {
240
-  DWIN_Draw_Line(color, xStart, yStart, xStart + xLength - 1, yStart);
241
-}
242
-
243
-// Draw a Vertical line
244
-//  color: Line segment color
245
-//  xStart/yStart: Start point
246
-//  yLength: Line Length
247
-inline void DWIN_Draw_VLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t yLength) {
248
-  DWIN_Draw_Line(color, xStart, yStart, xStart, yStart + yLength - 1);
249
-}
250
-
251
-// Draw a rectangle
252
-//  mode: 0=frame, 1=fill, 2=XOR fill
253
-//  color: Rectangle color
254
-//  xStart/yStart: upper left point
255
-//  xEnd/yEnd: lower right point
256
-void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,  uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
257
-
258
-// Draw a box
259
-//  mode: 0=frame, 1=fill, 2=XOR fill
260
-//  color: Rectangle color
261
-//  xStart/yStart: upper left point
262
-//  xSize/ySize: box size
263
-inline void DWIN_Draw_Box(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xSize, uint16_t ySize) {
264
-  DWIN_Draw_Rectangle(mode, color, xStart, yStart, xStart + xSize - 1, yStart + ySize - 1);
265
-}
266
-
267
-// Move a screen area
268
-//  mode: 0, circle shift; 1, translation
269
-//  dir: 0=left, 1=right, 2=up, 3=down
270
-//  dis: Distance
271
-//  color: Fill color
272
-//  xStart/yStart: upper left point
273
-//  xEnd/yEnd: bottom right point
274
-void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
275
-                         uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
276
-
277
-/*---------------------------------------- Text related functions ----------------------------------------*/
278
-
279
-// Draw a string
280
-//  bShow: true=display background color; false=don't display background color
281
-//  size: Font size
282
-//  color: Character color
283
-//  bColor: Background color
284
-//  x/y: Upper-left coordinate of the string
285
-//  *string: The string
286
-void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string);
287
-
288
-class __FlashStringHelper;
289
-
290
-inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
291
-  DWIN_Draw_String(bShow, size, color, bColor, x, y, (char *)title);
292
-}
293
-
294
-// Draw a positive integer
295
-//  bShow: true=display background color; false=don't display background color
296
-//  zeroFill: true=zero fill; false=no zero fill
297
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
298
-//  size: Font size
299
-//  color: Character color
300
-//  bColor: Background color
301
-//  iNum: Number of digits
302
-//  x/y: Upper-left coordinate
303
-//  value: Integer value
304
-void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
305
-                          uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value);
306
-
307
-// Draw a floating point number
308
-//  bShow: true=display background color; false=don't display background color
309
-//  zeroFill: true=zero fill; false=no zero fill
310
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
311
-//  size: Font size
312
-//  color: Character color
313
-//  bColor: Background color
314
-//  iNum: Number of whole digits
315
-//  fNum: Number of decimal digits
316
-//  x/y: Upper-left point
317
-//  value: Float value
318
-void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
319
-                            uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
320
-
321
-/*---------------------------------------- Picture related functions ----------------------------------------*/
322
-
323
-// Draw JPG and cached in #0 virtual display area
324
-// id: Picture ID
325
-void DWIN_JPG_ShowAndCache(const uint8_t id);
326
-
327
-// Draw an Icon
328
-//  libID: Icon library ID
329
-//  picID: Icon ID
330
-//  x/y: Upper-left point
331
-void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y);
332
-
333
-// Unzip the JPG picture to a virtual display area
334
-//  n: Cache index
335
-//  id: Picture ID
336
-void DWIN_JPG_CacheToN(uint8_t n, uint8_t id);
337
-
338
-// Unzip the JPG picture to virtual display area #1
339
-//  id: Picture ID
340
-inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); }
341
-
342
 // Copy area from virtual display area to current screen
45
 // Copy area from virtual display area to current screen
343
 //  cacheID: virtual area number
46
 //  cacheID: virtual area number
344
 //  xStart/yStart: Upper-left of virtual area
47
 //  xStart/yStart: Upper-left of virtual area
345
 //  xEnd/yEnd: Lower-right of virtual area
48
 //  xEnd/yEnd: Lower-right of virtual area
346
 //  x/y: Screen paste point
49
 //  x/y: Screen paste point
347
-void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
348
-                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
349
-
350
-// Animate a series of icons
351
-//  animID: Animation ID  up to 16
352
-//  animate: animation on or off
353
-//  libID: Icon library ID
354
-//  picIDs: Icon starting ID
355
-//  picIDe: Icon ending ID
356
-//  x/y: Upper-left point
357
-//  interval: Display time interval, unit 10mS
358
-void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs,
359
-                         uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval);
360
-
361
-// Animation Control
362
-//  state: 16 bits, each bit is the state of an animation id
363
-void DWIN_ICON_AnimationControl(uint16_t state);
50
+void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);

+ 0
- 263
Marlin/src/lcd/e3v2/creality/rotary_encoder.cpp 查看文件

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
-
23
-/*****************************************************************************
24
- * @file     lcd/e3v2/creality/rotary_encoder.cpp
25
- * @author   LEO / Creality3D
26
- * @date     2019/07/06
27
- * @version  2.0.1
28
- * @brief    Rotary encoder functions
29
- *****************************************************************************/
30
-
31
-#include "../../../inc/MarlinConfigPre.h"
32
-
33
-#if ENABLED(DWIN_CREALITY_LCD)
34
-
35
-#include "rotary_encoder.h"
36
-#include "../../buttons.h"
37
-
38
-#include "../../../MarlinCore.h"
39
-#include "../../../HAL/shared/Delay.h"
40
-
41
-#if HAS_BUZZER
42
-  #include "../../../libs/buzzer.h"
43
-#endif
44
-
45
-#include <stdlib.h>
46
-
47
-#ifndef ENCODER_PULSES_PER_STEP
48
-  #define ENCODER_PULSES_PER_STEP 4
49
-#endif
50
-
51
-ENCODER_Rate EncoderRate;
52
-
53
-// Buzzer
54
-void Encoder_tick() {
55
-  #if PIN_EXISTS(BEEPER)
56
-    WRITE(BEEPER_PIN, HIGH);
57
-    delay(10);
58
-    WRITE(BEEPER_PIN, LOW);
59
-  #endif
60
-}
61
-
62
-// Encoder initialization
63
-void Encoder_Configuration() {
64
-  #if BUTTON_EXISTS(EN1)
65
-    SET_INPUT_PULLUP(BTN_EN1);
66
-  #endif
67
-  #if BUTTON_EXISTS(EN2)
68
-    SET_INPUT_PULLUP(BTN_EN2);
69
-  #endif
70
-  #if BUTTON_EXISTS(ENC)
71
-    SET_INPUT_PULLUP(BTN_ENC);
72
-  #endif
73
-  #if PIN_EXISTS(BEEPER)
74
-    SET_OUTPUT(BEEPER_PIN);
75
-  #endif
76
-}
77
-
78
-// Analyze encoder value and return state
79
-ENCODER_DiffState Encoder_ReceiveAnalyze() {
80
-  const millis_t now = millis();
81
-  static uint8_t lastEncoderBits;
82
-  uint8_t newbutton = 0;
83
-  static signed char temp_diff = 0;
84
-
85
-  ENCODER_DiffState temp_diffState = ENCODER_DIFF_NO;
86
-  if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
87
-  if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
88
-  if (BUTTON_PRESSED(ENC)) {
89
-    static millis_t next_click_update_ms;
90
-    if (ELAPSED(now, next_click_update_ms)) {
91
-      next_click_update_ms = millis() + 300;
92
-      Encoder_tick();
93
-      #if PIN_EXISTS(LCD_LED)
94
-        //LED_Action();
95
-      #endif
96
-      const bool was_waiting = wait_for_user;
97
-      wait_for_user = false;
98
-      return was_waiting ? ENCODER_DIFF_NO : ENCODER_DIFF_ENTER;
99
-    }
100
-    else return ENCODER_DIFF_NO;
101
-  }
102
-  if (newbutton != lastEncoderBits) {
103
-    switch (newbutton) {
104
-      case ENCODER_PHASE_0:
105
-             if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++;
106
-        else if (lastEncoderBits == ENCODER_PHASE_1) temp_diff--;
107
-        break;
108
-      case ENCODER_PHASE_1:
109
-             if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++;
110
-        else if (lastEncoderBits == ENCODER_PHASE_2) temp_diff--;
111
-        break;
112
-      case ENCODER_PHASE_2:
113
-             if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++;
114
-        else if (lastEncoderBits == ENCODER_PHASE_3) temp_diff--;
115
-        break;
116
-      case ENCODER_PHASE_3:
117
-             if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++;
118
-        else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--;
119
-        break;
120
-    }
121
-    lastEncoderBits = newbutton;
122
-  }
123
-
124
-  if (ABS(temp_diff) >= ENCODER_PULSES_PER_STEP) {
125
-    #if ENABLED(REVERSE_ENCODER_DIRECTION)
126
-      if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CCW;
127
-      else temp_diffState = ENCODER_DIFF_CW;
128
-    #else
129
-      if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CW;
130
-      else temp_diffState = ENCODER_DIFF_CCW;
131
-    #endif
132
-
133
-    #if ENABLED(ENCODER_RATE_MULTIPLIER)
134
-
135
-      millis_t ms = millis();
136
-      int32_t encoderMultiplier = 1;
137
-
138
-      // if must encoder rati multiplier
139
-      if (EncoderRate.enabled) {
140
-        const float abs_diff = ABS(temp_diff),
141
-                    encoderMovementSteps = abs_diff / (ENCODER_PULSES_PER_STEP);
142
-        if (EncoderRate.lastEncoderTime) {
143
-          // Note that the rate is always calculated between two passes through the
144
-          // loop and that the abs of the temp_diff value is tracked.
145
-          const float encoderStepRate = encoderMovementSteps / float(ms - EncoderRate.lastEncoderTime) * 1000;
146
-               if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100;
147
-          else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC)  encoderMultiplier = 10;
148
-          #if ENCODER_5X_STEPS_PER_SEC
149
-            else if (encoderStepRate >= ENCODER_5X_STEPS_PER_SEC) encoderMultiplier = 5;
150
-          #endif
151
-        }
152
-        EncoderRate.lastEncoderTime = ms;
153
-      }
154
-
155
-    #else
156
-
157
-      constexpr int32_t encoderMultiplier = 1;
158
-
159
-    #endif
160
-
161
-    // EncoderRate.encoderMoveValue += (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
162
-    EncoderRate.encoderMoveValue = (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
163
-    if (EncoderRate.encoderMoveValue < 0) EncoderRate.encoderMoveValue = -EncoderRate.encoderMoveValue;
164
-
165
-    temp_diff = 0;
166
-  }
167
-  return temp_diffState;
168
-}
169
-
170
-#if PIN_EXISTS(LCD_LED)
171
-
172
-  // 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
173
-  uint16_t LED_DataArray[LED_NUM];
174
-
175
-  // LED light operation
176
-  void LED_Action() {
177
-    LED_Control(RGB_SCALE_WARM_WHITE,0x0F);
178
-    delay(30);
179
-    LED_Control(RGB_SCALE_WARM_WHITE,0x00);
180
-  }
181
-
182
-  // LED initialization
183
-  void LED_Configuration() {
184
-    SET_OUTPUT(LCD_LED_PIN);
185
-  }
186
-
187
-  // LED write data
188
-  void LED_WriteData() {
189
-    uint8_t tempCounter_LED, tempCounter_Bit;
190
-    for (tempCounter_LED = 0; tempCounter_LED < LED_NUM; tempCounter_LED++) {
191
-      for (tempCounter_Bit = 0; tempCounter_Bit < 24; tempCounter_Bit++) {
192
-        if (LED_DataArray[tempCounter_LED] & (0x800000 >> tempCounter_Bit)) {
193
-          LED_DATA_HIGH;
194
-          DELAY_NS(300);
195
-          LED_DATA_LOW;
196
-          DELAY_NS(200);
197
-        }
198
-        else {
199
-          LED_DATA_HIGH;
200
-          LED_DATA_LOW;
201
-          DELAY_NS(200);
202
-        }
203
-      }
204
-    }
205
-  }
206
-
207
-  // LED control
208
-  //  RGB_Scale: RGB color ratio
209
-  //  luminance: brightness (0~0xFF)
210
-  void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance) {
211
-    for (uint8_t i = 0; i < LED_NUM; i++) {
212
-      LED_DataArray[i] = 0;
213
-      switch (RGB_Scale) {
214
-        case RGB_SCALE_R10_G7_B5: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 7/10) << 16 | luminance * 5/10; break;
215
-        case RGB_SCALE_R10_G7_B4: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 7/10) << 16 | luminance * 4/10; break;
216
-        case RGB_SCALE_R10_G8_B7: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 8/10) << 16 | luminance * 7/10; break;
217
-      }
218
-    }
219
-    LED_WriteData();
220
-  }
221
-
222
-  // LED gradient control
223
-  //  RGB_Scale: RGB color ratio
224
-  //  luminance: brightness (0~0xFF)
225
-  //  change_Time: gradient time (ms)
226
-  void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval) {
227
-    struct { uint8_t g, r, b; } led_data[LED_NUM];
228
-    for (uint8_t i = 0; i < LED_NUM; i++) {
229
-      switch (RGB_Scale) {
230
-        case RGB_SCALE_R10_G7_B5:
231
-          led_data[i] = { luminance * 7/10, luminance * 10/10, luminance * 5/10 };
232
-          break;
233
-        case RGB_SCALE_R10_G7_B4:
234
-          led_data[i] = { luminance * 7/10, luminance * 10/10, luminance * 4/10 };
235
-          break;
236
-        case RGB_SCALE_R10_G8_B7:
237
-          led_data[i] = { luminance * 8/10, luminance * 10/10, luminance * 7/10 };
238
-          break;
239
-      }
240
-    }
241
-
242
-    struct { bool g, r, b; } led_flag = { false, false, false };
243
-    for (uint8_t i = 0; i < LED_NUM; i++) {
244
-      while (1) {
245
-        const uint8_t g = uint8_t(LED_DataArray[i] >> 16),
246
-                      r = uint8_t(LED_DataArray[i] >> 8),
247
-                      b = uint8_t(LED_DataArray[i]);
248
-        if (g == led_data[i].g) led_flag.g = true;
249
-        else LED_DataArray[i] += (g > led_data[i].g) ? -0x010000 : 0x010000;
250
-        if (r == led_data[i].r) led_flag.r = true;
251
-        else LED_DataArray[i] += (r > led_data[i].r) ? -0x000100 : 0x000100;
252
-        if (b == led_data[i].b) led_flag.b = true;
253
-        else LED_DataArray[i] += (b > led_data[i].b) ? -0x000001 : 0x000001;
254
-        LED_WriteData();
255
-        if (led_flag.r && led_flag.g && led_flag.b) break;
256
-        delay(change_Interval);
257
-      }
258
-    }
259
-  }
260
-
261
-#endif // LCD_LED
262
-
263
-#endif // DWIN_CREALITY_LCD

+ 0
- 94
Marlin/src/lcd/e3v2/creality/rotary_encoder.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
-/*****************************************************************************
25
- * @file     lcd/e3v2/creality/rotary_encoder.h
26
- * @author   LEO / Creality3D
27
- * @date     2019/07/06
28
- * @version  2.0.1
29
- * @brief    Rotary encoder functions
30
- ****************************************************************************/
31
-
32
-#include "../../../inc/MarlinConfig.h"
33
-
34
-/*********************** Encoder Set ***********************/
35
-
36
-typedef struct {
37
-  bool enabled = false;
38
-  int encoderMoveValue = 0;
39
-  millis_t lastEncoderTime = 0;
40
-} ENCODER_Rate;
41
-
42
-extern ENCODER_Rate EncoderRate;
43
-
44
-typedef enum {
45
-  ENCODER_DIFF_NO    = 0,  // no state
46
-  ENCODER_DIFF_CW    = 1,  // clockwise rotation
47
-  ENCODER_DIFF_CCW   = 2,  // counterclockwise rotation
48
-  ENCODER_DIFF_ENTER = 3   // click
49
-} ENCODER_DiffState;
50
-
51
-// Encoder initialization
52
-void Encoder_Configuration();
53
-
54
-// Analyze encoder value and return state
55
-ENCODER_DiffState Encoder_ReceiveAnalyze();
56
-
57
-/*********************** Encoder LED ***********************/
58
-
59
-#if PIN_EXISTS(LCD_LED)
60
-
61
-  #define LED_NUM  4
62
-  #define LED_DATA_HIGH  WRITE(LCD_LED_PIN, 1)
63
-  #define LED_DATA_LOW   WRITE(LCD_LED_PIN, 0)
64
-
65
-  #define RGB_SCALE_R10_G7_B5  1
66
-  #define RGB_SCALE_R10_G7_B4  2
67
-  #define RGB_SCALE_R10_G8_B7  3
68
-  #define RGB_SCALE_NEUTRAL_WHITE RGB_SCALE_R10_G7_B5
69
-  #define RGB_SCALE_WARM_WHITE    RGB_SCALE_R10_G7_B4
70
-  #define RGB_SCALE_COOL_WHITE    RGB_SCALE_R10_G8_B7
71
-
72
-  extern unsigned int LED_DataArray[LED_NUM];
73
-
74
-  // LED light operation
75
-  void LED_Action();
76
-
77
-  // LED initialization
78
-  void LED_Configuration();
79
-
80
-  // LED write data
81
-  void LED_WriteData();
82
-
83
-  // LED control
84
-  //  RGB_Scale: RGB color ratio
85
-  //  luminance: brightness (0~0xFF)
86
-  void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance);
87
-
88
-  // LED gradient control
89
-  //  RGB_Scale: RGB color ratio
90
-  //  luminance: brightness (0~0xFF)
91
-  //  change_Time: gradient time (ms)
92
-  void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval);
93
-
94
-#endif // LCD_LED

+ 71
- 63
Marlin/src/lcd/e3v2/enhanced/dwin.cpp 查看文件

1
 /**
1
 /**
2
- * DWIN UI Enhanced implementation
3
- * Author: Miguel A. Risco-Castillo
4
- * Version: 3.6.1
5
- * Date: 2021/08/29
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
6
  *
7
  *
7
  * This program is free software: you can redistribute it and/or modify
8
  * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as
9
- * published by the Free Software Foundation, either version 3 of the License, or
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
10
  * (at your option) any later version.
11
  * (at your option) any later version.
11
  *
12
  *
12
  * This program is distributed in the hope that it will be useful,
13
  * This program is distributed in the hope that it will be useful,
14
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * GNU General Public License for more details.
16
  * GNU General Public License for more details.
16
  *
17
  *
17
- * You should have received a copy of the GNU Lesser General Public License
18
+ * You should have received a copy of the GNU General Public License
18
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  *
20
  *
20
  */
21
  */
21
 
22
 
23
+/**
24
+ * DWIN UI Enhanced implementation
25
+ * Author: Miguel A. Risco-Castillo
26
+ * Version: 3.6.3
27
+ * Date: 2021/09/10
28
+ */
29
+
22
 #include "../../../inc/MarlinConfigPre.h"
30
 #include "../../../inc/MarlinConfigPre.h"
23
 
31
 
24
 #if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
32
 #if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
261
 
269
 
262
 void ICON_Button(const bool here, const int iconid, const frame_rect_t &ico, const text_info_t (&txt)[2]) {
270
 void ICON_Button(const bool here, const int iconid, const frame_rect_t &ico, const text_info_t (&txt)[2]) {
263
   const bool cn = HMI_IsChinese();
271
   const bool cn = HMI_IsChinese();
264
-  DWIN_ICON_Show(1, 0, 0, ICON, iconid + here, ico.x, ico.y);
272
+  DWIN_ICON_Show(true, false, false, ICON, iconid + here, ico.x, ico.y);
265
   if (here) DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, ico.x, ico.y, ico.x + ico.w - 1, ico.y + ico.h - 1);
273
   if (here) DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, ico.x, ico.y, ico.x + ico.w - 1, ico.y + ico.h - 1);
266
   DWIN_Frame_AreaCopy(1, txt[cn].x, txt[cn].y[here], txt[cn].x + txt[cn].w - 1, txt[cn].y[here] + txt[cn].h - 1, ico.x + (ico.w - txt[cn].w) / 2, (ico.y + ico.h - 28) - txt[cn].h/2);
274
   DWIN_Frame_AreaCopy(1, txt[cn].x, txt[cn].y[here], txt[cn].x + txt[cn].w - 1, txt[cn].y[here] + txt[cn].h - 1, ico.x + (ico.w - txt[cn].w) / 2, (ico.y + ico.h - 28) - txt[cn].h/2);
267
 }
275
 }
438
   if (is_sel) Draw_Menu_Cursor(0);
446
   if (is_sel) Draw_Menu_Cursor(0);
439
 }
447
 }
440
 
448
 
441
-inline ENCODER_DiffState get_encoder_state() {
449
+inline EncoderState get_encoder_state() {
442
   static millis_t Encoder_ms = 0;
450
   static millis_t Encoder_ms = 0;
443
   const millis_t ms = millis();
451
   const millis_t ms = millis();
444
   if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
452
   if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
445
-  const ENCODER_DiffState state = Encoder_ReceiveAnalyze();
453
+  const EncoderState state = Encoder_ReceiveAnalyze();
446
   if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS;
454
   if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS;
447
   return state;
455
   return state;
448
 }
456
 }
449
 
457
 
450
 template<typename T>
458
 template<typename T>
451
-inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, T &valref) {
459
+inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) {
452
   if (encoder_diffState == ENCODER_DIFF_CW)
460
   if (encoder_diffState == ENCODER_DIFF_CW)
453
     valref += EncoderRate.encoderMoveValue;
461
     valref += EncoderRate.encoderMoveValue;
454
   else if (encoder_diffState == ENCODER_DIFF_CCW)
462
   else if (encoder_diffState == ENCODER_DIFF_CCW)
762
     // Tune page temperature update
770
     // Tune page temperature update
763
     #if HAS_HOTEND
771
     #if HAS_HOTEND
764
       if (_new_hotend_target)
772
       if (_new_hotend_target)
765
-        HotendTargetItem->Draw(CurrentMenu->line(HotendTargetItem->pos));
773
+        HotendTargetItem->draw(CurrentMenu->line(HotendTargetItem->pos));
766
     #endif
774
     #endif
767
     #if HAS_HEATED_BED
775
     #if HAS_HEATED_BED
768
       if (_new_bed_target)
776
       if (_new_bed_target)
769
-        BedTargetItem->Draw(CurrentMenu->line(BedTargetItem->pos));
777
+        BedTargetItem->draw(CurrentMenu->line(BedTargetItem->pos));
770
     #endif
778
     #endif
771
     #if HAS_FAN
779
     #if HAS_FAN
772
       if (_new_fanspeed)
780
       if (_new_fanspeed)
773
-        FanSpeedItem->Draw(CurrentMenu->line(FanSpeedItem->pos));
781
+        FanSpeedItem->draw(CurrentMenu->line(FanSpeedItem->pos));
774
     #endif
782
     #endif
775
   }
783
   }
776
 
784
 
1098
 
1106
 
1099
 // Main Process
1107
 // Main Process
1100
 void HMI_MainMenu() {
1108
 void HMI_MainMenu() {
1101
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
1109
+  EncoderState encoder_diffState = get_encoder_state();
1102
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1110
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1103
 
1111
 
1104
   if (encoder_diffState == ENCODER_DIFF_CW) {
1112
   if (encoder_diffState == ENCODER_DIFF_CW) {
1147
 
1155
 
1148
 // Select (and Print) File
1156
 // Select (and Print) File
1149
 void HMI_SelectFile() {
1157
 void HMI_SelectFile() {
1150
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
1158
+  EncoderState encoder_diffState = get_encoder_state();
1151
 
1159
 
1152
   const uint16_t hasUpDir = !card.flag.workDirIsRoot;
1160
   const uint16_t hasUpDir = !card.flag.workDirIsRoot;
1153
 
1161
 
1267
 
1275
 
1268
 // Printing
1276
 // Printing
1269
 void HMI_Printing() {
1277
 void HMI_Printing() {
1270
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
1278
+  EncoderState encoder_diffState = get_encoder_state();
1271
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1279
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1272
   // Avoid flicker by updating only the previous menu
1280
   // Avoid flicker by updating only the previous menu
1273
   if (encoder_diffState == ENCODER_DIFF_CW) {
1281
   if (encoder_diffState == ENCODER_DIFF_CW) {
1331
 
1339
 
1332
 // Print done
1340
 // Print done
1333
 void HMI_PrintDone() {
1341
 void HMI_PrintDone() {
1334
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
1342
+  EncoderState encoder_diffState = get_encoder_state();
1335
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1343
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1336
   if (encoder_diffState == ENCODER_DIFF_ENTER) {
1344
   if (encoder_diffState == ENCODER_DIFF_ENTER) {
1337
     dwin_abort_flag = true; // Reset feedrate, return to Home
1345
     dwin_abort_flag = true; // Reset feedrate, return to Home
1341
 
1349
 
1342
 // Pause or Stop popup
1350
 // Pause or Stop popup
1343
 void HMI_PauseOrStop() {
1351
 void HMI_PauseOrStop() {
1344
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
1352
+  EncoderState encoder_diffState = get_encoder_state();
1345
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1353
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1346
 
1354
 
1347
   if (encoder_diffState == ENCODER_DIFF_CW)
1355
   if (encoder_diffState == ENCODER_DIFF_CW)
1404
     #if ENABLED(ADVANCED_PAUSE_FEATURE)
1412
     #if ENABLED(ADVANCED_PAUSE_FEATURE)
1405
       case FilamentPurge:        Draw_Popup_FilamentPurge(); break;
1413
       case FilamentPurge:        Draw_Popup_FilamentPurge(); break;
1406
     #endif
1414
     #endif
1407
-    case Locked:                 LockScreen.Draw(); break;
1415
+    case Locked:                 lockScreen.draw(); break;
1408
     case Menu:
1416
     case Menu:
1409
     case SetInt:
1417
     case SetInt:
1410
     case SetPInt:
1418
     case SetPInt:
1411
     case SetIntNoDraw:
1419
     case SetIntNoDraw:
1412
     case SetFloat:
1420
     case SetFloat:
1413
-    case SetPFloat:              CurrentMenu->Draw(); break;
1421
+    case SetPFloat:              CurrentMenu->draw(); break;
1414
     default: break;
1422
     default: break;
1415
   }
1423
   }
1416
 }
1424
 }
1423
 }
1431
 }
1424
 
1432
 
1425
 void HMI_Popup() {
1433
 void HMI_Popup() {
1426
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
1434
+  EncoderState encoder_diffState = get_encoder_state();
1427
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1435
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1428
   if (encoder_diffState == ENCODER_DIFF_ENTER) {
1436
   if (encoder_diffState == ENCODER_DIFF_ENTER) {
1429
     wait_for_user = false;
1437
     wait_for_user = false;
1560
       DWIN_UpdateLCD();
1568
       DWIN_UpdateLCD();
1561
 
1569
 
1562
       while (recovery_flag) {
1570
       while (recovery_flag) {
1563
-        ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1571
+        EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
1564
         if (encoder_diffState != ENCODER_DIFF_NO) {
1572
         if (encoder_diffState != ENCODER_DIFF_NO) {
1565
           if (encoder_diffState == ENCODER_DIFF_ENTER) {
1573
           if (encoder_diffState == ENCODER_DIFF_ENTER) {
1566
             recovery_flag = false;
1574
             recovery_flag = false;
1714
   if (title->frameid)
1722
   if (title->frameid)
1715
     DWIN_Frame_AreaCopy(title->frameid, title->frame.left, title->frame.top, title->frame.right, title->frame.bottom, 14, (TITLE_HEIGHT - (title->frame.bottom - title->frame.top)) / 2 - 1);
1723
     DWIN_Frame_AreaCopy(title->frameid, title->frame.left, title->frame.top, title->frame.right, title->frame.bottom, 14, (TITLE_HEIGHT - (title->frame.bottom - title->frame.top)) / 2 - 1);
1716
   else
1724
   else
1717
-    DWIN_Draw_String(false, false, DWIN_FONT_HEAD, HMI_data.TitleTxt_color, HMI_data.TitleBg_color, 14, (TITLE_HEIGHT - DWINUI::Get_font_height(DWIN_FONT_HEAD)) / 2 - 1, title->caption);
1725
+    DWIN_Draw_String(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_color, HMI_data.TitleBg_color, 14, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption);
1718
 }
1726
 }
1719
 
1727
 
1720
 void Draw_Menu(MenuClass* menu) {
1728
 void Draw_Menu(MenuClass* menu) {
1725
 
1733
 
1726
 // Startup routines
1734
 // Startup routines
1727
 void DWIN_Startup() {
1735
 void DWIN_Startup() {
1728
-  DWINUI::Init();
1736
+  DWINUI::init();
1729
   DWINUI::onCursorDraw = Draw_Menu_Cursor;
1737
   DWINUI::onCursorDraw = Draw_Menu_Cursor;
1730
   DWINUI::onCursorErase = Erase_Menu_Cursor;
1738
   DWINUI::onCursorErase = Erase_Menu_Cursor;
1731
   DWINUI::onTitleDraw = Draw_Title;
1739
   DWINUI::onTitleDraw = Draw_Title;
1890
   }
1898
   }
1891
 
1899
 
1892
   void HMI_FilamentPurge() {
1900
   void HMI_FilamentPurge() {
1893
-    ENCODER_DiffState encoder_diffState = get_encoder_state();
1901
+    EncoderState encoder_diffState = get_encoder_state();
1894
     if (encoder_diffState == ENCODER_DIFF_NO) return;
1902
     if (encoder_diffState == ENCODER_DIFF_NO) return;
1895
     if (encoder_diffState == ENCODER_DIFF_CW)
1903
     if (encoder_diffState == ENCODER_DIFF_CW)
1896
       Draw_Select_Highlight(false);
1904
       Draw_Select_Highlight(false);
1910
 #endif // ADVANCED_PAUSE_FEATURE
1918
 #endif // ADVANCED_PAUSE_FEATURE
1911
 
1919
 
1912
 void HMI_LockScreen() {
1920
 void HMI_LockScreen() {
1913
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
1921
+  EncoderState encoder_diffState = get_encoder_state();
1914
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1922
   if (encoder_diffState == ENCODER_DIFF_NO) return;
1915
-  LockScreen.onEncoderState(encoder_diffState);
1916
-  if (LockScreen.isUnlocked()) {
1923
+  lockScreen.onEncoder(encoder_diffState);
1924
+  if (lockScreen.isUnlocked()) {
1917
     if (CurrentMenu == AdvancedSettings)
1925
     if (CurrentMenu == AdvancedSettings)
1918
       Draw_AdvancedSettings_Menu();
1926
       Draw_AdvancedSettings_Menu();
1919
     else
1927
     else
1924
 void DWIN_LockScreen(const bool flag) {
1932
 void DWIN_LockScreen(const bool flag) {
1925
   HMI_flag.lock_flag = flag;
1933
   HMI_flag.lock_flag = flag;
1926
   checkkey = Locked;
1934
   checkkey = Locked;
1927
-  LockScreen.Init();
1935
+  lockScreen.init();
1928
 }
1936
 }
1929
 
1937
 
1930
 //
1938
 //
1974
 void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) {
1982
 void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) {
1975
   const int32_t value =  round(val * POW(10, dp));
1983
   const int32_t value =  round(val * POW(10, dp));
1976
   SetOnClick(process, lo * POW(10, dp), hi * POW(10, dp), dp, value, Apply, LiveUpdate);
1984
   SetOnClick(process, lo * POW(10, dp), hi * POW(10, dp), dp, value, Apply, LiveUpdate);
1977
-  DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), val);
1985
+  DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), val);
1978
 }
1986
 }
1979
 
1987
 
1980
 // Generic onclick event for integer values
1988
 // Generic onclick event for integer values
2379
     planner.synchronize();
2387
     planner.synchronize();
2380
     #ifdef MANUAL_PROBE_START_Z
2388
     #ifdef MANUAL_PROBE_START_Z
2381
       const uint8_t line = CurrentMenu->line(MMeshMoveZItem->pos);
2389
       const uint8_t line = CurrentMenu->line(MMeshMoveZItem->pos);
2382
-      DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, 2, VALX - 2 * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(line), MANUAL_PROBE_START_Z);
2390
+      DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, 2, VALX - 2 * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(line), MANUAL_PROBE_START_Z);
2383
     #endif
2391
     #endif
2384
   }
2392
   }
2385
 
2393
 
2395
   void ManualMeshContinue(){
2403
   void ManualMeshContinue(){
2396
     gcode.process_subcommands_now_P(PSTR("G29S2"));
2404
     gcode.process_subcommands_now_P(PSTR("G29S2"));
2397
     planner.synchronize();
2405
     planner.synchronize();
2398
-    MMeshMoveZItem->Draw(CurrentMenu->line(MMeshMoveZItem->pos));
2406
+    MMeshMoveZItem->draw(CurrentMenu->line(MMeshMoveZItem->pos));
2399
   }
2407
   }
2400
 
2408
 
2401
   void ManualMeshSave(){
2409
   void ManualMeshSave(){
2515
 
2523
 
2516
 void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value) {
2524
 void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value) {
2517
   onDrawMenuItem(menuitem, line);
2525
   onDrawMenuItem(menuitem, line);
2518
-  DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(line), value);
2526
+  DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(line), value);
2519
 }
2527
 }
2520
 
2528
 
2521
 void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) {
2529
 void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) {
2928
 
2936
 
2929
 // Generic menu control using the encoder
2937
 // Generic menu control using the encoder
2930
 void HMI_Menu() {
2938
 void HMI_Menu() {
2931
-  ENCODER_DiffState encoder_diffState = get_encoder_state();
2939
+  EncoderState encoder_diffState = get_encoder_state();
2932
   if (encoder_diffState == ENCODER_DIFF_NO) return;
2940
   if (encoder_diffState == ENCODER_DIFF_NO) return;
2933
   if (encoder_diffState == ENCODER_DIFF_ENTER) {
2941
   if (encoder_diffState == ENCODER_DIFF_ENTER) {
2934
     if (CurrentMenu != nullptr) CurrentMenu->onClick();
2942
     if (CurrentMenu != nullptr) CurrentMenu->onClick();
2943
 //  1 : live change
2951
 //  1 : live change
2944
 //  2 : apply change
2952
 //  2 : apply change
2945
 int8_t HMI_GetIntNoDraw(const int32_t lo, const int32_t hi) {
2953
 int8_t HMI_GetIntNoDraw(const int32_t lo, const int32_t hi) {
2946
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
2954
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
2947
   if (encoder_diffState != ENCODER_DIFF_NO) {
2955
   if (encoder_diffState != ENCODER_DIFF_NO) {
2948
     if (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
2956
     if (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
2949
       EncoderRate.enabled = false;
2957
       EncoderRate.enabled = false;
2964
 //  1 : live change
2972
 //  1 : live change
2965
 //  2 : apply change
2973
 //  2 : apply change
2966
 int8_t HMI_GetInt(const int32_t lo, const int32_t hi) {
2974
 int8_t HMI_GetInt(const int32_t lo, const int32_t hi) {
2967
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
2975
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
2968
   if (encoder_diffState != ENCODER_DIFF_NO) {
2976
   if (encoder_diffState != ENCODER_DIFF_NO) {
2969
     if (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
2977
     if (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
2970
       EncoderRate.enabled = false;
2978
       EncoderRate.enabled = false;
3018
 //  1 : live change
3026
 //  1 : live change
3019
 //  2 : apply change
3027
 //  2 : apply change
3020
 int8_t HMI_GetFloat(uint8_t dp, int32_t lo, int32_t hi) {
3028
 int8_t HMI_GetFloat(uint8_t dp, int32_t lo, int32_t hi) {
3021
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
3029
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
3022
   if (encoder_diffState != ENCODER_DIFF_NO) {
3030
   if (encoder_diffState != ENCODER_DIFF_NO) {
3023
     if (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
3031
     if (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
3024
       EncoderRate.enabled = false;
3032
       EncoderRate.enabled = false;
3025
-      DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value / POW(10, dp));
3033
+      DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value / POW(10, dp));
3026
       checkkey = Menu;
3034
       checkkey = Menu;
3027
       return 2;
3035
       return 2;
3028
     }
3036
     }
3029
     LIMIT(HMI_value.Value, lo, hi);
3037
     LIMIT(HMI_value.Value, lo, hi);
3030
-    DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value / POW(10, dp));
3038
+    DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value / POW(10, dp));
3031
     return 1;
3039
     return 1;
3032
   }
3040
   }
3033
   return 0;
3041
   return 0;
3098
     #endif
3106
     #endif
3099
     ADDMENUITEM(ICON_Language, PSTR("UI Language"), onDrawLanguage, SetLanguage);
3107
     ADDMENUITEM(ICON_Language, PSTR("UI Language"), onDrawLanguage, SetLanguage);
3100
   }
3108
   }
3101
-  CurrentMenu->Draw();
3109
+  CurrentMenu->draw();
3102
 }
3110
 }
3103
 
3111
 
3104
 void Draw_LevBedCorners_Menu() {
3112
 void Draw_LevBedCorners_Menu() {
3116
     ADDMENUITEM(ICON_Axis, GET_TEXT(MSG_LEVBED_BL), onDrawMenuItem, LevBedBL);
3124
     ADDMENUITEM(ICON_Axis, GET_TEXT(MSG_LEVBED_BL), onDrawMenuItem, LevBedBL);
3117
     ADDMENUITEM(ICON_Axis, GET_TEXT(MSG_LEVBED_C ), onDrawMenuItem, LevBedC );
3125
     ADDMENUITEM(ICON_Axis, GET_TEXT(MSG_LEVBED_C ), onDrawMenuItem, LevBedC );
3118
   }
3126
   }
3119
-  CurrentMenu->Draw();
3127
+  CurrentMenu->draw();
3120
 }
3128
 }
3121
 
3129
 
3122
 void Draw_Control_Menu() {
3130
 void Draw_Control_Menu() {
3138
     ADDMENUITEM(ICON_AdvSet, GET_TEXT(MSG_ADVANCED_SETTINGS), onDrawSubMenu, Draw_AdvancedSettings_Menu);
3146
     ADDMENUITEM(ICON_AdvSet, GET_TEXT(MSG_ADVANCED_SETTINGS), onDrawSubMenu, Draw_AdvancedSettings_Menu);
3139
     ADDMENUITEM(ICON_Info, GET_TEXT(MSG_INFO_SCREEN), onDrawInfoSubMenu, Goto_InfoMenu);
3147
     ADDMENUITEM(ICON_Info, GET_TEXT(MSG_INFO_SCREEN), onDrawInfoSubMenu, Goto_InfoMenu);
3140
   }
3148
   }
3141
-  CurrentMenu->Draw();
3149
+  CurrentMenu->draw();
3142
 }
3150
 }
3143
 
3151
 
3144
 void Draw_AdvancedSettings_Menu() {
3152
 void Draw_AdvancedSettings_Menu() {
3176
     #endif
3184
     #endif
3177
     ADDMENUITEM(ICON_Lock, F("Lock Screen"), onDrawMenuItem, Goto_LockScreen);
3185
     ADDMENUITEM(ICON_Lock, F("Lock Screen"), onDrawMenuItem, Goto_LockScreen);
3178
   }
3186
   }
3179
-  CurrentMenu->Draw();
3187
+  CurrentMenu->draw();
3180
 }
3188
 }
3181
 
3189
 
3182
 void Draw_Move_Menu() {
3190
 void Draw_Move_Menu() {
3194
       ADDMENUITEM_P(ICON_Extruder, GET_TEXT(MSG_MOVE_E), onDrawMoveE, SetMoveE, &current_position.e);
3202
       ADDMENUITEM_P(ICON_Extruder, GET_TEXT(MSG_MOVE_E), onDrawMoveE, SetMoveE, &current_position.e);
3195
     #endif
3203
     #endif
3196
   }
3204
   }
3197
-  CurrentMenu->Draw();
3205
+  CurrentMenu->draw();
3198
   if (!all_axes_trusted()) ui.set_status_P(PSTR("WARNING: position is unknow"));
3206
   if (!all_axes_trusted()) ui.set_status_P(PSTR("WARNING: position is unknow"));
3199
 }
3207
 }
3200
 
3208
 
3211
       ADDMENUITEM_P(ICON_HomeOffsetY, GET_TEXT(MSG_HOME_OFFSET_Y), onDrawPFloatMenu, SetHomeOffsetY, &home_offset[Y_AXIS]);
3219
       ADDMENUITEM_P(ICON_HomeOffsetY, GET_TEXT(MSG_HOME_OFFSET_Y), onDrawPFloatMenu, SetHomeOffsetY, &home_offset[Y_AXIS]);
3212
       ADDMENUITEM_P(ICON_HomeOffsetZ, GET_TEXT(MSG_HOME_OFFSET_Z), onDrawPFloatMenu, SetHomeOffsetZ, &home_offset[Z_AXIS]);
3220
       ADDMENUITEM_P(ICON_HomeOffsetZ, GET_TEXT(MSG_HOME_OFFSET_Z), onDrawPFloatMenu, SetHomeOffsetZ, &home_offset[Z_AXIS]);
3213
     }
3221
     }
3214
-    CurrentMenu->Draw();
3222
+    CurrentMenu->draw();
3215
   }
3223
   }
3216
 #endif
3224
 #endif
3217
 
3225
 
3229
       ADDMENUITEM_P(ICON_ProbeOffsetZ, GET_TEXT(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z);
3237
       ADDMENUITEM_P(ICON_ProbeOffsetZ, GET_TEXT(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z);
3230
       ADDMENUITEM(ICON_ProbeTest, GET_TEXT(MSG_M48_TEST), onDrawMenuItem, ProbeTest);
3238
       ADDMENUITEM(ICON_ProbeTest, GET_TEXT(MSG_M48_TEST), onDrawMenuItem, ProbeTest);
3231
     }
3239
     }
3232
-    CurrentMenu->Draw();
3240
+    CurrentMenu->draw();
3233
   }
3241
   }
3234
 #endif
3242
 #endif
3235
 
3243
 
3256
         ADDMENUITEM_P(ICON_FilUnload, GET_TEXT(MSG_FILAMENT_UNLOAD), onDrawPFloatMenu, SetFilUnload, &fc_settings[0].unload_length);
3264
         ADDMENUITEM_P(ICON_FilUnload, GET_TEXT(MSG_FILAMENT_UNLOAD), onDrawPFloatMenu, SetFilUnload, &fc_settings[0].unload_length);
3257
       #endif
3265
       #endif
3258
     }
3266
     }
3259
-    CurrentMenu->Draw();
3267
+    CurrentMenu->draw();
3260
   }
3268
   }
3261
 #endif // HAS_FILAMENT_SENSOR
3269
 #endif // HAS_FILAMENT_SENSOR
3262
 
3270
 
3288
     ADDMENUITEM_P(0, "Indicator value", onDrawSelColorItem, SelColor, &HMI_data.Indicator_Color);
3296
     ADDMENUITEM_P(0, "Indicator value", onDrawSelColorItem, SelColor, &HMI_data.Indicator_Color);
3289
     ADDMENUITEM_P(0, "Coordinate value", onDrawSelColorItem, SelColor, &HMI_data.Coordinate_Color);
3297
     ADDMENUITEM_P(0, "Coordinate value", onDrawSelColorItem, SelColor, &HMI_data.Coordinate_Color);
3290
   }
3298
   }
3291
-  CurrentMenu->Draw();
3299
+  CurrentMenu->draw();
3292
 }
3300
 }
3293
 
3301
 
3294
 void Draw_GetColor_Menu() {
3302
 void Draw_GetColor_Menu() {
3304
     ADDMENUITEM(1, "Green", onDrawGetColorItem, SetRGBColor);
3312
     ADDMENUITEM(1, "Green", onDrawGetColorItem, SetRGBColor);
3305
     ADDMENUITEM(2, "Blue", onDrawGetColorItem, SetRGBColor);
3313
     ADDMENUITEM(2, "Blue", onDrawGetColorItem, SetRGBColor);
3306
   }
3314
   }
3307
-  CurrentMenu->Draw();
3315
+  CurrentMenu->draw();
3308
   DWIN_Draw_Rectangle(1, *HMI_value.P_Int, 20, 315, DWIN_WIDTH - 20, 335);
3316
   DWIN_Draw_Rectangle(1, *HMI_value.P_Int, 20, 315, DWIN_WIDTH - 20, 335);
3309
 }
3317
 }
3310
 
3318
 
3338
       ADDMENUITEM_P(ICON_Brightness, F("LCD Brightness"), onDrawPInt8Menu, SetBrightness, &ui.brightness);
3346
       ADDMENUITEM_P(ICON_Brightness, F("LCD Brightness"), onDrawPInt8Menu, SetBrightness, &ui.brightness);
3339
     #endif
3347
     #endif
3340
   }
3348
   }
3341
-  CurrentMenu->Draw();
3349
+  CurrentMenu->draw();
3342
 }
3350
 }
3343
 
3351
 
3344
 void Draw_Motion_Menu() {
3352
 void Draw_Motion_Menu() {
3357
     ADDMENUITEM(ICON_Step, GET_TEXT(MSG_STEPS_PER_MM), onDrawSteps, Draw_Steps_Menu);
3365
     ADDMENUITEM(ICON_Step, GET_TEXT(MSG_STEPS_PER_MM), onDrawSteps, Draw_Steps_Menu);
3358
     ADDMENUITEM_P(ICON_Flow, GET_TEXT(MSG_FLOW), onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]);
3366
     ADDMENUITEM_P(ICON_Flow, GET_TEXT(MSG_FLOW), onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]);
3359
   }
3367
   }
3360
-  CurrentMenu->Draw();
3368
+  CurrentMenu->draw();
3361
 }
3369
 }
3362
 
3370
 
3363
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
3371
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
3376
         ADDMENUITEM(ICON_FilLoad, GET_TEXT(MSG_FILAMENTLOAD), onDrawMenuItem, LoadFilament);
3384
         ADDMENUITEM(ICON_FilLoad, GET_TEXT(MSG_FILAMENTLOAD), onDrawMenuItem, LoadFilament);
3377
       #endif
3385
       #endif
3378
     }
3386
     }
3379
-    CurrentMenu->Draw();
3387
+    CurrentMenu->draw();
3380
   }
3388
   }
3381
 #endif
3389
 #endif
3382
 
3390
 
3394
       ADDMENUITEM(ICON_Axis, GET_TEXT(MSG_UBL_CONTINUE_MESH), onDrawMenuItem, ManualMeshContinue);
3402
       ADDMENUITEM(ICON_Axis, GET_TEXT(MSG_UBL_CONTINUE_MESH), onDrawMenuItem, ManualMeshContinue);
3395
       ADDMENUITEM(ICON_MeshSave, GET_TEXT(MSG_UBL_SAVE_MESH), onDrawMenuItem, ManualMeshSave);
3403
       ADDMENUITEM(ICON_MeshSave, GET_TEXT(MSG_UBL_SAVE_MESH), onDrawMenuItem, ManualMeshSave);
3396
     }
3404
     }
3397
-    CurrentMenu->Draw();
3405
+    CurrentMenu->draw();
3398
   }
3406
   }
3399
 #endif
3407
 #endif
3400
 
3408
 
3420
         ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawWriteEeprom, WriteEeprom);
3428
         ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawWriteEeprom, WriteEeprom);
3421
       #endif
3429
       #endif
3422
     }
3430
     }
3423
-    CurrentMenu->Draw();
3431
+    CurrentMenu->draw();
3424
   }
3432
   }
3425
 
3433
 
3426
   void Draw_Preheat1_Menu() {
3434
   void Draw_Preheat1_Menu() {
3471
       #endif
3479
       #endif
3472
     #endif
3480
     #endif
3473
   }
3481
   }
3474
-  CurrentMenu->Draw();
3482
+  CurrentMenu->draw();
3475
 }
3483
 }
3476
 
3484
 
3477
 void Draw_MaxSpeed_Menu() {
3485
 void Draw_MaxSpeed_Menu() {
3489
       ADDMENUITEM_P(ICON_MaxSpeedE, GET_TEXT(MSG_MAXSPEED_E), onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[Z_AXIS]);
3497
       ADDMENUITEM_P(ICON_MaxSpeedE, GET_TEXT(MSG_MAXSPEED_E), onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[Z_AXIS]);
3490
     #endif
3498
     #endif
3491
   }
3499
   }
3492
-  CurrentMenu->Draw();
3500
+  CurrentMenu->draw();
3493
 }
3501
 }
3494
 
3502
 
3495
 void Draw_MaxAccel_Menu() {
3503
 void Draw_MaxAccel_Menu() {
3507
       ADDMENUITEM_P(ICON_MaxAccE, GET_TEXT(MSG_AMAX_E), onDrawMaxAccelE, SetMaxAccelE, &planner.settings.max_acceleration_mm_per_s2[E_AXIS]);
3515
       ADDMENUITEM_P(ICON_MaxAccE, GET_TEXT(MSG_AMAX_E), onDrawMaxAccelE, SetMaxAccelE, &planner.settings.max_acceleration_mm_per_s2[E_AXIS]);
3508
     #endif
3516
     #endif
3509
   }
3517
   }
3510
-  CurrentMenu->Draw();
3518
+  CurrentMenu->draw();
3511
 }
3519
 }
3512
 
3520
 
3513
 #if HAS_CLASSIC_JERK
3521
 #if HAS_CLASSIC_JERK
3526
         ADDMENUITEM_P(ICON_MaxSpeedJerkE, GET_TEXT(MSG_VE_JERK), onDrawMaxJerkE, SetMaxJerkE, &planner.max_jerk[E_AXIS]);
3534
         ADDMENUITEM_P(ICON_MaxSpeedJerkE, GET_TEXT(MSG_VE_JERK), onDrawMaxJerkE, SetMaxJerkE, &planner.max_jerk[E_AXIS]);
3527
       #endif
3535
       #endif
3528
     }
3536
     }
3529
-    CurrentMenu->Draw();
3537
+    CurrentMenu->draw();
3530
   }
3538
   }
3531
 #endif
3539
 #endif
3532
 
3540
 
3545
       ADDMENUITEM_P(ICON_StepE, GET_TEXT(MSG_E_STEPS), onDrawStepsE, SetStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]);
3553
       ADDMENUITEM_P(ICON_StepE, GET_TEXT(MSG_E_STEPS), onDrawStepsE, SetStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]);
3546
     #endif
3554
     #endif
3547
   }
3555
   }
3548
-  CurrentMenu->Draw();
3556
+  CurrentMenu->draw();
3549
 }
3557
 }
3550
 
3558
 
3551
 #if HAS_HOTEND
3559
 #if HAS_HOTEND
3567
         ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom);
3575
         ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom);
3568
       #endif
3576
       #endif
3569
     }
3577
     }
3570
-    CurrentMenu->Draw();
3578
+    CurrentMenu->draw();
3571
   }
3579
   }
3572
 #endif
3580
 #endif
3573
 
3581
 
3590
         ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom);
3598
         ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom);
3591
       #endif
3599
       #endif
3592
     }
3600
     }
3593
-    CurrentMenu->Draw();
3601
+    CurrentMenu->draw();
3594
   }
3602
   }
3595
 #endif
3603
 #endif
3596
 
3604
 
3607
       ADDMENUITEM(ICON_MoveZ0, F("Move Z to Home"), onDrawMenuItem, SetMoveZto0);
3615
       ADDMENUITEM(ICON_MoveZ0, F("Move Z to Home"), onDrawMenuItem, SetMoveZto0);
3608
       ADDMENUITEM_P(ICON_Zoffset, GET_TEXT(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR);
3616
       ADDMENUITEM_P(ICON_Zoffset, GET_TEXT(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR);
3609
     }
3617
     }
3610
-    CurrentMenu->Draw();
3618
+    CurrentMenu->draw();
3611
     if (!axis_is_trusted(Z_AXIS)) ui.set_status_P(PSTR("WARNING: Z position is unknow, move Z to home"));
3619
     if (!axis_is_trusted(Z_AXIS)) ui.set_status_P(PSTR("WARNING: Z position is unknow, move Z to home"));
3612
   }
3620
   }
3613
 #endif
3621
 #endif

+ 48
- 26
Marlin/src/lcd/e3v2/enhanced/dwin.h 查看文件

1
 /**
1
 /**
2
- * DWIN UI Enhanced implementation
3
- * Author: Miguel A. Risco-Castillo
4
- * Version: 3.6.1
5
- * Date: 2021/08/29
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
6
  *
7
  *
7
  * This program is free software: you can redistribute it and/or modify
8
  * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as
9
- * published by the Free Software Foundation, either version 3 of the License, or
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
10
  * (at your option) any later version.
11
  * (at your option) any later version.
11
  *
12
  *
12
  * This program is distributed in the hope that it will be useful,
13
  * This program is distributed in the hope that it will be useful,
14
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * GNU General Public License for more details.
16
  * GNU General Public License for more details.
16
  *
17
  *
17
- * You should have received a copy of the GNU Lesser General Public License
18
+ * You should have received a copy of the GNU General Public License
18
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  *
20
  *
20
  */
21
  */
21
 #pragma once
22
 #pragma once
22
 
23
 
24
+/**
25
+ * DWIN UI Enhanced implementation
26
+ * Author: Miguel A. Risco-Castillo
27
+ * Version: 3.6.3
28
+ * Date: 2021/09/08
29
+ */
30
+
23
 #include "../../../inc/MarlinConfigPre.h"
31
 #include "../../../inc/MarlinConfigPre.h"
24
 #include "dwinui.h"
32
 #include "dwinui.h"
25
-#include "rotary_encoder.h"
33
+#include "../common/encoder.h"
26
 #include "../../../libs/BL24CXX.h"
34
 #include "../../../libs/BL24CXX.h"
27
 
35
 
28
 #if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN) && PREHEAT_COUNT
36
 #if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN) && PREHEAT_COUNT
79
   PID_DONE
87
   PID_DONE
80
 };
88
 };
81
 
89
 
82
-// Picture ID
83
-#define Start_Process       0
84
-#define Language_English    1
85
-#define Language_Chinese    2
86
-
87
 #define DWIN_CHINESE 123
90
 #define DWIN_CHINESE 123
88
 #define DWIN_ENGLISH 0
91
 #define DWIN_ENGLISH 0
89
 
92
 
120
   uint16_t Barfill_Color    = Def_Barfill_Color;
123
   uint16_t Barfill_Color    = Def_Barfill_Color;
121
   uint16_t Indicator_Color  = Def_Indicator_Color;
124
   uint16_t Indicator_Color  = Def_Indicator_Color;
122
   uint16_t Coordinate_Color = Def_Coordinate_Color;
125
   uint16_t Coordinate_Color = Def_Coordinate_Color;
123
-  TERN_(HAS_HOTEND, int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND);
124
-  TERN_(HAS_HOTEND, int16_t PidCycles = 10);
126
+  #if HAS_HOTEND
127
+    int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND;
128
+    int16_t PidCycles = 10;
129
+  #endif
125
   #ifdef PREHEAT_1_TEMP_BED
130
   #ifdef PREHEAT_1_TEMP_BED
126
     int16_t BedPidT = PREHEAT_1_TEMP_BED;
131
     int16_t BedPidT = PREHEAT_1_TEMP_BED;
127
   #endif
132
   #endif
128
-  TERN_(PREVENT_COLD_EXTRUSION, int16_t ExtMinT = EXTRUDE_MINTEMP);
133
+  #if ENABLED(PREVENT_COLD_EXTRUSION)
134
+    int16_t ExtMinT = EXTRUDE_MINTEMP;
135
+  #endif
129
 } HMI_data_t;
136
 } HMI_data_t;
130
 
137
 
131
 typedef struct {
138
 typedef struct {
150
 #if HAS_HOTEND || HAS_HEATED_BED
157
 #if HAS_HOTEND || HAS_HEATED_BED
151
   void DWIN_Popup_Temperature(const bool toohigh);
158
   void DWIN_Popup_Temperature(const bool toohigh);
152
 #endif
159
 #endif
153
-TERN_(HAS_HOTEND, void Popup_Window_ETempTooLow());
160
+#if HAS_HOTEND
161
+  void Popup_Window_ETempTooLow();
162
+#endif
154
 void Popup_Window_Resume();
163
 void Popup_Window_Resume();
155
 
164
 
156
 // SD Card
165
 // SD Card
179
 void EachMomentUpdate();
188
 void EachMomentUpdate();
180
 void update_variable();
189
 void update_variable();
181
 void DWIN_HandleScreen();
190
 void DWIN_HandleScreen();
182
-void DWIN_Startup();
183
 void DWIN_Update();
191
 void DWIN_Update();
184
 void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text);
192
 void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text);
185
 void DWIN_StatusChanged(const char * const text);
193
 void DWIN_StatusChanged(const char * const text);
229
 void Draw_Prepare_Menu();
237
 void Draw_Prepare_Menu();
230
 void Draw_Move_Menu();
238
 void Draw_Move_Menu();
231
 void Draw_LevBedCorners_Menu();
239
 void Draw_LevBedCorners_Menu();
232
-TERN_(HAS_HOME_OFFSET, void Draw_HomeOffset_Menu());
233
-TERN_(HAS_BED_PROBE, void Draw_ProbeSet_Menu());
234
-TERN_(HAS_FILAMENT_SENSOR, void Draw_FilSet_Menu());
240
+#if HAS_HOME_OFFSET
241
+  void Draw_HomeOffset_Menu();
242
+#endif
243
+#if HAS_BED_PROBE
244
+  void Draw_ProbeSet_Menu();
245
+#endif
246
+#if HAS_FILAMENT_SENSOR
247
+  void Draw_FilSet_Menu();
248
+#endif
235
 void Draw_SelectColors_Menu();
249
 void Draw_SelectColors_Menu();
236
 void Draw_GetColor_Menu();
250
 void Draw_GetColor_Menu();
237
 void Draw_Tune_Menu();
251
 void Draw_Tune_Menu();
238
 void Draw_Motion_Menu();
252
 void Draw_Motion_Menu();
239
-TERN_(ADVANCED_PAUSE_FEATURE, void Draw_FilamentMan_Menu());
240
-TERN_(MESH_BED_LEVELING, void Draw_ManualMesh_Menu());
253
+#if ENABLED(ADVANCED_PAUSE_FEATURE)
254
+  void Draw_FilamentMan_Menu();
255
+#endif
256
+#if ENABLED(MESH_BED_LEVELING)
257
+  void Draw_ManualMesh_Menu();
258
+#endif
241
 #if HAS_HOTEND
259
 #if HAS_HOTEND
242
   void Draw_Preheat1_Menu();
260
   void Draw_Preheat1_Menu();
243
   void Draw_Preheat2_Menu();
261
   void Draw_Preheat2_Menu();
244
   void Draw_Preheat3_Menu();
262
   void Draw_Preheat3_Menu();
263
+  void Draw_HotendPID_Menu();
245
 #endif
264
 #endif
246
 void Draw_Temperature_Menu();
265
 void Draw_Temperature_Menu();
247
 void Draw_MaxSpeed_Menu();
266
 void Draw_MaxSpeed_Menu();
248
 void Draw_MaxAccel_Menu();
267
 void Draw_MaxAccel_Menu();
249
-TERN_(HAS_CLASSIC_JERK, void Draw_MaxJerk_Menu());
268
+#if HAS_CLASSIC_JERK
269
+  void Draw_MaxJerk_Menu();
270
+#endif
250
 void Draw_Steps_Menu();
271
 void Draw_Steps_Menu();
251
-TERN_(HAS_HOTEND, void Draw_HotendPID_Menu());
252
-TERN_(HAS_HEATED_BED, void Draw_BedPID_Menu());
272
+#if HAS_HEATED_BED
273
+  void Draw_BedPID_Menu();
274
+#endif
253
 #if EITHER(HAS_BED_PROBE, BABYSTEPPING)
275
 #if EITHER(HAS_BED_PROBE, BABYSTEPPING)
254
   void Draw_ZOffsetWiz_Menu();
276
   void Draw_ZOffsetWiz_Menu();
255
 #endif
277
 #endif

+ 37
- 447
Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp 查看文件

1
 /**
1
 /**
2
- * DWIN UI Enhanced implementation
3
- * Author: Miguel A. Risco-Castillo
4
- * Version: 3.6.1
5
- * Date: 2021/08/29
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
6
  *
7
  *
7
  * This program is free software: you can redistribute it and/or modify
8
  * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as
9
- * published by the Free Software Foundation, either version 3 of the License, or
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
10
  * (at your option) any later version.
11
  * (at your option) any later version.
11
  *
12
  *
12
  * This program is distributed in the hope that it will be useful,
13
  * This program is distributed in the hope that it will be useful,
14
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * GNU General Public License for more details.
16
  * GNU General Public License for more details.
16
  *
17
  *
17
- * You should have received a copy of the GNU Lesser General Public License
18
+ * You should have received a copy of the GNU General Public License
18
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  *
20
  *
20
  */
21
  */
21
 
22
 
22
-/********************************************************************************
23
- * @file     lcd/e3v2/enhanced/dwin_lcd.cpp
24
- * @author   LEO / Creality3D - Enhanced by Miguel A. Risco-Castillo
25
- * @date     2021/09/08
26
- * @version  2.2.1
27
- * @brief    DWIN screen control functions
28
- ********************************************************************************/
23
+/**
24
+ * DWIN UI Enhanced implementation
25
+ * Author: Miguel A. Risco-Castillo
26
+ * Version: 3.6.3
27
+ * Date: 2021/09/08
28
+ */
29
 
29
 
30
 #include "../../../inc/MarlinConfigPre.h"
30
 #include "../../../inc/MarlinConfigPre.h"
31
 
31
 
34
 #include "../../../inc/MarlinConfig.h"
34
 #include "../../../inc/MarlinConfig.h"
35
 
35
 
36
 #include "dwin_lcd.h"
36
 #include "dwin_lcd.h"
37
-#include <string.h> // for memset
38
-
39
-//#define DEBUG_OUT 1
40
-#include "../../../core/debug_out.h"
41
-
42
-// Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail.
43
-// Assume the narrowest (6 pixel) font and 2-byte gb2312-encoded characters.
44
-uint8_t DWIN_SendBuf[11 + DWIN_DataLength] = { 0xAA };
45
-uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C };
46
-uint8_t databuf[26] = { 0 };
47
-uint8_t receivedType;
48
-
49
-int recnum = 0;
50
-
51
-inline void DWIN_Byte(size_t &i, const uint16_t bval) {
52
-  DWIN_SendBuf[++i] = bval;
53
-}
54
-
55
-inline void DWIN_Word(size_t &i, const uint16_t wval) {
56
-  DWIN_SendBuf[++i] = wval >> 8;
57
-  DWIN_SendBuf[++i] = wval & 0xFF;
58
-}
59
-
60
-inline void DWIN_Long(size_t &i, const uint32_t lval) {
61
-  DWIN_SendBuf[++i] = (lval >> 24) & 0xFF;
62
-  DWIN_SendBuf[++i] = (lval >> 16) & 0xFF;
63
-  DWIN_SendBuf[++i] = (lval >>  8) & 0xFF;
64
-  DWIN_SendBuf[++i] = lval & 0xFF;
65
-}
66
-
67
-inline void DWIN_String(size_t &i, const char * const string, uint16_t rlimit = 0xFFFF) {
68
-  if (!string) return;
69
-  const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, _MIN(strlen(string), rlimit));
70
-  if (len == 0) return;
71
-  memcpy(&DWIN_SendBuf[i+1], string, len);
72
-  i += len;
73
-}
74
-
75
-inline void DWIN_String(size_t &i, const __FlashStringHelper * string, uint16_t rlimit = 0xFFFF) {
76
-  if (!string) return;
77
-  const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, _MIN(rlimit, strlen_P((PGM_P)string))); // cast it to PGM_P, which is basically const char *, and measure it using the _P version of strlen.
78
-  if (len == 0) return;
79
-  memcpy(&DWIN_SendBuf[i+1], string, len);
80
-  i += len;
81
-}
82
-
83
-// Send the data in the buffer and the packet end
84
-inline void DWIN_Send(size_t &i) {
85
-  ++i;
86
-  LOOP_L_N(n, i) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
87
-  LOOP_L_N(n, 4) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); }
88
-}
89
-
90
-/*-------------------------------------- System variable function --------------------------------------*/
91
-
92
-// Handshake (1: Success, 0: Fail)
93
-bool DWIN_Handshake(void) {
94
-  #ifndef LCD_BAUDRATE
95
-    #define LCD_BAUDRATE 115200
96
-  #endif
97
-  LCD_SERIAL.begin(LCD_BAUDRATE);
98
-  const millis_t serial_connect_timeout = millis() + 1000UL;
99
-  while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
100
-
101
-  size_t i = 0;
102
-  DWIN_Byte(i, 0x00);
103
-  DWIN_Send(i);
104
-
105
-  while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) {
106
-    databuf[recnum] = LCD_SERIAL.read();
107
-    // ignore the invalid data
108
-    if (databuf[0] != FHONE) { // prevent the program from running.
109
-      if (recnum > 0) {
110
-        recnum = 0;
111
-        ZERO(databuf);
112
-      }
113
-      continue;
114
-    }
115
-    delay(10);
116
-    recnum++;
117
-  }
118
-
119
-  return ( recnum >= 3
120
-        && databuf[0] == FHONE
121
-        && databuf[1] == '\0'
122
-        && databuf[2] == 'O'
123
-        && databuf[3] == 'K' );
124
-}
125
-
126
-// Set screen display direction
127
-//  dir: 0=0°, 1=90°, 2=180°, 3=270°
128
-void DWIN_Frame_SetDir(uint8_t dir) {
129
-  size_t i = 0;
130
-  DWIN_Byte(i, 0x34);
131
-  DWIN_Byte(i, 0x5A);
132
-  DWIN_Byte(i, 0xA5);
133
-  DWIN_Byte(i, dir);
134
-  DWIN_Send(i);
135
-}
136
-
137
-// Update display
138
-void DWIN_UpdateLCD(void) {
139
-  size_t i = 0;
140
-  DWIN_Byte(i, 0x3D);
141
-  DWIN_Send(i);
142
-}
143
-
144
-/*---------------------------------------- Drawing functions ----------------------------------------*/
145
-
146
-// Clear screen
147
-//  color: Clear screen color
148
-void DWIN_Frame_Clear(const uint16_t color) {
149
-  size_t i = 0;
150
-  DWIN_Byte(i, 0x01);
151
-  DWIN_Word(i, color);
152
-  DWIN_Send(i);
153
-}
154
-
155
-// Draw a point
156
-//  color: point color
157
-//  width: point width   0x01-0x0F
158
-//  height: point height 0x01-0x0F
159
-//  x,y: upper left point
160
-void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y) {
161
-  size_t i = 0;
162
-  DWIN_Byte(i, 0x02);
163
-  DWIN_Word(i, color);
164
-  DWIN_Byte(i, width);
165
-  DWIN_Byte(i, height);
166
-  DWIN_Word(i, x);
167
-  DWIN_Word(i, y);
168
-  DWIN_Send(i);
169
-}
170
-
171
-// Draw a line
172
-//  color: Line segment color
173
-//  xStart/yStart: Start point
174
-//  xEnd/yEnd: End point
175
-void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
176
-  size_t i = 0;
177
-  DWIN_Byte(i, 0x03);
178
-  DWIN_Word(i, color);
179
-  DWIN_Word(i, xStart);
180
-  DWIN_Word(i, yStart);
181
-  DWIN_Word(i, xEnd);
182
-  DWIN_Word(i, yEnd);
183
-  DWIN_Send(i);
184
-}
185
-
186
-// Draw a rectangle
187
-//  mode: 0=frame, 1=fill, 2=XOR fill
188
-//  color: Rectangle color
189
-//  xStart/yStart: upper left point
190
-//  xEnd/yEnd: lower right point
191
-void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
192
-                         uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
193
-  size_t i = 0;
194
-  DWIN_Byte(i, 0x05);
195
-  DWIN_Byte(i, mode);
196
-  DWIN_Word(i, color);
197
-  DWIN_Word(i, xStart);
198
-  DWIN_Word(i, yStart);
199
-  DWIN_Word(i, xEnd);
200
-  DWIN_Word(i, yEnd);
201
-  DWIN_Send(i);
202
-}
203
-
204
-// Move a screen area
205
-//  mode: 0, circle shift; 1, translation
206
-//  dir: 0=left, 1=right, 2=up, 3=down
207
-//  dis: Distance
208
-//  color: Fill color
209
-//  xStart/yStart: upper left point
210
-//  xEnd/yEnd: bottom right point
211
-void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
212
-                         uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
213
-  size_t i = 0;
214
-  DWIN_Byte(i, 0x09);
215
-  DWIN_Byte(i, (mode << 7) | dir);
216
-  DWIN_Word(i, dis);
217
-  DWIN_Word(i, color);
218
-  DWIN_Word(i, xStart);
219
-  DWIN_Word(i, yStart);
220
-  DWIN_Word(i, xEnd);
221
-  DWIN_Word(i, yEnd);
222
-  DWIN_Send(i);
223
-}
224
-
225
-/*---------------------------------------- Text related functions ----------------------------------------*/
226
-
227
-// Draw a string
228
-//  widthAdjust: true=self-adjust character width; false=no adjustment
229
-//  bShow: true=display background color; false=don't display background color
230
-//  size: Font size
231
-//  color: Character color
232
-//  bColor: Background color
233
-//  x/y: Upper-left coordinate of the string
234
-//  *string: The string
235
-//  rlimit: For draw less chars than string length use rlimit
236
-void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit) {
237
-  size_t i = 0;
238
-  DWIN_Byte(i, 0x11);
239
-  // Bit 7: widthAdjust
240
-  // Bit 6: bShow
241
-  // Bit 5-4: Unused (0)
242
-  // Bit 3-0: size
243
-  DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size);
244
-  DWIN_Word(i, color);
245
-  DWIN_Word(i, bColor);
246
-  DWIN_Word(i, x);
247
-  DWIN_Word(i, y);
248
-  DWIN_String(i, string, rlimit);
249
-  DWIN_Send(i);
250
-}
251
-
252
-// Draw a positive integer
253
-//  bShow: true=display background color; false=don't display background color
254
-//  zeroFill: true=zero fill; false=no zero fill
255
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
256
-//  size: Font size
257
-//  color: Character color
258
-//  bColor: Background color
259
-//  iNum: Number of digits
260
-//  x/y: Upper-left coordinate
261
-//  value: Integer value
262
-void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
263
-                          uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
264
-  size_t i = 0;
265
-  DWIN_Byte(i, 0x14);
266
-  // Bit 7: bshow
267
-  // Bit 6: 1 = signed; 0 = unsigned number;
268
-  // Bit 5: zeroFill
269
-  // Bit 4: zeroMode
270
-  // Bit 3-0: size
271
-  DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
272
-  DWIN_Word(i, color);
273
-  DWIN_Word(i, bColor);
274
-  DWIN_Byte(i, iNum);
275
-  DWIN_Byte(i, 0); // fNum
276
-  DWIN_Word(i, x);
277
-  DWIN_Word(i, y);
278
-  #if 0
279
-    for (char count = 0; count < 8; count++) {
280
-      DWIN_Byte(i, value);
281
-      value >>= 8;
282
-      if (!(value & 0xFF)) break;
283
-    }
284
-  #else
285
-    // Write a big-endian 64 bit integer
286
-    const size_t p = i + 1;
287
-    for (char count = 8; count--;) { // 7..0
288
-      ++i;
289
-      DWIN_SendBuf[p + count] = value;
290
-      value >>= 8;
291
-    }
292
-  #endif
293
-
294
-  DWIN_Send(i);
295
-}
296
-
297
-// Draw a positive floating point number
298
-//  bShow: true=display background color; false=don't display background color
299
-//  zeroFill: true=zero fill; false=no zero fill
300
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
301
-//  size: Font size
302
-//  color: Character color
303
-//  bColor: Background color
304
-//  iNum: Number of whole digits
305
-//  fNum: Number of decimal digits
306
-//  x/y: Upper-left point
307
-//  value: Scaled positive float value
308
-void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
309
-                            uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
310
-  size_t i = 0;
311
-  DWIN_Byte(i, 0x14);
312
-  DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
313
-  DWIN_Word(i, color);
314
-  DWIN_Word(i, bColor);
315
-  DWIN_Byte(i, iNum);
316
-  DWIN_Byte(i, fNum);
317
-  DWIN_Word(i, x);
318
-  DWIN_Word(i, y);
319
-  DWIN_Long(i, value);
320
-  DWIN_Send(i);
321
-}
322
-//  value: positive float value
323
-void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
324
-                            uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
325
-  const long val = round(value * POW(10, fNum));
326
-  DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, val);
327
-}
328
 
37
 
329
 /*---------------------------------------- Picture related functions ----------------------------------------*/
38
 /*---------------------------------------- Picture related functions ----------------------------------------*/
330
 
39
 
339
   DWIN_Word(i, x);
48
   DWIN_Word(i, x);
340
   DWIN_Word(i, y);
49
   DWIN_Word(i, y);
341
   DWIN_Byte(i, QR_Pixel);
50
   DWIN_Byte(i, QR_Pixel);
342
-  DWIN_String(i, string);
343
-  DWIN_Send(i);
344
-}
345
-
346
-// Draw JPG and cached in #0 virtual display area
347
-// id: Picture ID
348
-void DWIN_JPG_ShowAndCache(const uint8_t id) {
349
-  size_t i = 0;
350
-  DWIN_Word(i, 0x2200);
351
-  DWIN_Byte(i, id);
51
+  DWIN_Text(i, string);
352
   DWIN_Send(i);
52
   DWIN_Send(i);
353
 }
53
 }
354
 
54
 
355
-// Draw an Icon
356
-//  IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
357
-//  BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
358
-//  BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
55
+// Draw an Icon with transparent background
359
 //  libID: Icon library ID
56
 //  libID: Icon library ID
360
 //  picID: Icon ID
57
 //  picID: Icon ID
361
 //  x/y: Upper-left point
58
 //  x/y: Upper-left point
362
-void DWIN_ICON_Show(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
363
-  NOMORE(x, DWIN_WIDTH - 1);
364
-  NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
365
-  size_t i = 0;
366
-  DWIN_Byte(i, 0x23);
367
-  DWIN_Word(i, x);
368
-  DWIN_Word(i, y);
369
-  DWIN_Byte(i, IBD%2<<7 | BIR%2<<6 | BFI%2<<5 | libID);
370
-  DWIN_Byte(i, picID);
371
-  DWIN_Send(i);
372
-}
373
-
374
-// Draw an Icon from SRAM
375
-//  IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
376
-//  BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
377
-//  BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
378
-//  x/y: Upper-left point
379
-//  addr: SRAM address
380
-void DWIN_ICON_Show(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint16_t x, uint16_t y, uint16_t addr) {
381
-  NOMORE(x, DWIN_WIDTH - 1);
382
-  NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
383
-  size_t i = 0;
384
-  DWIN_Byte(i, 0x24);
385
-  DWIN_Word(i, x);
386
-  DWIN_Word(i, y);
387
-  DWIN_Byte(i, IBD%2<<7 | BIR%2<<6 | BFI%2<<5 | 0x00);
388
-  DWIN_Word(i, addr);
389
-  DWIN_Send(i);
390
-}
391
-
392
-// Unzip the JPG picture to a virtual display area
393
-//  n: Cache index
394
-//  id: Picture ID
395
-void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
396
-  size_t i = 0;
397
-  DWIN_Byte(i, 0x25);
398
-  DWIN_Byte(i, n);
399
-  DWIN_Byte(i, id);
400
-  DWIN_Send(i);
59
+void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
60
+  DWIN_ICON_Show(false, false, true, libID, picID, x, y);
401
 }
61
 }
402
 
62
 
403
 // Copy area from current virtual display area to current screen
63
 // Copy area from current virtual display area to current screen
404
 //  xStart/yStart: Upper-left of virtual area
64
 //  xStart/yStart: Upper-left of virtual area
405
 //  xEnd/yEnd: Lower-right of virtual area
65
 //  xEnd/yEnd: Lower-right of virtual area
406
 //  x/y: Screen paste point
66
 //  x/y: Screen paste point
407
-void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart,
408
-                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
67
+void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
409
   size_t i = 0;
68
   size_t i = 0;
410
   DWIN_Byte(i, 0x26);
69
   DWIN_Byte(i, 0x26);
411
   DWIN_Word(i, xStart);
70
   DWIN_Word(i, xStart);
425
 //  xStart/yStart: Upper-left of virtual area
84
 //  xStart/yStart: Upper-left of virtual area
426
 //  xEnd/yEnd: Lower-right of virtual area
85
 //  xEnd/yEnd: Lower-right of virtual area
427
 //  x/y: Screen paste point
86
 //  x/y: Screen paste point
428
-void DWIN_Frame_AreaCopy(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint8_t cacheID, uint16_t xStart, uint16_t yStart,
429
-                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
87
+void DWIN_Frame_AreaCopy(bool IBD, bool BIR, bool BFI, uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
430
   size_t i = 0;
88
   size_t i = 0;
431
   DWIN_Byte(i, 0x27);
89
   DWIN_Byte(i, 0x27);
432
-  DWIN_Byte(i, IBD%2<<7 | BIR%2<<6 | BFI%2<<5 | cacheID);
90
+  DWIN_Byte(i, (IBD & 1) << 7 | (BIR & 1) << 6 | (BFI & 1) << 5 | cacheID);
433
   DWIN_Word(i, xStart);
91
   DWIN_Word(i, xStart);
434
   DWIN_Word(i, yStart);
92
   DWIN_Word(i, yStart);
435
   DWIN_Word(i, xEnd);
93
   DWIN_Word(i, xEnd);
439
   DWIN_Send(i);
97
   DWIN_Send(i);
440
 }
98
 }
441
 
99
 
442
-// Animate a series of icons
443
-//  animID: Animation ID; 0x00-0x0F
444
-//  animate: true on; false off;
445
-//  libID: Icon library ID
446
-//  picIDs: Icon starting ID
447
-//  picIDe: Icon ending ID
448
-//  x/y: Upper-left point
449
-//  interval: Display time interval, unit 10mS
450
-void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval) {
451
-  NOMORE(x, DWIN_WIDTH - 1);
452
-  NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
453
-  size_t i = 0;
454
-  DWIN_Byte(i, 0x28);
455
-  DWIN_Word(i, x);
456
-  DWIN_Word(i, y);
457
-  // Bit 7: animation on or off
458
-  // Bit 6: start from begin or end
459
-  // Bit 5-4: unused (0)
460
-  // Bit 3-0: animID
461
-  DWIN_Byte(i, (animate * 0x80) | 0x40 | animID);
462
-  DWIN_Byte(i, libID);
463
-  DWIN_Byte(i, picIDs);
464
-  DWIN_Byte(i, picIDe);
465
-  DWIN_Byte(i, interval);
466
-  DWIN_Send(i);
467
-}
468
-
469
-// Animation Control
470
-//  state: 16 bits, each bit is the state of an animation id
471
-void DWIN_ICON_AnimationControl(uint16_t state) {
472
-  size_t i = 0;
473
-  DWIN_Byte(i, 0x29);
474
-  DWIN_Word(i, state);
475
-  DWIN_Send(i);
476
-}
477
-
478
-// Set LCD Brightness 0x00-0xFF
479
-void DWIN_LCD_Brightness(const uint8_t brightness) {
480
-  size_t i = 0;
481
-  DWIN_Byte(i, 0x30);
482
-  DWIN_Byte(i, brightness);
483
-  DWIN_Send(i);
100
+// Copy area from virtual display area to current screen with transparent background
101
+//  cacheID: virtual area number
102
+//  xStart/yStart: Upper-left of virtual area
103
+//  xEnd/yEnd: Lower-right of virtual area
104
+//  x/y: Screen paste point
105
+void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
106
+  DWIN_Frame_AreaCopy(false, false, true, cacheID, xStart, yStart, xEnd, yEnd, x, y);
484
 }
107
 }
485
 
108
 
486
 // Write buffer data to the SRAM or Flash
109
 // Write buffer data to the SRAM or Flash
524
 
147
 
525
 //--------------------------Test area -------------------------
148
 //--------------------------Test area -------------------------
526
 
149
 
527
-// void DWIN_ReadSRAM(uint16_t addr, uint8_t length, const char * const data) {
528
-//   size_t i = 0;
529
-//   DWIN_Byte(i, 0x32);
530
-//   DWIN_Byte(i, 0x5A);  // 0x5A Read from SRAM - 0xA5 Read from Flash
531
-//   DWIN_Word(i, addr);  // 0x0000 to 0x7FFF
532
-//   const size_t len = _MIN(0xF0, length);
533
-//   DWIN_Byte(i, len);
534
-//   DWIN_Send(i);
535
-// }
536
-
537
-/*---------------------------------------- Memory functions ----------------------------------------*/
538
-// The LCD has an additional 32KB SRAM and 16KB Flash
539
-
540
-// Data can be written to the sram and save to one of the jpeg page files
541
-
542
-// Write Data Memory
543
-//  command 0x31
544
-//  Type: Write memory selection; 0x5A=SRAM; 0xA5=Flash
545
-//  Address: Write data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
546
-//  Data: data
547
-//
548
-//  Flash writing returns 0xA5 0x4F 0x4B
549
-
550
-// Read Data Memory
551
-//  command 0x32
552
-//  Type: Read memory selection; 0x5A=SRAM; 0xA5=Flash
553
-//  Address: Read data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
554
-//  Length: leangth of data to read; 0x01-0xF0
555
-//
556
-//  Response:
557
-//    Type, Address, Length, Data
558
-
559
-// Write Picture Memory
560
-//  Write the contents of the 32KB SRAM data memory into the designated image memory space
561
-//  Issued: 0x5A, 0xA5, PIC_ID
562
-//  Response: 0xA5 0x4F 0x4B
563
-//
564
-//  command 0x33
565
-//  0x5A, 0xA5
566
-//  PicId: Picture Memory location, 0x00-0x0F
567
-//
568
-//  Flash writing returns 0xA5 0x4F 0x4B
150
+//void DWIN_ReadSRAM(uint16_t addr, uint8_t length, const char * const data) {
151
+//  size_t i = 0;
152
+//  DWIN_Byte(i, 0x32);
153
+//  DWIN_Byte(i, 0x5A);  // 0x5A Read from SRAM - 0xA5 Read from Flash
154
+//  DWIN_Word(i, addr);  // 0x0000 to 0x7FFF
155
+//  const size_t len = _MIN(0xF0, length);
156
+//  DWIN_Byte(i, len);
157
+//  DWIN_Send(i);
158
+//}
569
 
159
 
570
 #endif // DWIN_CREALITY_LCD_ENHANCED
160
 #endif // DWIN_CREALITY_LCD_ENHANCED

+ 29
- 231
Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h 查看文件

1
 /**
1
 /**
2
- * DWIN UI Enhanced implementation
3
- * Author: Miguel A. Risco-Castillo
4
- * Version: 3.6.1
5
- * Date: 2021/08/29
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
6
  *
7
  *
7
  * This program is free software: you can redistribute it and/or modify
8
  * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as
9
- * published by the Free Software Foundation, either version 3 of the License, or
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
10
  * (at your option) any later version.
11
  * (at your option) any later version.
11
  *
12
  *
12
  * This program is distributed in the hope that it will be useful,
13
  * This program is distributed in the hope that it will be useful,
14
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * GNU General Public License for more details.
16
  * GNU General Public License for more details.
16
  *
17
  *
17
- * You should have received a copy of the GNU Lesser General Public License
18
+ * You should have received a copy of the GNU General Public License
18
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  *
20
  *
20
  */
21
  */
21
-
22
-/********************************************************************************
23
- * @file     lcd/e3v2/enhanced/dwin_lcd.h
24
- * @author   LEO / Creality3D - Enhanced by Miguel A. Risco-Castillo
25
- * @date     2021/08/09
26
- * @version  2.2.1
27
- * @brief    DWIN screen control functions
28
- ********************************************************************************/
29
-
30
 #pragma once
22
 #pragma once
31
 
23
 
32
-#include <stdint.h>
33
-
34
-#define RECEIVED_NO_DATA         0x00
35
-#define RECEIVED_SHAKE_HAND_ACK  0x01
36
-
37
-#define FHONE                    0xAA
38
-
39
-#define DWIN_SCROLL_UP   2
40
-#define DWIN_SCROLL_DOWN 3
41
-
42
-#define DWIN_WIDTH  272
43
-#define DWIN_HEIGHT 480
44
-
45
-#define DWIN_DataLength (DWIN_WIDTH / 6 * 2)
46
-
47
-/*-------------------------------------- System variable function --------------------------------------*/
48
-
49
-// Handshake (1: Success, 0: Fail)
50
-bool DWIN_Handshake(void);
51
-
52
-// Set the backlight luminance
53
-//  luminance: (0x00-0xFF)
54
-void DWIN_Backlight_SetLuminance(const uint8_t luminance);
55
-
56
-// Set screen display direction
57
-//  dir: 0=0°, 1=90°, 2=180°, 3=270°
58
-void DWIN_Frame_SetDir(uint8_t dir);
59
-
60
-// Update display
61
-void DWIN_UpdateLCD(void);
62
-
63
-/*---------------------------------------- Drawing functions ----------------------------------------*/
64
-
65
-// Clear screen
66
-//  color: Clear screen color
67
-void DWIN_Frame_Clear(const uint16_t color);
68
-
69
-// Draw a point
70
-//  color: point color
71
-//  width: point width   0x01-0x0F
72
-//  height: point height 0x01-0x0F
73
-//  x,y: upper left point
74
-void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y);
75
-
76
-// Draw a line
77
-//  color: Line segment color
78
-//  xStart/yStart: Start point
79
-//  xEnd/yEnd: End point
80
-void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
81
-
82
-// Draw a Horizontal line
83
-//  color: Line segment color
84
-//  xStart/yStart: Start point
85
-//  xLength: Line Length
86
-inline void DWIN_Draw_HLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xLength) {
87
-  DWIN_Draw_Line(color, xStart, yStart, xStart + xLength - 1, yStart);
88
-}
89
-
90
-// Draw a Vertical line
91
-//  color: Line segment color
92
-//  xStart/yStart: Start point
93
-//  yLength: Line Length
94
-inline void DWIN_Draw_VLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t yLength) {
95
-  DWIN_Draw_Line(color, xStart, yStart, xStart, yStart + yLength - 1);
96
-}
97
-
98
-// Draw a rectangle
99
-//  mode: 0=frame, 1=fill, 2=XOR fill
100
-//  color: Rectangle color
101
-//  xStart/yStart: upper left point
102
-//  xEnd/yEnd: lower right point
103
-void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,  uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
104
-
105
-// Draw a box
106
-//  mode: 0=frame, 1=fill, 2=XOR fill
107
-//  color: Rectangle color
108
-//  xStart/yStart: upper left point
109
-//  xSize/ySize: box size
110
-inline void DWIN_Draw_Box(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xSize, uint16_t ySize) {
111
-  DWIN_Draw_Rectangle(mode, color, xStart, yStart, xStart + xSize - 1, yStart + ySize - 1);
112
-}
113
-
114
-// Move a screen area
115
-//  mode: 0, circle shift; 1, translation
116
-//  dir: 0=left, 1=right, 2=up, 3=down
117
-//  dis: Distance
118
-//  color: Fill color
119
-//  xStart/yStart: upper left point
120
-//  xEnd/yEnd: bottom right point
121
-void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
122
-                         uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
123
-
124
-/*---------------------------------------- Text related functions ----------------------------------------*/
125
-
126
-// Draw a string
127
-//  widthAdjust: true=self-adjust character width; false=no adjustment
128
-//  bShow: true=display background color; false=don't display background color
129
-//  size: Font size
130
-//  color: Character color
131
-//  bColor: Background color
132
-//  x/y: Upper-left coordinate of the string
133
-//  *string: The string
134
-//  rlimit: For draw less chars than string length use rlimit
135
-void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit = 0xFFFF);
136
-inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit = 0xFFFF) {
137
-  DWIN_Draw_String(0, bShow, size, color, bColor, x, y, string, rlimit);
138
-}
139
-
140
-class __FlashStringHelper;
141
-
142
-inline void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
143
-  DWIN_Draw_String(widthAdjust, bShow, size, color, bColor, x, y, (char *)title);
144
-}
145
-inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
146
-  DWIN_Draw_String(0, bShow, size, color, bColor, x, y, (char *)title);
147
-}
148
-
149
-// Draw a positive integer
150
-//  bShow: true=display background color; false=don't display background color
151
-//  zeroFill: true=zero fill; false=no zero fill
152
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
153
-//  size: Font size
154
-//  color: Character color
155
-//  bColor: Background color
156
-//  iNum: Number of digits
157
-//  x/y: Upper-left coordinate
158
-//  value: Integer value
159
-void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
160
-                          uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value);
161
-
162
-// Draw a positive floating point number
163
-//  bShow: true=display background color; false=don't display background color
164
-//  zeroFill: true=zero fill; false=no zero fill
165
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
166
-//  size: Font size
167
-//  color: Character color
168
-//  bColor: Background color
169
-//  iNum: Number of whole digits
170
-//  fNum: Number of decimal digits
171
-//  x/y: Upper-left point
172
-//  value: Scaled positive float value
173
-void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
174
-                            uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
175
-//  value: positive float value
176
-void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
177
-                            uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
24
+/**
25
+ * DWIN UI Enhanced implementation
26
+ * Author: Miguel A. Risco-Castillo
27
+ * Version: 3.6.3
28
+ * Date: 2021/09/08
29
+ */
178
 
30
 
179
-/*---------------------------------------- Picture related functions ----------------------------------------*/
31
+#include "../common/dwin_api.h"
180
 
32
 
181
 // Display QR code
33
 // Display QR code
182
 //  The size of the QR code is (46*QR_Pixel)*(46*QR_Pixel) dot matrix
34
 //  The size of the QR code is (46*QR_Pixel)*(46*QR_Pixel) dot matrix
189
   DWIN_Draw_QR(QR_Pixel, x, y, (char *)title);
41
   DWIN_Draw_QR(QR_Pixel, x, y, (char *)title);
190
 }
42
 }
191
 
43
 
192
-// Draw JPG and cached in #0 virtual display area
193
-// id: Picture ID
194
-void DWIN_JPG_ShowAndCache(const uint8_t id);
195
-
196
-// Draw an Icon
197
-//  IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
198
-//  BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
199
-//  BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
200
-//  libID: Icon library ID
201
-//  picID: Icon ID
202
-//  x/y: Upper-left point
203
-void DWIN_ICON_Show(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint8_t libID, uint8_t picID, uint16_t x, uint16_t y);
204
-
205
-// Draw an Icon with transparent background
206
-//  libID: Icon library ID
207
-//  picID: Icon ID
208
-//  x/y: Upper-left point
209
-inline void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
210
-  DWIN_ICON_Show(0, 0, 1, libID, picID, x, y);
211
-}
212
-
213
-// Draw an Icon from SRAM
214
-//  IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
215
-//  BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
216
-//  BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
217
-//  x/y: Upper-left point
218
-//  addr: SRAM address
219
-void DWIN_ICON_Show(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint16_t x, uint16_t y, uint16_t addr);
220
-
221
-// Unzip the JPG picture to a virtual display area
222
-//  n: Cache index
223
-//  id: Picture ID
224
-void DWIN_JPG_CacheToN(uint8_t n, uint8_t id);
44
+// Copy area from virtual display area to current screen
45
+//  cacheID: virtual area number
46
+//  xStart/yStart: Upper-left of virtual area
47
+//  xEnd/yEnd: Lower-right of virtual area
48
+//  x/y: Screen paste point
49
+void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
225
 
50
 
226
-// Unzip the JPG picture to virtual display area #1
227
-//  id: Picture ID
228
-inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); }
51
+// Copy area from virtual display area to current screen
52
+//  cacheID: virtual area number
53
+//  xStart/yStart: Upper-left of virtual area
54
+//  xEnd/yEnd: Lower-right of virtual area
55
+//  x/y: Screen paste point
56
+void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
229
 
57
 
230
 // Copy area from current virtual display area to current screen
58
 // Copy area from current virtual display area to current screen
231
 //  xStart/yStart: Upper-left of virtual area
59
 //  xStart/yStart: Upper-left of virtual area
232
 //  xEnd/yEnd: Lower-right of virtual area
60
 //  xEnd/yEnd: Lower-right of virtual area
233
 //  x/y: Screen paste point
61
 //  x/y: Screen paste point
234
-void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart,
235
-                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
62
+void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
236
 
63
 
237
 // Copy area from virtual display area to current screen
64
 // Copy area from virtual display area to current screen
238
 //  IBD: background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
65
 //  IBD: background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
242
 //  xStart/yStart: Upper-left of virtual area
69
 //  xStart/yStart: Upper-left of virtual area
243
 //  xEnd/yEnd: Lower-right of virtual area
70
 //  xEnd/yEnd: Lower-right of virtual area
244
 //  x/y: Screen paste point
71
 //  x/y: Screen paste point
245
-void DWIN_Frame_AreaCopy(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint8_t cacheID, uint16_t xStart, uint16_t yStart,
246
-                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
247
-
248
-// Copy area from virtual display area to current screen with transparent background
249
-//  cacheID: virtual area number
250
-//  xStart/yStart: Upper-left of virtual area
251
-//  xEnd/yEnd: Lower-right of virtual area
252
-//  x/y: Screen paste point
253
-inline void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
254
-                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
255
-  DWIN_Frame_AreaCopy(0, 0, 1, cacheID, xStart, yStart, xEnd, yEnd, x, y);
256
-}
257
-
258
-// Animate a series of icons
259
-//  animID: Animation ID  up to 16
260
-//  animate: animation on or off
261
-//  libID: Icon library ID
262
-//  picIDs: Icon starting ID
263
-//  picIDe: Icon ending ID
264
-//  x/y: Upper-left point
265
-//  interval: Display time interval, unit 10mS
266
-void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs,
267
-                         uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval);
268
-
269
-// Animation Control
270
-//  state: 16 bits, each bit is the state of an animation id
271
-void DWIN_ICON_AnimationControl(uint16_t state);
272
-
273
-// Set LCD Brightness 0x00-0x0F
274
-void DWIN_LCD_Brightness(const uint8_t brightness);
72
+void DWIN_Frame_AreaCopy(bool IBD, bool BIR, bool BFI, uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
275
 
73
 
276
 // Write buffer data to the SRAM or Flash
74
 // Write buffer data to the SRAM or Flash
277
 //  mem: 0x5A=32KB SRAM, 0xA5=16KB Flash
75
 //  mem: 0x5A=32KB SRAM, 0xA5=16KB Flash

+ 39
- 37
Marlin/src/lcd/e3v2/enhanced/dwinui.cpp 查看文件

1
 /**
1
 /**
2
- * DWIN UI Enhanced implementation
3
- * Author: Miguel A. Risco-Castillo
4
- * Version: 3.6.3
5
- * Date: 2021/08/09
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
6
  *
7
  *
7
  * This program is free software: you can redistribute it and/or modify
8
  * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as
9
- * published by the Free Software Foundation, either version 3 of the License, or
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
10
  * (at your option) any later version.
11
  * (at your option) any later version.
11
  *
12
  *
12
  * This program is distributed in the hope that it will be useful,
13
  * This program is distributed in the hope that it will be useful,
14
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * GNU General Public License for more details.
16
  * GNU General Public License for more details.
16
  *
17
  *
17
- * You should have received a copy of the GNU Lesser General Public License
18
+ * You should have received a copy of the GNU General Public License
18
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  *
20
  *
20
  */
21
  */
21
 
22
 
23
+/**
24
+ * DWIN UI Enhanced implementation
25
+ * Author: Miguel A. Risco-Castillo
26
+ * Version: 3.6.3
27
+ * Date: 2021/09/08
28
+ */
29
+
22
 #include "../../../inc/MarlinConfigPre.h"
30
 #include "../../../inc/MarlinConfigPre.h"
23
 
31
 
24
 #if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
32
 #if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
48
 void (*DWINUI::onTitleDraw)(TitleClass* title)=nullptr;
56
 void (*DWINUI::onTitleDraw)(TitleClass* title)=nullptr;
49
 void (*DWINUI::onMenuDraw)(MenuClass* menu)=nullptr;
57
 void (*DWINUI::onMenuDraw)(MenuClass* menu)=nullptr;
50
 
58
 
51
-void DWINUI::Init(void) {
59
+void DWINUI::init() {
52
   DEBUG_ECHOPGM("\r\nDWIN handshake ");
60
   DEBUG_ECHOPGM("\r\nDWIN handshake ");
53
   delay(750);   // Delay here or init later in the boot process
61
   delay(750);   // Delay here or init later in the boot process
54
   const bool success = DWIN_Handshake();
62
   const bool success = DWIN_Handshake();
65
 }
73
 }
66
 
74
 
67
 // Set text/number font
75
 // Set text/number font
68
-void DWINUI::SetFont(uint8_t cfont) {
76
+void DWINUI::setFont(uint8_t cfont) {
69
   font = cfont;
77
   font = cfont;
70
 }
78
 }
71
 
79
 
72
 // Get font character width
80
 // Get font character width
73
-uint8_t DWINUI::Get_font_width(uint8_t cfont) {
81
+uint8_t DWINUI::fontWidth(uint8_t cfont) {
74
   switch (cfont) {
82
   switch (cfont) {
75
     case font6x12 : return 6;
83
     case font6x12 : return 6;
76
     case font8x16 : return 8;
84
     case font8x16 : return 8;
87
 }
95
 }
88
 
96
 
89
 // Get font character heigh
97
 // Get font character heigh
90
-uint8_t DWINUI::Get_font_height(uint8_t cfont) {
98
+uint8_t DWINUI::fontHeight(uint8_t cfont) {
91
   switch (cfont) {
99
   switch (cfont) {
92
     case font6x12 : return 12;
100
     case font6x12 : return 12;
93
     case font8x16 : return 16;
101
     case font8x16 : return 16;
105
 
113
 
106
 // Get screen x coodinates from text column
114
 // Get screen x coodinates from text column
107
 uint16_t DWINUI::ColToX(uint8_t col) {
115
 uint16_t DWINUI::ColToX(uint8_t col) {
108
-  return col * Get_font_width(font);
116
+  return col * fontWidth(font);
109
 }
117
 }
110
 
118
 
111
 // Get screen y coodinates from text row
119
 // Get screen y coodinates from text row
112
 uint16_t DWINUI::RowToY(uint8_t row) {
120
 uint16_t DWINUI::RowToY(uint8_t row) {
113
-  return row * Get_font_height(font);
121
+  return row * fontHeight(font);
114
 }
122
 }
115
 
123
 
116
 // Set text/number color
124
 // Set text/number color
151
 
159
 
152
 // Draw a Centered string using DWIN_WIDTH
160
 // Draw a Centered string using DWIN_WIDTH
153
 void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) {
161
 void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) {
154
-  const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(string) * Get_font_width(size)) / 2 - 1;
162
+  const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(string) * fontWidth(size)) / 2 - 1;
155
   DWIN_Draw_String(bShow, size, color, bColor, x, y, string);
163
   DWIN_Draw_String(bShow, size, color, bColor, x, y, string);
156
 }
164
 }
157
 
165
 
159
 void DWINUI::Draw_Char(const char c) {
167
 void DWINUI::Draw_Char(const char c) {
160
   const char string[2] = { c, 0};
168
   const char string[2] = { c, 0};
161
   DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, 1);
169
   DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, 1);
162
-  MoveBy(Get_font_width(font), 0);
170
+  MoveBy(fontWidth(font), 0);
163
 }
171
 }
164
 
172
 
165
 // Draw a string at cursor position
173
 // Draw a string at cursor position
168
 //  rlimit: For draw less chars than string length use rlimit
176
 //  rlimit: For draw less chars than string length use rlimit
169
 void DWINUI::Draw_String(const char * const string, uint16_t rlimit) {
177
 void DWINUI::Draw_String(const char * const string, uint16_t rlimit) {
170
   DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, rlimit);
178
   DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, rlimit);
171
-  MoveBy(strlen(string) * Get_font_width(font), 0);
179
+  MoveBy(strlen(string) * fontWidth(font), 0);
172
 }
180
 }
173
 void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rlimit) {
181
 void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rlimit) {
174
   DWIN_Draw_String(false, font, color, backcolor, cursor.x, cursor.y, string, rlimit);
182
   DWIN_Draw_String(false, font, color, backcolor, cursor.x, cursor.y, string, rlimit);
175
-  MoveBy(strlen(string) * Get_font_width(font), 0);
183
+  MoveBy(strlen(string) * fontWidth(font), 0);
176
 }
184
 }
177
 
185
 
178
 // Draw a signed floating point number
186
 // Draw a signed floating point number
186
 //  x/y: Upper-left point
194
 //  x/y: Upper-left point
187
 //  value: Float value
195
 //  value: Float value
188
 void DWINUI::Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
196
 void DWINUI::Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
189
-  if (value < 0) {
190
-    DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, -value);
191
-    DWIN_Draw_String(bShow, size, color, bColor, x - 6, y, F("-"));
192
-  }
193
-  else {
194
-    DWIN_Draw_String(bShow, size, color, bColor, x - 6, y, F(" "));
195
-    DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value);
196
-  }
197
+  DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value < 0 ? -value : value);
198
+  DWIN_Draw_String(bShow, size, color, bColor, x - 6, y, value < 0 ? F("-") : F(" "));
197
 }
199
 }
198
 
200
 
199
 // Draw a circle
201
 // Draw a circle
239
 // Color Interpolator
241
 // Color Interpolator
240
 //  val : Interpolator minv..maxv
242
 //  val : Interpolator minv..maxv
241
 //  minv : Minimum value
243
 //  minv : Minimum value
242
-//  maxv : Maximun value
244
+//  maxv : Maximum value
243
 //  color1 : Start color
245
 //  color1 : Start color
244
 //  color2 : End color
246
 //  color2 : End color
245
 uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2) {
247
 uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2) {
255
 // Color Interpolator through Red->Yellow->Green->Blue
257
 // Color Interpolator through Red->Yellow->Green->Blue
256
 //  val : Interpolator minv..maxv
258
 //  val : Interpolator minv..maxv
257
 //  minv : Minimum value
259
 //  minv : Minimum value
258
-//  maxv : Maximun value
260
+//  maxv : Maximum value
259
 uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) {
261
 uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) {
260
   uint8_t B,G,R;
262
   uint8_t B,G,R;
261
   const uint8_t maxB = 28;
263
   const uint8_t maxB = 28;
292
 //  x/y: Upper-left point
294
 //  x/y: Upper-left point
293
 //  mode : 0 : unchecked, 1 : checked
295
 //  mode : 0 : unchecked, 1 : checked
294
 void DWINUI::Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked=false) {
296
 void DWINUI::Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked=false) {
295
-  DWIN_Draw_String(false, true, font8x16, color, bcolor, x + 4, y, checked ? F("x") : F(" "));
297
+  DWIN_Draw_String(true, font8x16, color, bcolor, x + 4, y, checked ? F("x") : F(" "));
296
   DWIN_Draw_Rectangle(0, color, x + 2, y + 2, x + 17, y + 17);
298
   DWIN_Draw_Rectangle(0, color, x + 2, y + 2, x + 17, y + 17);
297
 }
299
 }
298
 
300
 
332
 
334
 
333
 TitleClass Title;
335
 TitleClass Title;
334
 
336
 
335
-void TitleClass::Draw() {
337
+void TitleClass::draw() {
336
   if (DWINUI::onTitleDraw != nullptr) (*DWINUI::onTitleDraw)(this);
338
   if (DWINUI::onTitleDraw != nullptr) (*DWINUI::onTitleDraw)(this);
337
 }
339
 }
338
 
340
 
346
 
348
 
347
 void TitleClass::ShowCaption(const char * const title) {
349
 void TitleClass::ShowCaption(const char * const title) {
348
   SetCaption(title);
350
   SetCaption(title);
349
-  Draw();
351
+  draw();
350
 }
352
 }
351
 
353
 
352
 void TitleClass::SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
354
 void TitleClass::SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
361
 
363
 
362
 void TitleClass::FrameCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
364
 void TitleClass::FrameCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
363
   SetFrame(id, x1, y1, x2, y2);
365
   SetFrame(id, x1, y1, x2, y2);
364
-  Draw();
366
+  draw();
365
 }
367
 }
366
 
368
 
367
 void TitleClass::FrameCopy(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
369
 void TitleClass::FrameCopy(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
375
   topline = 0;
377
   topline = 0;
376
 }
378
 }
377
 
379
 
378
-void MenuClass::Draw() {
379
-  MenuTitle.Draw();
380
+void MenuClass::draw() {
381
+  MenuTitle.draw();
380
   if (DWINUI::onMenuDraw != nullptr) (*DWINUI::onMenuDraw)(this);
382
   if (DWINUI::onMenuDraw != nullptr) (*DWINUI::onMenuDraw)(this);
381
   for (uint8_t i = 0; i < MenuItemCount; i++)
383
   for (uint8_t i = 0; i < MenuItemCount; i++)
382
-    MenuItems[i]->Draw(i - topline);
384
+    MenuItems[i]->draw(i - topline);
383
   if (DWINUI::onCursorDraw != nullptr) DWINUI::onCursorDraw(line());
385
   if (DWINUI::onCursorDraw != nullptr) DWINUI::onCursorDraw(line());
384
   DWIN_UpdateLCD();
386
   DWIN_UpdateLCD();
385
 }
387
 }
393
     if ((sel - topline) == TROWS) {
395
     if ((sel - topline) == TROWS) {
394
       DWIN_Frame_AreaMove(1, DWIN_SCROLL_UP, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
396
       DWIN_Frame_AreaMove(1, DWIN_SCROLL_UP, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
395
       topline++;
397
       topline++;
396
-      MenuItems[sel]->Draw(TROWS - 1);
398
+      MenuItems[sel]->draw(TROWS - 1);
397
     }
399
     }
398
     if ((sel < topline)) {
400
     if ((sel < topline)) {
399
       DWIN_Frame_AreaMove(1, DWIN_SCROLL_DOWN, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
401
       DWIN_Frame_AreaMove(1, DWIN_SCROLL_DOWN, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
400
       topline--;
402
       topline--;
401
-      MenuItems[sel]->Draw(0);
403
+      MenuItems[sel]->draw(0);
402
     }
404
     }
403
     selected = sel;
405
     selected = sel;
404
     if (DWINUI::onCursorDraw != nullptr) DWINUI::onCursorDraw(line());
406
     if (DWINUI::onCursorDraw != nullptr) DWINUI::onCursorDraw(line());
440
   frame = { x1, y1, x2, y2 };
442
   frame = { x1, y1, x2, y2 };
441
 }
443
 }
442
 
444
 
443
-void MenuItemClass::Draw(int8_t line) {
445
+void MenuItemClass::draw(int8_t line) {
444
   if (line < 0 || line >= TROWS) return;
446
   if (line < 0 || line >= TROWS) return;
445
   if (onDraw != nullptr) (*onDraw)(this, line);
447
   if (onDraw != nullptr) (*onDraw)(this, line);
446
 };
448
 };

+ 33
- 173
Marlin/src/lcd/e3v2/enhanced/dwinui.h 查看文件

1
 /**
1
 /**
2
- * DWIN UI Enhanced implementation
3
- * Author: Miguel A. Risco-Castillo
4
- * Version: 3.6.3
5
- * Date: 2021/08/09
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
6
  *
7
  *
7
  * This program is free software: you can redistribute it and/or modify
8
  * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as
9
- * published by the Free Software Foundation, either version 3 of the License, or
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
10
  * (at your option) any later version.
11
  * (at your option) any later version.
11
  *
12
  *
12
  * This program is distributed in the hope that it will be useful,
13
  * This program is distributed in the hope that it will be useful,
14
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * GNU General Public License for more details.
16
  * GNU General Public License for more details.
16
  *
17
  *
17
- * You should have received a copy of the GNU Lesser General Public License
18
+ * You should have received a copy of the GNU General Public License
18
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  *
20
  *
20
  */
21
  */
21
 #pragma once
22
 #pragma once
22
 
23
 
24
+/**
25
+ * DWIN UI Enhanced implementation
26
+ * Author: Miguel A. Risco-Castillo
27
+ * Version: 3.6.3
28
+ * Date: 2021/09/08
29
+ */
30
+
23
 #include "../../../core/types.h"
31
 #include "../../../core/types.h"
24
 #include "dwin_lcd.h"
32
 #include "dwin_lcd.h"
25
-
26
-// ICON ID
27
-#define ICON                7 // Icon set file 7.ICO
28
-
29
-#define ICON_LOGO                  0
30
-#define ICON_Print_0               1
31
-#define ICON_Print_1               2
32
-#define ICON_Prepare_0             3
33
-#define ICON_Prepare_1             4
34
-#define ICON_Control_0             5
35
-#define ICON_Control_1             6
36
-#define ICON_Leveling_0            7
37
-#define ICON_Leveling_1            8
38
-#define ICON_HotendTemp            9
39
-#define ICON_BedTemp              10
40
-#define ICON_Speed                11
41
-#define ICON_Zoffset              12
42
-#define ICON_Back                 13
43
-#define ICON_File                 14
44
-#define ICON_PrintTime            15
45
-#define ICON_RemainTime           16
46
-#define ICON_Setup_0              17
47
-#define ICON_Setup_1              18
48
-#define ICON_Pause_0              19
49
-#define ICON_Pause_1              20
50
-#define ICON_Continue_0           21
51
-#define ICON_Continue_1           22
52
-#define ICON_Stop_0               23
53
-#define ICON_Stop_1               24
54
-#define ICON_Bar                  25
55
-#define ICON_More                 26
56
-
57
-#define ICON_Axis                 27
58
-#define ICON_CloseMotor           28
59
-#define ICON_Homing               29
60
-#define ICON_SetHome              30
61
-#define ICON_PLAPreheat           31
62
-#define ICON_ABSPreheat           32
63
-#define ICON_Cool                 33
64
-#define ICON_Language             34
65
-
66
-#define ICON_MoveX                35
67
-#define ICON_MoveY                36
68
-#define ICON_MoveZ                37
69
-#define ICON_Extruder             38
70
-
71
-#define ICON_Temperature          40
72
-#define ICON_Motion               41
73
-#define ICON_WriteEEPROM          42
74
-#define ICON_ReadEEPROM           43
75
-#define ICON_ResumeEEPROM         44
76
-#define ICON_Info                 45
77
-
78
-#define ICON_SetEndTemp           46
79
-#define ICON_SetBedTemp           47
80
-#define ICON_FanSpeed             48
81
-#define ICON_SetPLAPreheat        49
82
-#define ICON_SetABSPreheat        50
83
-
84
-#define ICON_MaxSpeed             51
85
-#define ICON_MaxAccelerated       52
86
-#define ICON_MaxJerk              53
87
-#define ICON_Step                 54
88
-#define ICON_PrintSize            55
89
-#define ICON_Version              56
90
-#define ICON_Contact              57
91
-#define ICON_StockConfiguration   58
92
-#define ICON_MaxSpeedX            59
93
-#define ICON_MaxSpeedY            60
94
-#define ICON_MaxSpeedZ            61
95
-#define ICON_MaxSpeedE            62
96
-#define ICON_MaxAccX              63
97
-#define ICON_MaxAccY              64
98
-#define ICON_MaxAccZ              65
99
-#define ICON_MaxAccE              66
100
-#define ICON_MaxSpeedJerkX        67
101
-#define ICON_MaxSpeedJerkY        68
102
-#define ICON_MaxSpeedJerkZ        69
103
-#define ICON_MaxSpeedJerkE        70
104
-#define ICON_StepX                71
105
-#define ICON_StepY                72
106
-#define ICON_StepZ                73
107
-#define ICON_StepE                74
108
-#define ICON_Setspeed             75
109
-#define ICON_SetZOffset           76
110
-#define ICON_Rectangle            77
111
-#define ICON_BLTouch              78
112
-#define ICON_TempTooLow           79
113
-#define ICON_AutoLeveling         80
114
-#define ICON_TempTooHigh          81
115
-#define ICON_NoTips_C             82
116
-#define ICON_NoTips_E             83
117
-#define ICON_Continue_C           84
118
-#define ICON_Continue_E           85
119
-#define ICON_Cancel_C             86
120
-#define ICON_Cancel_E             87
121
-#define ICON_Confirm_C            88
122
-#define ICON_Confirm_E            89
123
-#define ICON_Info_0               90
124
-#define ICON_Info_1               91
33
+#include "../common/dwin_set.h"
34
+#include "../common/dwin_font.h"
35
+#include "../common/dwin_color.h"
125
 
36
 
126
 // Extra Icons
37
 // Extra Icons
127
-#define ICON_AdvSet               ICON_Language
128
 #define ICON_Brightness           ICON_Motion
38
 #define ICON_Brightness           ICON_Motion
129
 #define ICON_Cancel               ICON_StockConfiguration
39
 #define ICON_Cancel               ICON_StockConfiguration
130
 #define ICON_CustomPreheat        ICON_SetEndTemp
40
 #define ICON_CustomPreheat        ICON_SetEndTemp
135
 #define ICON_FilSet               ICON_ResumeEEPROM
45
 #define ICON_FilSet               ICON_ResumeEEPROM
136
 #define ICON_FilUnload            ICON_ReadEEPROM
46
 #define ICON_FilUnload            ICON_ReadEEPROM
137
 #define ICON_Flow                 ICON_StepE
47
 #define ICON_Flow                 ICON_StepE
138
-#define ICON_HomeOffset           ICON_AdvSet
139
-#define ICON_HomeOffsetX          ICON_StepX
140
-#define ICON_HomeOffsetY          ICON_StepY
141
-#define ICON_HomeOffsetZ          ICON_StepZ
142
 #define ICON_LevBed               ICON_SetEndTemp
48
 #define ICON_LevBed               ICON_SetEndTemp
143
 #define ICON_Lock                 ICON_Cool
49
 #define ICON_Lock                 ICON_Cool
144
 #define ICON_ManualMesh           ICON_HotendTemp
50
 #define ICON_ManualMesh           ICON_HotendTemp
146
 #define ICON_MeshSave             ICON_WriteEEPROM
52
 #define ICON_MeshSave             ICON_WriteEEPROM
147
 #define ICON_MoveZ0               ICON_HotendTemp
53
 #define ICON_MoveZ0               ICON_HotendTemp
148
 #define ICON_Park                 ICON_Motion
54
 #define ICON_Park                 ICON_Motion
149
-#define ICON_PIDbed               ICON_SetBedTemp
150
 #define ICON_PIDcycles            ICON_ResumeEEPROM
55
 #define ICON_PIDcycles            ICON_ResumeEEPROM
151
-#define ICON_PIDNozzle            ICON_SetEndTemp
152
 #define ICON_PIDValue             ICON_Contact
56
 #define ICON_PIDValue             ICON_Contact
153
-#define ICON_ProbeOffsetX         ICON_StepX
154
-#define ICON_ProbeOffsetY         ICON_StepY
155
-#define ICON_ProbeOffsetZ         ICON_StepZ
156
 #define ICON_ProbeSet             ICON_SetEndTemp
57
 #define ICON_ProbeSet             ICON_SetEndTemp
157
 #define ICON_ProbeTest            ICON_SetEndTemp
58
 #define ICON_ProbeTest            ICON_SetEndTemp
158
 #define ICON_Pwrlossr             ICON_Motion
59
 #define ICON_Pwrlossr             ICON_Motion
162
 #define ICON_SetCustomPreheat     ICON_SetEndTemp
63
 #define ICON_SetCustomPreheat     ICON_SetEndTemp
163
 #define ICON_Sound                ICON_Cool
64
 #define ICON_Sound                ICON_Cool
164
 
65
 
165
-/**
166
- * 3-.0:The font size, 0x00-0x09, corresponds to the font size below:
167
- * 0x00=6*12   0x01=8*16   0x02=10*20  0x03=12*24  0x04=14*28
168
- * 0x05=16*32  0x06=20*40  0x07=24*48  0x08=28*56  0x09=32*64
169
- */
170
-#define font6x12  0x00
171
-#define font8x16  0x01
172
-#define font10x20 0x02
173
-#define font12x24 0x03
174
-#define font14x28 0x04
175
-#define font16x32 0x05
176
-#define font20x40 0x06
177
-#define font24x48 0x07
178
-#define font28x56 0x08
179
-#define font32x64 0x09
180
-
181
-// Extended and default UI Colors
182
-#define RGB(R,G,B)  (R << 11) | (G << 5) | (B) // R,B: 0..31; G: 0..63
183
-#define GetRColor(color) ((color >> 11) & 0x1F)
184
-#define GetGColor(color) ((color >>  5) & 0x3F)
185
-#define GetBColor(color) ((color >>  0) & 0x1F)
186
-
187
-#define Color_White       0xFFFF
188
-#define Color_Bg_Window   0x31E8  // Popup background color
189
-#define Color_Bg_Blue     0x1125  // Dark blue background color
190
-#define Color_Bg_Black    0x0841  // Black background color
191
-#define Color_Bg_Red      0xF00F  // Red background color
192
-#define Popup_Text_Color  0xD6BA  // Popup font background color
193
-#define Line_Color        0x3A6A  // Split line color
194
-#define Rectangle_Color   0xEE2F  // Blue square cursor color
195
-#define Percent_Color     0xFE29  // Percentage color
196
-#define BarFill_Color     0x10E4  // Fill color of progress bar
197
-#define Select_Color      0x33BB  // Selected color
198
-
199
-#define Color_Black           0
200
-#define Color_Red             RGB(31,0,0)
201
-#define Color_Yellow          RGB(31,63,0)
202
-#define Color_Green           RGB(0,63,0)
203
-#define Color_Aqua            RGB(0,63,31)
204
-#define Color_Blue            RGB(0,0,31)
205
-
206
 // Default UI Colors
66
 // Default UI Colors
207
 #define Def_Background_Color  Color_Bg_Black
67
 #define Def_Background_Color  Color_Bg_Black
208
 #define Def_Cursor_color      Rectangle_Color
68
 #define Def_Cursor_color      Rectangle_Color
223
 #define Def_Indicator_Color   Color_White
83
 #define Def_Indicator_Color   Color_White
224
 #define Def_Coordinate_Color   Color_White
84
 #define Def_Coordinate_Color   Color_White
225
 
85
 
226
-//UI elements defines and constants
86
+// UI element defines and constants
227
 #define DWIN_FONT_MENU font8x16
87
 #define DWIN_FONT_MENU font8x16
228
 #define DWIN_FONT_STAT font10x20
88
 #define DWIN_FONT_STAT font10x20
229
 #define DWIN_FONT_HEAD font10x20
89
 #define DWIN_FONT_HEAD font10x20
262
   char caption[32] = "";
122
   char caption[32] = "";
263
   uint8_t frameid = 0;
123
   uint8_t frameid = 0;
264
   rect_t frame = {0};
124
   rect_t frame = {0};
265
-  void Draw();
125
+  void draw();
266
   void SetCaption(const char * const title);
126
   void SetCaption(const char * const title);
267
   inline void SetCaption(const __FlashStringHelper * title) { SetCaption((char *)title); }
127
   inline void SetCaption(const __FlashStringHelper * title) { SetCaption((char *)title); }
268
   void ShowCaption(const char * const title);
128
   void ShowCaption(const char * const title);
290
   MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr);
150
   MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr);
291
   void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
151
   void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
292
   virtual ~MenuItemClass(){};
152
   virtual ~MenuItemClass(){};
293
-  virtual void Draw(int8_t line);
153
+  virtual void draw(int8_t line);
294
 };
154
 };
295
 
155
 
296
 class MenuItemPtrClass: public MenuItemClass {
156
 class MenuItemPtrClass: public MenuItemClass {
310
   virtual ~MenuClass(){};
170
   virtual ~MenuClass(){};
311
   inline int8_t line() { return selected - topline; };
171
   inline int8_t line() { return selected - topline; };
312
   inline int8_t line(uint8_t pos) {return pos - topline; };
172
   inline int8_t line(uint8_t pos) {return pos - topline; };
313
-  void Draw();
173
+  void draw();
314
   void onScroll(bool dir);
174
   void onScroll(bool dir);
315
   void onClick();
175
   void onClick();
316
   MenuItemClass* SelectedItem();
176
   MenuItemClass* SelectedItem();
330
   extern void (*onMenuDraw)(MenuClass* menu);
190
   extern void (*onMenuDraw)(MenuClass* menu);
331
 
191
 
332
   // DWIN LCD Initialization
192
   // DWIN LCD Initialization
333
-  void Init(void);
193
+  void init();
334
 
194
 
335
   // Set text/number font
195
   // Set text/number font
336
-  void SetFont(uint8_t cfont);
196
+  void setFont(uint8_t cfont);
337
 
197
 
338
   // Get font character width
198
   // Get font character width
339
-  uint8_t Get_font_width(uint8_t cfont);
199
+  uint8_t fontWidth(uint8_t cfont);
340
 
200
 
341
   // Get font character heigh
201
   // Get font character heigh
342
-  uint8_t Get_font_height(uint8_t cfont);
202
+  uint8_t fontHeight(uint8_t cfont);
343
 
203
 
344
   // Get screen x coodinates from text column
204
   // Get screen x coodinates from text column
345
   uint16_t ColToX(uint8_t col);
205
   uint16_t ColToX(uint8_t col);
398
   }
258
   }
399
   inline void Draw_Int(uint8_t iNum, long value) {
259
   inline void Draw_Int(uint8_t iNum, long value) {
400
     DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
260
     DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
401
-    MoveBy(iNum * Get_font_width(font), 0);
261
+    MoveBy(iNum * fontWidth(font), 0);
402
   }
262
   }
403
   inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) {
263
   inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) {
404
     DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, x, y, value);
264
     DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, x, y, value);
429
   }
289
   }
430
   inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) {
290
   inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) {
431
     DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum,  cursor.x, cursor.y, value);
291
     DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum,  cursor.x, cursor.y, value);
432
-    MoveBy((iNum + fNum + 1) * Get_font_width(font), 0);
292
+    MoveBy((iNum + fNum + 1) * fontWidth(font), 0);
433
   }
293
   }
434
   inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
294
   inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
435
     DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
295
     DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
457
   void Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
317
   void Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
458
   inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) {
318
   inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) {
459
     Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
319
     Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
460
-    MoveBy((iNum + fNum + 1) * Get_font_width(font), 0);
320
+    MoveBy((iNum + fNum + 1) * fontWidth(font), 0);
461
   }
321
   }
462
   inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
322
   inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
463
     Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
323
     Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
548
 
408
 
549
   // Draw a circle
409
   // Draw a circle
550
   //  Color: circle color
410
   //  Color: circle color
551
-  //  x: the abscissa of the center of the circle
411
+  //  x: abscissa of the center of the circle
552
   //  y: ordinate of the center of the circle
412
   //  y: ordinate of the center of the circle
553
   //  r: circle radius
413
   //  r: circle radius
554
   void Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r);
414
   void Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r);
569
   // Color Interpolator
429
   // Color Interpolator
570
   //  val : Interpolator minv..maxv
430
   //  val : Interpolator minv..maxv
571
   //  minv : Minimum value
431
   //  minv : Minimum value
572
-  //  maxv : Maximun value
432
+  //  maxv : Maximum value
573
   //  color1 : Start color
433
   //  color1 : Start color
574
   //  color2 : End color
434
   //  color2 : End color
575
   uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2);
435
   uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2);
578
 
438
 
579
   // Draw a circle filled with color
439
   // Draw a circle filled with color
580
   //  bcolor: fill color
440
   //  bcolor: fill color
581
-  //  x: the abscissa of the center of the circle
441
+  //  x: abscissa of the center of the circle
582
   //  y: ordinate of the center of the circle
442
   //  y: ordinate of the center of the circle
583
   //  r: circle radius
443
   //  r: circle radius
584
   void Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r);
444
   void Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r);
589
   // Color Interpolator through Red->Yellow->Green->Blue
449
   // Color Interpolator through Red->Yellow->Green->Blue
590
   //  val : Interpolator minv..maxv
450
   //  val : Interpolator minv..maxv
591
   //  minv : Minimum value
451
   //  minv : Minimum value
592
-  //  maxv : Maximun value
452
+  //  maxv : Maximum value
593
   uint16_t RainbowInt(int16_t val, int16_t minv, int16_t maxv);
453
   uint16_t RainbowInt(int16_t val, int16_t minv, int16_t maxv);
594
 
454
 
595
   // Write buffer data to the SRAM
455
   // Write buffer data to the SRAM

+ 31
- 25
Marlin/src/lcd/e3v2/enhanced/lockscreen.cpp 查看文件

1
 /**
1
 /**
2
- * DWIN UI Enhanced implementation
3
- * Author: Miguel A. Risco-Castillo
4
- * Version: 3.6.1
5
- * Date: 2021/08/29
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
6
  *
7
  *
7
  * This program is free software: you can redistribute it and/or modify
8
  * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as
9
- * published by the Free Software Foundation, either version 3 of the License, or
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
10
  * (at your option) any later version.
11
  * (at your option) any later version.
11
  *
12
  *
12
  * This program is distributed in the hope that it will be useful,
13
  * This program is distributed in the hope that it will be useful,
14
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * GNU General Public License for more details.
16
  * GNU General Public License for more details.
16
  *
17
  *
17
- * You should have received a copy of the GNU Lesser General Public License
18
+ * You should have received a copy of the GNU General Public License
18
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  *
20
  *
20
  */
21
  */
21
 
22
 
23
+/**
24
+ * DWIN UI Enhanced implementation
25
+ * Author: Miguel A. Risco-Castillo
26
+ * Version: 3.6.3
27
+ * Date: 2021/09/08
28
+ */
29
+
22
 #include "../../../inc/MarlinConfigPre.h"
30
 #include "../../../inc/MarlinConfigPre.h"
23
 
31
 
24
 #if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
32
 #if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
29
 #include "dwin.h"
37
 #include "dwin.h"
30
 #include "lockscreen.h"
38
 #include "lockscreen.h"
31
 
39
 
32
-LockScreenClass LockScreen;
40
+LockScreenClass lockScreen;
41
+
42
+uint8_t LockScreenClass::lock_pos = 0;
43
+bool LockScreenClass::unlocked = false;
33
 
44
 
34
-void LockScreenClass::Init() {
35
-  Lock_Pos = 0;
45
+void LockScreenClass::init() {
46
+  lock_pos = 0;
36
   unlocked = false;
47
   unlocked = false;
37
-  Draw();
48
+  draw();
38
 }
49
 }
39
 
50
 
40
-void LockScreenClass::Draw() {
51
+void LockScreenClass::draw() {
41
   Title.SetCaption(PSTR("Lock Screen"));
52
   Title.SetCaption(PSTR("Lock Screen"));
42
   DWINUI::ClearMenuArea();
53
   DWINUI::ClearMenuArea();
43
   DWINUI::Draw_Icon(ICON_LOGO, 71, 120);  // CREALITY logo
54
   DWINUI::Draw_Icon(ICON_LOGO, 71, 120);  // CREALITY logo
45
   DWINUI::Draw_CenteredString(Color_White, 200, F("Scroll to unlock."));
56
   DWINUI::Draw_CenteredString(Color_White, 200, F("Scroll to unlock."));
46
   DWINUI::Draw_CenteredString(Color_White, 240, F("-> | <-"));
57
   DWINUI::Draw_CenteredString(Color_White, 240, F("-> | <-"));
47
   DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
58
   DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
48
-  DWIN_Draw_VLine(Color_Yellow, Lock_Pos * DWIN_WIDTH / 255, 260, 20);
59
+  DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20);
49
   DWIN_UpdateLCD();
60
   DWIN_UpdateLCD();
50
 }
61
 }
51
 
62
 
52
-void LockScreenClass::onEncoderState(ENCODER_DiffState encoder_diffState) {
53
-  if (encoder_diffState == ENCODER_DIFF_CW) {
54
-    Lock_Pos += 8;
55
-  }
56
-  else if (encoder_diffState == ENCODER_DIFF_CCW) {
57
-    Lock_Pos -= 8;
58
-  }
59
-  else if (encoder_diffState == ENCODER_DIFF_ENTER) {
60
-    unlocked = (Lock_Pos == 128);
63
+void LockScreenClass::onEncoder(EncoderState encoder_diffState) {
64
+  switch (encoder_diffState) {
65
+    case ENCODER_DIFF_CW:    lock_pos += 8; break;
66
+    case ENCODER_DIFF_CCW:   lock_pos -= 8; break;
67
+    case ENCODER_DIFF_ENTER: unlocked = (lock_pos == 128); break;
68
+    default: break;
61
   }
69
   }
62
   DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
70
   DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
63
-  DWIN_Draw_VLine(Color_Yellow, Lock_Pos * DWIN_WIDTH / 255, 260, 20);
71
+  DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20);
64
   DWIN_UpdateLCD();
72
   DWIN_UpdateLCD();
65
 }
73
 }
66
 
74
 
67
-bool LockScreenClass::isUnlocked() { return unlocked; }
68
-
69
 #endif // DWIN_CREALITY_LCD_ENHANCED
75
 #endif // DWIN_CREALITY_LCD_ENHANCED

+ 25
- 15
Marlin/src/lcd/e3v2/enhanced/lockscreen.h 查看文件

1
 /**
1
 /**
2
- * DWIN UI Enhanced implementation
3
- * Author: Miguel A. Risco-Castillo
4
- * Version: 3.6.1
5
- * Date: 2021/08/29
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
6
  *
7
  *
7
  * This program is free software: you can redistribute it and/or modify
8
  * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as
9
- * published by the Free Software Foundation, either version 3 of the License, or
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
10
  * (at your option) any later version.
11
  * (at your option) any later version.
11
  *
12
  *
12
  * This program is distributed in the hope that it will be useful,
13
  * This program is distributed in the hope that it will be useful,
14
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  * GNU General Public License for more details.
16
  * GNU General Public License for more details.
16
  *
17
  *
17
- * You should have received a copy of the GNU Lesser General Public License
18
+ * You should have received a copy of the GNU General Public License
18
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  *
20
  *
20
  */
21
  */
21
 #pragma once
22
 #pragma once
22
 
23
 
23
-#include "../../../core/types.h"
24
+/**
25
+ * DWIN UI Enhanced implementation
26
+ * Author: Miguel A. Risco-Castillo
27
+ * Version: 3.6.3
28
+ * Date: 2021/09/08
29
+ */
30
+
31
+#include "../common/encoder.h"
32
+#include <stdint.h>
24
 
33
 
25
 class LockScreenClass {
34
 class LockScreenClass {
26
 private:
35
 private:
27
-  uint8_t Lock_Pos = 0;
28
-  bool unlocked = false;
36
+  static bool unlocked;
37
+  static uint8_t lock_pos;
29
 public:
38
 public:
30
-  void Init();
31
-  void onEncoderState(ENCODER_DiffState encoder_diffState);
32
-  void Draw();
33
-  bool isUnlocked();
39
+  static void init();
40
+  static void onEncoder(EncoderState encoder_diffState);
41
+  static void draw();
42
+  static inline bool isUnlocked() { return unlocked; }
34
 };
43
 };
35
-extern LockScreenClass LockScreen;
44
+
45
+extern LockScreenClass lockScreen;

+ 0
- 263
Marlin/src/lcd/e3v2/enhanced/rotary_encoder.cpp 查看文件

1
-/**
2
- * DWIN UI Enhanced implementation
3
- * Author: Miguel A. Risco-Castillo
4
- * Version: 3.6.1
5
- * Date: 2021/08/29
6
- *
7
- * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as
9
- * published by the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public License
18
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
- *
20
- */
21
-
22
-/*****************************************************************************
23
- * @file     lcd/e3v2/enhanced/rotary_encoder.cpp
24
- * @author   LEO / Creality3D
25
- * @date     2019/07/06
26
- * @version  2.0.1
27
- * @brief    Rotary encoder functions
28
- *****************************************************************************/
29
-
30
-#include "../../../inc/MarlinConfigPre.h"
31
-
32
-#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
33
-
34
-#include "rotary_encoder.h"
35
-#include "../../buttons.h"
36
-
37
-#include "../../../MarlinCore.h"
38
-#include "../../../HAL/shared/Delay.h"
39
-
40
-#if HAS_BUZZER
41
-  #include "../../../libs/buzzer.h"
42
-#endif
43
-
44
-#include <stdlib.h>
45
-
46
-#ifndef ENCODER_PULSES_PER_STEP
47
-  #define ENCODER_PULSES_PER_STEP 4
48
-#endif
49
-
50
-#if ENABLED(SOUND_MENU_ITEM)
51
-  #include "../../marlinui.h"
52
-#endif
53
-
54
-ENCODER_Rate EncoderRate;
55
-
56
-// Buzzer
57
-void Encoder_tick() {
58
-  #if PIN_EXISTS(BEEPER)
59
-    if (TERN1(SOUND_MENU_ITEM, ui.buzzer_enabled)) {
60
-      WRITE(BEEPER_PIN, HIGH);
61
-      delay(10);
62
-      WRITE(BEEPER_PIN, LOW);
63
-    }
64
-  #endif
65
-}
66
-
67
-// Encoder initialization
68
-void Encoder_Configuration() {
69
-  #if BUTTON_EXISTS(EN1)
70
-    SET_INPUT_PULLUP(BTN_EN1);
71
-  #endif
72
-  #if BUTTON_EXISTS(EN2)
73
-    SET_INPUT_PULLUP(BTN_EN2);
74
-  #endif
75
-  #if BUTTON_EXISTS(ENC)
76
-    SET_INPUT_PULLUP(BTN_ENC);
77
-  #endif
78
-  #if PIN_EXISTS(BEEPER)
79
-    SET_OUTPUT(BEEPER_PIN);
80
-  #endif
81
-}
82
-
83
-// Analyze encoder value and return state
84
-ENCODER_DiffState Encoder_ReceiveAnalyze() {
85
-  const millis_t now = millis();
86
-  static uint8_t lastEncoderBits;
87
-  uint8_t newbutton = 0;
88
-  static signed char temp_diff = 0;
89
-
90
-  ENCODER_DiffState temp_diffState = ENCODER_DIFF_NO;
91
-  if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
92
-  if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
93
-  if (BUTTON_PRESSED(ENC)) {
94
-    static millis_t next_click_update_ms;
95
-    if (ELAPSED(now, next_click_update_ms)) {
96
-      next_click_update_ms = millis() + 300;
97
-      Encoder_tick();
98
-      #if PIN_EXISTS(LCD_LED)
99
-        //LED_Action();
100
-      #endif
101
-      const bool was_waiting = wait_for_user;
102
-      wait_for_user = false;
103
-      return was_waiting ? ENCODER_DIFF_NO : ENCODER_DIFF_ENTER;
104
-    }
105
-    else return ENCODER_DIFF_NO;
106
-  }
107
-  if (newbutton != lastEncoderBits) {
108
-    switch (newbutton) {
109
-      case ENCODER_PHASE_0:
110
-             if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++;
111
-        else if (lastEncoderBits == ENCODER_PHASE_1) temp_diff--;
112
-        break;
113
-      case ENCODER_PHASE_1:
114
-             if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++;
115
-        else if (lastEncoderBits == ENCODER_PHASE_2) temp_diff--;
116
-        break;
117
-      case ENCODER_PHASE_2:
118
-             if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++;
119
-        else if (lastEncoderBits == ENCODER_PHASE_3) temp_diff--;
120
-        break;
121
-      case ENCODER_PHASE_3:
122
-             if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++;
123
-        else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--;
124
-        break;
125
-    }
126
-    lastEncoderBits = newbutton;
127
-  }
128
-
129
-  if (ABS(temp_diff) >= ENCODER_PULSES_PER_STEP) {
130
-    if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CW;
131
-    else temp_diffState = ENCODER_DIFF_CCW;
132
-
133
-    #if ENABLED(ENCODER_RATE_MULTIPLIER)
134
-
135
-      millis_t ms = millis();
136
-      int32_t encoderMultiplier = 1;
137
-
138
-      // if must encoder rati multiplier
139
-      if (EncoderRate.enabled) {
140
-        const float abs_diff = ABS(temp_diff),
141
-                    encoderMovementSteps = abs_diff / (ENCODER_PULSES_PER_STEP);
142
-        if (EncoderRate.lastEncoderTime) {
143
-          // Note that the rate is always calculated between two passes through the
144
-          // loop and that the abs of the temp_diff value is tracked.
145
-          const float encoderStepRate = encoderMovementSteps / float(ms - EncoderRate.lastEncoderTime) * 1000;
146
-               if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100;
147
-          else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC)  encoderMultiplier = 10;
148
-          #if ENCODER_5X_STEPS_PER_SEC
149
-            else if (encoderStepRate >= ENCODER_5X_STEPS_PER_SEC) encoderMultiplier = 5;
150
-          #endif
151
-        }
152
-        EncoderRate.lastEncoderTime = ms;
153
-      }
154
-
155
-    #else
156
-
157
-      constexpr int32_t encoderMultiplier = 1;
158
-
159
-    #endif
160
-
161
-    // EncoderRate.encoderMoveValue += (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
162
-    EncoderRate.encoderMoveValue = (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
163
-    if (EncoderRate.encoderMoveValue < 0) EncoderRate.encoderMoveValue = -EncoderRate.encoderMoveValue;
164
-
165
-    temp_diff = 0;
166
-  }
167
-  return temp_diffState;
168
-}
169
-
170
-#if PIN_EXISTS(LCD_LED)
171
-
172
-  // 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
173
-  uint16_t LED_DataArray[LED_NUM];
174
-
175
-  // LED light operation
176
-  void LED_Action() {
177
-    LED_Control(RGB_SCALE_WARM_WHITE,0x0F);
178
-    delay(30);
179
-    LED_Control(RGB_SCALE_WARM_WHITE,0x00);
180
-  }
181
-
182
-  // LED initialization
183
-  void LED_Configuration() {
184
-    SET_OUTPUT(LCD_LED_PIN);
185
-  }
186
-
187
-  // LED write data
188
-  void LED_WriteData() {
189
-    uint8_t tempCounter_LED, tempCounter_Bit;
190
-    for (tempCounter_LED = 0; tempCounter_LED < LED_NUM; tempCounter_LED++) {
191
-      for (tempCounter_Bit = 0; tempCounter_Bit < 24; tempCounter_Bit++) {
192
-        if (LED_DataArray[tempCounter_LED] & (0x800000 >> tempCounter_Bit)) {
193
-          LED_DATA_HIGH;
194
-          DELAY_NS(300);
195
-          LED_DATA_LOW;
196
-          DELAY_NS(200);
197
-        }
198
-        else {
199
-          LED_DATA_HIGH;
200
-          LED_DATA_LOW;
201
-          DELAY_NS(200);
202
-        }
203
-      }
204
-    }
205
-  }
206
-
207
-  // LED control
208
-  //  RGB_Scale: RGB color ratio
209
-  //  luminance: brightness (0~0xFF)
210
-  void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance) {
211
-    for (uint8_t i = 0; i < LED_NUM; i++) {
212
-      LED_DataArray[i] = 0;
213
-      switch (RGB_Scale) {
214
-        case RGB_SCALE_R10_G7_B5: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 7/10) << 16 | luminance * 5/10; break;
215
-        case RGB_SCALE_R10_G7_B4: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 7/10) << 16 | luminance * 4/10; break;
216
-        case RGB_SCALE_R10_G8_B7: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 8/10) << 16 | luminance * 7/10; break;
217
-      }
218
-    }
219
-    LED_WriteData();
220
-  }
221
-
222
-  // LED gradient control
223
-  //  RGB_Scale: RGB color ratio
224
-  //  luminance: brightness (0~0xFF)
225
-  //  change_Time: gradient time (ms)
226
-  void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval) {
227
-    struct { uint8_t g, r, b; } led_data[LED_NUM];
228
-    for (uint8_t i = 0; i < LED_NUM; i++) {
229
-      switch (RGB_Scale) {
230
-        case RGB_SCALE_R10_G7_B5:
231
-          led_data[i] = { luminance * 7/10, luminance * 10/10, luminance * 5/10 };
232
-          break;
233
-        case RGB_SCALE_R10_G7_B4:
234
-          led_data[i] = { luminance * 7/10, luminance * 10/10, luminance * 4/10 };
235
-          break;
236
-        case RGB_SCALE_R10_G8_B7:
237
-          led_data[i] = { luminance * 8/10, luminance * 10/10, luminance * 7/10 };
238
-          break;
239
-      }
240
-    }
241
-
242
-    struct { bool g, r, b; } led_flag = { false, false, false };
243
-    for (uint8_t i = 0; i < LED_NUM; i++) {
244
-      while (1) {
245
-        const uint8_t g = uint8_t(LED_DataArray[i] >> 16),
246
-                      r = uint8_t(LED_DataArray[i] >> 8),
247
-                      b = uint8_t(LED_DataArray[i]);
248
-        if (g == led_data[i].g) led_flag.g = true;
249
-        else LED_DataArray[i] += (g > led_data[i].g) ? -0x010000 : 0x010000;
250
-        if (r == led_data[i].r) led_flag.r = true;
251
-        else LED_DataArray[i] += (r > led_data[i].r) ? -0x000100 : 0x000100;
252
-        if (b == led_data[i].b) led_flag.b = true;
253
-        else LED_DataArray[i] += (b > led_data[i].b) ? -0x000001 : 0x000001;
254
-        LED_WriteData();
255
-        if (led_flag.r && led_flag.g && led_flag.b) break;
256
-        delay(change_Interval);
257
-      }
258
-    }
259
-  }
260
-
261
-#endif // LCD_LED
262
-
263
-#endif // DWIN_CREALITY_LCD_ENHANCED

+ 0
- 93
Marlin/src/lcd/e3v2/enhanced/rotary_encoder.h 查看文件

1
-/**
2
- * DWIN UI Enhanced implementation
3
- * Author: Miguel A. Risco-Castillo
4
- * Version: 3.6.1
5
- * Date: 2021/08/29
6
- *
7
- * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as
9
- * published by the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public License
18
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
- *
20
- */
21
-#pragma once
22
-
23
-/*****************************************************************************
24
- * @file     lcd/e3v2/enhanced/rotary_encoder.h
25
- * @author   LEO / Creality3D
26
- * @date     2019/07/06
27
- * @version  2.0.1
28
- * @brief    Rotary encoder functions
29
- ****************************************************************************/
30
-
31
-#include "../../../inc/MarlinConfig.h"
32
-
33
-/*********************** Encoder Set ***********************/
34
-
35
-typedef struct {
36
-  bool enabled = false;
37
-  int encoderMoveValue = 0;
38
-  millis_t lastEncoderTime = 0;
39
-} ENCODER_Rate;
40
-
41
-extern ENCODER_Rate EncoderRate;
42
-
43
-typedef enum {
44
-  ENCODER_DIFF_NO    = 0,  // no state
45
-  ENCODER_DIFF_CW    = 1,  // clockwise rotation
46
-  ENCODER_DIFF_CCW   = 2,  // counterclockwise rotation
47
-  ENCODER_DIFF_ENTER = 3   // click
48
-} ENCODER_DiffState;
49
-
50
-// Encoder initialization
51
-void Encoder_Configuration();
52
-
53
-// Analyze encoder value and return state
54
-ENCODER_DiffState Encoder_ReceiveAnalyze();
55
-
56
-/*********************** Encoder LED ***********************/
57
-
58
-#if PIN_EXISTS(LCD_LED)
59
-
60
-  #define LED_NUM  4
61
-  #define LED_DATA_HIGH  WRITE(LCD_LED_PIN, 1)
62
-  #define LED_DATA_LOW   WRITE(LCD_LED_PIN, 0)
63
-
64
-  #define RGB_SCALE_R10_G7_B5  1
65
-  #define RGB_SCALE_R10_G7_B4  2
66
-  #define RGB_SCALE_R10_G8_B7  3
67
-  #define RGB_SCALE_NEUTRAL_WHITE RGB_SCALE_R10_G7_B5
68
-  #define RGB_SCALE_WARM_WHITE    RGB_SCALE_R10_G7_B4
69
-  #define RGB_SCALE_COOL_WHITE    RGB_SCALE_R10_G8_B7
70
-
71
-  extern unsigned int LED_DataArray[LED_NUM];
72
-
73
-  // LED light operation
74
-  void LED_Action();
75
-
76
-  // LED initialization
77
-  void LED_Configuration();
78
-
79
-  // LED write data
80
-  void LED_WriteData();
81
-
82
-  // LED control
83
-  //  RGB_Scale: RGB color ratio
84
-  //  luminance: brightness (0~0xFF)
85
-  void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance);
86
-
87
-  // LED gradient control
88
-  //  RGB_Scale: RGB color ratio
89
-  //  luminance: brightness (0~0xFF)
90
-  //  change_Time: gradient time (ms)
91
-  void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval);
92
-
93
-#endif // LCD_LED

+ 131
- 140
Marlin/src/lcd/e3v2/jyersui/dwin.cpp 查看文件

40
 #include "../../../libs/buzzer.h"
40
 #include "../../../libs/buzzer.h"
41
 #include "../../../inc/Conditionals_post.h"
41
 #include "../../../inc/Conditionals_post.h"
42
 
42
 
43
+//#define DEBUG_OUT 1
44
+#include "../../../core/debug_out.h"
45
+
43
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
46
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
44
   #include "../../../feature/pause.h"
47
   #include "../../../feature/pause.h"
45
 #endif
48
 #endif
200
     uint8_t mesh_y = 0;
203
     uint8_t mesh_y = 0;
201
 
204
 
202
     #if ENABLED(AUTO_BED_LEVELING_UBL)
205
     #if ENABLED(AUTO_BED_LEVELING_UBL)
203
-      bed_mesh_t &mesh_z_values = ubl.z_values;
204
       uint8_t tilt_grid = 1;
206
       uint8_t tilt_grid = 1;
205
 
207
 
206
       void manual_value_update(bool undefined=false) {
208
       void manual_value_update(bool undefined=false) {
213
         struct linear_fit_data lsf_results;
215
         struct linear_fit_data lsf_results;
214
         incremental_LSF_reset(&lsf_results);
216
         incremental_LSF_reset(&lsf_results);
215
         GRID_LOOP(x, y) {
217
         GRID_LOOP(x, y) {
216
-          if (!isnan(mesh_z_values[x][y])) {
218
+          if (!isnan(Z_VALUES_ARR[x][y])) {
217
             xy_pos_t rpos;
219
             xy_pos_t rpos;
218
             rpos.x = ubl.mesh_index_to_xpos(x);
220
             rpos.x = ubl.mesh_index_to_xpos(x);
219
             rpos.y = ubl.mesh_index_to_ypos(y);
221
             rpos.y = ubl.mesh_index_to_ypos(y);
220
-            incremental_LSF(&lsf_results, rpos, mesh_z_values[x][y]);
222
+            incremental_LSF(&lsf_results, rpos, Z_VALUES_ARR[x][y]);
221
           }
223
           }
222
         }
224
         }
223
 
225
 
232
         GRID_LOOP(i, j) {
234
         GRID_LOOP(i, j) {
233
           float mx = ubl.mesh_index_to_xpos(i),
235
           float mx = ubl.mesh_index_to_xpos(i),
234
                 my = ubl.mesh_index_to_ypos(j),
236
                 my = ubl.mesh_index_to_ypos(j),
235
-                mz = mesh_z_values[i][j];
237
+                mz = Z_VALUES_ARR[i][j];
236
 
238
 
237
           if (DEBUGGING(LEVELING)) {
239
           if (DEBUGGING(LEVELING)) {
238
             DEBUG_ECHOPAIR_F("before rotation = [", mx, 7);
240
             DEBUG_ECHOPAIR_F("before rotation = [", mx, 7);
256
             DEBUG_DELAY(20);
258
             DEBUG_DELAY(20);
257
           }
259
           }
258
 
260
 
259
-          mesh_z_values[i][j] = mz - lsf_results.D;
261
+          Z_VALUES_ARR[i][j] = mz - lsf_results.D;
260
         }
262
         }
261
         return false;
263
         return false;
262
       }
264
       }
263
 
265
 
264
     #else
266
     #else
265
-      bed_mesh_t &mesh_z_values = z_values;
266
 
267
 
267
       void manual_value_update() {
268
       void manual_value_update() {
268
         sprintf_P(cmd, PSTR("G29 I%i J%i Z%s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1));
269
         sprintf_P(cmd, PSTR("G29 I%i J%i Z%s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1));
275
     void manual_move(bool zmove=false) {
276
     void manual_move(bool zmove=false) {
276
       if (zmove) {
277
       if (zmove) {
277
         planner.synchronize();
278
         planner.synchronize();
278
-        current_position.z = goto_mesh_value ? mesh_z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
279
+        current_position.z = goto_mesh_value ? Z_VALUES_ARR[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
279
         planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
280
         planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
280
         planner.synchronize();
281
         planner.synchronize();
281
       }
282
       }
286
         sprintf_P(cmd, PSTR("G42 F4000 I%i J%i"), mesh_x, mesh_y);
287
         sprintf_P(cmd, PSTR("G42 F4000 I%i J%i"), mesh_x, mesh_y);
287
         gcode.process_subcommands_now_P(cmd);
288
         gcode.process_subcommands_now_P(cmd);
288
         planner.synchronize();
289
         planner.synchronize();
289
-        current_position.z = goto_mesh_value ? mesh_z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
290
+        current_position.z = goto_mesh_value ? Z_VALUES_ARR[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
290
         planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
291
         planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
291
         planner.synchronize();
292
         planner.synchronize();
292
         CrealityDWIN.Redraw_Menu();
293
         CrealityDWIN.Redraw_Menu();
296
     float get_max_value() {
297
     float get_max_value() {
297
       float max = __FLT_MIN__;
298
       float max = __FLT_MIN__;
298
       GRID_LOOP(x, y) {
299
       GRID_LOOP(x, y) {
299
-        if (!isnan(mesh_z_values[x][y]) && mesh_z_values[x][y] > max)
300
-          max = mesh_z_values[x][y];
300
+        if (!isnan(Z_VALUES_ARR[x][y]) && Z_VALUES_ARR[x][y] > max)
301
+          max = Z_VALUES_ARR[x][y];
301
       }
302
       }
302
       return max;
303
       return max;
303
     }
304
     }
305
     float get_min_value() {
306
     float get_min_value() {
306
       float min = __FLT_MAX__;
307
       float min = __FLT_MAX__;
307
       GRID_LOOP(x, y) {
308
       GRID_LOOP(x, y) {
308
-        if (!isnan(mesh_z_values[x][y]) && mesh_z_values[x][y] < min)
309
-          min = mesh_z_values[x][y];
309
+        if (!isnan(Z_VALUES_ARR[x][y]) && Z_VALUES_ARR[x][y] < min)
310
+          min = Z_VALUES_ARR[x][y];
310
       }
311
       }
311
       return min;
312
       return min;
312
     }
313
     }
335
         const auto end_x_px   = start_x_px + cell_width_px - 1 - gridline_width;
336
         const auto end_x_px   = start_x_px + cell_width_px - 1 - gridline_width;
336
         const auto start_y_px = padding_y_top + (GRID_MAX_POINTS_Y - y - 1) * cell_height_px;
337
         const auto start_y_px = padding_y_top + (GRID_MAX_POINTS_Y - y - 1) * cell_height_px;
337
         const auto end_y_px   = start_y_px + cell_height_px - 1 - gridline_width;
338
         const auto end_y_px   = start_y_px + cell_height_px - 1 - gridline_width;
338
-        DWIN_Draw_Rectangle(1,                                                                                  // RGB565 colors: http://www.barth-dev.de/online/rgb565-color-picker/
339
-          isnan(mesh_z_values[x][y]) ? Color_Grey : (                                                           // gray if undefined
340
-            (mesh_z_values[x][y] < 0 ?
341
-              (uint16_t)round(0x1F * -mesh_z_values[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative
342
-              (uint16_t)round(0x3F *  mesh_z_values[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive
343
-                _MIN(0x1F, (((uint8_t)abs(mesh_z_values[x][y]) / 10) * 4))),                                    // + blue stepping for every mm
339
+        DWIN_Draw_Rectangle(1,                                                                                 // RGB565 colors: http://www.barth-dev.de/online/rgb565-color-picker/
340
+          isnan(Z_VALUES_ARR[x][y]) ? Color_Grey : (                                                           // gray if undefined
341
+            (Z_VALUES_ARR[x][y] < 0 ?
342
+              (uint16_t)round(0x1F * -Z_VALUES_ARR[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative
343
+              (uint16_t)round(0x3F *  Z_VALUES_ARR[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive
344
+                _MIN(0x1F, (((uint8_t)abs(Z_VALUES_ARR[x][y]) / 10) * 4))),                                    // + blue stepping for every mm
344
           start_x_px, start_y_px, end_x_px, end_y_px
345
           start_x_px, start_y_px, end_x_px, end_y_px
345
         );
346
         );
346
 
347
 
350
         // Draw value text on
351
         // Draw value text on
351
         if (viewer_print_value) {
352
         if (viewer_print_value) {
352
           int8_t offset_x, offset_y = cell_height_px / 2 - 6;
353
           int8_t offset_x, offset_y = cell_height_px / 2 - 6;
353
-          if (isnan(mesh_z_values[x][y])) {  // undefined
354
-            DWIN_Draw_String(false, false, font6x12, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X"));
354
+          if (isnan(Z_VALUES_ARR[x][y])) {  // undefined
355
+            DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X"));
355
           }
356
           }
356
           else {                          // has value
357
           else {                          // has value
357
             if (GRID_MAX_POINTS_X < 10)
358
             if (GRID_MAX_POINTS_X < 10)
358
-              sprintf_P(buf, PSTR("%s"), dtostrf(abs(mesh_z_values[x][y]), 1, 2, str_1));
359
+              sprintf_P(buf, PSTR("%s"), dtostrf(abs(Z_VALUES_ARR[x][y]), 1, 2, str_1));
359
             else
360
             else
360
-              sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(mesh_z_values[x][y] - (int16_t)mesh_z_values[x][y]) * 100));
361
+              sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(Z_VALUES_ARR[x][y] - (int16_t)Z_VALUES_ARR[x][y]) * 100));
361
             offset_x = cell_width_px / 2 - 3 * (strlen(buf)) - 2;
362
             offset_x = cell_width_px / 2 - 3 * (strlen(buf)) - 2;
362
             if (!(GRID_MAX_POINTS_X < 10))
363
             if (!(GRID_MAX_POINTS_X < 10))
363
-              DWIN_Draw_String(false, false, font6x12, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F("."));
364
-            DWIN_Draw_String(false, false, font6x12, Color_White, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, buf);
364
+              DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F("."));
365
+            DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, buf);
365
           }
366
           }
366
           safe_delay(10);
367
           safe_delay(10);
367
           LCD_SERIAL.flushTX();
368
           LCD_SERIAL.flushTX();
415
   const uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black;
416
   const uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black;
416
   const uint16_t xpos = 240 - (digits * 8);
417
   const uint16_t xpos = 240 - (digits * 8);
417
   DWIN_Draw_Rectangle(1, Color_Bg_Black, 194, MBASE(row), 234 - (digits * 8), MBASE(row) + 16);
418
   DWIN_Draw_Rectangle(1, Color_Bg_Black, 194, MBASE(row), 234 - (digits * 8), MBASE(row) + 16);
418
-  if (isnan(value)) {
419
-    DWIN_Draw_String(false, true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), F(" NaN"));
420
-  }
421
-  else if (value < 0) {
422
-    DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, Color_White, bColor, digits - log10(minunit) + 1, log10(minunit), xpos, MBASE(row), -value * minunit);
423
-    DWIN_Draw_String(false, true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), F("-"));
424
-  }
419
+  if (isnan(value))
420
+    DWIN_Draw_String(true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), F(" NaN"));
425
   else {
421
   else {
426
-    DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, Color_White, bColor, digits - log10(minunit) + 1, log10(minunit), xpos, MBASE(row), value * minunit);
427
-    DWIN_Draw_String(false, true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), F(" "));
422
+    DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, Color_White, bColor, digits - log10(minunit) + 1, log10(minunit), xpos, MBASE(row), (value < 0 ? -value : value) * minunit);
423
+    DWIN_Draw_String(true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), value < 0 ? F("-") : F(" "));
428
   }
424
   }
429
 }
425
 }
430
 
426
 
432
   uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black;
428
   uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black;
433
   uint16_t tColor = (color) ? GetColor(value, Color_White, false) : Color_White;
429
   uint16_t tColor = (color) ? GetColor(value, Color_White, false) : Color_White;
434
   DWIN_Draw_Rectangle(1, bColor, 202, MBASE(row) + 14, 258, MBASE(row) - 2);
430
   DWIN_Draw_Rectangle(1, bColor, 202, MBASE(row) + 14, 258, MBASE(row) - 2);
435
-  DWIN_Draw_String(false, false, DWIN_FONT_MENU, tColor, bColor, 202, MBASE(row) - 1, options[value]);
431
+  DWIN_Draw_String(false, DWIN_FONT_MENU, tColor, bColor, 202, MBASE(row) - 1, options[value]);
436
 }
432
 }
437
 
433
 
438
 uint16_t CrealityDWINClass::GetColor(uint8_t color, uint16_t original, bool light/*=false*/) {
434
 uint16_t CrealityDWINClass::GetColor(uint8_t color, uint16_t original, bool light/*=false*/) {
475
 }
471
 }
476
 
472
 
477
 void CrealityDWINClass::Draw_Title(const char * title) {
473
 void CrealityDWINClass::Draw_Title(const char * title) {
478
-  DWIN_Draw_String(false, false, DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Color_White, false), Color_Bg_Blue, (DWIN_WIDTH - strlen(title) * STAT_CHR_W) / 2, 5, title);
474
+  DWIN_Draw_String(false, DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Color_White, false), Color_Bg_Blue, (DWIN_WIDTH - strlen(title) * STAT_CHR_W) / 2, 5, title);
479
 }
475
 }
480
 
476
 
481
 void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, const char * label1, const char * label2, bool more/*=false*/, bool centered/*=false*/) {
477
 void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, const char * label1, const char * label2, bool more/*=false*/, bool centered/*=false*/) {
482
   const uint8_t label_offset_y = !(label1 && label2) ? 0 : MENU_CHR_H * 3 / 5;
478
   const uint8_t label_offset_y = !(label1 && label2) ? 0 : MENU_CHR_H * 3 / 5;
483
   const uint8_t label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label1 ? strlen(label1) : 0) * MENU_CHR_W) / 2);
479
   const uint8_t label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label1 ? strlen(label1) : 0) * MENU_CHR_W) / 2);
484
   const uint8_t label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label2 ? strlen(label2) : 0) * MENU_CHR_W) / 2);
480
   const uint8_t label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label2 ? strlen(label2) : 0) * MENU_CHR_W) / 2);
485
-  if (label1) DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label1_offset_x, MBASE(row) - 1 - label_offset_y, label1); // Draw Label
486
-  if (label2) DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label2_offset_x, MBASE(row) - 1 + label_offset_y, label2); // Draw Label
481
+  if (label1) DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label1_offset_x, MBASE(row) - 1 - label_offset_y, label1); // Draw Label
482
+  if (label2) DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label2_offset_x, MBASE(row) - 1 + label_offset_y, label2); // Draw Label
487
   if (icon) DWIN_ICON_Show(ICON, icon, 26, MBASE(row) - 3);   //Draw Menu Icon
483
   if (icon) DWIN_ICON_Show(ICON, icon, 26, MBASE(row) - 3);   //Draw Menu Icon
488
   if (more) DWIN_ICON_Show(ICON, ICON_More, 226, MBASE(row) - 3); // Draw More Arrow
484
   if (more) DWIN_ICON_Show(ICON, ICON_More, 226, MBASE(row) - 3); // Draw More Arrow
489
   DWIN_Draw_Line(GetColor(eeprom_settings.menu_split_line, Line_Color, true), 16, MBASE(row) + 33, 256, MBASE(row) + 33); // Draw Menu Line
485
   DWIN_Draw_Line(GetColor(eeprom_settings.menu_split_line, Line_Color, true), 16, MBASE(row) + 33, 256, MBASE(row) + 33); // Draw Menu Line
547
   if (selection == 0) {
543
   if (selection == 0) {
548
     DWIN_ICON_Show(ICON, ICON_Print_1, 17, 130);
544
     DWIN_ICON_Show(ICON, ICON_Print_1, 17, 130);
549
     DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 17, 130, 126, 229);
545
     DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 17, 130, 126, 229);
550
-    DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 52, 200, F("Print"));
546
+    DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 52, 200, F("Print"));
551
   }
547
   }
552
   else {
548
   else {
553
     DWIN_ICON_Show(ICON, ICON_Print_0, 17, 130);
549
     DWIN_ICON_Show(ICON, ICON_Print_0, 17, 130);
554
-    DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 52, 200, F("Print"));
550
+    DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 52, 200, F("Print"));
555
   }
551
   }
556
   if (selection == 1) {
552
   if (selection == 1) {
557
     DWIN_ICON_Show(ICON, ICON_Prepare_1, 145, 130);
553
     DWIN_ICON_Show(ICON, ICON_Prepare_1, 145, 130);
558
     DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 130, 254, 229);
554
     DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 130, 254, 229);
559
-    DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 170, 200, F("Prepare"));
555
+    DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 170, 200, F("Prepare"));
560
   }
556
   }
561
   else {
557
   else {
562
     DWIN_ICON_Show(ICON, ICON_Prepare_0, 145, 130);
558
     DWIN_ICON_Show(ICON, ICON_Prepare_0, 145, 130);
563
-    DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 170, 200, F("Prepare"));
559
+    DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 170, 200, F("Prepare"));
564
   }
560
   }
565
   if (selection == 2) {
561
   if (selection == 2) {
566
     DWIN_ICON_Show(ICON, ICON_Control_1, 17, 246);
562
     DWIN_ICON_Show(ICON, ICON_Control_1, 17, 246);
567
     DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 17, 246, 126, 345);
563
     DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 17, 246, 126, 345);
568
-    DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 43, 317, F("Control"));
564
+    DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 43, 317, F("Control"));
569
   }
565
   }
570
   else {
566
   else {
571
     DWIN_ICON_Show(ICON, ICON_Control_0, 17, 246);
567
     DWIN_ICON_Show(ICON, ICON_Control_0, 17, 246);
572
-    DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 43, 317, F("Control"));
568
+    DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 43, 317, F("Control"));
573
   }
569
   }
574
   #if HAS_ABL_OR_UBL
570
   #if HAS_ABL_OR_UBL
575
     if (selection == 3) {
571
     if (selection == 3) {
576
       DWIN_ICON_Show(ICON, ICON_Leveling_1, 145, 246);
572
       DWIN_ICON_Show(ICON, ICON_Leveling_1, 145, 246);
577
       DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 246, 254, 345);
573
       DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 246, 254, 345);
578
-      DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 179, 317, F("Level"));
574
+      DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 179, 317, F("Level"));
579
     }
575
     }
580
     else {
576
     else {
581
       DWIN_ICON_Show(ICON, ICON_Leveling_0, 145, 246);
577
       DWIN_ICON_Show(ICON, ICON_Leveling_0, 145, 246);
582
-      DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 179, 317, F("Level"));
578
+      DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 179, 317, F("Level"));
583
     }
579
     }
584
   #else
580
   #else
585
     if (selection == 3) {
581
     if (selection == 3) {
586
       DWIN_ICON_Show(ICON, ICON_Info_1, 145, 246);
582
       DWIN_ICON_Show(ICON, ICON_Info_1, 145, 246);
587
       DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 246, 254, 345);
583
       DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 246, 254, 345);
588
-      DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 181, 317, F("Info"));
584
+      DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 181, 317, F("Info"));
589
     }
585
     }
590
     else {
586
     else {
591
       DWIN_ICON_Show(ICON, ICON_Info_0, 145, 246);
587
       DWIN_ICON_Show(ICON, ICON_Info_0, 145, 246);
592
-      DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 181, 317, F("Info"));
593
-      //DWIN_Frame_AreaCopy(1, 132, 423, 159, 435, 186, 318);
588
+      DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 181, 317, F("Info"));
594
     }
589
     }
595
   #endif
590
   #endif
596
 }
591
 }
610
   if (selection == 0) {
605
   if (selection == 0) {
611
     DWIN_ICON_Show(ICON, ICON_Setup_1, 8, 252);
606
     DWIN_ICON_Show(ICON, ICON_Setup_1, 8, 252);
612
     DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 8, 252, 87, 351);
607
     DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 8, 252, 87, 351);
613
-    DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 30, 322, F("Tune"));
608
+    DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 30, 322, F("Tune"));
614
   }
609
   }
615
   else {
610
   else {
616
     DWIN_ICON_Show(ICON, ICON_Setup_0, 8, 252);
611
     DWIN_ICON_Show(ICON, ICON_Setup_0, 8, 252);
617
-    DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 30, 322, F("Tune"));
612
+    DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 30, 322, F("Tune"));
618
   }
613
   }
619
   if (selection == 2) {
614
   if (selection == 2) {
620
     DWIN_ICON_Show(ICON, ICON_Stop_1, 184, 252);
615
     DWIN_ICON_Show(ICON, ICON_Stop_1, 184, 252);
621
     DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 184, 252, 263, 351);
616
     DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 184, 252, 263, 351);
622
-    DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 205, 322, F("Stop"));
617
+    DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 205, 322, F("Stop"));
623
   }
618
   }
624
   else {
619
   else {
625
     DWIN_ICON_Show(ICON, ICON_Stop_0, 184, 252);
620
     DWIN_ICON_Show(ICON, ICON_Stop_0, 184, 252);
626
-    DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 205, 322, F("Stop"));
621
+    DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 205, 322, F("Stop"));
627
   }
622
   }
628
   if (paused) {
623
   if (paused) {
629
     if (selection == 1) {
624
     if (selection == 1) {
630
       DWIN_ICON_Show(ICON, ICON_Continue_1, 96, 252);
625
       DWIN_ICON_Show(ICON, ICON_Continue_1, 96, 252);
631
       DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 96, 252, 175, 351);
626
       DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 96, 252, 175, 351);
632
-      DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Print"));
627
+      DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Print"));
633
     }
628
     }
634
     else {
629
     else {
635
       DWIN_ICON_Show(ICON, ICON_Continue_0, 96, 252);
630
       DWIN_ICON_Show(ICON, ICON_Continue_0, 96, 252);
636
-      DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Print"));
631
+      DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Print"));
637
     }
632
     }
638
   }
633
   }
639
   else {
634
   else {
640
     if (selection == 1) {
635
     if (selection == 1) {
641
       DWIN_ICON_Show(ICON, ICON_Pause_1, 96, 252);
636
       DWIN_ICON_Show(ICON, ICON_Pause_1, 96, 252);
642
       DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 96, 252, 175, 351);
637
       DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 96, 252, 175, 351);
643
-      DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Pause"));
638
+      DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Pause"));
644
     }
639
     }
645
     else {
640
     else {
646
       DWIN_ICON_Show(ICON, ICON_Pause_0, 96, 252);
641
       DWIN_ICON_Show(ICON, ICON_Pause_0, 96, 252);
647
-      DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Pause"));
642
+      DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Pause"));
648
     }
643
     }
649
   }
644
   }
650
 }
645
 }
658
   Print_Screen_Icons();
653
   Print_Screen_Icons();
659
   DWIN_ICON_Show(ICON, ICON_PrintTime, 14, 171);
654
   DWIN_ICON_Show(ICON, ICON_PrintTime, 14, 171);
660
   DWIN_ICON_Show(ICON, ICON_RemainTime, 147, 169);
655
   DWIN_ICON_Show(ICON, ICON_RemainTime, 147, 169);
661
-  DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, 41, 163, "Elapsed");
662
-  DWIN_Draw_String(false, false, DWIN_FONT_MENU,  Color_White, Color_Bg_Black, 176, 163, "Remaining");
656
+  DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, 41, 163, F("Elapsed"));
657
+  DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, 176, 163, F("Remaining"));
663
   Update_Status_Bar(true);
658
   Update_Status_Bar(true);
664
   Draw_Print_ProgressBar();
659
   Draw_Print_ProgressBar();
665
   Draw_Print_ProgressElapsed();
660
   Draw_Print_ProgressElapsed();
687
       dispname[len] = '\0';
682
       dispname[len] = '\0';
688
       DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
683
       DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
689
       const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
684
       const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
690
-      DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, dispname);
685
+      DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, dispname);
691
       if (-pos >= 30) namescrl = 0;
686
       if (-pos >= 30) namescrl = 0;
692
       namescrl++;
687
       namescrl++;
693
     }
688
     }
694
     else {
689
     else {
695
       DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
690
       DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
696
       const int8_t npos = (DWIN_WIDTH - strlen(filename) * MENU_CHR_W) / 2;
691
       const int8_t npos = (DWIN_WIDTH - strlen(filename) * MENU_CHR_W) / 2;
697
-      DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, filename);
692
+      DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, filename);
698
     }
693
     }
699
   }
694
   }
700
 }
695
 }
704
   DWIN_ICON_Show(ICON, ICON_Bar, 15, 93);
699
   DWIN_ICON_Show(ICON, ICON_Bar, 15, 93);
705
   DWIN_Draw_Rectangle(1, BarFill_Color, 16 + printpercent * 240 / 100, 93, 256, 113);
700
   DWIN_Draw_Rectangle(1, BarFill_Color, 16 + printpercent * 240 / 100, 93, 256, 113);
706
   DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 3, 109, 133, printpercent);
701
   DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 3, 109, 133, printpercent);
707
-  DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 133, 133, "%");
702
+  DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 133, 133, F("%"));
708
 }
703
 }
709
 
704
 
710
 #if ENABLED(USE_M73_REMAINING_TIME)
705
 #if ENABLED(USE_M73_REMAINING_TIME)
714
     DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 176, 187, remainingtime / 3600);
709
     DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 176, 187, remainingtime / 3600);
715
     DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 200, 187, (remainingtime % 3600) / 60);
710
     DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 200, 187, (remainingtime % 3600) / 60);
716
     if (eeprom_settings.time_format_textual) {
711
     if (eeprom_settings.time_format_textual) {
717
-      DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 192, 187, "h");
718
-      DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 216, 187, "m");
712
+      DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 192, 187, F("h"));
713
+      DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 216, 187, F("m"));
719
     }
714
     }
720
     else
715
     else
721
-      DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 192, 187, ":");
716
+      DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 192, 187, F(":"));
722
   }
717
   }
723
 
718
 
724
 #endif
719
 #endif
728
   DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 42, 187, elapsed.value / 3600);
723
   DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 42, 187, elapsed.value / 3600);
729
   DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 66, 187, (elapsed.value % 3600) / 60);
724
   DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 66, 187, (elapsed.value % 3600) / 60);
730
   if (eeprom_settings.time_format_textual) {
725
   if (eeprom_settings.time_format_textual) {
731
-    DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 58, 187, "h");
732
-    DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 82, 187, "m");
726
+    DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 58, 187, F("h"));
727
+    DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 82, 187, F("m"));
733
   }
728
   }
734
   else
729
   else
735
-    DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 58, 187, ":");
730
+    DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 58, 187, F(":"));
736
 }
731
 }
737
 
732
 
738
 void CrealityDWINClass::Draw_Print_confirm() {
733
 void CrealityDWINClass::Draw_Print_confirm() {
779
   else {
774
   else {
780
     Draw_Menu_Item(0, ICON_Back, "Back");
775
     Draw_Menu_Item(0, ICON_Back, "Back");
781
     DWIN_Draw_Rectangle(1, Color_Bg_Red, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4));
776
     DWIN_Draw_Rectangle(1, Color_Bg_Red, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4));
782
-    DWIN_Draw_String(false, false, font16x32, Color_Yellow, Color_Bg_Red, ((DWIN_WIDTH) - 8 * 16) / 2, MBASE(3), "No Media");
777
+    DWIN_Draw_String(false, font16x32, Color_Yellow, Color_Bg_Red, ((DWIN_WIDTH) - 8 * 16) / 2, MBASE(3), F("No Media"));
783
   }
778
   }
784
   DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(0) - 18, 14, MBASE(0) + 33);
779
   DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(0) - 18, 14, MBASE(0) + 33);
785
 }
780
 }
795
       hotend = -1;
790
       hotend = -1;
796
       hotendtarget = -1;
791
       hotendtarget = -1;
797
       DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383);
792
       DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383);
798
-      DWIN_Draw_String(false, false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, F("/"));
793
+      DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, F("/"));
799
     }
794
     }
800
     if (thermalManager.temp_hotend[0].celsius != hotend) {
795
     if (thermalManager.temp_hotend[0].celsius != hotend) {
801
       hotend = thermalManager.temp_hotend[0].celsius;
796
       hotend = thermalManager.temp_hotend[0].celsius;
810
     if (icons) {
805
     if (icons) {
811
       flow = -1;
806
       flow = -1;
812
       DWIN_ICON_Show(ICON, ICON_StepE, 112, 417);
807
       DWIN_ICON_Show(ICON, ICON_StepE, 112, 417);
813
-      DWIN_Draw_String(false, false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 417, F("%"));
808
+      DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 417, F("%"));
814
     }
809
     }
815
     if (planner.flow_percentage[0] != flow) {
810
     if (planner.flow_percentage[0] != flow) {
816
       flow = planner.flow_percentage[0];
811
       flow = planner.flow_percentage[0];
825
       bed = -1;
820
       bed = -1;
826
       bedtarget = -1;
821
       bedtarget = -1;
827
       DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416);
822
       DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416);
828
-      DWIN_Draw_String(false, false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, F("/"));
823
+      DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, F("/"));
829
     }
824
     }
830
     if (thermalManager.temp_bed.celsius != bed) {
825
     if (thermalManager.temp_bed.celsius != bed) {
831
       bed = thermalManager.temp_bed.celsius;
826
       bed = thermalManager.temp_bed.celsius;
860
     }
855
     }
861
     if (zoffsetvalue != offset) {
856
     if (zoffsetvalue != offset) {
862
       offset = zoffsetvalue;
857
       offset = zoffsetvalue;
863
-      if (zoffsetvalue < 0) {
864
-        DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 2, 2, 207, 417, -zoffsetvalue * 100);
865
-        DWIN_Draw_String(false, true, DWIN_FONT_MENU, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 205, 419, "-");
866
-      }
867
-      else {
868
-        DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 2, 2, 207, 417, zoffsetvalue* 100);
869
-        DWIN_Draw_String(false, true, DWIN_FONT_MENU, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 205, 419, " ");
870
-      }
858
+      DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 2, 2, 207, 417, (zoffsetvalue < 0 ? -zoffsetvalue : zoffsetvalue) * 100);
859
+      DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 205, 419, zoffsetvalue < 0 ? F("-") : F(" "));
871
     }
860
     }
872
   #endif
861
   #endif
873
 
862
 
875
   if (icons) {
864
   if (icons) {
876
     feedrate = -1;
865
     feedrate = -1;
877
     DWIN_ICON_Show(ICON, ICON_Speed, 113, 383);
866
     DWIN_ICON_Show(ICON, ICON_Speed, 113, 383);
878
-    DWIN_Draw_String(false, false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 384, F("%"));
867
+    DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 384, F("%"));
879
   }
868
   }
880
   if (feedrate_percentage != feedrate) {
869
   if (feedrate_percentage != feedrate) {
881
     feedrate = feedrate_percentage;
870
     feedrate = feedrate_percentage;
897
   if (update_x) {
886
   if (update_x) {
898
     x = current_position.x;
887
     x = current_position.x;
899
     if ((update_x = axis_should_home(X_AXIS) && ui.get_blink()))
888
     if ((update_x = axis_should_home(X_AXIS) && ui.get_blink()))
900
-      DWIN_Draw_String(false, true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 35, 459, "  -?-  ");
889
+      DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 35, 459, F("  -?-  "));
901
     else
890
     else
902
       DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 1, 35, 459, current_position.x * 10);
891
       DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 1, 35, 459, current_position.x * 10);
903
   }
892
   }
904
   if (update_y) {
893
   if (update_y) {
905
     y = current_position.y;
894
     y = current_position.y;
906
     if ((update_y = axis_should_home(Y_AXIS) && ui.get_blink()))
895
     if ((update_y = axis_should_home(Y_AXIS) && ui.get_blink()))
907
-      DWIN_Draw_String(false, true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 120, 459, "  -?-  ");
896
+      DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 120, 459, F("  -?-  "));
908
     else
897
     else
909
       DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 1, 120, 459, current_position.y * 10);
898
       DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 1, 120, 459, current_position.y * 10);
910
   }
899
   }
911
   if (update_z) {
900
   if (update_z) {
912
     z = current_position.z;
901
     z = current_position.z;
913
     if ((update_z = axis_should_home(Z_AXIS) && ui.get_blink()))
902
     if ((update_z = axis_should_home(Z_AXIS) && ui.get_blink()))
914
-      DWIN_Draw_String(false, true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 205, 459, "  -?-  ");
903
+      DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 205, 459, F("  -?-  "));
915
     else
904
     else
916
       DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 2, 205, 459, (current_position.z>=0) ? current_position.z * 100 : 0);
905
       DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 2, 205, 459, (current_position.z>=0) ? current_position.z * 100 : 0);
917
   }
906
   }
927
   DWIN_Draw_Rectangle(1, Color_Bg_Window, 14, 60, 258, 350);
916
   DWIN_Draw_Rectangle(1, Color_Bg_Window, 14, 60, 258, 350);
928
   const uint8_t ypos = (mode == Popup || mode == Confirm) ? 150 : 230;
917
   const uint8_t ypos = (mode == Popup || mode == Confirm) ? 150 : 230;
929
   if (icon > 0) DWIN_ICON_Show(ICON, icon, 101, 105);
918
   if (icon > 0) DWIN_ICON_Show(ICON, icon, 101, 105);
930
-  DWIN_Draw_String(false, true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(line1)) / 2, ypos, line1);
931
-  DWIN_Draw_String(false, true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(line2)) / 2, ypos + 30, line2);
932
-  DWIN_Draw_String(false, true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(line3)) / 2, ypos + 60, line3);
919
+  DWIN_Draw_String(true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(line1)) / 2, ypos, line1);
920
+  DWIN_Draw_String(true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(line2)) / 2, ypos + 30, line2);
921
+  DWIN_Draw_String(true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(line3)) / 2, ypos + 60, line3);
933
   if (mode == Popup) {
922
   if (mode == Popup) {
934
     selection = 0;
923
     selection = 0;
935
     DWIN_Draw_Rectangle(1, Confirm_Color, 26, 280, 125, 317);
924
     DWIN_Draw_Rectangle(1, Confirm_Color, 26, 280, 125, 317);
936
     DWIN_Draw_Rectangle(1, Cancel_Color, 146, 280, 245, 317);
925
     DWIN_Draw_Rectangle(1, Cancel_Color, 146, 280, 245, 317);
937
-    DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 39, 290, "Confirm");
938
-    DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 165, 290, "Cancel");
926
+    DWIN_Draw_String(false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 39, 290, F("Confirm"));
927
+    DWIN_Draw_String(false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 165, 290, F("Cancel"));
939
     Popup_Select();
928
     Popup_Select();
940
   }
929
   }
941
   else if (mode == Confirm) {
930
   else if (mode == Confirm) {
942
     DWIN_Draw_Rectangle(1, Confirm_Color, 87, 280, 186, 317);
931
     DWIN_Draw_Rectangle(1, Confirm_Color, 87, 280, 186, 317);
943
-    DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 96, 290, "Continue");
932
+    DWIN_Draw_String(false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 96, 290, F("Continue"));
944
   }
933
   }
945
 }
934
 }
946
 
935
 
985
     if (process == Print) {
974
     if (process == Print) {
986
       DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238);
975
       DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238);
987
       const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
976
       const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
988
-      DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, dispmsg);
977
+      DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, dispmsg);
989
     }
978
     }
990
     else {
979
     else {
991
       DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376);
980
       DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376);
992
       const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
981
       const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
993
-      DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, dispmsg);
982
+      DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, dispmsg);
994
     }
983
     }
995
     if (-pos >= 30) msgscrl = 0;
984
     if (-pos >= 30) msgscrl = 0;
996
     msgscrl++;
985
     msgscrl++;
1001
       if (process == Print) {
990
       if (process == Print) {
1002
         DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238);
991
         DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238);
1003
         const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2;
992
         const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2;
1004
-        DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, statusmsg);
993
+        DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, statusmsg);
1005
       }
994
       }
1006
       else {
995
       else {
1007
         DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376);
996
         DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376);
1008
         const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2;
997
         const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2;
1009
-        DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, statusmsg);
998
+        DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, statusmsg);
1010
       }
999
       }
1011
     }
1000
     }
1012
   }
1001
   }
1280
         #if HAS_BED_PROBE
1269
         #if HAS_BED_PROBE
1281
           case MOVE_P:
1270
           case MOVE_P:
1282
             if (draw) {
1271
             if (draw) {
1283
-              Draw_Menu_Item(row, ICON_StockConfiguraton, "Probe");
1272
+              Draw_Menu_Item(row, ICON_StockConfiguration, "Probe");
1284
               Draw_Checkbox(row, probe_deployed);
1273
               Draw_Checkbox(row, probe_deployed);
1285
             }
1274
             }
1286
             else {
1275
             else {
2866
     case Advanced:
2855
     case Advanced:
2867
 
2856
 
2868
       #define ADVANCED_BACK 0
2857
       #define ADVANCED_BACK 0
2869
-      #define ADVANCED_BEEPER (ADVANCED_BACK + 1)
2858
+      #define ADVANCED_BEEPER (ADVANCED_BACK + ENABLED(SOUND_MENU_ITEM))
2870
       #define ADVANCED_PROBE (ADVANCED_BEEPER + ENABLED(HAS_BED_PROBE))
2859
       #define ADVANCED_PROBE (ADVANCED_BEEPER + ENABLED(HAS_BED_PROBE))
2871
       #define ADVANCED_CORNER (ADVANCED_PROBE + 1)
2860
       #define ADVANCED_CORNER (ADVANCED_PROBE + 1)
2872
       #define ADVANCED_LA (ADVANCED_CORNER + ENABLED(LIN_ADVANCE))
2861
       #define ADVANCED_LA (ADVANCED_CORNER + ENABLED(LIN_ADVANCE))
2886
             Draw_Menu(Control, CONTROL_ADVANCED);
2875
             Draw_Menu(Control, CONTROL_ADVANCED);
2887
           break;
2876
           break;
2888
 
2877
 
2889
-        case ADVANCED_BEEPER:
2890
-          if (draw) {
2891
-            Draw_Menu_Item(row, ICON_Version, "LCD Beeper");
2892
-            Draw_Checkbox(row, eeprom_settings.beeperenable);
2893
-          }
2894
-          else {
2895
-            eeprom_settings.beeperenable = !eeprom_settings.beeperenable;
2896
-            Draw_Checkbox(row, eeprom_settings.beeperenable);
2897
-          }
2898
-          break;
2878
+        #if ENABLED(SOUND_MENU_ITEM)
2879
+          case ADVANCED_BEEPER:
2880
+            if (draw) {
2881
+              Draw_Menu_Item(row, ICON_Version, "LCD Beeper");
2882
+              Draw_Checkbox(row, ui.buzzer_enabled);
2883
+            }
2884
+            else {
2885
+              ui.buzzer_enabled = !ui.buzzer_enabled;
2886
+              Draw_Checkbox(row, ui.buzzer_enabled);
2887
+            }
2888
+            break;
2889
+        #endif
2899
 
2890
 
2900
         #if HAS_BED_PROBE
2891
         #if HAS_BED_PROBE
2901
           case ADVANCED_PROBE:
2892
           case ADVANCED_PROBE:
3122
             break;
3113
             break;
3123
           case LEVELING_ACTIVE:
3114
           case LEVELING_ACTIVE:
3124
             if (draw) {
3115
             if (draw) {
3125
-              Draw_Menu_Item(row, ICON_StockConfiguraton, "Leveling Active");
3116
+              Draw_Menu_Item(row, ICON_StockConfiguration, "Leveling Active");
3126
               Draw_Checkbox(row, planner.leveling_active);
3117
               Draw_Checkbox(row, planner.leveling_active);
3127
             }
3118
             }
3128
             else {
3119
             else {
3407
               if (draw)
3398
               if (draw)
3408
                 Draw_Menu_Item(row, ICON_Mesh, "Zero Current Mesh");
3399
                 Draw_Menu_Item(row, ICON_Mesh, "Zero Current Mesh");
3409
               else
3400
               else
3410
-                ZERO(mesh_conf.mesh_z_values);
3401
+                ZERO(Z_VALUES_ARR);
3411
               break;
3402
               break;
3412
             case LEVELING_SETTINGS_UNDEF:
3403
             case LEVELING_SETTINGS_UNDEF:
3413
               if (draw)
3404
               if (draw)
3493
           case LEVELING_M_OFFSET:
3484
           case LEVELING_M_OFFSET:
3494
             if (draw) {
3485
             if (draw) {
3495
               Draw_Menu_Item(row, ICON_SetZOffset, "Point Z Offset");
3486
               Draw_Menu_Item(row, ICON_SetZOffset, "Point Z Offset");
3496
-              Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100);
3487
+              Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100);
3497
             }
3488
             }
3498
             else {
3489
             else {
3499
-              if (isnan(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y]))
3500
-                mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0;
3501
-              Modify_Value(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
3490
+              if (isnan(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y]))
3491
+                Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0;
3492
+              Modify_Value(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
3502
             }
3493
             }
3503
             break;
3494
             break;
3504
           case LEVELING_M_UP:
3495
           case LEVELING_M_UP:
3505
             if (draw)
3496
             if (draw)
3506
               Draw_Menu_Item(row, ICON_Axis, "Microstep Up");
3497
               Draw_Menu_Item(row, ICON_Axis, "Microstep Up");
3507
-            else if (mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) {
3508
-              mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01;
3498
+            else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) {
3499
+              Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01;
3509
               gcode.process_subcommands_now_P(PSTR("M290 Z0.01"));
3500
               gcode.process_subcommands_now_P(PSTR("M290 Z0.01"));
3510
               planner.synchronize();
3501
               planner.synchronize();
3511
               current_position.z += 0.01f;
3502
               current_position.z += 0.01f;
3512
               sync_plan_position();
3503
               sync_plan_position();
3513
-              Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100);
3504
+              Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100);
3514
             }
3505
             }
3515
             break;
3506
             break;
3516
           case LEVELING_M_DOWN:
3507
           case LEVELING_M_DOWN:
3517
             if (draw)
3508
             if (draw)
3518
               Draw_Menu_Item(row, ICON_AxisD, "Microstep Down");
3509
               Draw_Menu_Item(row, ICON_AxisD, "Microstep Down");
3519
-            else if (mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) {
3520
-              mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01;
3510
+            else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) {
3511
+              Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01;
3521
               gcode.process_subcommands_now_P(PSTR("M290 Z-0.01"));
3512
               gcode.process_subcommands_now_P(PSTR("M290 Z-0.01"));
3522
               planner.synchronize();
3513
               planner.synchronize();
3523
               current_position.z -= 0.01f;
3514
               current_position.z -= 0.01f;
3524
               sync_plan_position();
3515
               sync_plan_position();
3525
-              Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100);
3516
+              Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100);
3526
             }
3517
             }
3527
             break;
3518
             break;
3528
           case LEVELING_M_GOTO_VALUE:
3519
           case LEVELING_M_GOTO_VALUE:
3529
             if (draw) {
3520
             if (draw) {
3530
-              Draw_Menu_Item(row, ICON_StockConfiguraton, "Go to Mesh Z Value");
3521
+              Draw_Menu_Item(row, ICON_StockConfiguration, "Go to Mesh Z Value");
3531
               Draw_Checkbox(row, mesh_conf.goto_mesh_value);
3522
               Draw_Checkbox(row, mesh_conf.goto_mesh_value);
3532
             }
3523
             }
3533
             else {
3524
             else {
3614
           case UBL_M_OFFSET:
3605
           case UBL_M_OFFSET:
3615
             if (draw) {
3606
             if (draw) {
3616
               Draw_Menu_Item(row, ICON_SetZOffset, "Point Z Offset");
3607
               Draw_Menu_Item(row, ICON_SetZOffset, "Point Z Offset");
3617
-              Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100);
3608
+              Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100);
3618
             }
3609
             }
3619
             else {
3610
             else {
3620
-              if (isnan(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y]))
3621
-                mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0;
3622
-              Modify_Value(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
3611
+              if (isnan(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y]))
3612
+                Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0;
3613
+              Modify_Value(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
3623
             }
3614
             }
3624
             break;
3615
             break;
3625
           case UBL_M_UP:
3616
           case UBL_M_UP:
3626
             if (draw)
3617
             if (draw)
3627
               Draw_Menu_Item(row, ICON_Axis, "Microstep Up");
3618
               Draw_Menu_Item(row, ICON_Axis, "Microstep Up");
3628
-            else if (mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) {
3629
-              mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01;
3619
+            else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) {
3620
+              Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01;
3630
               gcode.process_subcommands_now_P(PSTR("M290 Z0.01"));
3621
               gcode.process_subcommands_now_P(PSTR("M290 Z0.01"));
3631
               planner.synchronize();
3622
               planner.synchronize();
3632
               current_position.z += 0.01f;
3623
               current_position.z += 0.01f;
3633
               sync_plan_position();
3624
               sync_plan_position();
3634
-              Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100);
3625
+              Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100);
3635
             }
3626
             }
3636
             break;
3627
             break;
3637
           case UBL_M_DOWN:
3628
           case UBL_M_DOWN:
3638
             if (draw)
3629
             if (draw)
3639
               Draw_Menu_Item(row, ICON_Axis, "Microstep Down");
3630
               Draw_Menu_Item(row, ICON_Axis, "Microstep Down");
3640
-            else if (mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) {
3641
-              mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01;
3631
+            else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) {
3632
+              Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01;
3642
               gcode.process_subcommands_now_P(PSTR("M290 Z-0.01"));
3633
               gcode.process_subcommands_now_P(PSTR("M290 Z-0.01"));
3643
               planner.synchronize();
3634
               planner.synchronize();
3644
               current_position.z -= 0.01f;
3635
               current_position.z -= 0.01f;
3645
               sync_plan_position();
3636
               sync_plan_position();
3646
-              Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100);
3637
+              Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100);
3647
             }
3638
             }
3648
             break;
3639
             break;
3649
         }
3640
         }
3733
             if (mesh_y % 2 == 1)
3724
             if (mesh_y % 2 == 1)
3734
               mesh_x = GRID_MAX_POINTS_X - mesh_x - 1;
3725
               mesh_x = GRID_MAX_POINTS_X - mesh_x - 1;
3735
 
3726
 
3736
-            const float currval = mesh_conf.mesh_z_values[mesh_x][mesh_y];
3727
+            const float currval = Z_VALUES_ARR[mesh_x][mesh_y];
3737
 
3728
 
3738
             if (draw) {
3729
             if (draw) {
3739
               Draw_Menu_Item(row, ICON_Zoffset, "Goto Mesh Value");
3730
               Draw_Menu_Item(row, ICON_Zoffset, "Goto Mesh Value");
4215
 /* Navigation and Control */
4206
 /* Navigation and Control */
4216
 
4207
 
4217
 void CrealityDWINClass::Main_Menu_Control() {
4208
 void CrealityDWINClass::Main_Menu_Control() {
4218
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
4209
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
4219
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4210
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4220
   if (encoder_diffState == ENCODER_DIFF_CW && selection < PAGE_COUNT - 1) {
4211
   if (encoder_diffState == ENCODER_DIFF_CW && selection < PAGE_COUNT - 1) {
4221
     selection++; // Select Down
4212
     selection++; // Select Down
4236
 }
4227
 }
4237
 
4228
 
4238
 void CrealityDWINClass::Menu_Control() {
4229
 void CrealityDWINClass::Menu_Control() {
4239
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
4230
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
4240
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4231
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4241
   if (encoder_diffState == ENCODER_DIFF_CW && selection < Get_Menu_Size(active_menu)) {
4232
   if (encoder_diffState == ENCODER_DIFF_CW && selection < Get_Menu_Size(active_menu)) {
4242
     DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33);
4233
     DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33);
4264
 }
4255
 }
4265
 
4256
 
4266
 void CrealityDWINClass::Value_Control() {
4257
 void CrealityDWINClass::Value_Control() {
4267
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
4258
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
4268
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4259
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4269
   if (encoder_diffState == ENCODER_DIFF_CW)
4260
   if (encoder_diffState == ENCODER_DIFF_CW)
4270
     tempvalue += EncoderRate.encoderMoveValue;
4261
     tempvalue += EncoderRate.encoderMoveValue;
4329
 }
4320
 }
4330
 
4321
 
4331
 void CrealityDWINClass::Option_Control() {
4322
 void CrealityDWINClass::Option_Control() {
4332
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
4323
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
4333
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4324
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4334
   if (encoder_diffState == ENCODER_DIFF_CW)
4325
   if (encoder_diffState == ENCODER_DIFF_CW)
4335
     tempvalue += EncoderRate.encoderMoveValue;
4326
     tempvalue += EncoderRate.encoderMoveValue;
4368
 }
4359
 }
4369
 
4360
 
4370
 void CrealityDWINClass::File_Control() {
4361
 void CrealityDWINClass::File_Control() {
4371
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
4362
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
4372
   static uint8_t filescrl = 0;
4363
   static uint8_t filescrl = 0;
4373
   if (encoder_diffState == ENCODER_DIFF_NO) {
4364
   if (encoder_diffState == ENCODER_DIFF_NO) {
4374
     if (selection > 0) {
4365
     if (selection > 0) {
4456
 }
4447
 }
4457
 
4448
 
4458
 void CrealityDWINClass::Print_Screen_Control() {
4449
 void CrealityDWINClass::Print_Screen_Control() {
4459
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
4450
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
4460
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4451
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4461
   if (encoder_diffState == ENCODER_DIFF_CW && selection < PRINT_COUNT - 1) {
4452
   if (encoder_diffState == ENCODER_DIFF_CW && selection < PRINT_COUNT - 1) {
4462
     selection++; // Select Down
4453
     selection++; // Select Down
4509
 }
4500
 }
4510
 
4501
 
4511
 void CrealityDWINClass::Popup_Control() {
4502
 void CrealityDWINClass::Popup_Control() {
4512
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
4503
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
4513
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4504
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4514
   if (encoder_diffState == ENCODER_DIFF_CW && selection < 1) {
4505
   if (encoder_diffState == ENCODER_DIFF_CW && selection < 1) {
4515
     selection++;
4506
     selection++;
4659
 }
4650
 }
4660
 
4651
 
4661
 void CrealityDWINClass::Confirm_Control() {
4652
 void CrealityDWINClass::Confirm_Control() {
4662
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
4653
+  EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
4663
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4654
   if (encoder_diffState == ENCODER_DIFF_NO) return;
4664
   if (encoder_diffState == ENCODER_DIFF_ENTER) {
4655
   if (encoder_diffState == ENCODER_DIFF_ENTER) {
4665
     switch (popup) {
4656
     switch (popup) {
4967
 
4958
 
4968
 void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) {
4959
 void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) {
4969
   if (success) {
4960
   if (success) {
4970
-    if (eeprom_settings.beeperenable) {
4961
+    if (ui.buzzer_enabled) {
4971
       BUZZ(100, 659);
4962
       BUZZ(100, 659);
4972
       BUZZ( 10,   0);
4963
       BUZZ( 10,   0);
4973
       BUZZ(100, 698);
4964
       BUZZ(100, 698);
4974
     }
4965
     }
4975
     else Update_Status("Success");
4966
     else Update_Status("Success");
4976
   }
4967
   }
4977
-  else if (eeprom_settings.beeperenable)
4968
+  else if (ui.buzzer_enabled)
4978
     BUZZ(40, 440);
4969
     BUZZ(40, 440);
4979
   else
4970
   else
4980
     Update_Status("Failed");
4971
     Update_Status("Failed");
5003
 
4994
 
5004
 void CrealityDWINClass::Reset_Settings() {
4995
 void CrealityDWINClass::Reset_Settings() {
5005
   eeprom_settings.time_format_textual = false;
4996
   eeprom_settings.time_format_textual = false;
5006
-  eeprom_settings.beeperenable = true;
5007
   TERN_(AUTO_BED_LEVELING_UBL, eeprom_settings.tilt_grid_size = 0);
4997
   TERN_(AUTO_BED_LEVELING_UBL, eeprom_settings.tilt_grid_size = 0);
5008
   eeprom_settings.corner_pos = 325;
4998
   eeprom_settings.corner_pos = 325;
5009
   eeprom_settings.cursor_color = 0;
4999
   eeprom_settings.cursor_color = 0;
5019
   eeprom_settings.coordinates_split_line = 0;
5009
   eeprom_settings.coordinates_split_line = 0;
5020
   TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1);
5010
   TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1);
5021
   corner_pos = eeprom_settings.corner_pos / 10.0f;
5011
   corner_pos = eeprom_settings.corner_pos / 10.0f;
5012
+  TERN_(SOUND_MENU_ITEM, ui.buzzer_enabled = true);
5022
   Redraw_Screen();
5013
   Redraw_Screen();
5023
 }
5014
 }
5024
 
5015
 

+ 10
- 131
Marlin/src/lcd/e3v2/jyersui/dwin.h 查看文件

26
  */
26
  */
27
 
27
 
28
 #include "dwin_lcd.h"
28
 #include "dwin_lcd.h"
29
-#include "rotary_encoder.h"
29
+#include "../common/dwin_set.h"
30
+#include "../common/dwin_font.h"
31
+#include "../common/dwin_color.h"
32
+#include "../common/encoder.h"
30
 #include "../../../libs/BL24CXX.h"
33
 #include "../../../libs/BL24CXX.h"
34
+
31
 #include "../../../inc/MarlinConfigPre.h"
35
 #include "../../../inc/MarlinConfigPre.h"
32
 
36
 
37
+//#define DWIN_CREALITY_LCD_CUSTOM_ICONS
38
+
33
 enum processID : uint8_t {
39
 enum processID : uint8_t {
34
   Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait
40
   Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait
35
 };
41
 };
82
   PreheatHotend
88
   PreheatHotend
83
 };
89
 };
84
 
90
 
85
-#define Start_Process       0
86
-#define Language_English    1
87
-#define Language_Chinese    2
88
-
89
-#define ICON                7 // Icon set file 7.ICO
90
-
91
-#define ICON_LOGO                  0
92
-#define ICON_Print_0               1
93
-#define ICON_Print_1               2
94
-#define ICON_Prepare_0             3
95
-#define ICON_Prepare_1             4
96
-#define ICON_Control_0             5
97
-#define ICON_Control_1             6
98
-#define ICON_Leveling_0            7
99
-#define ICON_Leveling_1            8
100
-#define ICON_HotendTemp            9
101
-#define ICON_BedTemp              10
102
-#define ICON_Speed                11
103
-#define ICON_Zoffset              12
104
-#define ICON_Back                 13
105
-#define ICON_File                 14
106
-#define ICON_PrintTime            15
107
-#define ICON_RemainTime           16
108
-#define ICON_Setup_0              17
109
-#define ICON_Setup_1              18
110
-#define ICON_Pause_0              19
111
-#define ICON_Pause_1              20
112
-#define ICON_Continue_0           21
113
-#define ICON_Continue_1           22
114
-#define ICON_Stop_0               23
115
-#define ICON_Stop_1               24
116
-#define ICON_Bar                  25
117
-#define ICON_More                 26
118
-
119
-#define ICON_Axis                 27
120
-#define ICON_CloseMotor           28
121
-#define ICON_Homing               29
122
-#define ICON_SetHome              30
123
-#define ICON_PLAPreheat           31
124
-#define ICON_ABSPreheat           32
125
-#define ICON_Cool                 33
126
-#define ICON_Language             34
127
-
128
-#define ICON_MoveX                35
129
-#define ICON_MoveY                36
130
-#define ICON_MoveZ                37
131
-#define ICON_Extruder             38
132
-
133
-#define ICON_Temperature          40
134
-#define ICON_Motion               41
135
-#define ICON_WriteEEPROM          42
136
-#define ICON_ReadEEPROM           43
137
-#define ICON_ResumeEEPROM         44
138
-#define ICON_Info                 45
139
-
140
-#define ICON_SetEndTemp           46
141
-#define ICON_SetBedTemp           47
142
-#define ICON_FanSpeed             48
143
-#define ICON_SetPLAPreheat        49
144
-#define ICON_SetABSPreheat        50
145
-
146
-#define ICON_MaxSpeed             51
147
-#define ICON_MaxAccelerated       52
148
-#define ICON_MaxJerk              53
149
-#define ICON_Step                 54
150
-#define ICON_PrintSize            55
151
-#define ICON_Version              56
152
-#define ICON_Contact              57
153
-#define ICON_StockConfiguraton    58
154
-#define ICON_MaxSpeedX            59
155
-#define ICON_MaxSpeedY            60
156
-#define ICON_MaxSpeedZ            61
157
-#define ICON_MaxSpeedE            62
158
-#define ICON_MaxAccX              63
159
-#define ICON_MaxAccY              64
160
-#define ICON_MaxAccZ              65
161
-#define ICON_MaxAccE              66
162
-#define ICON_MaxSpeedJerkX        67
163
-#define ICON_MaxSpeedJerkY        68
164
-#define ICON_MaxSpeedJerkZ        69
165
-#define ICON_MaxSpeedJerkE        70
166
-#define ICON_StepX                71
167
-#define ICON_StepY                72
168
-#define ICON_StepZ                73
169
-#define ICON_StepE                74
170
-#define ICON_Setspeed             75
171
-#define ICON_SetZOffset           76
172
-#define ICON_Rectangle            77
173
-#define ICON_BLTouch              78
174
-#define ICON_TempTooLow           79
175
-#define ICON_AutoLeveling         80
176
-#define ICON_TempTooHigh          81
177
-#define ICON_NoTips_C             82
178
-#define ICON_NoTips_E             83
179
-#define ICON_Continue_C           84
180
-#define ICON_Continue_E           85
181
-#define ICON_Cancel_C             86
182
-#define ICON_Cancel_E             87
183
-#define ICON_Confirm_C            88
184
-#define ICON_Confirm_E            89
185
-#define ICON_Info_0               90
186
-#define ICON_Info_1               91
187
-
188
 // Custom icons
91
 // Custom icons
189
 #if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS)
92
 #if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS)
190
   // index of every custom icon should be >= CUSTOM_ICON_START
93
   // index of every custom icon should be >= CUSTOM_ICON_START
214
   #define ICON_AxisC                ICON_Axis
117
   #define ICON_AxisC                ICON_Axis
215
 #endif
118
 #endif
216
 
119
 
217
-#define font6x12  0x00
218
-#define font8x16  0x01
219
-#define font10x20 0x02
220
-#define font12x24 0x03
221
-#define font14x28 0x04
222
-#define font16x32 0x05
223
-#define font20x40 0x06
224
-#define font24x48 0x07
225
-#define font28x56 0x08
226
-#define font32x64 0x09
227
-
228
 enum colorID : uint8_t {
120
 enum colorID : uint8_t {
229
   Default, White, Green, Cyan, Blue, Magenta, Red, Orange, Yellow, Brown, Black
121
   Default, White, Green, Cyan, Blue, Magenta, Red, Orange, Yellow, Brown, Black
230
 };
122
 };
231
 
123
 
232
 #define Custom_Colors       10
124
 #define Custom_Colors       10
233
-#define Color_White         0xFFFF
125
+#define Color_Aqua          RGB(0x00,0x3F,0x1F)
234
 #define Color_Light_White   0xBDD7
126
 #define Color_Light_White   0xBDD7
235
-#define Color_Green         0x07E0
127
+#define Color_Green         RGB(0x00,0x3F,0x00)
236
 #define Color_Light_Green   0x3460
128
 #define Color_Light_Green   0x3460
237
 #define Color_Cyan          0x07FF
129
 #define Color_Cyan          0x07FF
238
 #define Color_Light_Cyan    0x04F3
130
 #define Color_Light_Cyan    0x04F3
240
 #define Color_Light_Blue    0x3A6A
132
 #define Color_Light_Blue    0x3A6A
241
 #define Color_Magenta       0xF81F
133
 #define Color_Magenta       0xF81F
242
 #define Color_Light_Magenta 0x9813
134
 #define Color_Light_Magenta 0x9813
243
-#define Color_Red           0xF800
244
 #define Color_Light_Red     0x8800
135
 #define Color_Light_Red     0x8800
245
 #define Color_Orange        0xFA20
136
 #define Color_Orange        0xFA20
246
 #define Color_Light_Orange  0xFBC0
137
 #define Color_Light_Orange  0xFBC0
247
-#define Color_Yellow        0xFF0F
248
 #define Color_Light_Yellow  0x8BE0
138
 #define Color_Light_Yellow  0x8BE0
249
 #define Color_Brown         0xCC27
139
 #define Color_Brown         0xCC27
250
 #define Color_Light_Brown   0x6204
140
 #define Color_Light_Brown   0x6204
251
 #define Color_Black         0x0000
141
 #define Color_Black         0x0000
252
 #define Color_Grey          0x18E3
142
 #define Color_Grey          0x18E3
253
-#define Color_Bg_Window     0x31E8  // Popup background color
254
-#define Color_Bg_Blue       0x1125  // Dark blue background color
255
-#define Color_Bg_Black      0x0841  // Black background color
256
-#define Color_Bg_Red        0xF00F  // Red background color
257
-#define Popup_Text_Color    0xD6BA  // Popup font background color
258
-#define Line_Color          0x3A6A  // Split line color
259
-#define Rectangle_Color     0xEE2F  // Blue square cursor color
260
-#define Percent_Color       0xFE29  // Percentage color
261
-#define BarFill_Color       0x10E4  // Fill color of progress bar
262
-#define Select_Color        0x33BB  // Selected color
263
 #define Check_Color         0x4E5C  // Check-box check color
143
 #define Check_Color         0x4E5C  // Check-box check color
264
-#define Confirm_Color   	  0x34B9
144
+#define Confirm_Color       0x34B9
265
 #define Cancel_Color        0x3186
145
 #define Cancel_Color        0x3186
266
 
146
 
267
 class CrealityDWINClass {
147
 class CrealityDWINClass {
269
   static constexpr size_t eeprom_data_size = 48;
149
   static constexpr size_t eeprom_data_size = 48;
270
   static struct EEPROM_Settings { // use bit fields to save space, max 48 bytes
150
   static struct EEPROM_Settings { // use bit fields to save space, max 48 bytes
271
     bool time_format_textual : 1;
151
     bool time_format_textual : 1;
272
-    bool beeperenable : 1;
273
     #if ENABLED(AUTO_BED_LEVELING_UBL)
152
     #if ENABLED(AUTO_BED_LEVELING_UBL)
274
       uint8_t tilt_grid_size : 3;
153
       uint8_t tilt_grid_size : 3;
275
     #endif
154
     #endif

+ 5
- 415
Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp 查看文件

29
 
29
 
30
 #if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
30
 #if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
31
 
31
 
32
-#include "../../../inc/MarlinConfig.h"
33
-
34
 #include "dwin_lcd.h"
32
 #include "dwin_lcd.h"
35
-#include <string.h> // for memset
36
-
37
-//#define DEBUG_OUT 1
38
-#include "../../../core/debug_out.h"
39
-
40
-// Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail.
41
-// Assume the narrowest (6 pixel) font and 2-byte gb2312-encoded characters.
42
-uint8_t DWIN_SendBuf[11 + DWIN_WIDTH / 6 * 2] = { 0xAA };
43
-uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C };
44
-uint8_t databuf[26] = { 0 };
45
-uint8_t receivedType;
46
-
47
-int recnum = 0;
48
-
49
-inline void DWIN_Byte(size_t &i, const uint16_t bval) {
50
-  DWIN_SendBuf[++i] = bval;
51
-}
52
-
53
-inline void DWIN_Word(size_t &i, const uint16_t wval) {
54
-  DWIN_SendBuf[++i] = wval >> 8;
55
-  DWIN_SendBuf[++i] = wval & 0xFF;
56
-}
57
-
58
-inline void DWIN_Long(size_t &i, const uint32_t lval) {
59
-  DWIN_SendBuf[++i] = (lval >> 24) & 0xFF;
60
-  DWIN_SendBuf[++i] = (lval >> 16) & 0xFF;
61
-  DWIN_SendBuf[++i] = (lval >>  8) & 0xFF;
62
-  DWIN_SendBuf[++i] = lval & 0xFF;
63
-}
64
-
65
-inline void DWIN_String(size_t &i, const char * const string) {
66
-  const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, strlen(string));
67
-  memcpy(&DWIN_SendBuf[i + 1], string, len);
68
-  i += len;
69
-}
70
-
71
-inline void DWIN_String(size_t &i, const __FlashStringHelper * string) {
72
-  if (!string) return;
73
-  const size_t len = strlen_P((PGM_P)string); // cast it to PGM_P, which is basically const char *, and measure it using the _P version of strlen.
74
-  if (len == 0) return;
75
-  memcpy(&DWIN_SendBuf[i + 1], string, len);
76
-  i += len;
77
-}
78
-
79
-// Send the data in the buffer and the packet end
80
-inline void DWIN_Send(size_t &i) {
81
-  ++i;
82
-  LOOP_L_N(n, i) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
83
-  LOOP_L_N(n, 4) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); }
84
-}
85
 
33
 
86
 /*-------------------------------------- System variable function --------------------------------------*/
34
 /*-------------------------------------- System variable function --------------------------------------*/
87
 
35
 
88
-// Handshake (1: Success, 0: Fail)
89
-bool DWIN_Handshake(void) {
90
-  #ifndef LCD_BAUDRATE
91
-    #define LCD_BAUDRATE 115200
92
-  #endif
93
-  LCD_SERIAL.begin(LCD_BAUDRATE);
94
-  const millis_t serial_connect_timeout = millis() + 1000UL;
95
-  while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
96
-
97
-  size_t i = 0;
98
-  DWIN_Byte(i, 0x00);
99
-  DWIN_Send(i);
100
-
101
-  while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) {
102
-    databuf[recnum] = LCD_SERIAL.read();
103
-    // ignore the invalid data
104
-    if (databuf[0] != FHONE) { // prevent the program from running.
105
-      if (recnum > 0) {
106
-        recnum = 0;
107
-        ZERO(databuf);
108
-      }
109
-      continue;
110
-    }
111
-    delay(10);
112
-    recnum++;
113
-  }
114
-
115
-  return ( recnum >= 3
116
-        && databuf[0] == FHONE
117
-        && databuf[1] == '\0'
118
-        && databuf[2] == 'O'
119
-        && databuf[3] == 'K' );
120
-}
121
-
122
-// Set the backlight luminance
123
-//  luminance: (0x00-0xFF)
124
-void DWIN_Backlight_SetLuminance(const uint8_t luminance) {
125
-  size_t i = 0;
126
-  DWIN_Byte(i, 0x30);
127
-  DWIN_Byte(i, luminance);
128
-  DWIN_Send(i);
129
-}
130
-
131
-// Set screen display direction
132
-//  dir: 0=0°, 1=90°, 2=180°, 3=270°
133
-void DWIN_Frame_SetDir(uint8_t dir) {
134
-  size_t i = 0;
135
-  DWIN_Byte(i, 0x34);
136
-  DWIN_Byte(i, 0x5A);
137
-  DWIN_Byte(i, 0xA5);
138
-  DWIN_Byte(i, dir);
139
-  DWIN_Send(i);
140
-}
141
-
142
-// Update display
143
-void DWIN_UpdateLCD(void) {
144
-  size_t i = 0;
145
-  DWIN_Byte(i, 0x3D);
146
-  DWIN_Send(i);
147
-}
36
+void DWIN_Startup() {}
148
 
37
 
149
 /*---------------------------------------- Drawing functions ----------------------------------------*/
38
 /*---------------------------------------- Drawing functions ----------------------------------------*/
150
 
39
 
151
-// Clear screen
152
-//  color: Clear screen color
153
-void DWIN_Frame_Clear(const uint16_t color) {
154
-  size_t i = 0;
155
-  DWIN_Byte(i, 0x01);
156
-  DWIN_Word(i, color);
157
-  DWIN_Send(i);
158
-}
159
-
160
-// Draw a point
161
-//  color: Pixel segment color
162
-//  width: point width   0x01-0x0F
163
-//  height: point height 0x01-0x0F
164
-//  x,y: upper left point
165
-void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y) {
166
-  size_t i = 0;
167
-  DWIN_Byte(i, 0x02);
168
-  DWIN_Word(i, color);
169
-  DWIN_Byte(i, width);
170
-  DWIN_Byte(i, height);
171
-  DWIN_Word(i, x);
172
-  DWIN_Word(i, y);
173
-  DWIN_Send(i);
174
-}
175
-
176
-// Draw a line
177
-//  color: Line segment color
178
-//  xStart/yStart: Start point
179
-//  xEnd/yEnd: End point
180
-void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
181
-  size_t i = 0;
182
-  DWIN_Byte(i, 0x03);
183
-  DWIN_Word(i, color);
184
-  DWIN_Word(i, xStart);
185
-  DWIN_Word(i, yStart);
186
-  DWIN_Word(i, xEnd);
187
-  DWIN_Word(i, yEnd);
188
-  DWIN_Send(i);
189
-}
190
-
191
-// Draw a rectangle
192
-//  mode: 0=frame, 1=fill, 2=XOR fill
193
-//  color: Rectangle color
194
-//  xStart/yStart: upper left point
195
-//  xEnd/yEnd: lower right point
196
-void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
197
-                         uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
198
-  size_t i = 0;
199
-  DWIN_Byte(i, 0x05);
200
-  DWIN_Byte(i, mode);
201
-  DWIN_Word(i, color);
202
-  DWIN_Word(i, xStart);
203
-  DWIN_Word(i, yStart);
204
-  DWIN_Word(i, xEnd);
205
-  DWIN_Word(i, yEnd);
206
-  DWIN_Send(i);
207
-}
208
-
209
-//Color: color
210
-//x/y: Upper-left coordinate of the first pixel
40
+// Draw the degree (°) symbol
41
+// Color: color
42
+//  x/y: Upper-left coordinate of the first pixel
211
 void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y) {
43
 void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y) {
212
   DWIN_Draw_Point(Color, 1, 1, x + 1, y);
44
   DWIN_Draw_Point(Color, 1, 1, x + 1, y);
213
   DWIN_Draw_Point(Color, 1, 1, x + 2, y);
45
   DWIN_Draw_Point(Color, 1, 1, x + 2, y);
219
   DWIN_Draw_Point(Color, 1, 1, x + 2, y + 3);
51
   DWIN_Draw_Point(Color, 1, 1, x + 2, y + 3);
220
 }
52
 }
221
 
53
 
222
-// Move a screen area
223
-//  mode: 0, circle shift; 1, translation
224
-//  dir: 0=left, 1=right, 2=up, 3=down
225
-//  dis: Distance
226
-//  color: Fill color
227
-//  xStart/yStart: upper left point
228
-//  xEnd/yEnd: bottom right point
229
-void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
230
-                         uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
231
-  size_t i = 0;
232
-  DWIN_Byte(i, 0x09);
233
-  DWIN_Byte(i, (mode << 7) | dir);
234
-  DWIN_Word(i, dis);
235
-  DWIN_Word(i, color);
236
-  DWIN_Word(i, xStart);
237
-  DWIN_Word(i, yStart);
238
-  DWIN_Word(i, xEnd);
239
-  DWIN_Word(i, yEnd);
240
-  DWIN_Send(i);
241
-}
242
-
243
-/*---------------------------------------- Text related functions ----------------------------------------*/
244
-
245
-// Draw a string
246
-//  widthAdjust: true=self-adjust character width; false=no adjustment
247
-//  bShow: true=display background color; false=don't display background color
248
-//  size: Font size
249
-//  color: Character color
250
-//  bColor: Background color
251
-//  x/y: Upper-left coordinate of the string
252
-//  *string: The string
253
-void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size,
254
-                      uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * string) {
255
-  size_t i = 0;
256
-  DWIN_Byte(i, 0x11);
257
-  // Bit 7: widthAdjust
258
-  // Bit 6: bShow
259
-  // Bit 5-4: Unused (0)
260
-  // Bit 3-0: size
261
-  DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size);
262
-  DWIN_Word(i, color);
263
-  DWIN_Word(i, bColor);
264
-  DWIN_Word(i, x);
265
-  DWIN_Word(i, y);
266
-  DWIN_String(i, string);
267
-  DWIN_Send(i);
268
-}
269
-
270
-// Draw a positive integer
271
-//  bShow: true=display background color; false=don't display background color
272
-//  zeroFill: true=zero fill; false=no zero fill
273
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
274
-//  size: Font size
275
-//  color: Character color
276
-//  bColor: Background color
277
-//  iNum: Number of digits
278
-//  x/y: Upper-left coordinate
279
-//  value: Integer value
280
-void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
281
-                          uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value) {
282
-  size_t i = 0;
283
-  DWIN_Byte(i, 0x14);
284
-  // Bit 7: bshow
285
-  // Bit 6: 1 = signed; 0 = unsigned number;
286
-  // Bit 5: zeroFill
287
-  // Bit 4: zeroMode
288
-  // Bit 3-0: size
289
-  DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
290
-  DWIN_Word(i, color);
291
-  DWIN_Word(i, bColor);
292
-  DWIN_Byte(i, iNum);
293
-  DWIN_Byte(i, 0); // fNum
294
-  DWIN_Word(i, x);
295
-  DWIN_Word(i, y);
296
-  #if 0
297
-    for (char count = 0; count < 8; count++) {
298
-      DWIN_Byte(i, value);
299
-      value >>= 8;
300
-      if (!(value & 0xFF)) break;
301
-    }
302
-  #else
303
-    // Write a big-endian 64 bit integer
304
-    const size_t p = i + 1;
305
-    for (char count = 8; count--;) { // 7..0
306
-      ++i;
307
-      DWIN_SendBuf[p + count] = value;
308
-      value >>= 8;
309
-    }
310
-  #endif
311
-
312
-  DWIN_Send(i);
313
-}
314
-
315
-// Draw a floating point number
316
-//  bShow: true=display background color; false=don't display background color
317
-//  zeroFill: true=zero fill; false=no zero fill
318
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
319
-//  size: Font size
320
-//  color: Character color
321
-//  bColor: Background color
322
-//  iNum: Number of whole digits
323
-//  fNum: Number of decimal digits
324
-//  x/y: Upper-left point
325
-//  value: Float value
326
-void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
327
-                            uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
328
-  //uint8_t *fvalue = (uint8_t*)&value;
329
-  size_t i = 0;
330
-  DWIN_Byte(i, 0x14);
331
-  DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
332
-  DWIN_Word(i, color);
333
-  DWIN_Word(i, bColor);
334
-  DWIN_Byte(i, iNum);
335
-  DWIN_Byte(i, fNum);
336
-  DWIN_Word(i, x);
337
-  DWIN_Word(i, y);
338
-  DWIN_Long(i, value);
339
-  /*
340
-  DWIN_Byte(i, fvalue[3]);
341
-  DWIN_Byte(i, fvalue[2]);
342
-  DWIN_Byte(i, fvalue[1]);
343
-  DWIN_Byte(i, fvalue[0]);
344
-  */
345
-  DWIN_Send(i);
346
-}
347
-
348
 /*---------------------------------------- Picture related functions ----------------------------------------*/
54
 /*---------------------------------------- Picture related functions ----------------------------------------*/
349
 
55
 
350
-// Draw JPG and cached in #0 virtual display area
351
-// id: Picture ID
352
-void DWIN_JPG_ShowAndCache(const uint8_t id) {
353
-  size_t i = 0;
354
-  DWIN_Word(i, 0x2200);
355
-  DWIN_Byte(i, id);
356
-  DWIN_Send(i);     // AA 23 00 00 00 00 08 00 01 02 03 CC 33 C3 3C
357
-}
358
-
359
 // Draw an Icon
56
 // Draw an Icon
360
 //  libID: Icon library ID
57
 //  libID: Icon library ID
361
 //  picID: Icon ID
58
 //  picID: Icon ID
362
 //  x/y: Upper-left point
59
 //  x/y: Upper-left point
363
 void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
60
 void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
364
-  NOMORE(x, DWIN_WIDTH - 1);
365
-  NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
366
-  size_t i = 0;
367
-  DWIN_Byte(i, 0x23);
368
-  DWIN_Word(i, x);
369
-  DWIN_Word(i, y);
370
-  DWIN_Byte(i, 0x80 | libID);
371
-  DWIN_Byte(i, picID);
372
-  DWIN_Send(i);
61
+  DWIN_ICON_Show(true, false, false, libID, picID, x, y);
373
 }
62
 }
374
 
63
 
375
-// Unzip the JPG picture to a virtual display area
376
-//  n: Cache index
377
-//  id: Picture ID
378
-void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
379
-  size_t i = 0;
380
-  DWIN_Byte(i, 0x25);
381
-  DWIN_Byte(i, n);
382
-  DWIN_Byte(i, id);
383
-  DWIN_Send(i);
384
-}
385
-
386
-// Copy area from virtual display area to current screen
387
-//  cacheID: virtual area number
388
-//  xStart/yStart: Upper-left of virtual area
389
-//  xEnd/yEnd: Lower-right of virtual area
390
-//  x/y: Screen paste point
391
-void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
392
-                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
393
-  size_t i = 0;
394
-  DWIN_Byte(i, 0x27);
395
-  DWIN_Byte(i, 0x80 | cacheID);
396
-  DWIN_Word(i, xStart);
397
-  DWIN_Word(i, yStart);
398
-  DWIN_Word(i, xEnd);
399
-  DWIN_Word(i, yEnd);
400
-  DWIN_Word(i, x);
401
-  DWIN_Word(i, y);
402
-  DWIN_Send(i);
403
-}
404
-
405
-// Animate a series of icons
406
-//  animID: Animation ID; 0x00-0x0F
407
-//  animate: true on; false off;
408
-//  libID: Icon library ID
409
-//  picIDs: Icon starting ID
410
-//  picIDe: Icon ending ID
411
-//  x/y: Upper-left point
412
-//  interval: Display time interval, unit 10mS
413
-void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval) {
414
-  NOMORE(x, DWIN_WIDTH - 1);
415
-  NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
416
-  size_t i = 0;
417
-  DWIN_Byte(i, 0x28);
418
-  DWIN_Word(i, x);
419
-  DWIN_Word(i, y);
420
-  // Bit 7: animation on or off
421
-  // Bit 6: start from begin or end
422
-  // Bit 5-4: unused (0)
423
-  // Bit 3-0: animID
424
-  DWIN_Byte(i, (animate * 0x80) | 0x40 | animID);
425
-  DWIN_Byte(i, libID);
426
-  DWIN_Byte(i, picIDs);
427
-  DWIN_Byte(i, picIDe);
428
-  DWIN_Byte(i, interval);
429
-  DWIN_Send(i);
430
-}
431
-
432
-// Animation Control
433
-//  state: 16 bits, each bit is the state of an animation id
434
-void DWIN_ICON_AnimationControl(uint16_t state) {
435
-  size_t i = 0;
436
-  DWIN_Byte(i, 0x28);
437
-  DWIN_Word(i, state);
438
-  DWIN_Send(i);
439
-}
440
-
441
-/*---------------------------------------- Memory functions ----------------------------------------*/
442
-// The LCD has an additional 32KB SRAM and 16KB Flash
443
-
444
-// Data can be written to the sram and save to one of the jpeg page files
445
-
446
-// Write Data Memory
447
-//  command 0x31
448
-//  Type: Write memory selection; 0x5A=SRAM; 0xA5=Flash
449
-//  Address: Write data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
450
-//  Data: data
451
-//
452
-//  Flash writing returns 0xA5 0x4F 0x4B
453
-
454
-// Read Data Memory
455
-//  command 0x32
456
-//  Type: Read memory selection; 0x5A=SRAM; 0xA5=Flash
457
-//  Address: Read data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
458
-//  Length: leangth of data to read; 0x01-0xF0
459
-//
460
-//  Response:
461
-//    Type, Address, Length, Data
462
-
463
-// Write Picture Memory
464
-//  Write the contents of the 32KB SRAM data memory into the designated image memory space
465
-//  Issued: 0x5A, 0xA5, PIC_ID
466
-//  Response: 0xA5 0x4F 0x4B
467
-//
468
-//  command 0x33
469
-//  0x5A, 0xA5
470
-//  PicId: Picture Memory location, 0x00-0x0F
471
-//
472
-//  Flash writing returns 0xA5 0x4F 0x4B
473
-
474
 #endif // DWIN_CREALITY_LCD_JYERSUI
64
 #endif // DWIN_CREALITY_LCD_JYERSUI

+ 4
- 185
Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h 查看文件

26
  * @brief    DWIN screen control functions
26
  * @brief    DWIN screen control functions
27
  ********************************************************************************/
27
  ********************************************************************************/
28
 
28
 
29
-#include <stdint.h>
29
+#include "../common/dwin_api.h"
30
 
30
 
31
-#define RECEIVED_NO_DATA         0x00
32
-#define RECEIVED_SHAKE_HAND_ACK  0x01
33
-
34
-#define FHONE                    0xAA
35
-
36
-#define DWIN_SCROLL_UP   2
37
-#define DWIN_SCROLL_DOWN 3
38
-
39
-#define DWIN_WIDTH  272
40
-#define DWIN_HEIGHT 480
41
-
42
-/*-------------------------------------- System variable function --------------------------------------*/
43
-
44
-// Handshake (1: Success, 0: Fail)
45
-bool DWIN_Handshake(void);
46
-
47
-// Set the backlight luminance
48
-//  luminance: (0x00-0xFF)
49
-void DWIN_Backlight_SetLuminance(const uint8_t luminance);
50
-
51
-// Set screen display direction
52
-//  dir: 0=0°, 1=90°, 2=180°, 3=270°
53
-void DWIN_Frame_SetDir(uint8_t dir);
54
-
55
-// Update display
56
-void DWIN_UpdateLCD(void);
57
-
58
-/*---------------------------------------- Drawing functions ----------------------------------------*/
59
-
60
-// Clear screen
61
-//  color: Clear screen color
62
-void DWIN_Frame_Clear(const uint16_t color);
63
-
64
-// Draw a point
65
-//  color: Line segment color
66
-//  width: point width   0x01-0x0F
67
-//  height: point height 0x01-0x0F
68
-//  x,y: upper left point
69
-void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y);
70
-
71
-// Draw a line
72
-//  color: Line segment color
73
-//  xStart/yStart: Start point
74
-//  xEnd/yEnd: End point
75
-void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
76
-
77
-// Draw a Horizontal line
78
-//  color: Line segment color
79
-//  xStart/yStart: Start point
80
-//  xLength: Line Length
81
-inline void DWIN_Draw_HLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xLength) {
82
-  DWIN_Draw_Line(color, xStart, yStart, xStart + xLength - 1, yStart);
83
-}
84
-
85
-// Draw a Vertical line
86
-//  color: Line segment color
87
-//  xStart/yStart: Start point
88
-//  yLength: Line Length
89
-inline void DWIN_Draw_VLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t yLength) {
90
-  DWIN_Draw_Line(color, xStart, yStart, xStart, yStart + yLength - 1);
91
-}
92
-
93
-// Draw a rectangle
94
-//  mode: 0=frame, 1=fill, 2=XOR fill
95
-//  color: Rectangle color
96
-//  xStart/yStart: upper left point
97
-//  xEnd/yEnd: lower right point
98
-void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
99
-                         uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
100
-
101
-// Draw a box
102
-//  mode: 0=frame, 1=fill, 2=XOR fill
103
-//  color: Rectangle color
104
-//  xStart/yStart: upper left point
105
-//  xSize/ySize: box size
106
-inline void DWIN_Draw_Box(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xSize, uint16_t ySize) {
107
-  DWIN_Draw_Rectangle(mode, color, xStart, yStart, xStart + xSize - 1, yStart + ySize - 1);
108
-}
109
-
110
-//Color: color
111
-//x: upper left point
112
-//y: bottom right point
31
+// Draw the degree (°) symbol
32
+// Color: color
33
+//  x/y: Upper-left coordinate of the first pixel
113
 void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y);
34
 void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y);
114
-
115
-// Move a screen area
116
-//  mode: 0, circle shift; 1, translation
117
-//  dir: 0=left, 1=right, 2=up, 3=down
118
-//  dis: Distance
119
-//  color: Fill color
120
-//  xStart/yStart: upper left point
121
-//  xEnd/yEnd: bottom right point
122
-void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
123
-                         uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
124
-
125
-/*---------------------------------------- Text related functions ----------------------------------------*/
126
-
127
-// Draw a string
128
-//  widthAdjust: true=self-adjust character width; false=no adjustment
129
-//  bShow: true=display background color; false=don't display background color
130
-//  size: Font size
131
-//  color: Character color
132
-//  bColor: Background color
133
-//  x/y: Upper-left coordinate of the string
134
-//  *string: The string
135
-void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size,
136
-                      uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * string);
137
-
138
-class __FlashStringHelper;
139
-
140
-inline void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
141
-  // Note that this won't work on AVR. This is for 32-bit systems only!
142
-  // Are __FlashStringHelper versions worth keeping?
143
-  DWIN_Draw_String(widthAdjust, bShow, size, color, bColor, x, y, reinterpret_cast<const char*>(title));
144
-}
145
-
146
-// Draw a positive integer
147
-//  bShow: true=display background color; false=don't display background color
148
-//  zeroFill: true=zero fill; false=no zero fill
149
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
150
-//  size: Font size
151
-//  color: Character color
152
-//  bColor: Background color
153
-//  iNum: Number of digits
154
-//  x/y: Upper-left coordinate
155
-//  value: Integer value
156
-void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
157
-                          uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value);
158
-
159
-// Draw a floating point number
160
-//  bShow: true=display background color; false=don't display background color
161
-//  zeroFill: true=zero fill; false=no zero fill
162
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
163
-//  size: Font size
164
-//  color: Character color
165
-//  bColor: Background color
166
-//  iNum: Number of whole digits
167
-//  fNum: Number of decimal digits
168
-//  x/y: Upper-left point
169
-//  value: Float value
170
-void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
171
-                            uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
172
-
173
-/*---------------------------------------- Picture related functions ----------------------------------------*/
174
-
175
-// Draw JPG and cached in #0 virtual display area
176
-// id: Picture ID
177
-void DWIN_JPG_ShowAndCache(const uint8_t id);
178
-
179
-// Draw an Icon
180
-//  libID: Icon library ID
181
-//  picID: Icon ID
182
-//  x/y: Upper-left point
183
-void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y);
184
-
185
-// Unzip the JPG picture to a virtual display area
186
-//  n: Cache index
187
-//  id: Picture ID
188
-void DWIN_JPG_CacheToN(uint8_t n, uint8_t id);
189
-
190
-// Unzip the JPG picture to virtual display area #1
191
-//  id: Picture ID
192
-inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); }
193
-
194
-// Copy area from virtual display area to current screen
195
-//  cacheID: virtual area number
196
-//  xStart/yStart: Upper-left of virtual area
197
-//  xEnd/yEnd: Lower-right of virtual area
198
-//  x/y: Screen paste point
199
-void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
200
-                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
201
-
202
-// Animate a series of icons
203
-//  animID: Animation ID  up to 16
204
-//  animate: animation on or off
205
-//  libID: Icon library ID
206
-//  picIDs: Icon starting ID
207
-//  picIDe: Icon ending ID
208
-//  x/y: Upper-left point
209
-//  interval: Display time interval, unit 10mS
210
-void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs,
211
-                         uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval);
212
-
213
-// Animation Control
214
-//  state: 16 bits, each bit is the state of an animation id
215
-void DWIN_ICON_AnimationControl(uint16_t state);

+ 2
- 410
Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp 查看文件

37
 //#define DEBUG_OUT 1
37
 //#define DEBUG_OUT 1
38
 #include "../../../core/debug_out.h"
38
 #include "../../../core/debug_out.h"
39
 
39
 
40
-// Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail.
41
-// Assume the narrowest (6 pixel) font and 2-byte gb2312-encoded characters.
42
-uint8_t DWIN_SendBuf[11 + DWIN_WIDTH / 6 * 2] = { 0xAA };
43
-uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C };
44
-uint8_t databuf[26] = { 0 };
45
-uint8_t receivedType;
46
-
47
-int recnum = 0;
48
-
49
-inline void DWIN_Byte(size_t &i, const uint16_t bval) {
50
-  DWIN_SendBuf[++i] = bval;
51
-}
52
-
53
-inline void DWIN_Word(size_t &i, const uint16_t wval) {
54
-  DWIN_SendBuf[++i] = wval >> 8;
55
-  DWIN_SendBuf[++i] = wval & 0xFF;
56
-}
57
-
58
-inline void DWIN_Long(size_t &i, const uint32_t lval) {
59
-  DWIN_SendBuf[++i] = (lval >> 24) & 0xFF;
60
-  DWIN_SendBuf[++i] = (lval >> 16) & 0xFF;
61
-  DWIN_SendBuf[++i] = (lval >>  8) & 0xFF;
62
-  DWIN_SendBuf[++i] = lval & 0xFF;
63
-}
64
-
65
-inline void DWIN_String(size_t &i, char * const string) {
66
-  const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, strlen(string));
67
-  memcpy(&DWIN_SendBuf[i+1], string, len);
68
-  i += len;
69
-}
70
-
71
-inline void DWIN_String(size_t &i, const __FlashStringHelper * string) {
72
-  if (!string) return;
73
-  const size_t len = strlen_P((PGM_P)string); // cast it to PGM_P, which is basically const char *, and measure it using the _P version of strlen.
74
-  if (len == 0) return;
75
-  memcpy(&DWIN_SendBuf[i+1], string, len);
76
-  i += len;
77
-}
78
-
79
-// Send the data in the buffer and the packet end
80
-inline void DWIN_Send(size_t &i) {
81
-  ++i;
82
-  LOOP_L_N(n, i) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
83
-  LOOP_L_N(n, 4) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); }
84
-}
85
-
86
 /*-------------------------------------- System variable function --------------------------------------*/
40
 /*-------------------------------------- System variable function --------------------------------------*/
87
 
41
 
88
-// Handshake (1: Success, 0: Fail)
89
-bool DWIN_Handshake(void) {
90
-  #ifndef LCD_BAUDRATE
91
-    #define LCD_BAUDRATE 115200
92
-  #endif
93
-  LCD_SERIAL.begin(LCD_BAUDRATE);
94
-  const millis_t serial_connect_timeout = millis() + 1000UL;
95
-  while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
96
-
97
-  size_t i = 0;
98
-  DWIN_Byte(i, 0x00);
99
-  DWIN_Send(i);
100
-
101
-  while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) {
102
-    databuf[recnum] = LCD_SERIAL.read();
103
-    // ignore the invalid data
104
-    if (databuf[0] != FHONE) { // prevent the program from running.
105
-      if (recnum > 0) {
106
-        recnum = 0;
107
-        ZERO(databuf);
108
-      }
109
-      continue;
110
-    }
111
-    delay(10);
112
-    recnum++;
113
-  }
114
-
115
-  return ( recnum >= 3
116
-        && databuf[0] == FHONE
117
-        && databuf[1] == '\0'
118
-        && databuf[2] == 'O'
119
-        && databuf[3] == 'K' );
120
-}
121
-
122
-void DWIN_Startup(void) {
42
+void DWIN_Startup() {
123
   DEBUG_ECHOPGM("\r\nDWIN handshake ");
43
   DEBUG_ECHOPGM("\r\nDWIN handshake ");
124
   delay(750);   // Delay here or init later in the boot process
44
   delay(750);   // Delay here or init later in the boot process
125
   const bool success = DWIN_Handshake();
45
   const bool success = DWIN_Handshake();
129
   DWIN_UpdateLCD();
49
   DWIN_UpdateLCD();
130
 }
50
 }
131
 
51
 
132
-// Set the backlight luminance
133
-//  luminance: (0x00-0xFF)
134
-void DWIN_Backlight_SetLuminance(const uint8_t luminance) {
135
-  size_t i = 0;
136
-  DWIN_Byte(i, 0x30);
137
-  DWIN_Byte(i, _MAX(luminance, 0x1F));
138
-  DWIN_Send(i);
139
-}
140
-
141
-// Set screen display direction
142
-//  dir: 0=0°, 1=90°, 2=180°, 3=270°
143
-void DWIN_Frame_SetDir(uint8_t dir) {
144
-  size_t i = 0;
145
-  DWIN_Byte(i, 0x34);
146
-  DWIN_Byte(i, 0x5A);
147
-  DWIN_Byte(i, 0xA5);
148
-  DWIN_Byte(i, dir);
149
-  DWIN_Send(i);
150
-}
151
-
152
-// Update display
153
-void DWIN_UpdateLCD(void) {
154
-  size_t i = 0;
155
-  DWIN_Byte(i, 0x3D);
156
-  DWIN_Send(i);
157
-}
158
-
159
-/*---------------------------------------- Drawing functions ----------------------------------------*/
160
-
161
-// Clear screen
162
-//  color: Clear screen color
163
-void DWIN_Frame_Clear(const uint16_t color) {
164
-  size_t i = 0;
165
-  DWIN_Byte(i, 0x01);
166
-  DWIN_Word(i, color);
167
-  DWIN_Send(i);
168
-}
169
-
170
-// Draw a point
171
-//  width: point width   0x01-0x0F
172
-//  height: point height 0x01-0x0F
173
-//  x,y: upper left point
174
-void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y) {
175
-  size_t i = 0;
176
-  DWIN_Byte(i, 0x02);
177
-  DWIN_Word(i, color);
178
-  DWIN_Byte(i, width);
179
-  DWIN_Byte(i, height);
180
-  DWIN_Word(i, x);
181
-  DWIN_Word(i, y);
182
-  DWIN_Send(i);
183
-}
184
-
185
-// Draw a line
186
-//  color: Line segment color
187
-//  xStart/yStart: Start point
188
-//  xEnd/yEnd: End point
189
-void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
190
-  size_t i = 0;
191
-  DWIN_Byte(i, 0x03);
192
-  DWIN_Word(i, color);
193
-  DWIN_Word(i, xStart);
194
-  DWIN_Word(i, yStart);
195
-  DWIN_Word(i, xEnd);
196
-  DWIN_Word(i, yEnd);
197
-  DWIN_Send(i);
198
-}
199
-
200
-// Draw a rectangle
201
-//  mode: 0=frame, 1=fill, 2=XOR fill
202
-//  color: Rectangle color
203
-//  xStart/yStart: upper left point
204
-//  xEnd/yEnd: lower right point
205
-void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
206
-                         uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
207
-  size_t i = 0;
208
-  DWIN_Byte(i, 0x05);
209
-  DWIN_Byte(i, mode);
210
-  DWIN_Word(i, color);
211
-  DWIN_Word(i, xStart);
212
-  DWIN_Word(i, yStart);
213
-  DWIN_Word(i, xEnd);
214
-  DWIN_Word(i, yEnd);
215
-  DWIN_Send(i);
216
-}
217
-
218
-// Move a screen area
219
-//  mode: 0, circle shift; 1, translation
220
-//  dir: 0=left, 1=right, 2=up, 3=down
221
-//  dis: Distance
222
-//  color: Fill color
223
-//  xStart/yStart: upper left point
224
-//  xEnd/yEnd: bottom right point
225
-void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
226
-                         uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
227
-  size_t i = 0;
228
-  DWIN_Byte(i, 0x09);
229
-  DWIN_Byte(i, (mode << 7) | dir);
230
-  DWIN_Word(i, dis);
231
-  DWIN_Word(i, color);
232
-  DWIN_Word(i, xStart);
233
-  DWIN_Word(i, yStart);
234
-  DWIN_Word(i, xEnd);
235
-  DWIN_Word(i, yEnd);
236
-  DWIN_Send(i);
237
-}
238
-
239
-/*---------------------------------------- Text related functions ----------------------------------------*/
240
-
241
-// Draw a string
242
-//  bShow: true=display background color; false=don't display background color
243
-//  size: Font size
244
-//  color: Character color
245
-//  bColor: Background color
246
-//  x/y: Upper-left coordinate of the string
247
-//  *string: The string
248
-void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string) {
249
-  uint8_t widthAdjust = 0;
250
-  size_t i = 0;
251
-  DWIN_Byte(i, 0x11);
252
-  // Bit 7: widthAdjust
253
-  // Bit 6: bShow
254
-  // Bit 5-4: Unused (0)
255
-  // Bit 3-0: size
256
-  DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size);
257
-  DWIN_Word(i, color);
258
-  DWIN_Word(i, bColor);
259
-  DWIN_Word(i, x);
260
-  DWIN_Word(i, y);
261
-  DWIN_String(i, string);
262
-  DWIN_Send(i);
263
-}
264
-
265
-// Draw a positive integer
266
-//  bShow: true=display background color; false=don't display background color
267
-//  zeroFill: true=zero fill; false=no zero fill
268
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
269
-//  size: Font size
270
-//  color: Character color
271
-//  bColor: Background color
272
-//  iNum: Number of digits
273
-//  x/y: Upper-left coordinate
274
-//  value: Integer value
275
-void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
276
-                          uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value) {
277
-  size_t i = 0;
278
-  DWIN_Byte(i, 0x14);
279
-  // Bit 7: bshow
280
-  // Bit 6: 1 = signed; 0 = unsigned number;
281
-  // Bit 5: zeroFill
282
-  // Bit 4: zeroMode
283
-  // Bit 3-0: size
284
-  DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
285
-  DWIN_Word(i, color);
286
-  DWIN_Word(i, bColor);
287
-  DWIN_Byte(i, iNum);
288
-  DWIN_Byte(i, 0); // fNum
289
-  DWIN_Word(i, x);
290
-  DWIN_Word(i, y);
291
-  #if 0
292
-    for (char count = 0; count < 8; count++) {
293
-      DWIN_Byte(i, value);
294
-      value >>= 8;
295
-      if (!(value & 0xFF)) break;
296
-    }
297
-  #else
298
-    // Write a big-endian 64 bit integer
299
-    const size_t p = i + 1;
300
-    for (char count = 8; count--;) { // 7..0
301
-      ++i;
302
-      DWIN_SendBuf[p + count] = value;
303
-      value >>= 8;
304
-    }
305
-  #endif
306
-
307
-  DWIN_Send(i);
308
-}
309
-
310
-// Draw a floating point number
311
-//  bShow: true=display background color; false=don't display background color
312
-//  zeroFill: true=zero fill; false=no zero fill
313
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
314
-//  size: Font size
315
-//  color: Character color
316
-//  bColor: Background color
317
-//  iNum: Number of whole digits
318
-//  fNum: Number of decimal digits
319
-//  x/y: Upper-left point
320
-//  value: Float value
321
-void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
322
-                            uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
323
-  //uint8_t *fvalue = (uint8_t*)&value;
324
-  size_t i = 0;
325
-  DWIN_Byte(i, 0x14);
326
-  DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
327
-  DWIN_Word(i, color);
328
-  DWIN_Word(i, bColor);
329
-  DWIN_Byte(i, iNum);
330
-  DWIN_Byte(i, fNum);
331
-  DWIN_Word(i, x);
332
-  DWIN_Word(i, y);
333
-  DWIN_Long(i, value);
334
-  /*
335
-  DWIN_Byte(i, fvalue[3]);
336
-  DWIN_Byte(i, fvalue[2]);
337
-  DWIN_Byte(i, fvalue[1]);
338
-  DWIN_Byte(i, fvalue[0]);
339
-  */
340
-  DWIN_Send(i);
341
-}
342
-
343
 /*---------------------------------------- Picture related functions ----------------------------------------*/
52
 /*---------------------------------------- Picture related functions ----------------------------------------*/
344
 
53
 
345
-// Draw JPG and cached in #0 virtual display area
346
-// id: Picture ID
347
-void DWIN_JPG_ShowAndCache(const uint8_t id) {
348
-  size_t i = 0;
349
-  DWIN_Word(i, 0x2200);
350
-  DWIN_Byte(i, id);
351
-  DWIN_Send(i);     // AA 23 00 00 00 00 08 00 01 02 03 CC 33 C3 3C
352
-}
353
-
354
 // Draw an Icon
54
 // Draw an Icon
355
 //  libID: Icon library ID
55
 //  libID: Icon library ID
356
 //  picID: Icon ID
56
 //  picID: Icon ID
357
 //  x/y: Upper-left point
57
 //  x/y: Upper-left point
358
 void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
58
 void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
359
-  NOMORE(x, DWIN_WIDTH - 1);
360
-  NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
361
-  size_t i = 0;
362
-  DWIN_Byte(i, 0x23);
363
-  DWIN_Word(i, x);
364
-  DWIN_Word(i, y);
365
-  DWIN_Byte(i, 0x80 | libID);
366
-  //DWIN_Byte(i, libID);
367
-  DWIN_Byte(i, picID);
368
-  DWIN_Send(i);
59
+  DWIN_ICON_Show(true, false, false, libID, picID, x, y);
369
 }
60
 }
370
 
61
 
371
-// Unzip the JPG picture to a virtual display area
372
-//  n: Cache index
373
-//  id: Picture ID
374
-void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
375
-  size_t i = 0;
376
-  DWIN_Byte(i, 0x25);
377
-  DWIN_Byte(i, n);
378
-  DWIN_Byte(i, id);
379
-  DWIN_Send(i);
380
-}
381
-
382
-// Copy area from virtual display area to current screen
383
-//  cacheID: virtual area number
384
-//  xStart/yStart: Upper-left of virtual area
385
-//  xEnd/yEnd: Lower-right of virtual area
386
-//  x/y: Screen paste point
387
-void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
388
-                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
389
-  size_t i = 0;
390
-  DWIN_Byte(i, 0x27);
391
-  DWIN_Byte(i, 0x80 | cacheID);
392
-  DWIN_Word(i, xStart);
393
-  DWIN_Word(i, yStart);
394
-  DWIN_Word(i, xEnd);
395
-  DWIN_Word(i, yEnd);
396
-  DWIN_Word(i, x);
397
-  DWIN_Word(i, y);
398
-  DWIN_Send(i);
399
-}
400
-
401
-// Animate a series of icons
402
-//  animID: Animation ID; 0x00-0x0F
403
-//  animate: true on; false off;
404
-//  libID: Icon library ID
405
-//  picIDs: Icon starting ID
406
-//  picIDe: Icon ending ID
407
-//  x/y: Upper-left point
408
-//  interval: Display time interval, unit 10mS
409
-void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval) {
410
-  NOMORE(x, DWIN_WIDTH - 1);
411
-  NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
412
-  size_t i = 0;
413
-  DWIN_Byte(i, 0x28);
414
-  DWIN_Word(i, x);
415
-  DWIN_Word(i, y);
416
-  // Bit 7: animation on or off
417
-  // Bit 6: start from begin or end
418
-  // Bit 5-4: unused (0)
419
-  // Bit 3-0: animID
420
-  DWIN_Byte(i, (animate * 0x80) | 0x40 | animID);
421
-  DWIN_Byte(i, libID);
422
-  DWIN_Byte(i, picIDs);
423
-  DWIN_Byte(i, picIDe);
424
-  DWIN_Byte(i, interval);
425
-  DWIN_Send(i);
426
-}
427
-
428
-// Animation Control
429
-//  state: 16 bits, each bit is the state of an animation id
430
-void DWIN_ICON_AnimationControl(uint16_t state) {
431
-  size_t i = 0;
432
-  DWIN_Byte(i, 0x29);
433
-  DWIN_Word(i, state);
434
-  DWIN_Send(i);
435
-}
436
-
437
-/*---------------------------------------- Memory functions ----------------------------------------*/
438
-// The LCD has an additional 32KB SRAM and 16KB Flash
439
-
440
-// Data can be written to the sram and save to one of the jpeg page files
441
-
442
-// Write Data Memory
443
-//  command 0x31
444
-//  Type: Write memory selection; 0x5A=SRAM; 0xA5=Flash
445
-//  Address: Write data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
446
-//  Data: data
447
-//
448
-//  Flash writing returns 0xA5 0x4F 0x4B
449
-
450
-// Read Data Memory
451
-//  command 0x32
452
-//  Type: Read memory selection; 0x5A=SRAM; 0xA5=Flash
453
-//  Address: Read data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
454
-//  Length: leangth of data to read; 0x01-0xF0
455
-//
456
-//  Response:
457
-//    Type, Address, Length, Data
458
-
459
-// Write Picture Memory
460
-//  Write the contents of the 32KB SRAM data memory into the designated image memory space
461
-//  Issued: 0x5A, 0xA5, PIC_ID
462
-//  Response: 0xA5 0x4F 0x4B
463
-//
464
-//  command 0x33
465
-//  0x5A, 0xA5
466
-//  PicId: Picture Memory location, 0x00-0x0F
467
-//
468
-//  Flash writing returns 0xA5 0x4F 0x4B
469
-
470
 #endif // IS_DWIN_MARLINUI
62
 #endif // IS_DWIN_MARLINUI

+ 14
- 232
Marlin/src/lcd/e3v2/marlinui/dwin_lcd.h 查看文件

26
  * @brief    DWIN screen control functions
26
  * @brief    DWIN screen control functions
27
  ********************************************************************************/
27
  ********************************************************************************/
28
 
28
 
29
-#include <stdint.h>
30
-
31
-#define RECEIVED_NO_DATA         0x00
32
-#define RECEIVED_SHAKE_HAND_ACK  0x01
33
-
34
-#define FHONE                    0xAA
35
-
36
-#define DWIN_SCROLL_UP   2
37
-#define DWIN_SCROLL_DOWN 3
38
-
39
-#if DISABLED(DWIN_MARLINUI_LANDSCAPE)
40
-  #define DWIN_WIDTH  272
41
-  #define DWIN_HEIGHT 480
42
-#else
29
+#if ENABLED(DWIN_MARLINUI_LANDSCAPE)
43
   #define DWIN_WIDTH  480
30
   #define DWIN_WIDTH  480
44
   #define DWIN_HEIGHT 272
31
   #define DWIN_HEIGHT 272
45
 #endif
32
 #endif
46
 
33
 
34
+#include "../common/dwin_api.h"
35
+
47
 // Picture ID
36
 // Picture ID
48
 #define DWIN_Boot_Horiz      0
37
 #define DWIN_Boot_Horiz      0
49
 #define DWIN_Boot_Vert       1
38
 #define DWIN_Boot_Vert       1
50
 #define DWIN_MarlinUI_Assets 2
39
 #define DWIN_MarlinUI_Assets 2
51
 
40
 
52
-/**
53
- * 3-.0:The font size, 0x00-0x09, corresponds to the font size below:
54
- * 0x00=6*12   0x01=8*16   0x02=10*20  0x03=12*24  0x04=14*28
55
- * 0x05=16*32  0x06=20*40  0x07=24*48  0x08=28*56  0x09=32*64
56
- */
57
-#define font6x12  0x00
58
-#define font8x16  0x01
59
-#define font10x20 0x02
60
-#define font12x24 0x03
61
-#define font14x28 0x04
62
-#define font16x32 0x05
63
-#define font20x40 0x06
64
-#define font24x48 0x07
65
-#define font28x56 0x08
66
-#define font32x64 0x09
67
-
68
-#define DWIN_FONT_MENU  font10x20
69
-#define DWIN_FONT_STAT  font14x28
70
-#define DWIN_FONT_ALERT font14x28
71
-
72
-// Color
73
-#define Color_White       0xFFFF
74
-#define Color_Yellow      0xFF0F
75
-#define Color_Error_Red   0xB000  // Error!
76
-#define Color_Bg_Red      0xF00F  // Red background color
77
-#define Color_Bg_Window   0x31E8  // Popup background color
78
-#define Color_Bg_Heading  0x3344  // Static Heading
79
-#define Color_Bg_Blue     0x1125  // Dark blue background color
80
-#define Color_Bg_Black    0x0841  // Black background color
81
-#define Color_IconBlue    0x45FA  // Lighter blue that matches icons/accents
82
-#define Popup_Text_Color  0xD6BA  // Popup font background color
83
-#define Line_Color        0x3A6A  // Split line color
84
-#define Rectangle_Color   0xEE2F  // Blue square cursor color
85
-#define Percent_Color     0xFE29  // Percentage color
86
-#define BarFill_Color     0x10E4  // Fill color of progress bar
87
-#define Select_Color      0x33BB  // Selected color
88
-
89
-// Character matrix width x height
90
-//#define LCD_WIDTH ((DWIN_WIDTH) / 8)
91
-//#define LCD_HEIGHT ((DWIN_HEIGHT) / 12)
92
-
93
 // ICON ID
41
 // ICON ID
94
 #define BOOT_ICON           3 // Icon set file 3.ICO
42
 #define BOOT_ICON           3 // Icon set file 3.ICO
95
 #define ICON                4 // Icon set file 4.ICO
43
 #define ICON                4 // Icon set file 4.ICO
96
 
44
 
97
-// MarlinUI Boot Icons
45
+// MarlinUI Boot Icons from Set 3
98
 #define ICON_MarlinBoot            0
46
 #define ICON_MarlinBoot            0
99
 #define ICON_OpenSource            1
47
 #define ICON_OpenSource            1
100
 #define ICON_GitHubURL             2
48
 #define ICON_GitHubURL             2
101
 #define ICON_MarlinURL             3
49
 #define ICON_MarlinURL             3
102
 #define ICON_Copyright             4
50
 #define ICON_Copyright             4
103
 
51
 
104
-// MarlinUI Icons
52
+// MarlinUI Icons from Set 4
105
 #define ICON_LOGO_Marlin           0
53
 #define ICON_LOGO_Marlin           0
106
 #define ICON_HotendOff             1
54
 #define ICON_HotendOff             1
107
 #define ICON_HotendOn              2
55
 #define ICON_HotendOn              2
120
 #define ICON_DownArrow            15
68
 #define ICON_DownArrow            15
121
 #define ICON_BedLine              16
69
 #define ICON_BedLine              16
122
 
70
 
123
-#define ICON_AdvSet               ICON_Language
124
-#define ICON_HomeOff              ICON_AdvSet
125
-#define ICON_HomeOffX             ICON_StepX
126
-#define ICON_HomeOffY             ICON_StepY
127
-#define ICON_HomeOffZ             ICON_StepZ
128
-#define ICON_ProbeOff             ICON_AdvSet
129
-#define ICON_ProbeOffX            ICON_StepX
130
-#define ICON_ProbeOffY            ICON_StepY
131
-#define ICON_PIDNozzle            ICON_SetEndTemp
132
-#define ICON_PIDbed               ICON_SetBedTemp
133
-
134
-/*-------------------------------------- System variable function --------------------------------------*/
135
-
136
-// Handshake (1: Success, 0: Fail)
137
-bool DWIN_Handshake(void);
138
-
139
-// Common DWIN startup
140
-void DWIN_Startup(void);
141
-
142
-// Set the backlight luminance
143
-//  luminance: (0x00-0xFF)
144
-void DWIN_Backlight_SetLuminance(const uint8_t luminance);
145
-
146
-// Set screen display direction
147
-//  dir: 0=0°, 1=90°, 2=180°, 3=270°
148
-void DWIN_Frame_SetDir(uint8_t dir);
149
-
150
-// Update display
151
-void DWIN_UpdateLCD(void);
152
-
153
-/*---------------------------------------- Drawing functions ----------------------------------------*/
71
+#include "../common/dwin_font.h"
154
 
72
 
155
-// Clear screen
156
-//  color: Clear screen color
157
-void DWIN_Frame_Clear(const uint16_t color);
158
-
159
-// Draw a point
160
-//  color: point color
161
-//  width: point width   0x01-0x0F
162
-//  height: point height 0x01-0x0F
163
-//  x,y: upper left point
164
-void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y);
165
-
166
-// Draw a line
167
-//  color: Line segment color
168
-//  xStart/yStart: Start point
169
-//  xEnd/yEnd: End point
170
-void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
171
-
172
-// Draw a Horizontal line
173
-//  color: Line segment color
174
-//  xStart/yStart: Start point
175
-//  xLength: Line Length
176
-inline void DWIN_Draw_HLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xLength) {
177
-  DWIN_Draw_Line(color, xStart, yStart, xStart + xLength - 1, yStart);
178
-}
179
-
180
-// Draw a Vertical line
181
-//  color: Line segment color
182
-//  xStart/yStart: Start point
183
-//  yLength: Line Length
184
-inline void DWIN_Draw_VLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t yLength) {
185
-  DWIN_Draw_Line(color, xStart, yStart, xStart, yStart + yLength - 1);
186
-}
187
-
188
-// Draw a rectangle
189
-//  mode: 0=frame, 1=fill, 2=XOR fill
190
-//  color: Rectangle color
191
-//  xStart/yStart: upper left point
192
-//  xEnd/yEnd: lower right point
193
-void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
194
-                         uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
195
-
196
-// Draw a box
197
-//  mode: 0=frame, 1=fill, 2=XOR fill
198
-//  color: Rectangle color
199
-//  xStart/yStart: upper left point
200
-//  xSize/ySize: box size
201
-inline void DWIN_Draw_Box(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xSize, uint16_t ySize) {
202
-  DWIN_Draw_Rectangle(mode, color, xStart, yStart, xStart + xSize - 1, yStart + ySize - 1);
203
-}
204
-
205
-// Move a screen area
206
-//  mode: 0, circle shift; 1, translation
207
-//  dir: 0=left, 1=right, 2=up, 3=down
208
-//  dis: Distance
209
-//  color: Fill color
210
-//  xStart/yStart: upper left point
211
-//  xEnd/yEnd: bottom right point
212
-void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
213
-                         uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
214
-
215
-/*---------------------------------------- Text related functions ----------------------------------------*/
216
-
217
-// Draw a string
218
-//  bShow: true=display background color; false=don't display background color
219
-//  size: Font size
220
-//  color: Character color
221
-//  bColor: Background color
222
-//  x/y: Upper-left coordinate of the string
223
-//  *string: The string
224
-void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string);
225
-
226
-class __FlashStringHelper;
227
-
228
-inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
229
-  DWIN_Draw_String(bShow, size, color, bColor, x, y, (char *)title);
230
-}
231
-
232
-// Draw a positive integer
233
-//  bShow: true=display background color; false=don't display background color
234
-//  zeroFill: true=zero fill; false=no zero fill
235
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
236
-//  size: Font size
237
-//  color: Character color
238
-//  bColor: Background color
239
-//  iNum: Number of digits
240
-//  x/y: Upper-left coordinate
241
-//  value: Integer value
242
-void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
243
-                          uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value);
244
-
245
-// Draw a floating point number
246
-//  bShow: true=display background color; false=don't display background color
247
-//  zeroFill: true=zero fill; false=no zero fill
248
-//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
249
-//  size: Font size
250
-//  color: Character color
251
-//  bColor: Background color
252
-//  iNum: Number of whole digits
253
-//  fNum: Number of decimal digits
254
-//  x/y: Upper-left point
255
-//  value: Float value
256
-void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
257
-                            uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
258
-
259
-/*---------------------------------------- Picture related functions ----------------------------------------*/
260
-
261
-// Draw JPG and cached in #0 virtual display area
262
-// id: Picture ID
263
-void DWIN_JPG_ShowAndCache(const uint8_t id);
264
-
265
-// Draw an Icon
266
-//  libID: Icon library ID
267
-//  picID: Icon ID
268
-//  x/y: Upper-left point
269
-void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y);
270
-
271
-// Unzip the JPG picture to a virtual display area
272
-//  n: Cache index
273
-//  id: Picture ID
274
-void DWIN_JPG_CacheToN(uint8_t n, uint8_t id);
275
-
276
-// Unzip the JPG picture to virtual display area #1
277
-//  id: Picture ID
278
-inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); }
73
+#define DWIN_FONT_MENU  font10x20
74
+#define DWIN_FONT_STAT  font14x28
75
+#define DWIN_FONT_ALERT font14x28
279
 
76
 
280
-// Copy area from virtual display area to current screen
281
-//  cacheID: virtual area number
282
-//  xStart/yStart: Upper-left of virtual area
283
-//  xEnd/yEnd: Lower-right of virtual area
284
-//  x/y: Screen paste point
285
-void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
286
-                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
77
+#include "../common/dwin_color.h"
287
 
78
 
288
-// Animate a series of icons
289
-//  animID: Animation ID  up to 16
290
-//  animate: animation on or off
291
-//  libID: Icon library ID
292
-//  picIDs: Icon starting ID
293
-//  picIDe: Icon ending ID
294
-//  x/y: Upper-left point
295
-//  interval: Display time interval, unit 10mS
296
-void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs,
297
-                         uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval);
79
+#define Color_Bg_Heading  0x3344  // Static Heading
298
 
80
 
299
-// Animation Control
300
-//  state: 16 bits, each bit is the state of an animation id
301
-void DWIN_ICON_AnimationControl(uint16_t state);
81
+// Character matrix width x height
82
+//#define LCD_WIDTH ((DWIN_WIDTH) / 8)
83
+//#define LCD_HEIGHT ((DWIN_HEIGHT) / 12)

+ 2
- 3
Marlin/src/lcd/e3v2/marlinui/dwin_string.h 查看文件

21
  */
21
  */
22
 #pragma once
22
 #pragma once
23
 
23
 
24
-#include <stdint.h>
25
-
26
-
27
 #include "../../fontutils.h"
24
 #include "../../fontutils.h"
28
 #include "../../marlinui.h"
25
 #include "../../marlinui.h"
29
 
26
 
27
+#include <stdint.h>
28
+
30
 typedef struct _dwin_charmap_t {
29
 typedef struct _dwin_charmap_t {
31
   wchar_t uchar; // the unicode char
30
   wchar_t uchar; // the unicode char
32
   uint8_t idx;   // the glyph of the char in the ROM
31
   uint8_t idx;   // the glyph of the char in the ROM

+ 3
- 3
Marlin/src/lcd/e3v2/marlinui/ui_common.cpp 查看文件

83
   DWIN_Startup();
83
   DWIN_Startup();
84
 
84
 
85
   // Load the assets JPG (currently just the status screen 'icon')
85
   // Load the assets JPG (currently just the status screen 'icon')
86
-  DWIN_JPG_CacheToN(1, DWIN_MarlinUI_Assets);
86
+  DWIN_JPG_CacheTo1(DWIN_MarlinUI_Assets);
87
 }
87
 }
88
 
88
 
89
 // This LCD should clear where it will draw anew
89
 // This LCD should clear where it will draw anew
545
 
545
 
546
       // Show the location value
546
       // Show the location value
547
       dwin_string.set(Z_LBL);
547
       dwin_string.set(Z_LBL);
548
-      if (!isnan(ubl.z_values[x_plot][y_plot]))
549
-        dwin_string.add(ftostr43sign(ubl.z_values[x_plot][y_plot]));
548
+      if (!isnan(Z_VALUES_ARR[x_plot][y_plot]))
549
+        dwin_string.add(ftostr43sign(Z_VALUES_ARR[x_plot][y_plot]));
550
       else
550
       else
551
         dwin_string.add(PSTR(" -----"));
551
         dwin_string.add(PSTR(" -----"));
552
       lcd_moveto(
552
       lcd_moveto(

+ 1
- 1
Marlin/src/lcd/marlinui.cpp 查看文件

104
     if (backlight) brightness = constrain(value, MIN_LCD_BRIGHTNESS, MAX_LCD_BRIGHTNESS);
104
     if (backlight) brightness = constrain(value, MIN_LCD_BRIGHTNESS, MAX_LCD_BRIGHTNESS);
105
     // Set brightness on enabled LCD here
105
     // Set brightness on enabled LCD here
106
     TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_LCD_Brightness(brightness));
106
     TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_LCD_Brightness(brightness));
107
-    TERN_(DWIN_CREALITY_LCD_JYERSUI, DWIN_Backlight_SetLuminance(backlight ? brightness : 0));
107
+    TERN_(DWIN_CREALITY_LCD_JYERSUI, DWIN_LCD_Brightness(backlight ? brightness : 0));
108
   }
108
   }
109
 #endif
109
 #endif
110
 
110
 

+ 2
- 3
Marlin/src/lcd/marlinui.h 查看文件

21
  */
21
  */
22
 #pragma once
22
 #pragma once
23
 
23
 
24
-#include "../inc/MarlinConfig.h"
25
-
26
 #include "../module/motion.h"
24
 #include "../module/motion.h"
27
-
28
 #include "buttons.h"
25
 #include "buttons.h"
29
 
26
 
27
+#include "../inc/MarlinConfig.h"
28
+
30
 #if HAS_BUZZER
29
 #if HAS_BUZZER
31
   #include "../libs/buzzer.h"
30
   #include "../libs/buzzer.h"
32
 #endif
31
 #endif

+ 0
- 1
Marlin/src/sd/SdFile.h 查看文件

33
 #include "SdBaseFile.h"
33
 #include "SdBaseFile.h"
34
 
34
 
35
 #include <stdint.h>
35
 #include <stdint.h>
36
-#include <string.h>
37
 
36
 
38
 /**
37
 /**
39
  * \class SdFile
38
  * \class SdFile

+ 4
- 4
buildroot/tests/STM32F103RET6_creality 查看文件

10
 # Build with configs included in the PR
10
 # Build with configs included in the PR
11
 #
11
 #
12
 use_example_configs "Creality/Ender-3 V2/CrealityUI"
12
 use_example_configs "Creality/Ender-3 V2/CrealityUI"
13
-opt_enable MARLIN_DEV_MODE BUFFER_MONITORING
13
+opt_enable MARLIN_DEV_MODE BUFFER_MONITORING BLTOUCH AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING
14
 exec_test $1 $2 "Ender 3 v2 with CrealityUI" "$3"
14
 exec_test $1 $2 "Ender 3 v2 with CrealityUI" "$3"
15
 
15
 
16
 use_example_configs "Creality/Ender-3 V2/CrealityUI"
16
 use_example_configs "Creality/Ender-3 V2/CrealityUI"
17
 opt_disable DWIN_CREALITY_LCD
17
 opt_disable DWIN_CREALITY_LCD
18
-opt_enable DWIN_CREALITY_LCD_ENHANCED
18
+opt_enable DWIN_CREALITY_LCD_ENHANCED BLTOUCH AUTO_BED_LEVELING_UBL Z_SAFE_HOMING
19
 exec_test $1 $2 "Ender 3 v2 with Enhanced UI" "$3"
19
 exec_test $1 $2 "Ender 3 v2 with Enhanced UI" "$3"
20
 
20
 
21
 use_example_configs "Creality/Ender-3 V2/CrealityUI"
21
 use_example_configs "Creality/Ender-3 V2/CrealityUI"
22
 opt_disable DWIN_CREALITY_LCD
22
 opt_disable DWIN_CREALITY_LCD
23
-opt_enable DWIN_CREALITY_LCD_JYERSUI
23
+opt_enable DWIN_CREALITY_LCD_JYERSUI AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY
24
 exec_test $1 $2 "Ender 3 v2 with JyersUI" "$3"
24
 exec_test $1 $2 "Ender 3 v2 with JyersUI" "$3"
25
 
25
 
26
 use_example_configs "Creality/Ender-3 V2/MarlinUI"
26
 use_example_configs "Creality/Ender-3 V2/MarlinUI"
27
-opt_add SDCARD_EEPROM_EMULATION
27
+opt_add SDCARD_EEPROM_EMULATION NOZZLE_AS_PROBE AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING
28
 exec_test $1 $2 "Ender 3 v2 with MarlinUI" "$3"
28
 exec_test $1 $2 "Ender 3 v2 with MarlinUI" "$3"
29
 
29
 
30
 restore_configs
30
 restore_configs

+ 2
- 1
ini/features.ini 查看文件

44
 I2C_EEPROM                             = src_filter=+<src/HAL/shared/eeprom_if_i2c.cpp>
44
 I2C_EEPROM                             = src_filter=+<src/HAL/shared/eeprom_if_i2c.cpp>
45
 SOFT_I2C_EEPROM                        = SlowSoftI2CMaster, SlowSoftWire=https://github.com/felias-fogg/SlowSoftWire/archive/master.zip
45
 SOFT_I2C_EEPROM                        = SlowSoftI2CMaster, SlowSoftWire=https://github.com/felias-fogg/SlowSoftWire/archive/master.zip
46
 SPI_EEPROM                             = src_filter=+<src/HAL/shared/eeprom_if_spi.cpp>
46
 SPI_EEPROM                             = src_filter=+<src/HAL/shared/eeprom_if_spi.cpp>
47
+HAS_DWIN_E3V2|IS_DWIN_MARLINUI         = src_filter=+<src/lcd/e3v2/common>
47
 DWIN_CREALITY_LCD                      = src_filter=+<src/lcd/e3v2/creality>
48
 DWIN_CREALITY_LCD                      = src_filter=+<src/lcd/e3v2/creality>
48
 DWIN_CREALITY_LCD_ENHANCED             = src_filter=+<src/lcd/e3v2/enhanced>
49
 DWIN_CREALITY_LCD_ENHANCED             = src_filter=+<src/lcd/e3v2/enhanced>
49
 DWIN_CREALITY_LCD_JYERSUI              = src_filter=+<src/lcd/e3v2/jyersui>
50
 DWIN_CREALITY_LCD_JYERSUI              = src_filter=+<src/lcd/e3v2/jyersui>
50
-DWIN_MARLINUI_.+                       = src_filter=+<src/lcd/e3v2/marlinui>
51
+IS_DWIN_MARLINUI                       = src_filter=+<src/lcd/e3v2/marlinui>
51
 HAS_GRAPHICAL_TFT                      = src_filter=+<src/lcd/tft>
52
 HAS_GRAPHICAL_TFT                      = src_filter=+<src/lcd/tft>
52
 IS_TFTGLCD_PANEL                       = src_filter=+<src/lcd/TFTGLCD>
53
 IS_TFTGLCD_PANEL                       = src_filter=+<src/lcd/TFTGLCD>
53
 HAS_TOUCH_BUTTONS                      = src_filter=+<src/lcd/touch/touch_buttons.cpp>
54
 HAS_TOUCH_BUTTONS                      = src_filter=+<src/lcd/touch/touch_buttons.cpp>

+ 1
- 1
platformio.ini 查看文件

50
 default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
50
 default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
51
   -<src/lcd/HD44780> -<src/lcd/TFTGLCD> -<src/lcd/dogm> -<src/lcd/tft> -<src/lcd/tft_io>
51
   -<src/lcd/HD44780> -<src/lcd/TFTGLCD> -<src/lcd/dogm> -<src/lcd/tft> -<src/lcd/tft_io>
52
   -<src/HAL/STM32/tft> -<src/HAL/STM32F1/tft>
52
   -<src/HAL/STM32/tft> -<src/HAL/STM32F1/tft>
53
-  -<src/lcd/e3v2/creality> -<src/lcd/e3v2/enhanced> -<src/lcd/e3v2/jyersui> -<src/lcd/e3v2/marlinui>
53
+  -<src/lcd/e3v2/common> -<src/lcd/e3v2/creality> -<src/lcd/e3v2/enhanced> -<src/lcd/e3v2/jyersui> -<src/lcd/e3v2/marlinui>
54
   -<src/lcd/menu>
54
   -<src/lcd/menu>
55
   -<src/lcd/menu/game/game.cpp> -<src/lcd/menu/game/brickout.cpp> -<src/lcd/menu/game/invaders.cpp>
55
   -<src/lcd/menu/game/game.cpp> -<src/lcd/menu/game/brickout.cpp> -<src/lcd/menu/game/invaders.cpp>
56
   -<src/lcd/menu/game/maze.cpp> -<src/lcd/menu/game/snake.cpp>
56
   -<src/lcd/menu/game/maze.cpp> -<src/lcd/menu/game/snake.cpp>

正在加载...
取消
保存