Browse Source

✨Add DGUS_LCD_UI_RELOADED (#21931)

mrv96 2 years ago
parent
commit
b0e798330d
No account linked to committer's email address
31 changed files with 4966 additions and 8 deletions
  1. 5
    0
      Marlin/Configuration.h
  2. 4
    0
      Marlin/src/inc/Conditionals_LCD.h
  3. 30
    1
      Marlin/src/inc/SanityCheck.h
  4. 2
    2
      Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp
  5. 2
    2
      Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp
  6. 2
    2
      Marlin/src/lcd/extui/dgus/dgus_extui.cpp
  7. 407
    0
      Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.cpp
  8. 171
    0
      Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h
  9. 1059
    0
      Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp
  10. 123
    0
      Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.h
  11. 540
    0
      Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp
  12. 152
    0
      Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h
  13. 209
    0
      Marlin/src/lcd/extui/dgus_reloaded/DGUSSetupHandler.cpp
  14. 43
    0
      Marlin/src/lcd/extui/dgus_reloaded/DGUSSetupHandler.h
  15. 632
    0
      Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp
  16. 127
    0
      Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.h
  17. 173
    0
      Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Addr.h
  18. 96
    0
      Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Constants.h
  19. 50
    0
      Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Control.h
  20. 148
    0
      Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Data.h
  21. 52
    0
      Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Screen.h
  22. 240
    0
      Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_ScreenAddrList.cpp
  23. 32
    0
      Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_ScreenAddrList.h
  24. 57
    0
      Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_ScreenSetup.cpp
  25. 31
    0
      Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_ScreenSetup.h
  26. 40
    0
      Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_VP.h
  27. 368
    0
      Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_VPList.cpp
  28. 26
    0
      Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_VPList.h
  29. 142
    0
      Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp
  30. 2
    1
      ini/features.ini
  31. 1
    0
      platformio.ini

+ 5
- 0
Marlin/Configuration.h View File

@@ -2565,10 +2565,15 @@
2565 2565
 //  - Download https://github.com/makerbase-mks/MKS-H43
2566 2566
 //  - Copy the downloaded DWIN_SET folder to the SD card.
2567 2567
 //
2568
+// RELOADED (T5UID1)
2569
+//  - Download https://github.com/Desuuuu/DGUS-reloaded
2570
+//  - Copy the downloaded DWIN_SET folder to the SD card.
2571
+//
2568 2572
 //#define DGUS_LCD_UI_ORIGIN
2569 2573
 //#define DGUS_LCD_UI_FYSETC
2570 2574
 //#define DGUS_LCD_UI_HIPRECY
2571 2575
 //#define DGUS_LCD_UI_MKS
2576
+//#define DGUS_LCD_UI_RELOADED
2572 2577
 #if ENABLED(DGUS_LCD_UI_MKS)
2573 2578
   #define USE_MKS_GREEN_UI
2574 2579
 #endif

+ 4
- 0
Marlin/src/inc/Conditionals_LCD.h View File

@@ -479,6 +479,10 @@
479 479
 
480 480
 // Aliases for LCD features
481 481
 #if ANY(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_MKS)
482
+  #define HAS_DGUS_LCD_CLASSIC 1
483
+#endif
484
+
485
+#if ANY(HAS_DGUS_LCD_CLASSIC, DGUS_LCD_UI_RELOADED)
482 486
   #define HAS_DGUS_LCD 1
483 487
 #endif
484 488
 

+ 30
- 1
Marlin/src/inc/SanityCheck.h View File

@@ -2655,7 +2655,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
2655 2655
   + (DISABLED(IS_LEGACY_TFT) && ENABLED(TFT_GENERIC)) \
2656 2656
   + (ENABLED(IS_LEGACY_TFT) && COUNT_ENABLED(TFT_320x240, TFT_320x240_SPI, TFT_480x320, TFT_480x320_SPI)) \
2657 2657
   + COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35) \
2658
-  + COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_MKS) \
2658
+  + COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_MKS, DGUS_LCD_UI_RELOADED) \
2659 2659
   + COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY) \
2660 2660
   + COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \
2661 2661
   + COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_GENERIC_12864_1_1) \
@@ -3798,6 +3798,35 @@ static_assert(   _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
3798 3798
 #endif
3799 3799
 #undef _BAD_DRIVER
3800 3800
 
3801
+/**
3802
+ * Require certain features for DGUS_LCD_UI_RELOADED.
3803
+ */
3804
+#if ENABLED(DGUS_LCD_UI_RELOADED)
3805
+  #if BUFSIZE < 4
3806
+    #error "DGUS_LCD_UI_RELOADED requires a BUFSIZE of at least 4."
3807
+  #elif HOTENDS < 1
3808
+    #error "DGUS_LCD_UI_RELOADED requires at least 1 hotend."
3809
+  #elif EXTRUDERS < 1
3810
+    #error "DGUS_LCD_UI_RELOADED requires at least 1 extruder."
3811
+  #elif !HAS_HEATED_BED
3812
+    #error "DGUS_LCD_UI_RELOADED requires a heated bed."
3813
+  #elif FAN_COUNT < 1
3814
+    #error "DGUS_LCD_UI_RELOADED requires a fan."
3815
+  #elif !HAS_BED_PROBE
3816
+    #error "DGUS_LCD_UI_RELOADED requires a bed probe."
3817
+  #elif !HAS_MESH
3818
+    #error "DGUS_LCD_UI_RELOADED requires mesh leveling."
3819
+  #elif DISABLED(LEVEL_BED_CORNERS)
3820
+    #error "DGUS_LCD_UI_RELOADED requires LEVEL_BED_CORNERS."
3821
+  #elif DISABLED(BABYSTEP_ALWAYS_AVAILABLE)
3822
+    #error "DGUS_LCD_UI_RELOADED requires BABYSTEP_ALWAYS_AVAILABLE."
3823
+  #elif DISABLED(BABYSTEP_ZPROBE_OFFSET)
3824
+    #error "DGUS_LCD_UI_RELOADED requires BABYSTEP_ZPROBE_OFFSET."
3825
+  #elif ENABLED(AUTO_BED_LEVELING_UBL) && DISABLED(UBL_SAVE_ACTIVE_ON_M500)
3826
+    #warning "Without UBL_SAVE_ACTIVE_ON_M500, your mesh will not be saved when using the touchscreen."
3827
+  #endif
3828
+#endif
3829
+
3801 3830
 // Misc. Cleanup
3802 3831
 #undef _TEST_PWM
3803 3832
 #undef _LINEAR_AXES_STR

+ 2
- 2
Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 #include "../../../inc/MarlinConfigPre.h"
24 24
 
25
-#if HAS_DGUS_LCD
25
+#if HAS_DGUS_LCD_CLASSIC
26 26
 
27 27
 #if HOTENDS > 2
28 28
   #warning "More than 2 hotends not implemented on DGUS Display UI."
@@ -268,4 +268,4 @@ bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy) {
268 268
   return true;
269 269
 }
270 270
 
271
-#endif // HAS_DGUS_LCD
271
+#endif // HAS_DGUS_LCD_CLASSIC

+ 2
- 2
Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 #include "../../../inc/MarlinConfigPre.h"
24 24
 
25
-#if HAS_DGUS_LCD
25
+#if HAS_DGUS_LCD_CLASSIC
26 26
 
27 27
 #include "DGUSScreenHandler.h"
28 28
 
@@ -772,4 +772,4 @@ void DGUSDisplay::RequestScreen(DGUSLCD_Screens screen) {
772 772
   WriteVariable(0x84, gotoscreen, sizeof(gotoscreen));
773 773
 }
774 774
 
775
-#endif // HAS_DGUS_LCD
775
+#endif // HAS_DGUS_LCD_CLASSIC

+ 2
- 2
Marlin/src/lcd/extui/dgus/dgus_extui.cpp View File

@@ -26,7 +26,7 @@
26 26
 
27 27
 #include "../../../inc/MarlinConfigPre.h"
28 28
 
29
-#if HAS_DGUS_LCD
29
+#if HAS_DGUS_LCD_CLASSIC
30 30
 
31 31
 #include "../ui_api.h"
32 32
 #include "DGUSDisplay.h"
@@ -159,4 +159,4 @@ namespace ExtUI {
159 159
   void onSteppersEnabled()  {}
160 160
 }
161 161
 
162
-#endif // HAS_DGUS_LCD
162
+#endif // HAS_DGUS_LCD_CLASSIC

+ 407
- 0
Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.cpp View File

@@ -0,0 +1,407 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/* DGUS implementation written by coldtobi in 2019 for Marlin */
24
+
25
+#include "../../../inc/MarlinConfigPre.h"
26
+
27
+#if ENABLED(DGUS_LCD_UI_RELOADED)
28
+
29
+#include "DGUSDisplay.h"
30
+
31
+#include "config/DGUS_Addr.h"
32
+#include "config/DGUS_Constants.h"
33
+#include "definition/DGUS_VPList.h"
34
+
35
+#include "../ui_api.h"
36
+#include "../../../gcode/gcode.h"
37
+
38
+long map_precise(float x, long in_min, long in_max, long out_min, long out_max) {
39
+  return LROUND((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min);
40
+}
41
+
42
+uint8_t DGUSDisplay::gui_version = 0;
43
+uint8_t DGUSDisplay::os_version = 0;
44
+
45
+uint8_t DGUSDisplay::volume = 255;
46
+uint8_t DGUSDisplay::brightness = 100;
47
+
48
+DGUSDisplay::rx_datagram_state_t DGUSDisplay::rx_datagram_state = DGUS_IDLE;
49
+uint8_t DGUSDisplay::rx_datagram_len = 0;
50
+
51
+bool DGUSDisplay::initialized = false;
52
+
53
+void DGUSDisplay::Loop() {
54
+  ProcessRx();
55
+}
56
+
57
+void DGUSDisplay::Init() {
58
+  LCD_SERIAL.begin(LCD_BAUDRATE);
59
+
60
+  Read(DGUS_VERSION, 1);
61
+}
62
+
63
+void DGUSDisplay::Read(uint16_t addr, uint8_t size) {
64
+  WriteHeader(addr, DGUS_READVAR, size);
65
+
66
+  LCD_SERIAL.write(size);
67
+}
68
+
69
+void DGUSDisplay::Write(uint16_t addr, const void* data_ptr, uint8_t size) {
70
+  if (!data_ptr) return;
71
+
72
+  WriteHeader(addr, DGUS_WRITEVAR, size);
73
+
74
+  const char* data = static_cast<const char*>(data_ptr);
75
+
76
+  while (size--) {
77
+    LCD_SERIAL.write(*data++);
78
+  }
79
+}
80
+
81
+void DGUSDisplay::WriteString(uint16_t addr, const void* data_ptr, uint8_t size, bool left, bool right, bool use_space) {
82
+  if (!data_ptr) return;
83
+
84
+  WriteHeader(addr, DGUS_WRITEVAR, size);
85
+
86
+  const char* data = static_cast<const char*>(data_ptr);
87
+  size_t len = strlen(data);
88
+  uint8_t left_spaces = 0;
89
+  uint8_t right_spaces = 0;
90
+
91
+  if (len < size) {
92
+    if (!len) {
93
+      right_spaces = size;
94
+    }
95
+    else if ((left && right) || (!left && !right)) {
96
+      left_spaces = (size - len) / 2;
97
+      right_spaces = size - len - left_spaces;
98
+    }
99
+    else if (left) {
100
+      right_spaces = size - len;
101
+    }
102
+    else {
103
+      left_spaces = size - len;
104
+    }
105
+  }
106
+  else {
107
+    len = size;
108
+  }
109
+
110
+  while (left_spaces--) {
111
+    LCD_SERIAL.write(' ');
112
+  }
113
+  while (len--) {
114
+    LCD_SERIAL.write(*data++);
115
+  }
116
+  while (right_spaces--) {
117
+    LCD_SERIAL.write(use_space ? ' ' : '\0');
118
+  }
119
+}
120
+
121
+void DGUSDisplay::WriteStringPGM(uint16_t addr, const void* data_ptr, uint8_t size, bool left, bool right, bool use_space) {
122
+  if (!data_ptr) return;
123
+
124
+  WriteHeader(addr, DGUS_WRITEVAR, size);
125
+
126
+  const char* data = static_cast<const char*>(data_ptr);
127
+  size_t len = strlen_P(data);
128
+  uint8_t left_spaces = 0;
129
+  uint8_t right_spaces = 0;
130
+
131
+  if (len < size) {
132
+    if (!len) {
133
+      right_spaces = size;
134
+    }
135
+    else if ((left && right) || (!left && !right)) {
136
+      left_spaces = (size - len) / 2;
137
+      right_spaces = size - len - left_spaces;
138
+    }
139
+    else if (left) {
140
+      right_spaces = size - len;
141
+    }
142
+    else {
143
+      left_spaces = size - len;
144
+    }
145
+  }
146
+  else {
147
+    len = size;
148
+  }
149
+
150
+  while (left_spaces--) {
151
+    LCD_SERIAL.write(' ');
152
+  }
153
+  while (len--) {
154
+    LCD_SERIAL.write(pgm_read_byte(data++));
155
+  }
156
+  while (right_spaces--) {
157
+    LCD_SERIAL.write(use_space ? ' ' : '\0');
158
+  }
159
+}
160
+
161
+void DGUSDisplay::SwitchScreen(DGUS_Screen screen) {
162
+  DEBUG_ECHOLNPAIR("SwitchScreen ", (uint8_t)screen);
163
+  const uint8_t command[] = { 0x5A, 0x01, 0x00, (uint8_t)screen };
164
+  Write(0x84, command, sizeof(command));
165
+}
166
+
167
+void DGUSDisplay::PlaySound(uint8_t start, uint8_t len, uint8_t volume) {
168
+  if (volume == 0) volume = DGUSDisplay::volume;
169
+  if (volume == 0) return;
170
+  DEBUG_ECHOLNPAIR("PlaySound ", start, ":", len, "\nVolume ", volume);
171
+  const uint8_t command[] = { start, len, volume, 0x00 };
172
+  Write(0xA0, command, sizeof(command));
173
+}
174
+
175
+void DGUSDisplay::EnableControl(DGUS_Screen screen, DGUS_ControlType type, DGUS_Control control) {
176
+  DEBUG_ECHOLNPAIR("EnableControl ", (uint8_t)control, "\nScreen ", (uint8_t)screen, "\nType ", (uint8_t)type);
177
+
178
+  const uint8_t command[] = { 0x5A, 0xA5, 0x00, (uint8_t)screen, (uint8_t)control, type, 0x00, 0x01 };
179
+  Write(0xB0, command, sizeof(command));
180
+
181
+  FlushTx();
182
+  delay(50);
183
+}
184
+
185
+void DGUSDisplay::DisableControl(DGUS_Screen screen, DGUS_ControlType type, DGUS_Control control) {
186
+  DEBUG_ECHOLNPAIR("DisableControl ", (uint8_t)control, "\nScreen ", (uint8_t)screen, "\nType ", (uint8_t)type);
187
+
188
+  const uint8_t command[] = { 0x5A, 0xA5, 0x00, (uint8_t)screen, (uint8_t)control, type, 0x00, 0x00 };
189
+  Write(0xB0, command, sizeof(command));
190
+
191
+  FlushTx();
192
+  delay(50);
193
+}
194
+
195
+uint8_t DGUSDisplay::GetBrightness() {
196
+  return brightness;
197
+}
198
+
199
+uint8_t DGUSDisplay::GetVolume() {
200
+  return map_precise(volume, 0, 255, 0, 100);
201
+}
202
+
203
+void DGUSDisplay::SetBrightness(uint8_t new_brightness) {
204
+  brightness = constrain(new_brightness, 0, 100);
205
+  new_brightness = map_precise(brightness, 0, 100, 5, 100);
206
+  DEBUG_ECHOLNPAIR("SetBrightness ", new_brightness);
207
+  const uint8_t command[] = { new_brightness, new_brightness };
208
+  Write(0x82, command, sizeof(command));
209
+}
210
+
211
+void DGUSDisplay::SetVolume(uint8_t new_volume) {
212
+  volume = map_precise(constrain(new_volume, 0, 100), 0, 100, 0, 255);
213
+  DEBUG_ECHOLNPAIR("SetVolume ", volume);
214
+  const uint8_t command[] = { volume, 0x00 };
215
+  Write(0xA1, command, sizeof(command));
216
+}
217
+
218
+void DGUSDisplay::ProcessRx() {
219
+
220
+  #if ENABLED(LCD_SERIAL_STATS_RX_BUFFER_OVERRUNS)
221
+    if (!LCD_SERIAL.available() && LCD_SERIAL.buffer_overruns()) {
222
+      // Overrun, but reset the flag only when the buffer is empty
223
+      // We want to extract as many as valid datagrams possible...
224
+      DEBUG_ECHOPGM("OVFL");
225
+      rx_datagram_state = DGUS_IDLE;
226
+      //LCD_SERIAL.reset_rx_overun();
227
+      LCD_SERIAL.flush();
228
+    }
229
+  #endif
230
+
231
+  uint8_t receivedbyte;
232
+  while (LCD_SERIAL.available()) {
233
+    switch (rx_datagram_state) {
234
+
235
+      case DGUS_IDLE: // Waiting for the first header byte
236
+        receivedbyte = LCD_SERIAL.read();
237
+        DEBUG_ECHOPAIR("< ", receivedbyte);
238
+        if (DGUS_HEADER1 == receivedbyte) rx_datagram_state = DGUS_HEADER1_SEEN;
239
+        break;
240
+
241
+      case DGUS_HEADER1_SEEN: // Waiting for the second header byte
242
+        receivedbyte = LCD_SERIAL.read();
243
+        DEBUG_ECHOPAIR(" ", receivedbyte);
244
+        rx_datagram_state = (DGUS_HEADER2 == receivedbyte) ? DGUS_HEADER2_SEEN : DGUS_IDLE;
245
+        break;
246
+
247
+      case DGUS_HEADER2_SEEN: // Waiting for the length byte
248
+        rx_datagram_len = LCD_SERIAL.read();
249
+        DEBUG_ECHOPAIR(" (", rx_datagram_len, ") ");
250
+
251
+        // Telegram min len is 3 (command and one word of payload)
252
+        rx_datagram_state = WITHIN(rx_datagram_len, 3, DGUS_RX_BUFFER_SIZE) ? DGUS_WAIT_TELEGRAM : DGUS_IDLE;
253
+        break;
254
+
255
+      case DGUS_WAIT_TELEGRAM: // wait for complete datagram to arrive.
256
+        if (LCD_SERIAL.available() < rx_datagram_len) return;
257
+
258
+        initialized = true; // We've talked to it, so we defined it as initialized.
259
+        uint8_t command = LCD_SERIAL.read();
260
+
261
+        DEBUG_ECHOPAIR("# ", command);
262
+
263
+        uint8_t readlen = rx_datagram_len - 1;  // command is part of len.
264
+        unsigned char tmp[rx_datagram_len - 1];
265
+        unsigned char *ptmp = tmp;
266
+
267
+        while (readlen--) {
268
+          receivedbyte = LCD_SERIAL.read();
269
+          DEBUG_ECHOPAIR(" ", receivedbyte);
270
+          *ptmp++ = receivedbyte;
271
+        }
272
+        DEBUG_ECHOPGM(" # ");
273
+        // mostly we'll get this: 5A A5 03 82 4F 4B -- ACK on 0x82, so discard it.
274
+        if (command == DGUS_WRITEVAR && 'O' == tmp[0] && 'K' == tmp[1]) {
275
+          DEBUG_ECHOLNPGM(">");
276
+          rx_datagram_state = DGUS_IDLE;
277
+          break;
278
+        }
279
+
280
+        /* AutoUpload, (and answer to) Command 0x83 :
281
+        |      tmp[0  1  2  3  4 ... ]
282
+        | Example 5A A5 06 83 20 01 01 78 01 ……
283
+        |          / /  |  |   \ /   |  \     \
284
+        |        Header |  |    |    |   \_____\_ DATA (Words!)
285
+        |     DatagramLen  /  VPAdr  |
286
+        |           Command          DataLen (in Words) */
287
+        if (command == DGUS_READVAR) {
288
+          const uint16_t addr = tmp[0] << 8 | tmp[1];
289
+          const uint8_t dlen = tmp[2] << 1;  // Convert to Bytes. (Display works with words)
290
+          DEBUG_ECHOPAIR("addr=", addr, " dlen=", dlen, "> ");
291
+
292
+          if (addr == DGUS_VERSION && dlen == 2) {
293
+            DEBUG_ECHOLNPGM("VERSIONS");
294
+            gui_version = tmp[3];
295
+            os_version = tmp[4];
296
+            rx_datagram_state = DGUS_IDLE;
297
+            break;
298
+          }
299
+
300
+          DGUS_VP vp;
301
+          if (!DGUS_PopulateVP((DGUS_Addr)addr, &vp)) {
302
+            DEBUG_ECHOLNPGM("VP not found");
303
+            rx_datagram_state = DGUS_IDLE;
304
+            break;
305
+          }
306
+
307
+          if (!vp.rx_handler) {
308
+            DEBUG_ECHOLNPGM("VP found, no handler.");
309
+            rx_datagram_state = DGUS_IDLE;
310
+            break;
311
+          }
312
+
313
+          gcode.reset_stepper_timeout();
314
+
315
+          if (!vp.size) {
316
+            DEBUG_ECHOLN();
317
+            vp.rx_handler(vp, nullptr);
318
+
319
+            rx_datagram_state = DGUS_IDLE;
320
+            break;
321
+          }
322
+
323
+          if (vp.flags & VPFLAG_RXSTRING) {
324
+            unsigned char buffer[vp.size];
325
+            memset(buffer, 0, vp.size);
326
+
327
+            for (uint8_t i = 0; i < dlen; i++) {
328
+              if (i >= vp.size) {
329
+                break;
330
+              }
331
+
332
+              if (i + 1 < dlen && tmp[i + 3] == 0xFF && tmp[i + 4] == 0xFF) {
333
+                break;
334
+              }
335
+
336
+              buffer[i] = tmp[i + 3];
337
+            }
338
+
339
+            DEBUG_ECHOLN();
340
+            vp.rx_handler(vp, buffer);
341
+
342
+            rx_datagram_state = DGUS_IDLE;
343
+            break;
344
+          }
345
+
346
+          if (dlen != vp.size) {
347
+            DEBUG_ECHOLNPGM("VP found, size mismatch.");
348
+            rx_datagram_state = DGUS_IDLE;
349
+            break;
350
+          }
351
+
352
+          DEBUG_ECHOLN();
353
+          vp.rx_handler(vp, &tmp[3]);
354
+
355
+          rx_datagram_state = DGUS_IDLE;
356
+          break;
357
+        }
358
+
359
+        DEBUG_ECHOLNPGM(">");
360
+        rx_datagram_state = DGUS_IDLE;
361
+        break;
362
+    }
363
+  }
364
+}
365
+
366
+size_t DGUSDisplay::GetFreeTxBuffer() {
367
+  #ifdef LCD_SERIAL_GET_TX_BUFFER_FREE
368
+    return LCD_SERIAL_GET_TX_BUFFER_FREE();
369
+  #else
370
+    return SIZE_MAX;
371
+  #endif
372
+}
373
+
374
+void DGUSDisplay::FlushTx() {
375
+  #ifdef ARDUINO_ARCH_STM32
376
+    LCD_SERIAL.flush();
377
+  #else
378
+    LCD_SERIAL.flushTX();
379
+  #endif
380
+}
381
+
382
+void DGUSDisplay::WriteHeader(uint16_t addr, uint8_t command, uint8_t len) {
383
+  LCD_SERIAL.write(DGUS_HEADER1);
384
+  LCD_SERIAL.write(DGUS_HEADER2);
385
+  LCD_SERIAL.write(len + 3);
386
+  LCD_SERIAL.write(command);
387
+  LCD_SERIAL.write(addr >> 8);
388
+  LCD_SERIAL.write(addr & 0xFF);
389
+}
390
+
391
+bool DGUS_PopulateVP(const DGUS_Addr addr, DGUS_VP * const buffer) {
392
+  const DGUS_VP *ret = vp_list;
393
+
394
+  do {
395
+    const uint16_t *paddr = (uint16_t *)(&ret->addr);
396
+    const uint16_t addrcheck = pgm_read_word(paddr);
397
+    if (addrcheck == 0) break;
398
+    if ((DGUS_Addr)addrcheck == addr) {
399
+      memcpy_P(buffer, ret, sizeof(*ret));
400
+      return true;
401
+    }
402
+  } while (++ret);
403
+  DEBUG_ECHOLNPAIR("VP not found: ", (uint16_t)addr);
404
+  return false;
405
+}
406
+
407
+#endif // DGUS_LCD_UI_RELOADED

+ 171
- 0
Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h View File

@@ -0,0 +1,171 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/* DGUS implementation written by coldtobi in 2019 for Marlin */
25
+
26
+#include "config/DGUS_Screen.h"
27
+#include "config/DGUS_Control.h"
28
+#include "definition/DGUS_VP.h"
29
+
30
+#include "../../../inc/MarlinConfigPre.h"
31
+#include "../../../MarlinCore.h"
32
+
33
+#define DEBUG_OUT ENABLED(DEBUG_DGUSLCD)
34
+#include "../../../core/debug_out.h"
35
+
36
+#define Swap16(val) ((uint16_t)(((uint16_t)(val) >> 8) |\
37
+                                ((uint16_t)(val) << 8)))
38
+
39
+// Low-Level access to the display.
40
+class DGUSDisplay {
41
+public:
42
+
43
+  enum DGUS_ControlType : uint8_t {
44
+    VARIABLE_DATA_INPUT = 0x00,
45
+    POPUP_WINDOW = 0x01,
46
+    INCREMENTAL_ADJUST = 0x02,
47
+    SLIDER_ADJUST = 0x03,
48
+    RTC_SETTINGS = 0x04,
49
+    RETURN_KEY_CODE = 0x05,
50
+    TEXT_INPUT = 0x06,
51
+    FIRMWARE_SETTINGS = 0x07
52
+  };
53
+
54
+  DGUSDisplay() = default;
55
+
56
+  static void Init();
57
+
58
+  static void Read(uint16_t addr, uint8_t size);
59
+  static void Write(uint16_t addr, const void* data_ptr, uint8_t size);
60
+
61
+  static void WriteString(uint16_t addr, const void* data_ptr, uint8_t size, bool left = true, bool right = false, bool use_space = true);
62
+  static void WriteStringPGM(uint16_t addr, const void* data_ptr, uint8_t size, bool left = true, bool right = false, bool use_space = true);
63
+
64
+  template<typename T>
65
+  static void Write(uint16_t addr, T data) {
66
+    Write(addr, static_cast<const void*>(&data), sizeof(T));
67
+  }
68
+
69
+  // Until now I did not need to actively read from the display. That's why there is no ReadVariable
70
+  // (I extensively use the auto upload of the display)
71
+
72
+  // Force display into another screen.
73
+  static void SwitchScreen(DGUS_Screen screen);
74
+  // Play sounds using the display speaker.
75
+  //   start: position at which the sound was stored on the display.
76
+  //   len: how many sounds to play. Sounds will play consecutively from start to start+len-1.
77
+  //   volume: playback volume. 0 keeps the current volume.
78
+  static void PlaySound(uint8_t start, uint8_t len = 1, uint8_t volume = 0);
79
+  // Enable/disable a specific touch control.
80
+  //   type: control type.
81
+  //   control: index of the control on the page (set during screen development).
82
+  static void EnableControl(DGUS_Screen screen, DGUS_ControlType type, DGUS_Control control);
83
+  static void DisableControl(DGUS_Screen screen, DGUS_ControlType type, DGUS_Control control);
84
+
85
+  static uint8_t GetBrightness();
86
+  static uint8_t GetVolume();
87
+
88
+  // Set the display brightness/volume, ranging 0 - 100
89
+  static void SetBrightness(uint8_t brightness);
90
+  static void SetVolume(uint8_t volume);
91
+
92
+  // Periodic tasks, eg. Rx-Queue handling.
93
+  static void Loop();
94
+
95
+  // Helper for users of this class to estimate if an interaction would be blocking.
96
+  static size_t GetFreeTxBuffer();
97
+  static void FlushTx();
98
+
99
+  // Checks two things: Can we confirm the presence of the display and has we initiliazed it.
100
+  // (both boils down that the display answered to our chatting)
101
+  static inline bool IsInitialized() {
102
+    return initialized;
103
+  }
104
+
105
+  static uint8_t gui_version;
106
+  static uint8_t os_version;
107
+
108
+  template<typename T>
109
+  static T SwapBytes(const T value) {
110
+    union {
111
+      T val;
112
+      char byte[sizeof(T)];
113
+    } src, dst;
114
+
115
+    src.val = value;
116
+    LOOP_L_N(i, sizeof(T)) dst.byte[i] = src.byte[sizeof(T) - i - 1];
117
+    return dst.val;
118
+  }
119
+
120
+  template<typename T_in, typename T_out, uint8_t decimals>
121
+  T_out FromFixedPoint(const T_in value) {
122
+    return (T_out)((float)value / POW(10, decimals));
123
+  }
124
+
125
+  template<typename T_in, typename T_out, uint8_t decimals>
126
+  T_out ToFixedPoint(const T_in value) {
127
+    return (T_out)LROUND((float)value * POW(10, decimals));
128
+  }
129
+
130
+private:
131
+  enum dgus_header : uint8_t {
132
+    DGUS_HEADER1 = 0x5A,
133
+    DGUS_HEADER2 = 0xA5
134
+  };
135
+
136
+  enum dgus_command : uint8_t {
137
+    DGUS_WRITEVAR = 0x82,
138
+    DGUS_READVAR = 0x83
139
+  };
140
+
141
+  enum rx_datagram_state_t : uint8_t {
142
+    DGUS_IDLE,           //< waiting for DGUS_HEADER1.
143
+    DGUS_HEADER1_SEEN,   //< DGUS_HEADER1 received
144
+    DGUS_HEADER2_SEEN,   //< DGUS_HEADER2 received
145
+    DGUS_WAIT_TELEGRAM,  //< LEN received, Waiting for to receive all bytes.
146
+  };
147
+
148
+  enum dgus_system_addr : uint16_t {
149
+    DGUS_VERSION = 0x000f // OS/GUI version
150
+  };
151
+
152
+  static void WriteHeader(uint16_t addr, uint8_t command, uint8_t len);
153
+  static void ProcessRx();
154
+
155
+  static uint8_t volume;
156
+  static uint8_t brightness;
157
+
158
+  static rx_datagram_state_t rx_datagram_state;
159
+  static uint8_t rx_datagram_len;
160
+
161
+  static bool initialized;
162
+};
163
+
164
+template<> inline uint16_t DGUSDisplay::SwapBytes(const uint16_t value) {
165
+  return ((value << 8) | (value >> 8));
166
+}
167
+
168
+extern DGUSDisplay dgus_display;
169
+
170
+/// Helper to populate a DGUS_VP for a given VP. Return false if not found.
171
+extern bool DGUS_PopulateVP(const DGUS_Addr addr, DGUS_VP * const buffer);

+ 1059
- 0
Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp
File diff suppressed because it is too large
View File


+ 123
- 0
Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.h View File

@@ -0,0 +1,123 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#pragma once
24
+
25
+#include "DGUSDisplay.h"
26
+#include "definition/DGUS_VP.h"
27
+
28
+namespace DGUSRxHandler {
29
+
30
+  void ScreenChange(DGUS_VP &, void *);
31
+
32
+  #if ENABLED(SDSUPPORT)
33
+    void Scroll(DGUS_VP &, void *);
34
+    void SelectFile(DGUS_VP &, void *);
35
+    void PrintFile(DGUS_VP &, void *);
36
+  #endif
37
+
38
+  void PrintAbort(DGUS_VP &, void *);
39
+  void PrintPause(DGUS_VP &, void *);
40
+  void PrintResume(DGUS_VP &, void *);
41
+
42
+  void Feedrate(DGUS_VP &, void *);
43
+  void Flowrate(DGUS_VP &, void *);
44
+  void BabystepSet(DGUS_VP &, void *);
45
+  void Babystep(DGUS_VP &, void *);
46
+
47
+  void TempPreset(DGUS_VP &, void *);
48
+  void TempTarget(DGUS_VP &, void *);
49
+  void TempCool(DGUS_VP &, void *);
50
+
51
+  void Steppers(DGUS_VP &, void *);
52
+
53
+  void ZOffset(DGUS_VP &, void *);
54
+  void ZOffsetStep(DGUS_VP &, void *);
55
+  void ZOffsetSetStep(DGUS_VP &, void *);
56
+
57
+  void MoveToPoint(DGUS_VP &, void *);
58
+
59
+  void Probe(DGUS_VP &, void *);
60
+  void DisableABL(DGUS_VP &, void *);
61
+
62
+  void FilamentSelect(DGUS_VP &, void *);
63
+  void FilamentLength(DGUS_VP &, void *);
64
+  void FilamentMove(DGUS_VP &, void *);
65
+
66
+  void Home(DGUS_VP &, void *);
67
+  void Move(DGUS_VP &, void *);
68
+  void MoveStep(DGUS_VP &, void *);
69
+  void MoveSetStep(DGUS_VP &, void *);
70
+
71
+  void GcodeClear(DGUS_VP &, void *);
72
+  void GcodeExecute(DGUS_VP &, void *);
73
+
74
+  void ResetEEPROM(DGUS_VP &, void *);
75
+
76
+  void SettingsExtra(DGUS_VP &, void *);
77
+
78
+  void PIDSelect(DGUS_VP &, void *);
79
+  void PIDSetTemp(DGUS_VP &, void *);
80
+  void PIDRun(DGUS_VP &, void *);
81
+
82
+  #if ENABLED(POWER_LOSS_RECOVERY)
83
+    void PowerLossAbort(DGUS_VP &, void *);
84
+    void PowerLossResume(DGUS_VP &, void *);
85
+  #endif
86
+
87
+  void WaitAbort(DGUS_VP &, void *);
88
+  void WaitContinue(DGUS_VP &, void *);
89
+
90
+  void FanSpeed(DGUS_VP &, void *);
91
+
92
+  void Volume(DGUS_VP &, void *);
93
+
94
+  void Brightness(DGUS_VP &, void *);
95
+
96
+  void Debug(DGUS_VP &, void *);
97
+
98
+  void StringToExtra(DGUS_VP &, void *);
99
+
100
+  template<typename T>
101
+  void IntegerToExtra(DGUS_VP &vp, void *data_ptr) {
102
+    if (!vp.size || !vp.extra) return;
103
+    switch (vp.size) {
104
+      default: return;
105
+      case 1: {
106
+        const uint8_t data = *(uint8_t*)data_ptr;
107
+        *(T*)vp.extra = (T)data;
108
+        break;
109
+      }
110
+      case 2: {
111
+        const uint16_t data = Swap16(*(uint16_t*)data_ptr);
112
+        *(T*)vp.extra = (T)data;
113
+        break;
114
+      }
115
+      case 4: {
116
+        const uint32_t data = dgus_display.SwapBytes(*(uint32_t*)data_ptr);
117
+        *(T*)vp.extra = (T)data;
118
+        break;
119
+      }
120
+    }
121
+  }
122
+
123
+}

+ 540
- 0
Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp View File

@@ -0,0 +1,540 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "../../../inc/MarlinConfigPre.h"
24
+
25
+#if ENABLED(DGUS_LCD_UI_RELOADED)
26
+
27
+#include "DGUSScreenHandler.h"
28
+
29
+#include "DGUSDisplay.h"
30
+#include "definition/DGUS_ScreenAddrList.h"
31
+#include "definition/DGUS_ScreenSetup.h"
32
+
33
+#include "../../../gcode/queue.h"
34
+
35
+uint8_t DGUSScreenHandler::debug_count = 0;
36
+
37
+#if ENABLED(SDSUPPORT)
38
+  ExtUI::FileList DGUSScreenHandler::filelist;
39
+  uint16_t DGUSScreenHandler::filelist_offset = 0;
40
+  int16_t DGUSScreenHandler::filelist_selected = -1;
41
+#endif
42
+
43
+DGUS_Data::StepSize DGUSScreenHandler::offset_steps = DGUS_Data::StepSize::MMP1;
44
+DGUS_Data::StepSize DGUSScreenHandler::move_steps = DGUS_Data::StepSize::MM10;
45
+
46
+uint16_t DGUSScreenHandler::probing_icons[] = { 0, 0 };
47
+
48
+DGUS_Data::Extruder DGUSScreenHandler::filament_extruder = DGUS_Data::Extruder::CURRENT;
49
+uint16_t DGUSScreenHandler::filament_length = DGUS_DEFAULT_FILAMENT_LEN;
50
+
51
+char DGUSScreenHandler::gcode[] = "";
52
+
53
+DGUS_Data::Heater DGUSScreenHandler::pid_heater = DGUS_Data::Heater::H0;
54
+uint16_t DGUSScreenHandler::pid_temp = DGUS_PLA_TEMP_HOTEND;
55
+uint8_t DGUSScreenHandler::pid_cycles = 5;
56
+
57
+bool DGUSScreenHandler::settings_ready = false;
58
+bool DGUSScreenHandler::booted = false;
59
+
60
+DGUS_Screen DGUSScreenHandler::current_screen = DGUS_Screen::BOOT;
61
+DGUS_Screen DGUSScreenHandler::new_screen = DGUS_Screen::BOOT;
62
+bool DGUSScreenHandler::full_update = false;
63
+
64
+DGUS_Screen DGUSScreenHandler::wait_return_screen = DGUS_Screen::HOME;
65
+bool DGUSScreenHandler::wait_continue = false;
66
+
67
+bool DGUSScreenHandler::leveling_active = false;
68
+
69
+millis_t DGUSScreenHandler::status_expire = 0;
70
+millis_t DGUSScreenHandler::eeprom_save = 0;
71
+
72
+const char DGUS_MSG_HOMING_REQUIRED[] PROGMEM = "Homing required",
73
+           DGUS_MSG_BUSY[] PROGMEM = "Busy",
74
+           DGUS_MSG_UNDEF[] PROGMEM = "-",
75
+           DGUS_MSG_HOMING[] PROGMEM = "Homing...",
76
+           DGUS_MSG_FW_OUTDATED[] PROGMEM = "DWIN GUI/OS update required",
77
+           DGUS_MSG_ABL_REQUIRED[] PROGMEM = "Auto bed leveling required";
78
+
79
+const char DGUS_CMD_HOME[] PROGMEM = "G28",
80
+           DGUS_CMD_EEPROM_SAVE[] PROGMEM = "M500";
81
+
82
+void DGUSScreenHandler::Init() {
83
+  dgus_display.Init();
84
+
85
+  MoveToScreen(DGUS_Screen::BOOT, true);
86
+}
87
+
88
+void DGUSScreenHandler::Ready() {
89
+  dgus_display.PlaySound(1);
90
+}
91
+
92
+void DGUSScreenHandler::Loop() {
93
+  if (!settings_ready || current_screen == DGUS_Screen::KILL) {
94
+    return;
95
+  }
96
+
97
+  const millis_t ms = ExtUI::safe_millis();
98
+  static millis_t next_event_ms = 0;
99
+
100
+  if (new_screen != DGUS_Screen::BOOT) {
101
+    const DGUS_Screen screen = new_screen;
102
+    new_screen = DGUS_Screen::BOOT;
103
+
104
+    if (current_screen == screen) {
105
+      TriggerFullUpdate();
106
+    }
107
+    else {
108
+      MoveToScreen(screen);
109
+    }
110
+    return;
111
+  }
112
+
113
+  if (!booted && ELAPSED(ms, 3000)) {
114
+    booted = true;
115
+
116
+    if (current_screen == DGUS_Screen::BOOT) {
117
+      MoveToScreen(DGUS_Screen::HOME);
118
+    }
119
+    return;
120
+  }
121
+
122
+  if (ELAPSED(ms, next_event_ms) || full_update) {
123
+    next_event_ms = ms + DGUS_UPDATE_INTERVAL_MS;
124
+
125
+    if (!SendScreenVPData(current_screen, full_update)) {
126
+      DEBUG_ECHOLNPGM("SendScreenVPData failed");
127
+    }
128
+    return;
129
+  }
130
+
131
+  if (current_screen == DGUS_Screen::WAIT
132
+      && ((wait_continue && !wait_for_user)
133
+          || (!wait_continue && IsPrinterIdle()))) {
134
+    MoveToScreen(wait_return_screen, true);
135
+    return;
136
+  }
137
+
138
+  if (current_screen == DGUS_Screen::LEVELING_PROBING
139
+      && IsPrinterIdle()) {
140
+    dgus_display.PlaySound(3);
141
+
142
+    SetStatusMessagePGM(ExtUI::getMeshValid() ?
143
+                          PSTR("Probing successful")
144
+                        : PSTR("Probing failed"));
145
+
146
+    MoveToScreen(DGUS_Screen::LEVELING_AUTOMATIC);
147
+    return;
148
+  }
149
+
150
+  if (status_expire > 0 && ELAPSED(ms, status_expire)) {
151
+    SetStatusMessagePGM(NUL_STR, 0);
152
+    return;
153
+  }
154
+
155
+  if (eeprom_save > 0 && ELAPSED(ms, eeprom_save) && IsPrinterIdle()) {
156
+    eeprom_save = 0;
157
+
158
+    queue.enqueue_now_P(DGUS_CMD_EEPROM_SAVE);
159
+    return;
160
+  }
161
+
162
+  dgus_display.Loop();
163
+}
164
+
165
+void DGUSScreenHandler::PrinterKilled(PGM_P error, PGM_P component) {
166
+  SetMessageLinePGM(error, 1);
167
+  SetMessageLinePGM(component, 2);
168
+  SetMessageLinePGM(NUL_STR, 3);
169
+  SetMessageLinePGM(GET_TEXT(MSG_PLEASE_RESET), 4);
170
+
171
+  dgus_display.PlaySound(3, 1, 200);
172
+
173
+  MoveToScreen(DGUS_Screen::KILL, true);
174
+}
175
+
176
+void DGUSScreenHandler::UserConfirmRequired(const char * const msg) {
177
+  dgus_screen_handler.SetMessageLinePGM(NUL_STR, 1);
178
+  dgus_screen_handler.SetMessageLine(msg, 2);
179
+  dgus_screen_handler.SetMessageLinePGM(NUL_STR, 3);
180
+  dgus_screen_handler.SetMessageLinePGM(NUL_STR, 4);
181
+
182
+  dgus_display.PlaySound(3);
183
+
184
+  dgus_screen_handler.ShowWaitScreen(current_screen, true);
185
+}
186
+
187
+void DGUSScreenHandler::SettingsReset() {
188
+  dgus_display.SetVolume(DGUS_DEFAULT_VOLUME);
189
+  dgus_display.SetBrightness(DGUS_DEFAULT_BRIGHTNESS);
190
+
191
+  if (!settings_ready) {
192
+    settings_ready = true;
193
+
194
+    Ready();
195
+  }
196
+
197
+  SetStatusMessagePGM(PSTR("EEPROM reset"));
198
+}
199
+
200
+void DGUSScreenHandler::StoreSettings(char *buff) {
201
+  eeprom_data_t data;
202
+
203
+  static_assert(sizeof(data) <= ExtUI::eeprom_data_size, "sizeof(eeprom_data_t) > eeprom_data_size.");
204
+
205
+  data.initialized = true;
206
+  data.volume = dgus_display.GetVolume();
207
+  data.brightness = dgus_display.GetBrightness();
208
+  data.abl = (ExtUI::getLevelingActive() && ExtUI::getMeshValid());
209
+
210
+  memcpy(buff, &data, sizeof(data));
211
+}
212
+
213
+void DGUSScreenHandler::LoadSettings(const char *buff) {
214
+  eeprom_data_t data;
215
+
216
+  static_assert(sizeof(data) <= ExtUI::eeprom_data_size, "sizeof(eeprom_data_t) > eeprom_data_size.");
217
+
218
+  memcpy(&data, buff, sizeof(data));
219
+
220
+  dgus_display.SetVolume(data.initialized ? data.volume : DGUS_DEFAULT_VOLUME);
221
+  dgus_display.SetBrightness(data.initialized ? data.brightness : DGUS_DEFAULT_BRIGHTNESS);
222
+
223
+  if (data.initialized) {
224
+    leveling_active = (data.abl && ExtUI::getMeshValid());
225
+
226
+    ExtUI::setLevelingActive(leveling_active);
227
+  }
228
+}
229
+
230
+void DGUSScreenHandler::ConfigurationStoreWritten(bool success) {
231
+  if (!success) {
232
+    SetStatusMessagePGM(PSTR("EEPROM write failed"));
233
+  }
234
+}
235
+
236
+void DGUSScreenHandler::ConfigurationStoreRead(bool success) {
237
+  if (!success) {
238
+    SetStatusMessagePGM(PSTR("EEPROM read failed"));
239
+  }
240
+  else if (!settings_ready) {
241
+    settings_ready = true;
242
+
243
+    Ready();
244
+  }
245
+}
246
+
247
+void DGUSScreenHandler::PlayTone(const uint16_t frequency, const uint16_t duration) {
248
+  UNUSED(duration);
249
+
250
+  if (frequency >= 1 && frequency <= 255) {
251
+    if (duration >= 1 && duration <= 255) {
252
+      dgus_display.PlaySound((uint8_t)frequency, (uint8_t)duration);
253
+    }
254
+    else {
255
+      dgus_display.PlaySound((uint8_t)frequency);
256
+    }
257
+  }
258
+}
259
+
260
+void DGUSScreenHandler::MeshUpdate(const int8_t xpos, const int8_t ypos) {
261
+  if (current_screen != DGUS_Screen::LEVELING_PROBING) {
262
+    if (current_screen == DGUS_Screen::LEVELING_AUTOMATIC) {
263
+      TriggerFullUpdate();
264
+    }
265
+
266
+    return;
267
+  }
268
+
269
+  uint8_t point = ypos * GRID_MAX_POINTS_X + xpos;
270
+  probing_icons[point < 16 ? 0 : 1] |= (1U << (point % 16));
271
+
272
+  if (xpos >= GRID_MAX_POINTS_X - 1
273
+      && ypos >= GRID_MAX_POINTS_Y - 1
274
+      && !ExtUI::getMeshValid()) {
275
+    probing_icons[0] = 0;
276
+    probing_icons[1] = 0;
277
+  }
278
+
279
+  TriggerFullUpdate();
280
+}
281
+
282
+void DGUSScreenHandler::PrintTimerStarted() {
283
+  TriggerScreenChange(DGUS_Screen::PRINT_STATUS);
284
+}
285
+
286
+void DGUSScreenHandler::PrintTimerPaused() {
287
+  dgus_display.PlaySound(3);
288
+
289
+  TriggerFullUpdate();
290
+}
291
+
292
+void DGUSScreenHandler::PrintTimerStopped() {
293
+  if (current_screen != DGUS_Screen::PRINT_STATUS
294
+      && current_screen != DGUS_Screen::PRINT_ADJUST) {
295
+    return;
296
+  }
297
+
298
+  dgus_display.PlaySound(3);
299
+
300
+  TriggerScreenChange(DGUS_Screen::PRINT_FINISHED);
301
+}
302
+
303
+void DGUSScreenHandler::FilamentRunout(const ExtUI::extruder_t extruder) {
304
+  char buffer[21];
305
+  snprintf_P(buffer, sizeof(buffer), PSTR("Filament runout E%d"), extruder);
306
+
307
+  SetStatusMessage(buffer);
308
+
309
+  dgus_display.PlaySound(3);
310
+}
311
+
312
+#if ENABLED(SDSUPPORT)
313
+
314
+  void DGUSScreenHandler::SDCardInserted() {
315
+    if (current_screen == DGUS_Screen::HOME) {
316
+      TriggerScreenChange(DGUS_Screen::PRINT);
317
+    }
318
+  }
319
+
320
+  void DGUSScreenHandler::SDCardRemoved() {
321
+    if (current_screen == DGUS_Screen::PRINT) {
322
+      TriggerScreenChange(DGUS_Screen::HOME);
323
+    }
324
+  }
325
+
326
+  void DGUSScreenHandler::SDCardError() {
327
+    SetStatusMessagePGM(GET_TEXT(MSG_MEDIA_READ_ERROR));
328
+
329
+    if (current_screen == DGUS_Screen::PRINT) {
330
+      TriggerScreenChange(DGUS_Screen::HOME);
331
+    }
332
+  }
333
+
334
+#endif // SDSUPPORT
335
+
336
+#if ENABLED(POWER_LOSS_RECOVERY)
337
+
338
+  void DGUSScreenHandler::PowerLossResume() {
339
+    MoveToScreen(DGUS_Screen::POWERLOSS, true);
340
+  }
341
+
342
+#endif // POWER_LOSS_RECOVERY
343
+
344
+#if HAS_PID_HEATING
345
+
346
+  void DGUSScreenHandler::PidTuning(const ExtUI::result_t rst) {
347
+    switch (rst) {
348
+      case ExtUI::PID_STARTED:
349
+        SetStatusMessagePGM(GET_TEXT(MSG_PID_AUTOTUNE));
350
+        break;
351
+      case ExtUI::PID_BAD_EXTRUDER_NUM:
352
+        SetStatusMessagePGM(GET_TEXT(MSG_PID_BAD_EXTRUDER_NUM));
353
+        break;
354
+      case ExtUI::PID_TEMP_TOO_HIGH:
355
+        SetStatusMessagePGM(GET_TEXT(MSG_PID_TEMP_TOO_HIGH));
356
+        break;
357
+      case ExtUI::PID_TUNING_TIMEOUT:
358
+        SetStatusMessagePGM(GET_TEXT(MSG_PID_TIMEOUT));
359
+        break;
360
+      case ExtUI::PID_DONE:
361
+        SetStatusMessagePGM(GET_TEXT(MSG_PID_AUTOTUNE_DONE));
362
+        break;
363
+      default:
364
+        return;
365
+    }
366
+
367
+    dgus_display.PlaySound(3);
368
+  }
369
+
370
+#endif // HAS_PID_HEATING
371
+
372
+void DGUSScreenHandler::SetMessageLine(const char* msg, uint8_t line) {
373
+  switch (line) {
374
+    default: return;
375
+    case 1:
376
+      dgus_display.WriteString((uint16_t)DGUS_Addr::MESSAGE_Line1, msg, DGUS_LINE_LEN, true, true);
377
+      break;
378
+    case 2:
379
+      dgus_display.WriteString((uint16_t)DGUS_Addr::MESSAGE_Line2, msg, DGUS_LINE_LEN, true, true);
380
+      break;
381
+    case 3:
382
+      dgus_display.WriteString((uint16_t)DGUS_Addr::MESSAGE_Line3, msg, DGUS_LINE_LEN, true, true);
383
+      break;
384
+    case 4:
385
+      dgus_display.WriteString((uint16_t)DGUS_Addr::MESSAGE_Line4, msg, DGUS_LINE_LEN, true, true);
386
+      break;
387
+  }
388
+}
389
+
390
+void DGUSScreenHandler::SetMessageLinePGM(PGM_P msg, uint8_t line) {
391
+  switch (line) {
392
+    default: return;
393
+    case 1:
394
+      dgus_display.WriteStringPGM((uint16_t)DGUS_Addr::MESSAGE_Line1, msg, DGUS_LINE_LEN, true, true);
395
+      break;
396
+    case 2:
397
+      dgus_display.WriteStringPGM((uint16_t)DGUS_Addr::MESSAGE_Line2, msg, DGUS_LINE_LEN, true, true);
398
+      break;
399
+    case 3:
400
+      dgus_display.WriteStringPGM((uint16_t)DGUS_Addr::MESSAGE_Line3, msg, DGUS_LINE_LEN, true, true);
401
+      break;
402
+    case 4:
403
+      dgus_display.WriteStringPGM((uint16_t)DGUS_Addr::MESSAGE_Line4, msg, DGUS_LINE_LEN, true, true);
404
+      break;
405
+  }
406
+}
407
+
408
+void DGUSScreenHandler::SetStatusMessage(const char* msg, const millis_t duration) {
409
+  dgus_display.WriteString((uint16_t)DGUS_Addr::MESSAGE_Status, msg, DGUS_STATUS_LEN, false, true);
410
+
411
+  status_expire = (duration > 0 ? ExtUI::safe_millis() + duration : 0);
412
+}
413
+
414
+void DGUSScreenHandler::SetStatusMessagePGM(PGM_P msg, const millis_t duration) {
415
+  dgus_display.WriteStringPGM((uint16_t)DGUS_Addr::MESSAGE_Status, msg, DGUS_STATUS_LEN, false, true);
416
+
417
+  status_expire = (duration > 0 ? ExtUI::safe_millis() + duration : 0);
418
+}
419
+
420
+void DGUSScreenHandler::ShowWaitScreen(DGUS_Screen return_screen, bool has_continue) {
421
+  if (return_screen != DGUS_Screen::WAIT) {
422
+    wait_return_screen = return_screen;
423
+  }
424
+  wait_continue = has_continue;
425
+
426
+  TriggerScreenChange(DGUS_Screen::WAIT);
427
+}
428
+
429
+DGUS_Screen DGUSScreenHandler::GetCurrentScreen() {
430
+  return current_screen;
431
+}
432
+
433
+void DGUSScreenHandler::TriggerScreenChange(DGUS_Screen screen) {
434
+  new_screen = screen;
435
+}
436
+
437
+void DGUSScreenHandler::TriggerFullUpdate() {
438
+  full_update = true;
439
+}
440
+
441
+void DGUSScreenHandler::TriggerEEPROMSave() {
442
+  eeprom_save = ExtUI::safe_millis() + 500;
443
+}
444
+
445
+bool DGUSScreenHandler::IsPrinterIdle() {
446
+  return (!ExtUI::commandsInQueue()
447
+          && !ExtUI::isMoving());
448
+}
449
+
450
+const DGUS_Addr* DGUSScreenHandler::FindScreenAddrList(DGUS_Screen screen) {
451
+  DGUS_ScreenAddrList list;
452
+  const DGUS_ScreenAddrList *map = screen_addr_list_map;
453
+
454
+  do {
455
+    memcpy_P(&list, map, sizeof(*map));
456
+    if (!list.addr_list) break;
457
+    if (list.screen == screen) {
458
+      return list.addr_list;
459
+    }
460
+  } while (++map);
461
+
462
+  return nullptr;
463
+}
464
+
465
+bool DGUSScreenHandler::CallScreenSetup(DGUS_Screen screen) {
466
+  DGUS_ScreenSetup setup;
467
+  const DGUS_ScreenSetup *list = screen_setup_list;
468
+
469
+  do {
470
+    memcpy_P(&setup, list, sizeof(*list));
471
+    if (!setup.setup_fn) break;
472
+    if (setup.screen == screen) {
473
+      return setup.setup_fn();
474
+    }
475
+  } while (++list);
476
+
477
+  return true;
478
+}
479
+
480
+void DGUSScreenHandler::MoveToScreen(DGUS_Screen screen, bool abort_wait) {
481
+  if (current_screen == DGUS_Screen::KILL) {
482
+    return;
483
+  }
484
+
485
+  if (current_screen == DGUS_Screen::WAIT) {
486
+    if (screen != DGUS_Screen::WAIT) {
487
+      wait_return_screen = screen;
488
+    }
489
+
490
+    if (!abort_wait) return;
491
+
492
+    if (wait_continue && wait_for_user) {
493
+      ExtUI::setUserConfirmed();
494
+    }
495
+  }
496
+
497
+  if (!CallScreenSetup(screen)) return;
498
+
499
+  if (!SendScreenVPData(screen, true)) {
500
+    DEBUG_ECHOLNPGM("SendScreenVPData failed");
501
+    return;
502
+  }
503
+
504
+  current_screen = screen;
505
+  dgus_display.SwitchScreen(current_screen);
506
+}
507
+
508
+bool DGUSScreenHandler::SendScreenVPData(DGUS_Screen screen, bool complete_update) {
509
+  if (complete_update) {
510
+    full_update = false;
511
+  }
512
+
513
+  const DGUS_Addr *list = FindScreenAddrList(screen);
514
+
515
+  while (true) {
516
+    if (!list) return true; // Nothing left to send
517
+
518
+    const uint16_t addr = pgm_read_word(list++);
519
+    if (!addr) return true; // Nothing left to send
520
+
521
+    DGUS_VP vp;
522
+    if (!DGUS_PopulateVP((DGUS_Addr)addr, &vp)) continue; // Invalid VP
523
+    if (!vp.tx_handler) continue; // Nothing to send
524
+    if (!complete_update && !(vp.flags & VPFLAG_AUTOUPLOAD)) continue; // Unnecessary VP
525
+
526
+    uint8_t expected_tx = 6 + vp.size; // 6 bytes header + payload.
527
+    const millis_t try_until = ExtUI::safe_millis() + 1000;
528
+
529
+    while (expected_tx > dgus_display.GetFreeTxBuffer()) {
530
+      if (ELAPSED(ExtUI::safe_millis(), try_until)) return false; // Stop trying after 1 second
531
+
532
+      dgus_display.FlushTx(); // Flush the TX buffer
533
+      delay(50);
534
+    }
535
+
536
+    vp.tx_handler(vp);
537
+  }
538
+}
539
+
540
+#endif // DGUS_LCD_UI_RELOADED

+ 152
- 0
Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h View File

@@ -0,0 +1,152 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#pragma once
24
+
25
+#include "config/DGUS_Addr.h"
26
+#include "config/DGUS_Data.h"
27
+#include "config/DGUS_Screen.h"
28
+#include "config/DGUS_Constants.h"
29
+
30
+#include "../ui_api.h"
31
+#include "../../../inc/MarlinConfigPre.h"
32
+
33
+class DGUSScreenHandler {
34
+public:
35
+  DGUSScreenHandler() = default;
36
+
37
+  static void Init();
38
+  static void Ready();
39
+  static void Loop();
40
+
41
+  static void PrinterKilled(PGM_P error, PGM_P component);
42
+  static void UserConfirmRequired(const char * const msg);
43
+  static void SettingsReset();
44
+  static void StoreSettings(char *buff);
45
+  static void LoadSettings(const char *buff);
46
+  static void ConfigurationStoreWritten(bool success);
47
+  static void ConfigurationStoreRead(bool success);
48
+
49
+  static void PlayTone(const uint16_t frequency, const uint16_t duration);
50
+  static void MeshUpdate(const int8_t xpos, const int8_t ypos);
51
+  static void PrintTimerStarted();
52
+  static void PrintTimerPaused();
53
+  static void PrintTimerStopped();
54
+  static void FilamentRunout(const ExtUI::extruder_t extruder);
55
+
56
+  #if ENABLED(SDSUPPORT)
57
+    /// Marlin informed us that a new SD has been inserted.
58
+    static void SDCardInserted();
59
+    /// Marlin informed us that the SD Card has been removed().
60
+    static void SDCardRemoved();
61
+    /// Marlin informed us about a bad SD Card.
62
+    static void SDCardError();
63
+  #endif
64
+
65
+  #if ENABLED(POWER_LOSS_RECOVERY)
66
+    static void PowerLossResume();
67
+  #endif
68
+
69
+  #if HAS_PID_HEATING
70
+    static void PidTuning(const ExtUI::result_t rst);
71
+  #endif
72
+
73
+  static void SetMessageLine(const char* msg, uint8_t line);
74
+  static void SetMessageLinePGM(PGM_P msg, uint8_t line);
75
+
76
+  static void SetStatusMessage(const char* msg, const millis_t duration = DGUS_STATUS_EXPIRATION_MS);
77
+  static void SetStatusMessagePGM(PGM_P msg, const millis_t duration = DGUS_STATUS_EXPIRATION_MS);
78
+
79
+  static void ShowWaitScreen(DGUS_Screen return_screen, bool has_continue = false);
80
+
81
+  static DGUS_Screen GetCurrentScreen();
82
+  static void TriggerScreenChange(DGUS_Screen screen);
83
+  static void TriggerFullUpdate();
84
+
85
+  static void TriggerEEPROMSave();
86
+
87
+  static bool IsPrinterIdle();
88
+
89
+  static uint8_t debug_count;
90
+
91
+  #if ENABLED(SDSUPPORT)
92
+    static ExtUI::FileList filelist;
93
+    static uint16_t filelist_offset;
94
+    static int16_t filelist_selected;
95
+  #endif
96
+
97
+  static DGUS_Data::StepSize offset_steps;
98
+  static DGUS_Data::StepSize move_steps;
99
+
100
+  static uint16_t probing_icons[2];
101
+
102
+  static DGUS_Data::Extruder filament_extruder;
103
+  static uint16_t filament_length;
104
+
105
+  static char gcode[DGUS_GCODE_LEN + 1];
106
+
107
+  static DGUS_Data::Heater pid_heater;
108
+  static uint16_t pid_temp;
109
+  static uint8_t pid_cycles;
110
+
111
+  static bool wait_continue;
112
+
113
+  static bool leveling_active;
114
+
115
+private:
116
+  static const DGUS_Addr* FindScreenAddrList(DGUS_Screen screen);
117
+  static bool CallScreenSetup(DGUS_Screen screen);
118
+
119
+  static void MoveToScreen(DGUS_Screen screen, bool abort_wait = false);
120
+  static bool SendScreenVPData(DGUS_Screen screen, bool complete_update);
121
+
122
+  static bool settings_ready;
123
+  static bool booted;
124
+
125
+  static DGUS_Screen current_screen;
126
+  static DGUS_Screen new_screen;
127
+  static bool full_update;
128
+
129
+  static DGUS_Screen wait_return_screen;
130
+
131
+  static millis_t status_expire;
132
+  static millis_t eeprom_save;
133
+
134
+  typedef struct {
135
+    bool initialized;
136
+    uint8_t volume;
137
+    uint8_t brightness;
138
+    bool abl;
139
+  } eeprom_data_t;
140
+};
141
+
142
+extern DGUSScreenHandler dgus_screen_handler;
143
+
144
+extern const char DGUS_MSG_HOMING_REQUIRED[],
145
+                  DGUS_MSG_BUSY[],
146
+                  DGUS_MSG_UNDEF[],
147
+                  DGUS_MSG_HOMING[],
148
+                  DGUS_MSG_FW_OUTDATED[],
149
+                  DGUS_MSG_ABL_REQUIRED[];
150
+
151
+extern const char DGUS_CMD_HOME[],
152
+                  DGUS_CMD_EEPROM_SAVE[];

+ 209
- 0
Marlin/src/lcd/extui/dgus_reloaded/DGUSSetupHandler.cpp View File

@@ -0,0 +1,209 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "../../../inc/MarlinConfigPre.h"
24
+
25
+#if ENABLED(DGUS_LCD_UI_RELOADED)
26
+
27
+#include "DGUSSetupHandler.h"
28
+
29
+#include "DGUSDisplay.h"
30
+#include "DGUSScreenHandler.h"
31
+
32
+#include "../../../gcode/queue.h"
33
+
34
+#if ENABLED(SDSUPPORT)
35
+  bool DGUSSetupHandler::Print() {
36
+    dgus_screen_handler.filelist.refresh();
37
+
38
+    while (!dgus_screen_handler.filelist.isAtRootDir()) {
39
+      dgus_screen_handler.filelist.upDir();
40
+    }
41
+
42
+    dgus_screen_handler.filelist_offset = 0;
43
+    dgus_screen_handler.filelist_selected = -1;
44
+
45
+    return true;
46
+  }
47
+#endif
48
+
49
+bool DGUSSetupHandler::PrintStatus() {
50
+  if (printingIsActive() || printingIsPaused()) {
51
+    return true;
52
+  }
53
+
54
+  dgus_screen_handler.TriggerScreenChange(DGUS_Screen::PRINT_FINISHED);
55
+  return false;
56
+}
57
+
58
+bool DGUSSetupHandler::PrintAdjust() {
59
+  if (printingIsActive() || printingIsPaused()) {
60
+    return true;
61
+  }
62
+
63
+  dgus_screen_handler.TriggerScreenChange(DGUS_Screen::PRINT_FINISHED);
64
+  return false;
65
+}
66
+
67
+bool DGUSSetupHandler::LevelingMenu() {
68
+  ExtUI::setLevelingActive(dgus_screen_handler.leveling_active);
69
+
70
+  if (!dgus_screen_handler.IsPrinterIdle()) {
71
+    dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY);
72
+    return false;
73
+  }
74
+
75
+  if (ExtUI::isPositionKnown()) {
76
+    if (ExtUI::getAxisPosition_mm(ExtUI::Z) < 10.0f) {
77
+      queue.enqueue_now_P(PSTR("G0Z10"));
78
+    }
79
+
80
+    return true;
81
+  }
82
+
83
+  dgus_screen_handler.SetMessageLinePGM(NUL_STR, 1);
84
+  dgus_screen_handler.SetMessageLinePGM(DGUS_MSG_HOMING, 2);
85
+  dgus_screen_handler.SetMessageLinePGM(NUL_STR, 3);
86
+  dgus_screen_handler.SetMessageLinePGM(NUL_STR, 4);
87
+  dgus_screen_handler.ShowWaitScreen(DGUS_Screen::LEVELING_MENU);
88
+
89
+  queue.enqueue_now_P(DGUS_CMD_HOME);
90
+
91
+  return false;
92
+}
93
+
94
+bool DGUSSetupHandler::LevelingManual() {
95
+  ExtUI::setLevelingActive(false);
96
+
97
+  if (ExtUI::isPositionKnown()) {
98
+    return true;
99
+  }
100
+
101
+  if (!dgus_screen_handler.IsPrinterIdle()) {
102
+    dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY);
103
+    return false;
104
+  }
105
+
106
+  dgus_screen_handler.SetMessageLinePGM(NUL_STR, 1);
107
+  dgus_screen_handler.SetMessageLinePGM(DGUS_MSG_HOMING, 2);
108
+  dgus_screen_handler.SetMessageLinePGM(NUL_STR, 3);
109
+  dgus_screen_handler.SetMessageLinePGM(NUL_STR, 4);
110
+  dgus_screen_handler.ShowWaitScreen(DGUS_Screen::LEVELING_MANUAL);
111
+
112
+  queue.enqueue_now_P(DGUS_CMD_HOME);
113
+
114
+  return false;
115
+}
116
+
117
+bool DGUSSetupHandler::LevelingOffset() {
118
+  dgus_screen_handler.offset_steps = DGUS_Data::StepSize::MMP1;
119
+
120
+  if (!dgus_screen_handler.IsPrinterIdle()) {
121
+    dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY);
122
+    return false;
123
+  }
124
+
125
+  if (ExtUI::isPositionKnown()) {
126
+    if (ExtUI::getAxisPosition_mm(ExtUI::Z) < 4.0f) {
127
+      queue.enqueue_now_P(PSTR("G0Z4"));
128
+    }
129
+
130
+    char buffer[20];
131
+    snprintf_P(buffer, sizeof(buffer), PSTR("G0X%dY%d"), DGUS_LEVEL_CENTER_X, DGUS_LEVEL_CENTER_Y);
132
+
133
+    queue.enqueue_one_now(buffer);
134
+    queue.enqueue_now_P(PSTR("G0Z0"));
135
+
136
+    return true;
137
+  }
138
+
139
+  dgus_screen_handler.SetMessageLinePGM(NUL_STR, 1);
140
+  dgus_screen_handler.SetMessageLinePGM(DGUS_MSG_HOMING, 2);
141
+  dgus_screen_handler.SetMessageLinePGM(NUL_STR, 3);
142
+  dgus_screen_handler.SetMessageLinePGM(NUL_STR, 4);
143
+  dgus_screen_handler.ShowWaitScreen(DGUS_Screen::LEVELING_OFFSET);
144
+
145
+  queue.enqueue_now_P(DGUS_CMD_HOME);
146
+
147
+  return false;
148
+}
149
+
150
+bool DGUSSetupHandler::LevelingAutomatic() {
151
+  if (ExtUI::getMeshValid()) {
152
+    dgus_screen_handler.leveling_active = true;
153
+
154
+    ExtUI::setLevelingActive(true);
155
+  }
156
+
157
+  return true;
158
+}
159
+
160
+bool DGUSSetupHandler::LevelingProbing() {
161
+  dgus_screen_handler.probing_icons[0] = 0;
162
+  dgus_screen_handler.probing_icons[1] = 0;
163
+
164
+  return true;
165
+}
166
+
167
+bool DGUSSetupHandler::Filament() {
168
+  dgus_screen_handler.filament_extruder = DGUS_Data::Extruder::CURRENT;
169
+  dgus_screen_handler.filament_length = DGUS_DEFAULT_FILAMENT_LEN;
170
+
171
+  return true;
172
+}
173
+
174
+bool DGUSSetupHandler::Move() {
175
+  dgus_screen_handler.move_steps = DGUS_Data::StepSize::MM10;
176
+
177
+  if (!dgus_screen_handler.IsPrinterIdle()) {
178
+    dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY);
179
+    return false;
180
+  }
181
+
182
+  return true;
183
+}
184
+
185
+bool DGUSSetupHandler::Gcode() {
186
+  ZERO(dgus_screen_handler.gcode);
187
+
188
+  if (dgus_display.gui_version < 0x30 || dgus_display.os_version < 0x21) {
189
+    dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_FW_OUTDATED);
190
+    return false;
191
+  }
192
+
193
+  return true;
194
+}
195
+
196
+bool DGUSSetupHandler::PID() {
197
+  dgus_screen_handler.pid_heater = DGUS_Data::Heater::H0;
198
+  dgus_screen_handler.pid_temp = DGUS_PLA_TEMP_HOTEND;
199
+
200
+  return true;
201
+}
202
+
203
+bool DGUSSetupHandler::Infos() {
204
+  dgus_screen_handler.debug_count = 0;
205
+
206
+  return true;
207
+}
208
+
209
+#endif // DGUS_LCD_UI_RELOADED

+ 43
- 0
Marlin/src/lcd/extui/dgus_reloaded/DGUSSetupHandler.h View File

@@ -0,0 +1,43 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#pragma once
24
+
25
+namespace DGUSSetupHandler {
26
+
27
+  #if ENABLED(SDSUPPORT)
28
+    bool Print();
29
+  #endif
30
+  bool PrintStatus();
31
+  bool PrintAdjust();
32
+  bool LevelingMenu();
33
+  bool LevelingOffset();
34
+  bool LevelingManual();
35
+  bool LevelingAutomatic();
36
+  bool LevelingProbing();
37
+  bool Filament();
38
+  bool Move();
39
+  bool Gcode();
40
+  bool PID();
41
+  bool Infos();
42
+
43
+}

+ 632
- 0
Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp View File

@@ -0,0 +1,632 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "../../../inc/MarlinConfigPre.h"
24
+
25
+#if ENABLED(DGUS_LCD_UI_RELOADED)
26
+
27
+#include "DGUSTxHandler.h"
28
+
29
+#include "DGUSScreenHandler.h"
30
+#include "config/DGUS_Data.h"
31
+
32
+#include "../ui_api.h"
33
+#include "../../../module/stepper.h"
34
+#include "../../../module/printcounter.h"
35
+#if ENABLED(ADVANCED_PAUSE_FEATURE)
36
+  #include "../../../feature/pause.h"
37
+#endif
38
+
39
+#if ENABLED(SDSUPPORT)
40
+  void DGUSTxHandler::SetFileControlState(int file, bool state) {
41
+    DGUS_Control control;
42
+
43
+    switch (file) {
44
+      default: return;
45
+      case 0:
46
+        control = DGUS_Control::FILE0;
47
+        break;
48
+      case 1:
49
+        control = DGUS_Control::FILE1;
50
+        break;
51
+      case 2:
52
+        control = DGUS_Control::FILE2;
53
+        break;
54
+      case 3:
55
+        control = DGUS_Control::FILE3;
56
+        break;
57
+      case 4:
58
+        control = DGUS_Control::FILE4;
59
+        break;
60
+    }
61
+
62
+    if (state) {
63
+      dgus_display.EnableControl(DGUS_Screen::PRINT,
64
+                                 DGUSDisplay::RETURN_KEY_CODE,
65
+                                 control);
66
+    }
67
+    else {
68
+      dgus_display.DisableControl(DGUS_Screen::PRINT,
69
+                                  DGUSDisplay::RETURN_KEY_CODE,
70
+                                  control);
71
+    }
72
+  }
73
+
74
+  void DGUSTxHandler::FileType(DGUS_VP &vp) {
75
+    // Batch send
76
+    uint16_t data[DGUS_FILE_COUNT];
77
+
78
+    for (int i = 0; i < DGUS_FILE_COUNT; i++) {
79
+      if (!dgus_screen_handler.filelist.seek(dgus_screen_handler.filelist_offset + i)) {
80
+        data[i] = Swap16((uint16_t)DGUS_Data::SDType::NONE);
81
+
82
+        SetFileControlState(i, false);
83
+        continue;
84
+      }
85
+
86
+      data[i] = dgus_screen_handler.filelist.isDir() ?
87
+                  Swap16((uint16_t)DGUS_Data::SDType::DIRECTORY)
88
+                : Swap16((uint16_t)DGUS_Data::SDType::FILE);
89
+
90
+      SetFileControlState(i, true);
91
+    }
92
+
93
+    dgus_display.Write((uint16_t)vp.addr, data, sizeof(*data) * DGUS_FILE_COUNT);
94
+  }
95
+
96
+  void DGUSTxHandler::FileName(DGUS_VP &vp) {
97
+    uint8_t offset;
98
+
99
+    switch (vp.addr) {
100
+      default: return;
101
+      case DGUS_Addr::SD_FileName0:
102
+        offset = 0;
103
+        break;
104
+      case DGUS_Addr::SD_FileName1:
105
+        offset = 1;
106
+        break;
107
+      case DGUS_Addr::SD_FileName2:
108
+        offset = 2;
109
+        break;
110
+      case DGUS_Addr::SD_FileName3:
111
+        offset = 3;
112
+        break;
113
+      case DGUS_Addr::SD_FileName4:
114
+        offset = 4;
115
+        break;
116
+    }
117
+
118
+    if (dgus_screen_handler.filelist.seek(dgus_screen_handler.filelist_offset + offset)) {
119
+      dgus_display.WriteString((uint16_t)vp.addr, dgus_screen_handler.filelist.filename(), vp.size);
120
+    }
121
+    else {
122
+      dgus_display.WriteStringPGM((uint16_t)vp.addr, NUL_STR, vp.size);
123
+    }
124
+  }
125
+
126
+  void DGUSTxHandler::ScrollIcons(DGUS_VP &vp) {
127
+    uint16_t icons = 0;
128
+
129
+    if (!dgus_screen_handler.filelist.isAtRootDir()) {
130
+      icons |= (uint16_t)DGUS_Data::ScrollIcon::GO_BACK;
131
+
132
+      dgus_display.EnableControl(DGUS_Screen::PRINT,
133
+                                 DGUSDisplay::RETURN_KEY_CODE,
134
+                                 DGUS_Control::GO_BACK);
135
+    }
136
+    else {
137
+      dgus_display.DisableControl(DGUS_Screen::PRINT,
138
+                                  DGUSDisplay::RETURN_KEY_CODE,
139
+                                  DGUS_Control::GO_BACK);
140
+    }
141
+
142
+    if (dgus_screen_handler.filelist_offset > 0) {
143
+      icons |= (uint16_t)DGUS_Data::ScrollIcon::UP;
144
+
145
+      dgus_display.EnableControl(DGUS_Screen::PRINT,
146
+                                 DGUSDisplay::RETURN_KEY_CODE,
147
+                                 DGUS_Control::SCROLL_UP);
148
+    }
149
+    else {
150
+      dgus_display.DisableControl(DGUS_Screen::PRINT,
151
+                                  DGUSDisplay::RETURN_KEY_CODE,
152
+                                  DGUS_Control::SCROLL_UP);
153
+    }
154
+
155
+    if (dgus_screen_handler.filelist_offset + DGUS_FILE_COUNT < dgus_screen_handler.filelist.count()) {
156
+      icons |= (uint16_t)DGUS_Data::ScrollIcon::DOWN;
157
+
158
+      dgus_display.EnableControl(DGUS_Screen::PRINT,
159
+                                 DGUSDisplay::RETURN_KEY_CODE,
160
+                                 DGUS_Control::SCROLL_DOWN);
161
+    }
162
+    else {
163
+      dgus_display.DisableControl(DGUS_Screen::PRINT,
164
+                                  DGUSDisplay::RETURN_KEY_CODE,
165
+                                  DGUS_Control::SCROLL_DOWN);
166
+    }
167
+
168
+    dgus_display.Write((uint16_t)vp.addr, Swap16(icons));
169
+  }
170
+
171
+  void DGUSTxHandler::SelectedFileName(DGUS_VP &vp) {
172
+    if (dgus_screen_handler.filelist_selected < 0
173
+        || !dgus_screen_handler.filelist.seek(dgus_screen_handler.filelist_selected)) {
174
+      dgus_display.WriteStringPGM((uint16_t)vp.addr, NUL_STR, vp.size);
175
+      return;
176
+    }
177
+
178
+    dgus_display.WriteString((uint16_t)vp.addr, dgus_screen_handler.filelist.filename(), vp.size);
179
+  }
180
+#endif // SDSUPPORT
181
+
182
+void DGUSTxHandler::PositionZ(DGUS_VP &vp) {
183
+  float position = ExtUI::isAxisPositionKnown(ExtUI::Z) ?
184
+                     planner.get_axis_position_mm(Z_AXIS)
185
+                   : 0;
186
+
187
+  const int16_t data = dgus_display.ToFixedPoint<float, int16_t, 1>(position);
188
+  dgus_display.Write((uint16_t)vp.addr, Swap16(data));
189
+}
190
+
191
+void DGUSTxHandler::Ellapsed(DGUS_VP &vp) {
192
+  char buffer[21];
193
+  duration_t(print_job_timer.duration()).toString(buffer);
194
+
195
+  dgus_display.WriteString((uint16_t)vp.addr, buffer, vp.size);
196
+}
197
+
198
+void DGUSTxHandler::Percent(DGUS_VP &vp) {
199
+  uint16_t progress;
200
+
201
+  switch (vp.addr) {
202
+    default: return;
203
+    case DGUS_Addr::STATUS_Percent:
204
+      progress = constrain(ExtUI::getProgress_percent(), 0, 100);
205
+      break;
206
+    case DGUS_Addr::STATUS_Percent_Complete:
207
+      progress = 100;
208
+      break;
209
+  }
210
+
211
+  dgus_display.Write((uint16_t)DGUS_Addr::STATUS_Percent, Swap16(progress));
212
+}
213
+
214
+void DGUSTxHandler::StatusIcons(DGUS_VP &vp) {
215
+  uint16_t icons = 0;
216
+
217
+  if (printingIsActive()) {
218
+    icons |= (uint16_t)DGUS_Data::StatusIcon::PAUSE;
219
+
220
+    dgus_display.EnableControl(DGUS_Screen::PRINT_STATUS,
221
+                               DGUSDisplay::POPUP_WINDOW,
222
+                               DGUS_Control::PAUSE);
223
+  }
224
+  else {
225
+    dgus_display.DisableControl(DGUS_Screen::PRINT_STATUS,
226
+                                DGUSDisplay::POPUP_WINDOW,
227
+                                DGUS_Control::PAUSE);
228
+  }
229
+
230
+  if (printingIsPaused()) {
231
+    icons |= (uint16_t)DGUS_Data::StatusIcon::RESUME;
232
+
233
+    dgus_display.EnableControl(DGUS_Screen::PRINT_STATUS,
234
+                               DGUSDisplay::POPUP_WINDOW,
235
+                               DGUS_Control::RESUME);
236
+  }
237
+  else {
238
+    dgus_display.DisableControl(DGUS_Screen::PRINT_STATUS,
239
+                                DGUSDisplay::POPUP_WINDOW,
240
+                                DGUS_Control::RESUME);
241
+  }
242
+
243
+  dgus_display.Write((uint16_t)vp.addr, Swap16(icons));
244
+}
245
+
246
+void DGUSTxHandler::Flowrate(DGUS_VP &vp) {
247
+  int16_t flowrate;
248
+
249
+  switch (vp.addr) {
250
+    default: return;
251
+    case DGUS_Addr::ADJUST_Flowrate_CUR:
252
+      #if EXTRUDERS > 1
253
+        flowrate = ExtUI::getFlow_percent(ExtUI::getActiveTool());
254
+      #else
255
+        flowrate = ExtUI::getFlow_percent(ExtUI::E0);
256
+      #endif
257
+      break;
258
+    #if EXTRUDERS > 1
259
+      case DGUS_Addr::ADJUST_Flowrate_E0:
260
+        flowrate = ExtUI::getFlow_percent(ExtUI::E0);
261
+        break;
262
+      case DGUS_Addr::ADJUST_Flowrate_E1:
263
+        flowrate = ExtUI::getFlow_percent(ExtUI::E1);
264
+        break;
265
+    #endif
266
+  }
267
+
268
+  dgus_display.Write((uint16_t)vp.addr, Swap16(flowrate));
269
+}
270
+
271
+void DGUSTxHandler::TempMax(DGUS_VP &vp) {
272
+  uint16_t temp;
273
+
274
+  switch (vp.addr) {
275
+    default: return;
276
+    case DGUS_Addr::TEMP_Max_Bed:
277
+      temp = BED_MAX_TARGET;
278
+      break;
279
+    case DGUS_Addr::TEMP_Max_H0:
280
+      temp = HEATER_0_MAXTEMP - HOTEND_OVERSHOOT;
281
+      break;
282
+    #if HOTENDS > 1
283
+      case DGUS_Addr::TEMP_Max_H1:
284
+        temp = HEATER_1_MAXTEMP - HOTEND_OVERSHOOT;
285
+        break;
286
+    #endif
287
+  }
288
+
289
+  dgus_display.Write((uint16_t)vp.addr, Swap16(temp));
290
+}
291
+
292
+void DGUSTxHandler::StepperStatus(DGUS_VP &vp) {
293
+  if (X_ENABLE_READ() == X_ENABLE_ON
294
+      && Y_ENABLE_READ() == Y_ENABLE_ON
295
+      && Z_ENABLE_READ() == Z_ENABLE_ON) {
296
+    dgus_display.Write((uint16_t)vp.addr, Swap16((uint16_t)DGUS_Data::Status::ENABLED));
297
+  }
298
+  else {
299
+    dgus_display.Write((uint16_t)vp.addr, Swap16((uint16_t)DGUS_Data::Status::DISABLED));
300
+  }
301
+}
302
+
303
+void DGUSTxHandler::StepIcons(DGUS_VP &vp) {
304
+  if (!vp.extra) return;
305
+  uint16_t icons = 0;
306
+  DGUS_Data::StepSize size = *(DGUS_Data::StepSize*)vp.extra;
307
+
308
+  switch (size) {
309
+    case DGUS_Data::StepSize::MM10:
310
+      icons |= (uint16_t)DGUS_Data::StepIcon::MM10;
311
+      break;
312
+    case DGUS_Data::StepSize::MM1:
313
+      icons |= (uint16_t)DGUS_Data::StepIcon::MM1;
314
+      break;
315
+    case DGUS_Data::StepSize::MMP1:
316
+      icons |= (uint16_t)DGUS_Data::StepIcon::MMP1;
317
+      break;
318
+    case DGUS_Data::StepSize::MMP01:
319
+      icons |= (uint16_t)DGUS_Data::StepIcon::MMP01;
320
+      break;
321
+  }
322
+
323
+  dgus_display.Write((uint16_t)vp.addr, Swap16(icons));
324
+}
325
+
326
+void DGUSTxHandler::ABLDisableIcon(DGUS_VP &vp) {
327
+  uint16_t data;
328
+
329
+  if (ExtUI::getLevelingActive()) {
330
+    data = (uint16_t)DGUS_Data::Status::ENABLED;
331
+
332
+    dgus_display.EnableControl(DGUS_Screen::LEVELING_AUTOMATIC,
333
+                               DGUSDisplay::RETURN_KEY_CODE,
334
+                               DGUS_Control::DISABLE);
335
+  }
336
+  else {
337
+    data = (uint16_t)DGUS_Data::Status::DISABLED;
338
+
339
+    dgus_display.DisableControl(DGUS_Screen::LEVELING_AUTOMATIC,
340
+                                DGUSDisplay::RETURN_KEY_CODE,
341
+                                DGUS_Control::DISABLE);
342
+  }
343
+
344
+  dgus_display.Write((uint16_t)vp.addr, Swap16(data));
345
+}
346
+
347
+void DGUSTxHandler::ABLGrid(DGUS_VP &vp) {
348
+  // Batch send
349
+  int16_t data[DGUS_LEVEL_GRID_SIZE];
350
+  xy_uint8_t point;
351
+  int16_t fixed;
352
+
353
+  for (int i = 0; i < DGUS_LEVEL_GRID_SIZE; i++) {
354
+    point.x = i % GRID_MAX_POINTS_X;
355
+    point.y = i / GRID_MAX_POINTS_X;
356
+    fixed = dgus_display.ToFixedPoint<float, int16_t, 3>(ExtUI::getMeshPoint(point));
357
+    data[i] = Swap16(fixed);
358
+  }
359
+
360
+  dgus_display.Write((uint16_t)vp.addr, data, sizeof(*data) * DGUS_LEVEL_GRID_SIZE);
361
+}
362
+
363
+void DGUSTxHandler::FilamentIcons(DGUS_VP &vp) {
364
+  uint16_t icons = 0;
365
+
366
+  switch (dgus_screen_handler.filament_extruder) {
367
+    default: return;
368
+    case DGUS_Data::Extruder::CURRENT:
369
+      #if EXTRUDERS > 1
370
+        switch (ExtUI::getActiveTool()) {
371
+          default: break;
372
+          case ExtUI::E0:
373
+            icons |= (uint16_t)DGUS_Data::ExtruderIcon::E0;
374
+            break;
375
+          case ExtUI::E1:
376
+            icons |= (uint16_t)DGUS_Data::ExtruderIcon::E1;
377
+            break;
378
+        }
379
+        break;
380
+      #endif
381
+    case DGUS_Data::Extruder::E0:
382
+      icons |= (uint16_t)DGUS_Data::ExtruderIcon::E0;
383
+      break;
384
+    case DGUS_Data::Extruder::E1:
385
+      icons |= (uint16_t)DGUS_Data::ExtruderIcon::E1;
386
+      break;
387
+  }
388
+
389
+  dgus_display.Write((uint16_t)vp.addr, Swap16(icons));
390
+}
391
+
392
+void DGUSTxHandler::BLTouch(DGUS_VP &vp) {
393
+  #if ENABLED(BLTOUCH)
394
+    dgus_display.EnableControl(DGUS_Screen::SETTINGS_MENU2,
395
+                               DGUSDisplay::RETURN_KEY_CODE,
396
+                               DGUS_Control::EXTRA2);
397
+
398
+    dgus_display.Write((uint16_t)vp.addr, Swap16((uint16_t)DGUS_Data::Status::ENABLED));
399
+  #else
400
+    dgus_display.DisableControl(DGUS_Screen::SETTINGS_MENU2,
401
+                                DGUSDisplay::RETURN_KEY_CODE,
402
+                                DGUS_Control::EXTRA2);
403
+
404
+    dgus_display.Write((uint16_t)vp.addr, Swap16((uint16_t)DGUS_Data::Status::DISABLED));
405
+  #endif
406
+}
407
+
408
+void DGUSTxHandler::PIDIcons(DGUS_VP &vp) {
409
+  uint16_t icons = 0;
410
+
411
+  switch (dgus_screen_handler.pid_heater) {
412
+    default: return;
413
+    case DGUS_Data::Heater::BED:
414
+      icons |= (uint16_t)DGUS_Data::HeaterIcon::BED;
415
+      break;
416
+    case DGUS_Data::Heater::H0:
417
+      icons |= (uint16_t)DGUS_Data::HeaterIcon::H0;
418
+      break;
419
+    case DGUS_Data::Heater::H1:
420
+      icons |= (uint16_t)DGUS_Data::HeaterIcon::H1;
421
+      break;
422
+  }
423
+
424
+  dgus_display.Write((uint16_t)vp.addr, Swap16(icons));
425
+}
426
+
427
+void DGUSTxHandler::PIDKp(DGUS_VP &vp) {
428
+  float value;
429
+
430
+  switch (dgus_screen_handler.pid_heater) {
431
+    default: return;
432
+    #if ENABLED(PIDTEMPBED)
433
+      case DGUS_Data::Heater::BED:
434
+        value = ExtUI::getBedPIDValues_Kp();
435
+        break;
436
+    #endif
437
+    #if ENABLED(PIDTEMP)
438
+      case DGUS_Data::Heater::H0:
439
+        value = ExtUI::getPIDValues_Kp(ExtUI::E0);
440
+        break;
441
+      #if HOTENDS > 1
442
+        case DGUS_Data::Heater::H1:
443
+          value = ExtUI::getPIDValues_Kp(ExtUI::E1);
444
+          break;
445
+      #endif
446
+    #endif
447
+  }
448
+
449
+  const int32_t data = dgus_display.ToFixedPoint<float, int32_t, 2>(value);
450
+  dgus_display.Write((uint16_t)vp.addr, dgus_display.SwapBytes(data));
451
+}
452
+
453
+void DGUSTxHandler::PIDKi(DGUS_VP &vp) {
454
+  float value;
455
+
456
+  switch (dgus_screen_handler.pid_heater) {
457
+    default: return;
458
+    #if ENABLED(PIDTEMPBED)
459
+      case DGUS_Data::Heater::BED:
460
+        value = ExtUI::getBedPIDValues_Ki();
461
+        break;
462
+    #endif
463
+    #if ENABLED(PIDTEMP)
464
+      case DGUS_Data::Heater::H0:
465
+        value = ExtUI::getPIDValues_Ki(ExtUI::E0);
466
+        break;
467
+      #if HOTENDS > 1
468
+        case DGUS_Data::Heater::H1:
469
+          value = ExtUI::getPIDValues_Ki(ExtUI::E1);
470
+          break;
471
+      #endif
472
+    #endif
473
+  }
474
+
475
+  const int32_t data = dgus_display.ToFixedPoint<float, int32_t, 2>(value);
476
+  dgus_display.Write((uint16_t)vp.addr, dgus_display.SwapBytes(data));
477
+}
478
+
479
+void DGUSTxHandler::PIDKd(DGUS_VP &vp) {
480
+  float value;
481
+
482
+  switch (dgus_screen_handler.pid_heater) {
483
+    default: return;
484
+    #if ENABLED(PIDTEMPBED)
485
+      case DGUS_Data::Heater::BED:
486
+        value = ExtUI::getBedPIDValues_Kd();
487
+        break;
488
+    #endif
489
+    #if ENABLED(PIDTEMP)
490
+      case DGUS_Data::Heater::H0:
491
+        value = ExtUI::getPIDValues_Kd(ExtUI::E0);
492
+        break;
493
+      #if HOTENDS > 1
494
+        case DGUS_Data::Heater::H1:
495
+          value = ExtUI::getPIDValues_Kd(ExtUI::E1);
496
+          break;
497
+      #endif
498
+    #endif
499
+  }
500
+
501
+  const int32_t data = dgus_display.ToFixedPoint<float, int32_t, 2>(value);
502
+  dgus_display.Write((uint16_t)vp.addr, dgus_display.SwapBytes(data));
503
+}
504
+
505
+void DGUSTxHandler::BuildVolume(DGUS_VP &vp) {
506
+  char buffer[vp.size];
507
+  snprintf_P(buffer, vp.size, PSTR("%dx%dx%d"), X_BED_SIZE, Y_BED_SIZE, (Z_MAX_POS - Z_MIN_POS));
508
+
509
+  dgus_display.WriteString((uint16_t)vp.addr, buffer, vp.size);
510
+}
511
+
512
+void DGUSTxHandler::TotalPrints(DGUS_VP &vp) {
513
+  #if ENABLED(PRINTCOUNTER)
514
+    dgus_display.Write((uint16_t)vp.addr, dgus_display.SwapBytes(print_job_timer.getStats().totalPrints));
515
+  #else
516
+    UNUSED(vp);
517
+  #endif
518
+}
519
+
520
+void DGUSTxHandler::FinishedPrints(DGUS_VP &vp) {
521
+  #if ENABLED(PRINTCOUNTER)
522
+    dgus_display.Write((uint16_t)vp.addr, dgus_display.SwapBytes(print_job_timer.getStats().finishedPrints));
523
+  #else
524
+    UNUSED(vp);
525
+  #endif
526
+}
527
+
528
+void DGUSTxHandler::PrintTime(DGUS_VP &vp) {
529
+  #if ENABLED(PRINTCOUNTER)
530
+    char buffer[21];
531
+    ExtUI::getTotalPrintTime_str(buffer);
532
+
533
+    dgus_display.WriteString((uint16_t)vp.addr, buffer, vp.size);
534
+  #else
535
+    dgus_display.WriteStringPGM((uint16_t)vp.addr, DGUS_MSG_UNDEF, vp.size);
536
+  #endif
537
+}
538
+
539
+void DGUSTxHandler::LongestPrint(DGUS_VP &vp) {
540
+  #if ENABLED(PRINTCOUNTER)
541
+    char buffer[21];
542
+    ExtUI::getLongestPrint_str(buffer);
543
+
544
+    dgus_display.WriteString((uint16_t)vp.addr, buffer, vp.size);
545
+  #else
546
+    dgus_display.WriteStringPGM((uint16_t)vp.addr, DGUS_MSG_UNDEF, vp.size);
547
+  #endif
548
+}
549
+
550
+void DGUSTxHandler::FilamentUsed(DGUS_VP &vp) {
551
+  #if ENABLED(PRINTCOUNTER)
552
+    char buffer[21];
553
+    ExtUI::getFilamentUsed_str(buffer);
554
+
555
+    dgus_display.WriteString((uint16_t)vp.addr, buffer, vp.size);
556
+  #else
557
+    dgus_display.WriteStringPGM((uint16_t)vp.addr, DGUS_MSG_UNDEF, vp.size);
558
+  #endif
559
+}
560
+
561
+void DGUSTxHandler::WaitIcons(DGUS_VP &vp) {
562
+  uint16_t icons = 0;
563
+
564
+  if (printingIsPaused()
565
+    #if ENABLED(ADVANCED_PAUSE_FEATURE)
566
+      && did_pause_print
567
+    #endif
568
+  ) {
569
+    icons |= (uint16_t)DGUS_Data::WaitIcon::ABORT;
570
+
571
+    dgus_display.EnableControl(DGUS_Screen::WAIT,
572
+                               DGUSDisplay::POPUP_WINDOW,
573
+                               DGUS_Control::ABORT);
574
+  }
575
+  else {
576
+    dgus_display.DisableControl(DGUS_Screen::WAIT,
577
+                                DGUSDisplay::POPUP_WINDOW,
578
+                                DGUS_Control::ABORT);
579
+  }
580
+
581
+  if (dgus_screen_handler.wait_continue) {
582
+    icons |= (uint16_t)DGUS_Data::WaitIcon::CONTINUE;
583
+
584
+    dgus_display.EnableControl(DGUS_Screen::WAIT,
585
+                               DGUSDisplay::RETURN_KEY_CODE,
586
+                               DGUS_Control::CONTINUE);
587
+  }
588
+  else {
589
+    dgus_display.DisableControl(DGUS_Screen::WAIT,
590
+                                DGUSDisplay::RETURN_KEY_CODE,
591
+                                DGUS_Control::CONTINUE);
592
+  }
593
+
594
+  dgus_display.Write((uint16_t)vp.addr, Swap16(icons));
595
+}
596
+
597
+void DGUSTxHandler::FanSpeed(DGUS_VP &vp) {
598
+  uint16_t fan_speed;
599
+
600
+  switch (vp.addr) {
601
+    default: return;
602
+    case DGUS_Addr::FAN0_Speed: fan_speed = ExtUI::getTargetFan_percent(ExtUI::FAN0); break;
603
+  }
604
+
605
+  dgus_display.Write((uint16_t)vp.addr, Swap16(fan_speed));
606
+}
607
+
608
+void DGUSTxHandler::Volume(DGUS_VP &vp) {
609
+  const uint16_t volume = dgus_display.GetVolume();
610
+
611
+  dgus_display.Write((uint16_t)vp.addr, Swap16(volume));
612
+}
613
+
614
+void DGUSTxHandler::Brightness(DGUS_VP &vp) {
615
+  const uint16_t brightness = dgus_display.GetBrightness();
616
+
617
+  dgus_display.Write((uint16_t)vp.addr, Swap16(brightness));
618
+}
619
+
620
+void DGUSTxHandler::ExtraToString(DGUS_VP &vp) {
621
+  if (!vp.size || !vp.extra) return;
622
+
623
+  dgus_display.WriteString((uint16_t)vp.addr, vp.extra, vp.size, true, false, false);
624
+}
625
+
626
+void DGUSTxHandler::ExtraPGMToString(DGUS_VP &vp) {
627
+  if (!vp.size || !vp.extra) return;
628
+
629
+  dgus_display.WriteStringPGM((uint16_t)vp.addr, vp.extra, vp.size, true, false, false);
630
+}
631
+
632
+#endif // DGUS_LCD_UI_RELOADED

+ 127
- 0
Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.h View File

@@ -0,0 +1,127 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#pragma once
24
+
25
+#include "DGUSDisplay.h"
26
+#include "definition/DGUS_VP.h"
27
+
28
+namespace DGUSTxHandler {
29
+
30
+  #if ENABLED(SDSUPPORT)
31
+    void SetFileControlState(int, bool);
32
+    void FileType(DGUS_VP &);
33
+    void FileName(DGUS_VP &);
34
+    void ScrollIcons(DGUS_VP &);
35
+    void SelectedFileName(DGUS_VP &);
36
+  #endif
37
+
38
+  void PositionZ(DGUS_VP &);
39
+  void Ellapsed(DGUS_VP &);
40
+  void Percent(DGUS_VP &);
41
+  void StatusIcons(DGUS_VP &);
42
+
43
+  void Flowrate(DGUS_VP &);
44
+
45
+  void TempMax(DGUS_VP &);
46
+
47
+  void StepperStatus(DGUS_VP &);
48
+
49
+  void StepIcons(DGUS_VP &);
50
+
51
+  void ABLDisableIcon(DGUS_VP &);
52
+  void ABLGrid(DGUS_VP &);
53
+
54
+  void FilamentIcons(DGUS_VP &);
55
+
56
+  void BLTouch(DGUS_VP &);
57
+
58
+  void PIDIcons(DGUS_VP &);
59
+  void PIDKp(DGUS_VP &);
60
+  void PIDKi(DGUS_VP &);
61
+  void PIDKd(DGUS_VP &);
62
+
63
+  void BuildVolume(DGUS_VP &);
64
+  void TotalPrints(DGUS_VP &);
65
+  void FinishedPrints(DGUS_VP &);
66
+  void PrintTime(DGUS_VP &);
67
+  void LongestPrint(DGUS_VP &);
68
+  void FilamentUsed(DGUS_VP &);
69
+
70
+  void WaitIcons(DGUS_VP &);
71
+
72
+  void FanSpeed(DGUS_VP &);
73
+
74
+  void Volume(DGUS_VP &);
75
+
76
+  void Brightness(DGUS_VP &);
77
+
78
+  void ExtraToString(DGUS_VP &);
79
+  void ExtraPGMToString(DGUS_VP &);
80
+
81
+  template<typename T>
82
+  void ExtraToInteger(DGUS_VP &vp) {
83
+    if (!vp.size || !vp.extra) return;
84
+    switch (vp.size) {
85
+      default: return;
86
+      case 1: {
87
+        const uint8_t data = (uint8_t)(*(T*)vp.extra);
88
+        dgus_display.Write((uint16_t)vp.addr, data);
89
+        break;
90
+      }
91
+      case 2: {
92
+        const uint16_t data = (uint16_t)(*(T*)vp.extra);
93
+        dgus_display.Write((uint16_t)vp.addr, Swap16(data));
94
+        break;
95
+      }
96
+      case 4: {
97
+        const uint32_t data = (uint32_t)(*(T*)vp.extra);
98
+        dgus_display.Write((uint16_t)vp.addr, dgus_display.SwapBytes(data));
99
+        break;
100
+      }
101
+    }
102
+  }
103
+
104
+  template<typename T, uint8_t decimals>
105
+  void ExtraToFixedPoint(DGUS_VP &vp) {
106
+    if (!vp.size || !vp.extra) return;
107
+    switch (vp.size) {
108
+      default: return;
109
+      case 1: {
110
+        const uint8_t data = dgus_display.ToFixedPoint<T, uint8_t, decimals>(*(T*)vp.extra);
111
+        dgus_display.Write((uint16_t)vp.addr, data);
112
+        break;
113
+      }
114
+      case 2: {
115
+        const uint16_t data = dgus_display.ToFixedPoint<T, uint16_t, decimals>(*(T*)vp.extra);
116
+        dgus_display.Write((uint16_t)vp.addr, Swap16(data));
117
+        break;
118
+      }
119
+      case 4: {
120
+        const uint32_t data = dgus_display.ToFixedPoint<T, uint32_t, decimals>(*(T*)vp.extra);
121
+        dgus_display.Write((uint16_t)vp.addr, dgus_display.SwapBytes(data));
122
+        break;
123
+      }
124
+    }
125
+  }
126
+
127
+}

+ 173
- 0
Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Addr.h View File

@@ -0,0 +1,173 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+constexpr uint8_t DGUS_LINE_LEN             = 32;
25
+constexpr uint8_t DGUS_STATUS_LEN           = 32;
26
+constexpr uint8_t DGUS_FILE_COUNT           = 5;
27
+constexpr uint8_t DGUS_FILENAME_LEN         = 32;
28
+constexpr uint8_t DGUS_ELLAPSED_LEN         = 15;
29
+constexpr uint8_t DGUS_LEVEL_GRID_SIZE      = 25;
30
+constexpr uint8_t DGUS_MACHINE_LEN          = 24;
31
+constexpr uint8_t DGUS_BUILDVOLUME_LEN      = 24;
32
+constexpr uint8_t DGUS_VERSION_LEN          = 16;
33
+constexpr uint8_t DGUS_PRINTTIME_LEN        = 24;
34
+constexpr uint8_t DGUS_LONGESTPRINT_LEN     = 24;
35
+constexpr uint8_t DGUS_FILAMENTUSED_LEN     = 24;
36
+constexpr uint8_t DGUS_GCODE_LEN            = 32;
37
+
38
+enum class DGUS_Addr : uint16_t {
39
+  MESSAGE_Line1             = 0x1100, // 0x1100 - 0x111F
40
+  MESSAGE_Line2             = 0x1120, // 0x1120 - 0x113F
41
+  MESSAGE_Line3             = 0x1140, // 0x1140 - 0x115F
42
+  MESSAGE_Line4             = 0x1160, // 0x1160 - 0x117F
43
+
44
+  // READ-ONLY VARIABLES
45
+
46
+  SCREENCHANGE              = 0x2000, // Screen change request. Data contains target screen in low byte.
47
+  SCREENCHANGE_SD           = 0x2001, // Only change if SD card present.
48
+  SCREENCHANGE_Idle         = 0x2002, // Only change if not printing.
49
+  SCREENCHANGE_Printing     = 0x2003, // Only change if printing.
50
+  SD_SelectFile             = 0x2004, // Data: file index (0-4)
51
+  SD_Scroll                 = 0x2005, // Data: DGUS_Data::Scroll
52
+  SD_Print                  = 0x2006,
53
+  STATUS_Abort              = 0x2007, // Popup / Data: DGUS_Data::Popup
54
+  STATUS_Pause              = 0x2008, // Popup / Data: DGUS_Data::Popup
55
+  STATUS_Resume             = 0x2009, // Popup / Data: DGUS_Data::Popup
56
+  ADJUST_SetFeedrate        = 0x200A, // Type: Integer (16 bits signed)
57
+  ADJUST_SetFlowrate_CUR    = 0x200B, // Type: Integer (16 bits signed)
58
+  #if EXTRUDERS > 1
59
+    ADJUST_SetFlowrate_E0   = 0x200C, // Type: Integer (16 bits signed)
60
+    ADJUST_SetFlowrate_E1   = 0x200D, // Type: Integer (16 bits signed)
61
+  #endif
62
+  ADJUST_SetBabystep        = 0x200E, // Type: Fixed point, 2 decimals (16 bits signed)
63
+  ADJUST_Babystep           = 0x200F, // Data: DGUS_Data::Adjust
64
+  TEMP_Preset               = 0x2010, // Popup / Data: DGUS_Data::TempPreset
65
+  TEMP_SetTarget_Bed        = 0x2011, // Type: Integer (16 bits signed)
66
+  TEMP_SetTarget_H0         = 0x2012, // Type: Integer (16 bits signed)
67
+  #if HOTENDS > 1
68
+    TEMP_SetTarget_H1       = 0x2013, // Type: Integer (16 bits signed)
69
+  #endif
70
+  TEMP_Cool                 = 0x2014, // Data: DGUS_Data::Heater
71
+  STEPPER_Control           = 0x2015, // Popup / Data: DGUS_Data::Control
72
+  LEVEL_OFFSET_Set          = 0x2016, // Type: Fixed point, 2 decimals (16 bits signed)
73
+  LEVEL_OFFSET_Step         = 0x2017, // Data: DGUS_Data::Adjust
74
+  LEVEL_OFFSET_SetStep      = 0x2018, // Data: DGUS_Data::StepSize
75
+  LEVEL_MANUAL_Point        = 0x2019, // Data: point index (1-5)
76
+  LEVEL_AUTO_Probe          = 0x201A,
77
+  LEVEL_AUTO_Disable        = 0x201B,
78
+  FILAMENT_Select           = 0x201C, // Data: DGUS_Data::Extruder
79
+  FILAMENT_SetLength        = 0x201D, // Type: Integer (16 bits unsigned)
80
+  FILAMENT_Move             = 0x201E, // Data: DGUS_Data::FilamentMove
81
+  MOVE_Home                 = 0x201F, // Data: DGUS_Data::Axis
82
+  MOVE_SetX                 = 0x2020, // Type: Fixed point, 1 decimal (16 bits signed)
83
+  MOVE_SetY                 = 0x2021, // Type: Fixed point, 1 decimal (16 bits signed)
84
+  MOVE_SetZ                 = 0x2022, // Type: Fixed point, 1 decimal (16 bits signed)
85
+  MOVE_Step                 = 0x2023, // Data: DGUS_Data::MoveDirection
86
+  MOVE_SetStep              = 0x2024, // Data: DGUS_Data::StepSize
87
+  GCODE_Clear               = 0x2025,
88
+  GCODE_Execute             = 0x2026,
89
+  EEPROM_Reset              = 0x2027, // Popup / Data: DGUS_Data::Popup
90
+  SETTINGS2_Extra           = 0x2028, // Data: DGUS_Data::Extra
91
+  PID_Select                = 0x2029, // Data: DGUS_Data::Heater
92
+  PID_SetTemp               = 0x202A, // Type: Integer (16 bits unsigned)
93
+  PID_Run                   = 0x202B,
94
+  POWERLOSS_Abort           = 0x202C, // Popup / Data: DGUS_Data::Popup
95
+  POWERLOSS_Resume          = 0x202D, // Popup / Data: DGUS_Data::Popup
96
+  WAIT_Abort                = 0x202E, // Popup / Data: DGUS_Data::Popup
97
+  WAIT_Continue             = 0x202F,
98
+
99
+  // WRITE-ONLY VARIABLES
100
+
101
+  MESSAGE_Status            = 0x3000, // 0x3000 - 0x301F
102
+  SD_Type                   = 0x3020, // 0x3020 - 0x3024 / Data: DGUS_Data::SDType
103
+  SD_FileName0              = 0x3025, // 0x3025 - 0x3044
104
+  SD_FileName1              = 0x3045, // 0x3045 - 0x3064
105
+  SD_FileName2              = 0x3065, // 0x3065 - 0x3084
106
+  SD_FileName3              = 0x3085, // 0x3085 - 0x30A4
107
+  SD_FileName4              = 0x30A5, // 0x30A5 - 0x30C4
108
+  SD_ScrollIcons            = 0x30C5, // Bits: DGUS_Data::ScrollIcon
109
+  SD_SelectedFileName       = 0x30C6, // 0x30C6 - 0x30E5
110
+  STATUS_PositionZ          = 0x30E6, // Type: Fixed point, 1 decimal (16 bits signed)
111
+  STATUS_Ellapsed           = 0x30E7, // 0x30E7 - 0x30F5
112
+  STATUS_Percent            = 0x30F6, // Type: Integer (16 bits unsigned)
113
+  STATUS_Icons              = 0x30F7, // Bits: DGUS_Data::StatusIcon
114
+  ADJUST_Feedrate           = 0x30F8, // Type: Integer (16 bits signed)
115
+  ADJUST_Flowrate_CUR       = 0x30F9, // Type: Integer (16 bits signed)
116
+  #if EXTRUDERS > 1
117
+    ADJUST_Flowrate_E0      = 0x30FA, // Type: Integer (16 bits signed)
118
+    ADJUST_Flowrate_E1      = 0x30FB, // Type: Integer (16 bits signed)
119
+  #endif
120
+  TEMP_Current_Bed          = 0x30FC, // Type: Integer (16 bits signed)
121
+  TEMP_Target_Bed           = 0x30FD, // Type: Integer (16 bits signed)
122
+  TEMP_Max_Bed              = 0x30FE, // Type: Integer (16 bits unsigned)
123
+  TEMP_Current_H0           = 0x30FF, // Type: Integer (16 bits signed)
124
+  TEMP_Target_H0            = 0x3100, // Type: Integer (16 bits signed)
125
+  TEMP_Max_H0               = 0x3101, // Type: Integer (16 bits unsigned)
126
+  #if HOTENDS > 1
127
+    TEMP_Current_H1         = 0x3102, // Type: Integer (16 bits signed)
128
+    TEMP_Target_H1          = 0x3103, // Type: Integer (16 bits signed)
129
+    TEMP_Max_H1             = 0x3104, // Type: Integer (16 bits unsigned)
130
+  #endif
131
+  STEPPER_Status            = 0x3105, // Data: DGUS_Data::Status
132
+  LEVEL_OFFSET_Current      = 0x3106, // Type: Fixed point, 2 decimals (16 bits signed)
133
+  LEVEL_OFFSET_StepIcons    = 0x3107, // Bits: DGUS_Data::StepIcon
134
+  LEVEL_AUTO_DisableIcon    = 0x3108, // Data: DGUS_Data::Status
135
+  LEVEL_AUTO_Grid           = 0x3109, // 0x3109 - 0x3121 / Type: Fixed point, 3 decimals (16 bits signed)
136
+  LEVEL_PROBING_Icons1      = 0x3122, // Type: Integer (16 bits unsigned) / Each bit represents a grid point
137
+  LEVEL_PROBING_Icons2      = 0x3123, // Type: Integer (16 bits unsigned) / Each bit represents a grid point
138
+  FILAMENT_ExtruderIcons    = 0x3124, // Data: DGUS_Data::ExtruderIcon
139
+  FILAMENT_Length           = 0x3125, // Type: Integer (16 bits unsigned)
140
+  MOVE_CurrentX             = 0x3126, // Type: Fixed point, 1 decimal (16 bits signed)
141
+  MOVE_CurrentY             = 0x3127, // Type: Fixed point, 1 decimal (16 bits signed)
142
+  MOVE_CurrentZ             = 0x3128, // Type: Fixed point, 1 decimal (16 bits signed)
143
+  MOVE_StepIcons            = 0x3129, // Bits: DGUS_Data::StepIcon
144
+  SETTINGS2_BLTouch         = 0x312A, // Data: DGUS_Data::Status
145
+  PID_HeaterIcons           = 0x312B, // Data: DGUS_Data::HeaterIcon
146
+  PID_Temp                  = 0x312C, // Type: Integer (16 bits unsigned)
147
+  PID_Kp                    = 0x312D, // Type: Fixed point, 2 decimals (32 bits signed)
148
+  PID_Ki                    = 0x312F, // Type: Fixed point, 2 decimals (32 bits signed)
149
+  PID_Kd                    = 0x3131, // Type: Fixed point, 2 decimals (32 bits signed)
150
+  INFOS_Machine             = 0x3133, // 0x3133 - 0x314A
151
+  INFOS_BuildVolume         = 0x314B, // 0x314B - 0x3162
152
+  INFOS_Version             = 0x3163, // 0x3163 - 0x3172
153
+  INFOS_TotalPrints         = 0x3173, // Type: Integer (16 bits unsigned)
154
+  INFOS_FinishedPrints      = 0x3174, // Type: Integer (16 bits unsigned)
155
+  INFOS_PrintTime           = 0x3175, // 0x3175 - 0x318C
156
+  INFOS_LongestPrint        = 0x318D, // 0x318D - 0x31A4
157
+  INFOS_FilamentUsed        = 0x31A5, // 0x31A5 - 0x31BC
158
+  WAIT_Icons                = 0x31BD, // Bits: DGUS_Data::WaitIcon
159
+
160
+  // READ-WRITE VARIABLES
161
+
162
+  FAN0_Speed                = 0x4000, // Type: Integer (16 bits unsigned) / Data: fan speed as percent (0-100)
163
+  GCODE_Data                = 0x4001, // 0x4001 - 0x4020
164
+  PID_Cycles                = 0x4021, // Type: Integer (16 bits unsigned)
165
+  VOLUME_Level              = 0x4022, // Type: Integer (16 bits unsigned) / Data: volume as percent (0-100)
166
+  BRIGHTNESS_Level          = 0x4023, // Type: Integer (16 bits unsigned) / Data: brightness as percent (0-100)
167
+
168
+  // SPECIAL CASES
169
+
170
+  STATUS_Percent_Complete   = 0x5000, // Same as STATUS_Percent, but always 100%
171
+  INFOS_Debug               = 0x5001,
172
+
173
+};

+ 96
- 0
Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Constants.h View File

@@ -0,0 +1,96 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "../../../../inc/MarlinConfigPre.h"
25
+
26
+#include "DGUS_Addr.h"
27
+
28
+static_assert((DGUS_LEVEL_GRID_SIZE == GRID_MAX_POINTS_X * GRID_MAX_POINTS_Y), "DGUS_LEVEL_GRID_SIZE incompatible with current mesh.");
29
+
30
+#ifndef DGUS_DEFAULT_VOLUME
31
+  #define DGUS_DEFAULT_VOLUME 50
32
+#endif
33
+
34
+#ifndef DGUS_DEFAULT_BRIGHTNESS
35
+  #define DGUS_DEFAULT_BRIGHTNESS 100
36
+#endif
37
+
38
+#ifndef DGUS_STATUS_EXPIRATION_MS
39
+  #define DGUS_STATUS_EXPIRATION_MS 30000
40
+#endif
41
+
42
+#ifndef DGUS_PRINT_BABYSTEP
43
+  #define DGUS_PRINT_BABYSTEP 0.01f
44
+#endif
45
+
46
+#ifndef DGUS_PLA_TEMP_HOTEND
47
+  #define DGUS_PLA_TEMP_HOTEND 200
48
+#endif
49
+
50
+#ifndef DGUS_PLA_TEMP_BED
51
+  #define DGUS_PLA_TEMP_BED 60
52
+#endif
53
+
54
+#ifndef DGUS_ABS_TEMP_HOTEND
55
+  #define DGUS_ABS_TEMP_HOTEND 240
56
+#endif
57
+
58
+#ifndef DGUS_ABS_TEMP_BED
59
+  #define DGUS_ABS_TEMP_BED 80
60
+#endif
61
+
62
+#ifndef DGUS_PETG_TEMP_HOTEND
63
+  #define DGUS_PETG_TEMP_HOTEND 240
64
+#endif
65
+
66
+#ifndef DGUS_PETG_TEMP_BED
67
+  #define DGUS_PETG_TEMP_BED 60
68
+#endif
69
+
70
+#ifndef DGUS_DEFAULT_FILAMENT_LEN
71
+  #define DGUS_DEFAULT_FILAMENT_LEN 10
72
+#endif
73
+
74
+#ifndef LEVEL_CORNERS_Z_HOP
75
+  #define LEVEL_CORNERS_Z_HOP 4.0
76
+#endif
77
+
78
+#ifndef LEVEL_CORNERS_HEIGHT
79
+  #define LEVEL_CORNERS_HEIGHT 0.0
80
+#endif
81
+
82
+static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration.");
83
+
84
+#ifndef DGUS_LEVEL_CENTER_X
85
+  #define DGUS_LEVEL_CENTER_X ((X_BED_SIZE) / 2)
86
+#endif
87
+
88
+#ifndef DGUS_LEVEL_CENTER_Y
89
+  #define DGUS_LEVEL_CENTER_Y ((Y_BED_SIZE) / 2)
90
+#endif
91
+
92
+#if ENABLED(BLTOUCH)
93
+  #ifndef DGUS_RESET_BLTOUCH
94
+    #define DGUS_RESET_BLTOUCH "M999\nM280P0S160"
95
+  #endif
96
+#endif

+ 50
- 0
Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Control.h View File

@@ -0,0 +1,50 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+enum class DGUS_Control : uint8_t {
25
+
26
+  // PRINT
27
+  FILE0       = 1, // RETURN_KEY_CODE
28
+  FILE1       = 2, // RETURN_KEY_CODE
29
+  FILE2       = 3, // RETURN_KEY_CODE
30
+  FILE3       = 4, // RETURN_KEY_CODE
31
+  FILE4       = 5, // RETURN_KEY_CODE
32
+  GO_BACK     = 6, // RETURN_KEY_CODE
33
+  SCROLL_UP   = 7, // RETURN_KEY_CODE
34
+  SCROLL_DOWN = 8, // RETURN_KEY_CODE
35
+
36
+  // PRINT_STATUS
37
+  PAUSE       = 1, // POPUP_WINDOW
38
+  RESUME      = 2, // POPUP_WINDOW
39
+
40
+  // LEVELING_AUTOMATIC
41
+  DISABLE     = 5, // RETURN_KEY_CODE
42
+
43
+  // SETTINGS_MENU2
44
+  EXTRA2      = 6, // RETURN_KEY_CODE
45
+
46
+  // WAIT
47
+  ABORT       = 1, // POPUP_WINDOW
48
+  CONTINUE    = 2  // RETURN_KEY_CODE
49
+
50
+};

+ 148
- 0
Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Data.h View File

@@ -0,0 +1,148 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include <inttypes.h>
25
+
26
+namespace DGUS_Data {
27
+
28
+  // RX constants
29
+
30
+  enum class Scroll : uint8_t {
31
+    GO_BACK = 0,
32
+    UP      = 1,
33
+    DOWN    = 2
34
+  };
35
+
36
+  enum class Popup : uint8_t {
37
+    CONFIRMED = 1
38
+  };
39
+
40
+  enum class Adjust : uint8_t {
41
+    INCREMENT = 0,
42
+    DECREMENT = 1
43
+  };
44
+
45
+  enum class TempPreset : uint8_t {
46
+    PLA  = 1,
47
+    ABS  = 2,
48
+    PETG = 3
49
+  };
50
+
51
+  enum class Extruder : int8_t {
52
+    CURRENT = -1,
53
+    E0      = 0,
54
+    E1      = 1
55
+  };
56
+
57
+  enum class Heater : int8_t {
58
+    ALL = -2,
59
+    BED = -1,
60
+    H0  = 0,
61
+    H1  = 1
62
+  };
63
+
64
+  enum class Control : uint8_t {
65
+    ENABLE  = 1,
66
+    DISABLE = 2
67
+  };
68
+
69
+  enum class StepSize : uint8_t {
70
+    MM10  = 0, // 10mm
71
+    MM1   = 1, // 1mm
72
+    MMP1  = 2, // 0.1mm
73
+    MMP01 = 3  // 0.01mm
74
+  };
75
+
76
+  enum class FilamentMove : uint8_t {
77
+    RETRACT = 0,
78
+    EXTRUDE = 1
79
+  };
80
+
81
+  enum class Axis : uint8_t {
82
+    X_Y_Z = 0,
83
+    X_Y   = 1,
84
+    Z     = 2
85
+  };
86
+
87
+  enum class MoveDirection : uint8_t {
88
+    XP = 0, // X+
89
+    XM = 1, // X-
90
+    YP = 2, // Y+
91
+    YM = 3, // Y-
92
+    ZP = 4, // Z+
93
+    ZM = 5  // Z-
94
+  };
95
+
96
+  enum class Extra : uint8_t {
97
+    BUTTON1 = 0,
98
+    BUTTON2 = 1
99
+  };
100
+
101
+  // TX constants
102
+
103
+  enum class SDType : uint16_t {
104
+    NONE      = 0,
105
+    FILE      = 1,
106
+    DIRECTORY = 2
107
+  };
108
+
109
+  enum class ScrollIcon : uint16_t {
110
+    GO_BACK = 1U << 0,
111
+    UP      = 1U << 1,
112
+    DOWN    = 1U << 2
113
+  };
114
+
115
+  enum class StatusIcon : uint16_t {
116
+    PAUSE  = 1U << 0,
117
+    RESUME = 1U << 1
118
+  };
119
+
120
+  enum class Status : uint16_t {
121
+    DISABLED = 0,
122
+    ENABLED  = 1
123
+  };
124
+
125
+  enum class StepIcon : uint16_t {
126
+    MM10  = 1U << 0, // 10mm
127
+    MM1   = 1U << 1, // 1mm
128
+    MMP1  = 1U << 2, // 0.1mm
129
+    MMP01 = 1U << 3  // 0.01mm
130
+  };
131
+
132
+  enum class ExtruderIcon : uint16_t {
133
+    E0  = 1U << 0,
134
+    E1  = 1U << 1
135
+  };
136
+
137
+  enum class HeaterIcon : uint16_t {
138
+    BED = 1U << 0,
139
+    H0  = 1U << 1,
140
+    H1  = 1U << 2
141
+  };
142
+
143
+  enum class WaitIcon : uint16_t {
144
+    ABORT    = 1U << 0,
145
+    CONTINUE = 1U << 1
146
+  };
147
+
148
+};

+ 52
- 0
Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Screen.h View File

@@ -0,0 +1,52 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+enum class DGUS_Screen : uint8_t {
25
+  BOOT                = 0,
26
+  HOME                = 1,
27
+  PRINT               = 2,
28
+  PRINT_STATUS        = 3,
29
+  PRINT_ADJUST        = 4,
30
+  PRINT_FINISHED      = 5,
31
+  TEMP_MENU           = 6,
32
+  TEMP_MANUAL         = 7,
33
+  FAN                 = 8,
34
+  SETTINGS_MENU       = 9,
35
+  LEVELING_MENU       = 10,
36
+  LEVELING_OFFSET     = 11,
37
+  LEVELING_MANUAL     = 12,
38
+  LEVELING_AUTOMATIC  = 13,
39
+  LEVELING_PROBING    = 14,
40
+  FILAMENT            = 15,
41
+  MOVE                = 16,
42
+  GCODE               = 17,
43
+  SETTINGS_MENU2      = 18,
44
+  PID                 = 19,
45
+  VOLUME              = 20,
46
+  BRIGHTNESS          = 21,
47
+  INFOS               = 22,
48
+  DEBUG               = 240,
49
+  POWERLOSS           = 248,
50
+  WAIT                = 249,
51
+  KILL                = 250
52
+};

+ 240
- 0
Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_ScreenAddrList.cpp View File

@@ -0,0 +1,240 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "../../../../inc/MarlinConfigPre.h"
24
+
25
+#if ENABLED(DGUS_LCD_UI_RELOADED)
26
+
27
+#include "DGUS_ScreenAddrList.h"
28
+
29
+#include "../../ui_api.h"
30
+
31
+constexpr DGUS_Addr LIST_HOME[] PROGMEM = {
32
+  DGUS_Addr::TEMP_Current_H0,
33
+  DGUS_Addr::TEMP_Target_H0,
34
+  DGUS_Addr::TEMP_Current_Bed,
35
+  DGUS_Addr::TEMP_Target_Bed,
36
+  (DGUS_Addr)0
37
+};
38
+
39
+#if ENABLED(SDSUPPORT)
40
+  constexpr DGUS_Addr LIST_PRINT[] PROGMEM = {
41
+    DGUS_Addr::SD_Type,
42
+    DGUS_Addr::SD_FileName0,
43
+    DGUS_Addr::SD_FileName1,
44
+    DGUS_Addr::SD_FileName2,
45
+    DGUS_Addr::SD_FileName3,
46
+    DGUS_Addr::SD_FileName4,
47
+    DGUS_Addr::SD_ScrollIcons,
48
+    DGUS_Addr::SD_SelectedFileName,
49
+    (DGUS_Addr)0
50
+  };
51
+#endif
52
+
53
+constexpr DGUS_Addr LIST_PRINT_STATUS[] PROGMEM = {
54
+  DGUS_Addr::TEMP_Current_H0,
55
+  DGUS_Addr::TEMP_Target_H0,
56
+  DGUS_Addr::TEMP_Current_Bed,
57
+  DGUS_Addr::TEMP_Target_Bed,
58
+  DGUS_Addr::STATUS_PositionZ,
59
+  DGUS_Addr::STATUS_Ellapsed,
60
+  DGUS_Addr::STATUS_Percent,
61
+  DGUS_Addr::STATUS_Icons,
62
+  (DGUS_Addr)0
63
+};
64
+
65
+constexpr DGUS_Addr LIST_PRINT_ADJUST[] PROGMEM = {
66
+  DGUS_Addr::TEMP_Target_H0,
67
+  DGUS_Addr::TEMP_Target_Bed,
68
+  DGUS_Addr::FAN0_Speed,
69
+  DGUS_Addr::ADJUST_Feedrate,
70
+  DGUS_Addr::ADJUST_Flowrate_CUR,
71
+  DGUS_Addr::LEVEL_OFFSET_Current,
72
+  (DGUS_Addr)0
73
+};
74
+
75
+constexpr DGUS_Addr LIST_PRINT_FINISHED[] PROGMEM = {
76
+  DGUS_Addr::TEMP_Current_H0,
77
+  DGUS_Addr::TEMP_Target_H0,
78
+  DGUS_Addr::TEMP_Current_Bed,
79
+  DGUS_Addr::TEMP_Target_Bed,
80
+  DGUS_Addr::STATUS_PositionZ,
81
+  DGUS_Addr::STATUS_Ellapsed,
82
+  DGUS_Addr::STATUS_Percent_Complete,
83
+  (DGUS_Addr)0
84
+};
85
+
86
+constexpr DGUS_Addr LIST_TEMP_MENU[] PROGMEM = {
87
+  DGUS_Addr::TEMP_Current_H0,
88
+  DGUS_Addr::TEMP_Target_H0,
89
+  DGUS_Addr::TEMP_Current_Bed,
90
+  DGUS_Addr::TEMP_Target_Bed,
91
+  (DGUS_Addr)0
92
+};
93
+
94
+constexpr DGUS_Addr LIST_TEMP_MANUAL[] PROGMEM = {
95
+  DGUS_Addr::TEMP_Current_H0,
96
+  DGUS_Addr::TEMP_Target_H0,
97
+  DGUS_Addr::TEMP_Max_H0,
98
+  DGUS_Addr::TEMP_Current_Bed,
99
+  DGUS_Addr::TEMP_Target_Bed,
100
+  DGUS_Addr::TEMP_Max_Bed,
101
+  (DGUS_Addr)0
102
+};
103
+
104
+constexpr DGUS_Addr LIST_FAN[] PROGMEM = {
105
+  DGUS_Addr::FAN0_Speed,
106
+  (DGUS_Addr)0
107
+};
108
+
109
+constexpr DGUS_Addr LIST_SETTINGS_MENU[] PROGMEM = {
110
+  DGUS_Addr::STEPPER_Status,
111
+  (DGUS_Addr)0
112
+};
113
+
114
+constexpr DGUS_Addr LIST_LEVELING_OFFSET[] PROGMEM = {
115
+  DGUS_Addr::LEVEL_OFFSET_Current,
116
+  DGUS_Addr::LEVEL_OFFSET_StepIcons,
117
+  (DGUS_Addr)0
118
+};
119
+
120
+constexpr DGUS_Addr LIST_LEVELING_MANUAL[] PROGMEM = {
121
+  DGUS_Addr::TEMP_Current_H0,
122
+  DGUS_Addr::TEMP_Target_H0,
123
+  DGUS_Addr::TEMP_Current_Bed,
124
+  DGUS_Addr::TEMP_Target_Bed,
125
+  (DGUS_Addr)0
126
+};
127
+
128
+constexpr DGUS_Addr LIST_LEVELING_AUTOMATIC[] PROGMEM = {
129
+  DGUS_Addr::TEMP_Current_H0,
130
+  DGUS_Addr::TEMP_Target_H0,
131
+  DGUS_Addr::TEMP_Current_Bed,
132
+  DGUS_Addr::TEMP_Target_Bed,
133
+  DGUS_Addr::LEVEL_AUTO_DisableIcon,
134
+  DGUS_Addr::LEVEL_AUTO_Grid,
135
+  (DGUS_Addr)0
136
+};
137
+
138
+constexpr DGUS_Addr LIST_LEVELING_PROBING[] PROGMEM = {
139
+  DGUS_Addr::LEVEL_PROBING_Icons1,
140
+  DGUS_Addr::LEVEL_PROBING_Icons2,
141
+  (DGUS_Addr)0
142
+};
143
+
144
+constexpr DGUS_Addr LIST_FILAMENT[] PROGMEM = {
145
+  DGUS_Addr::TEMP_Current_H0,
146
+  DGUS_Addr::TEMP_Target_H0,
147
+  DGUS_Addr::FILAMENT_ExtruderIcons,
148
+  DGUS_Addr::FILAMENT_Length,
149
+  (DGUS_Addr)0
150
+};
151
+
152
+constexpr DGUS_Addr LIST_MOVE[] PROGMEM = {
153
+  DGUS_Addr::MOVE_CurrentX,
154
+  DGUS_Addr::MOVE_CurrentY,
155
+  DGUS_Addr::MOVE_CurrentZ,
156
+  DGUS_Addr::MOVE_StepIcons,
157
+  (DGUS_Addr)0
158
+};
159
+
160
+constexpr DGUS_Addr LIST_GCODE[] PROGMEM = {
161
+  DGUS_Addr::GCODE_Data,
162
+  (DGUS_Addr)0
163
+};
164
+
165
+constexpr DGUS_Addr LIST_SETTINGS_MENU2[] PROGMEM = {
166
+  DGUS_Addr::SETTINGS2_BLTouch,
167
+  (DGUS_Addr)0
168
+};
169
+
170
+constexpr DGUS_Addr LIST_PID[] PROGMEM = {
171
+  DGUS_Addr::PID_HeaterIcons,
172
+  DGUS_Addr::PID_Temp,
173
+  DGUS_Addr::PID_Cycles,
174
+  DGUS_Addr::PID_Kp,
175
+  DGUS_Addr::PID_Ki,
176
+  DGUS_Addr::PID_Kd,
177
+  (DGUS_Addr)0
178
+};
179
+
180
+constexpr DGUS_Addr LIST_VOLUME[] PROGMEM = {
181
+  DGUS_Addr::VOLUME_Level,
182
+  (DGUS_Addr)0
183
+};
184
+
185
+constexpr DGUS_Addr LIST_BRIGHTNESS[] PROGMEM = {
186
+  DGUS_Addr::BRIGHTNESS_Level,
187
+  (DGUS_Addr)0
188
+};
189
+
190
+constexpr DGUS_Addr LIST_INFOS[] PROGMEM = {
191
+  DGUS_Addr::INFOS_Machine,
192
+  DGUS_Addr::INFOS_BuildVolume,
193
+  DGUS_Addr::INFOS_Version,
194
+  DGUS_Addr::INFOS_TotalPrints,
195
+  DGUS_Addr::INFOS_FinishedPrints,
196
+  DGUS_Addr::INFOS_PrintTime,
197
+  DGUS_Addr::INFOS_LongestPrint,
198
+  DGUS_Addr::INFOS_FilamentUsed,
199
+  (DGUS_Addr)0
200
+};
201
+
202
+constexpr DGUS_Addr LIST_WAIT[] PROGMEM = {
203
+  DGUS_Addr::WAIT_Icons,
204
+  (DGUS_Addr)0
205
+};
206
+
207
+#define MAP_HELPER(SCREEN, LIST) \
208
+  { .screen = SCREEN, \
209
+  .addr_list = LIST }
210
+
211
+const struct DGUS_ScreenAddrList screen_addr_list_map[] PROGMEM = {
212
+  MAP_HELPER(DGUS_Screen::HOME,                 LIST_HOME),
213
+  #if ENABLED(SDSUPPORT)
214
+    MAP_HELPER(DGUS_Screen::PRINT,              LIST_PRINT),
215
+  #endif
216
+  MAP_HELPER(DGUS_Screen::PRINT_STATUS,         LIST_PRINT_STATUS),
217
+  MAP_HELPER(DGUS_Screen::PRINT_ADJUST,         LIST_PRINT_ADJUST),
218
+  MAP_HELPER(DGUS_Screen::PRINT_FINISHED,       LIST_PRINT_FINISHED),
219
+  MAP_HELPER(DGUS_Screen::TEMP_MENU,            LIST_TEMP_MENU),
220
+  MAP_HELPER(DGUS_Screen::TEMP_MANUAL,          LIST_TEMP_MANUAL),
221
+  MAP_HELPER(DGUS_Screen::FAN,                  LIST_FAN),
222
+  MAP_HELPER(DGUS_Screen::SETTINGS_MENU,        LIST_SETTINGS_MENU),
223
+  MAP_HELPER(DGUS_Screen::LEVELING_OFFSET,      LIST_LEVELING_OFFSET),
224
+  MAP_HELPER(DGUS_Screen::LEVELING_MANUAL,      LIST_LEVELING_MANUAL),
225
+  MAP_HELPER(DGUS_Screen::LEVELING_AUTOMATIC,   LIST_LEVELING_AUTOMATIC),
226
+  MAP_HELPER(DGUS_Screen::LEVELING_PROBING,     LIST_LEVELING_PROBING),
227
+  MAP_HELPER(DGUS_Screen::FILAMENT,             LIST_FILAMENT),
228
+  MAP_HELPER(DGUS_Screen::MOVE,                 LIST_MOVE),
229
+  MAP_HELPER(DGUS_Screen::GCODE,                LIST_GCODE),
230
+  MAP_HELPER(DGUS_Screen::SETTINGS_MENU2,       LIST_SETTINGS_MENU2),
231
+  MAP_HELPER(DGUS_Screen::PID,                  LIST_PID),
232
+  MAP_HELPER(DGUS_Screen::VOLUME,               LIST_VOLUME),
233
+  MAP_HELPER(DGUS_Screen::BRIGHTNESS,           LIST_BRIGHTNESS),
234
+  MAP_HELPER(DGUS_Screen::INFOS,                LIST_INFOS),
235
+  MAP_HELPER(DGUS_Screen::WAIT,                 LIST_WAIT),
236
+
237
+  MAP_HELPER((DGUS_Screen)0, nullptr)
238
+};
239
+
240
+#endif // DGUS_LCD_UI_RELOADED

+ 32
- 0
Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_ScreenAddrList.h View File

@@ -0,0 +1,32 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "../config/DGUS_Screen.h"
25
+#include "../config/DGUS_Addr.h"
26
+
27
+struct DGUS_ScreenAddrList {
28
+  DGUS_Screen       screen;
29
+  const DGUS_Addr   *addr_list;
30
+};
31
+
32
+extern const struct DGUS_ScreenAddrList screen_addr_list_map[];

+ 57
- 0
Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_ScreenSetup.cpp View File

@@ -0,0 +1,57 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "../../../../inc/MarlinConfigPre.h"
24
+
25
+#if ENABLED(DGUS_LCD_UI_RELOADED)
26
+
27
+#include "DGUS_ScreenSetup.h"
28
+
29
+#include "../DGUSSetupHandler.h"
30
+
31
+#include "../../ui_api.h"
32
+
33
+#define SETUP_HELPER(SCREEN, SETUP) \
34
+  { .screen = SCREEN, \
35
+  .setup_fn = SETUP }
36
+
37
+const struct DGUS_ScreenSetup screen_setup_list[] PROGMEM = {
38
+  #if ENABLED(SDSUPPORT)
39
+    SETUP_HELPER(DGUS_Screen::PRINT,            &DGUSSetupHandler::Print),
40
+  #endif
41
+  SETUP_HELPER(DGUS_Screen::PRINT_STATUS,       &DGUSSetupHandler::PrintStatus),
42
+  SETUP_HELPER(DGUS_Screen::PRINT_ADJUST,       &DGUSSetupHandler::PrintAdjust),
43
+  SETUP_HELPER(DGUS_Screen::LEVELING_MENU,      &DGUSSetupHandler::LevelingMenu),
44
+  SETUP_HELPER(DGUS_Screen::LEVELING_OFFSET,    &DGUSSetupHandler::LevelingOffset),
45
+  SETUP_HELPER(DGUS_Screen::LEVELING_MANUAL,    &DGUSSetupHandler::LevelingManual),
46
+  SETUP_HELPER(DGUS_Screen::LEVELING_AUTOMATIC, &DGUSSetupHandler::LevelingAutomatic),
47
+  SETUP_HELPER(DGUS_Screen::LEVELING_PROBING,   &DGUSSetupHandler::LevelingProbing),
48
+  SETUP_HELPER(DGUS_Screen::FILAMENT,           &DGUSSetupHandler::Filament),
49
+  SETUP_HELPER(DGUS_Screen::MOVE,               &DGUSSetupHandler::Move),
50
+  SETUP_HELPER(DGUS_Screen::GCODE,              &DGUSSetupHandler::Gcode),
51
+  SETUP_HELPER(DGUS_Screen::PID,                &DGUSSetupHandler::PID),
52
+  SETUP_HELPER(DGUS_Screen::INFOS,              &DGUSSetupHandler::Infos),
53
+
54
+  SETUP_HELPER((DGUS_Screen)0, nullptr)
55
+};
56
+
57
+#endif // DGUS_LCD_UI_RELOADED

+ 31
- 0
Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_ScreenSetup.h View File

@@ -0,0 +1,31 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "../config/DGUS_Screen.h"
25
+
26
+struct DGUS_ScreenSetup {
27
+  DGUS_Screen   screen;
28
+  bool          (*setup_fn)(void);
29
+};
30
+
31
+extern const struct DGUS_ScreenSetup screen_setup_list[];

+ 40
- 0
Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_VP.h View File

@@ -0,0 +1,40 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "../config/DGUS_Addr.h"
25
+
26
+#define VPFLAG_NONE        0
27
+#define VPFLAG_AUTOUPLOAD  (1U << 0) // Upload on every DGUS update
28
+#define VPFLAG_RXSTRING    (1U << 1) // Treat the received data as a string (terminated with 0xFFFF)
29
+
30
+struct DGUS_VP {
31
+  DGUS_Addr addr;
32
+  uint8_t   size;
33
+  uint8_t   flags;
34
+  void      *extra;
35
+
36
+  // Callback that will be called if the display modified the value.
37
+  // nullptr makes it readonly for the display.
38
+  void (*rx_handler)(DGUS_VP &, void *);
39
+  void (*tx_handler)(DGUS_VP &);
40
+};

+ 368
- 0
Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_VPList.cpp View File

@@ -0,0 +1,368 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "../../../../inc/MarlinConfigPre.h"
24
+
25
+#if ENABLED(DGUS_LCD_UI_RELOADED)
26
+
27
+#include "DGUS_VPList.h"
28
+
29
+#include "../config/DGUS_Addr.h"
30
+#include "../DGUSScreenHandler.h"
31
+#include "../DGUSRxHandler.h"
32
+#include "../DGUSTxHandler.h"
33
+
34
+#include "../../ui_api.h"
35
+#include "../../../../module/probe.h"
36
+#include "../../../../module/motion.h"
37
+#include "../../../../module/temperature.h"
38
+
39
+const char DGUS_MACHINENAME[] PROGMEM = MACHINE_NAME;
40
+const char DGUS_MARLINVERSION[] PROGMEM = SHORT_BUILD_VERSION;
41
+
42
+#define VP_HELPER(ADDR, SIZE, FLAGS, EXTRA, RXHANDLER, TXHANDLER) \
43
+  { .addr = ADDR, \
44
+  .size = SIZE, \
45
+  .flags = FLAGS, \
46
+  .extra = EXTRA, \
47
+  .rx_handler = RXHANDLER, \
48
+  .tx_handler = TXHANDLER }
49
+
50
+#define VP_HELPER_WORD(ADDR, FLAGS, EXTRA, RXHANDLER, TXHANDLER) \
51
+  VP_HELPER(ADDR, 2, FLAGS, EXTRA, RXHANDLER, TXHANDLER)
52
+
53
+#define VP_HELPER_DWORD(ADDR, FLAGS, EXTRA, RXHANDLER, TXHANDLER) \
54
+  VP_HELPER(ADDR, 4, FLAGS, EXTRA, RXHANDLER, TXHANDLER)
55
+
56
+#define VP_HELPER_RX(ADDR, RXHANDLER) \
57
+  VP_HELPER_WORD(ADDR, VPFLAG_NONE, nullptr, RXHANDLER, nullptr)
58
+
59
+#define VP_HELPER_RX_NODATA(ADDR, RXHANDLER) \
60
+  VP_HELPER(ADDR, 0, VPFLAG_NONE, nullptr, RXHANDLER, nullptr)
61
+
62
+#define VP_HELPER_TX(ADDR, TXHANDLER) \
63
+  VP_HELPER_WORD(ADDR, VPFLAG_NONE, nullptr, nullptr, TXHANDLER)
64
+
65
+#define VP_HELPER_TX_SIZE(ADDR, SIZE, TXHANDLER) \
66
+  VP_HELPER(ADDR, SIZE, VPFLAG_NONE, nullptr, nullptr, TXHANDLER)
67
+
68
+#define VP_HELPER_TX_EXTRA(ADDR, EXTRA, TXHANDLER) \
69
+  VP_HELPER_WORD(ADDR, VPFLAG_NONE, EXTRA, nullptr, TXHANDLER)
70
+
71
+#define VP_HELPER_TX_AUTO(ADDR, EXTRA, TXHANDLER) \
72
+  VP_HELPER_WORD(ADDR, VPFLAG_AUTOUPLOAD, EXTRA, nullptr, TXHANDLER)
73
+
74
+const struct DGUS_VP vp_list[] PROGMEM = {
75
+
76
+  // READ-ONLY VARIABLES
77
+
78
+  VP_HELPER_RX(DGUS_Addr::SCREENCHANGE,          &DGUSRxHandler::ScreenChange),
79
+  VP_HELPER_RX(DGUS_Addr::SCREENCHANGE_SD,       &DGUSRxHandler::ScreenChange),
80
+  VP_HELPER_RX(DGUS_Addr::SCREENCHANGE_Idle,     &DGUSRxHandler::ScreenChange),
81
+  VP_HELPER_RX(DGUS_Addr::SCREENCHANGE_Printing, &DGUSRxHandler::ScreenChange),
82
+
83
+  #if ENABLED(SDSUPPORT)
84
+    VP_HELPER_RX(DGUS_Addr::SD_SelectFile,   &DGUSRxHandler::SelectFile),
85
+    VP_HELPER_RX(DGUS_Addr::SD_Scroll,       &DGUSRxHandler::Scroll),
86
+    VP_HELPER_RX_NODATA(DGUS_Addr::SD_Print, &DGUSRxHandler::PrintFile),
87
+  #endif
88
+
89
+  VP_HELPER_RX(DGUS_Addr::STATUS_Abort,  &DGUSRxHandler::PrintAbort),
90
+  VP_HELPER_RX(DGUS_Addr::STATUS_Pause,  &DGUSRxHandler::PrintPause),
91
+  VP_HELPER_RX(DGUS_Addr::STATUS_Resume, &DGUSRxHandler::PrintResume),
92
+
93
+  VP_HELPER_RX(DGUS_Addr::ADJUST_SetFeedrate,     &DGUSRxHandler::Feedrate),
94
+  VP_HELPER_RX(DGUS_Addr::ADJUST_SetFlowrate_CUR, &DGUSRxHandler::Flowrate),
95
+  #if EXTRUDERS > 1
96
+    VP_HELPER_RX(DGUS_Addr::ADJUST_SetFlowrate_E0,  &DGUSRxHandler::Flowrate),
97
+    VP_HELPER_RX(DGUS_Addr::ADJUST_SetFlowrate_E1,  &DGUSRxHandler::Flowrate),
98
+  #endif
99
+  VP_HELPER_RX(DGUS_Addr::ADJUST_SetBabystep,     &DGUSRxHandler::BabystepSet),
100
+  VP_HELPER_RX(DGUS_Addr::ADJUST_Babystep,        &DGUSRxHandler::Babystep),
101
+
102
+  VP_HELPER_RX(DGUS_Addr::TEMP_Preset,        &DGUSRxHandler::TempPreset),
103
+  VP_HELPER_RX(DGUS_Addr::TEMP_SetTarget_Bed, &DGUSRxHandler::TempTarget),
104
+  VP_HELPER_RX(DGUS_Addr::TEMP_SetTarget_H0,  &DGUSRxHandler::TempTarget),
105
+  #if HOTENDS > 1
106
+    VP_HELPER_RX(DGUS_Addr::TEMP_SetTarget_H1,  &DGUSRxHandler::TempTarget),
107
+  #endif
108
+  VP_HELPER_RX(DGUS_Addr::TEMP_Cool,          &DGUSRxHandler::TempCool),
109
+
110
+  VP_HELPER_RX(DGUS_Addr::STEPPER_Control, &DGUSRxHandler::Steppers),
111
+
112
+  VP_HELPER_RX(DGUS_Addr::LEVEL_OFFSET_Set,     &DGUSRxHandler::ZOffset),
113
+  VP_HELPER_RX(DGUS_Addr::LEVEL_OFFSET_Step,    &DGUSRxHandler::ZOffsetStep),
114
+  VP_HELPER_RX(DGUS_Addr::LEVEL_OFFSET_SetStep, &DGUSRxHandler::ZOffsetSetStep),
115
+
116
+  VP_HELPER_RX(DGUS_Addr::LEVEL_MANUAL_Point, &DGUSRxHandler::MoveToPoint),
117
+
118
+  VP_HELPER_RX_NODATA(DGUS_Addr::LEVEL_AUTO_Probe,   &DGUSRxHandler::Probe),
119
+  VP_HELPER_RX_NODATA(DGUS_Addr::LEVEL_AUTO_Disable,
120
+                      &DGUSRxHandler::DisableABL),
121
+
122
+  VP_HELPER_RX(DGUS_Addr::FILAMENT_Select,    &DGUSRxHandler::FilamentSelect),
123
+  VP_HELPER_RX(DGUS_Addr::FILAMENT_SetLength, &DGUSRxHandler::FilamentLength),
124
+  VP_HELPER_RX(DGUS_Addr::FILAMENT_Move,      &DGUSRxHandler::FilamentMove),
125
+
126
+  VP_HELPER_RX(DGUS_Addr::MOVE_Home,    &DGUSRxHandler::Home),
127
+  VP_HELPER_RX(DGUS_Addr::MOVE_SetX,    &DGUSRxHandler::Move),
128
+  VP_HELPER_RX(DGUS_Addr::MOVE_SetY,    &DGUSRxHandler::Move),
129
+  VP_HELPER_RX(DGUS_Addr::MOVE_SetZ,    &DGUSRxHandler::Move),
130
+  VP_HELPER_RX(DGUS_Addr::MOVE_Step,    &DGUSRxHandler::MoveStep),
131
+  VP_HELPER_RX(DGUS_Addr::MOVE_SetStep, &DGUSRxHandler::MoveSetStep),
132
+
133
+  VP_HELPER_RX_NODATA(DGUS_Addr::GCODE_Clear,   &DGUSRxHandler::GcodeClear),
134
+  VP_HELPER_RX_NODATA(DGUS_Addr::GCODE_Execute, &DGUSRxHandler::GcodeExecute),
135
+
136
+  VP_HELPER_RX(DGUS_Addr::EEPROM_Reset, &DGUSRxHandler::ResetEEPROM),
137
+
138
+  VP_HELPER_RX(DGUS_Addr::SETTINGS2_Extra, &DGUSRxHandler::SettingsExtra),
139
+
140
+  VP_HELPER_RX(DGUS_Addr::PID_Select,     &DGUSRxHandler::PIDSelect),
141
+  VP_HELPER_RX(DGUS_Addr::PID_SetTemp,    &DGUSRxHandler::PIDSetTemp),
142
+  VP_HELPER_RX_NODATA(DGUS_Addr::PID_Run, &DGUSRxHandler::PIDRun),
143
+
144
+  #if ENABLED(POWER_LOSS_RECOVERY)
145
+    VP_HELPER_RX(DGUS_Addr::POWERLOSS_Abort,  &DGUSRxHandler::PowerLossAbort),
146
+    VP_HELPER_RX(DGUS_Addr::POWERLOSS_Resume, &DGUSRxHandler::PowerLossResume),
147
+  #endif
148
+
149
+  VP_HELPER_RX(DGUS_Addr::WAIT_Abort, &DGUSRxHandler::WaitAbort),
150
+  VP_HELPER_RX_NODATA(DGUS_Addr::WAIT_Continue, &DGUSRxHandler::WaitContinue),
151
+
152
+  // WRITE-ONLY VARIABLES
153
+
154
+  #if ENABLED(SDSUPPORT)
155
+    VP_HELPER_TX(DGUS_Addr::SD_Type, &DGUSTxHandler::FileType),
156
+    VP_HELPER_TX_SIZE(DGUS_Addr::SD_FileName0,
157
+                      DGUS_FILENAME_LEN,
158
+                      &DGUSTxHandler::FileName),
159
+    VP_HELPER_TX_SIZE(DGUS_Addr::SD_FileName1,
160
+                      DGUS_FILENAME_LEN,
161
+                      &DGUSTxHandler::FileName),
162
+    VP_HELPER_TX_SIZE(DGUS_Addr::SD_FileName2,
163
+                      DGUS_FILENAME_LEN,
164
+                      &DGUSTxHandler::FileName),
165
+    VP_HELPER_TX_SIZE(DGUS_Addr::SD_FileName3,
166
+                      DGUS_FILENAME_LEN,
167
+                      &DGUSTxHandler::FileName),
168
+    VP_HELPER_TX_SIZE(DGUS_Addr::SD_FileName4,
169
+                      DGUS_FILENAME_LEN,
170
+                      &DGUSTxHandler::FileName),
171
+    VP_HELPER_TX(DGUS_Addr::SD_ScrollIcons, &DGUSTxHandler::ScrollIcons),
172
+    VP_HELPER_TX_SIZE(DGUS_Addr::SD_SelectedFileName,
173
+                      DGUS_FILENAME_LEN,
174
+                      &DGUSTxHandler::SelectedFileName),
175
+  #endif
176
+
177
+  VP_HELPER_TX_AUTO(DGUS_Addr::STATUS_PositionZ,
178
+                    nullptr,
179
+                    &DGUSTxHandler::PositionZ),
180
+  VP_HELPER(DGUS_Addr::STATUS_Ellapsed,
181
+            DGUS_ELLAPSED_LEN,
182
+            VPFLAG_AUTOUPLOAD,
183
+            nullptr,
184
+            nullptr,
185
+            &DGUSTxHandler::Ellapsed),
186
+  VP_HELPER_TX_AUTO(DGUS_Addr::STATUS_Percent,
187
+                    nullptr,
188
+                    &DGUSTxHandler::Percent),
189
+  VP_HELPER_TX(DGUS_Addr::STATUS_Icons, &DGUSTxHandler::StatusIcons),
190
+
191
+  VP_HELPER_TX_AUTO(DGUS_Addr::ADJUST_Feedrate,
192
+                    &feedrate_percentage,
193
+                    &DGUSTxHandler::ExtraToInteger<int16_t>),
194
+  VP_HELPER_TX_AUTO(DGUS_Addr::ADJUST_Flowrate_CUR,
195
+                    nullptr,
196
+                    &DGUSTxHandler::Flowrate),
197
+  #if EXTRUDERS > 1
198
+    VP_HELPER_TX_AUTO(DGUS_Addr::ADJUST_Flowrate_E0,
199
+                      nullptr,
200
+                      &DGUSTxHandler::Flowrate),
201
+    VP_HELPER_TX_AUTO(DGUS_Addr::ADJUST_Flowrate_E1,
202
+                      nullptr,
203
+                      &DGUSTxHandler::Flowrate),
204
+  #endif
205
+
206
+  VP_HELPER_TX_AUTO(DGUS_Addr::TEMP_Current_Bed,
207
+                    &thermalManager.temp_bed.celsius,
208
+                    &DGUSTxHandler::ExtraToInteger<float>),
209
+  VP_HELPER_TX_AUTO(DGUS_Addr::TEMP_Target_Bed,
210
+                    &thermalManager.temp_bed.target,
211
+                    &DGUSTxHandler::ExtraToInteger<int16_t>),
212
+  VP_HELPER_TX(DGUS_Addr::TEMP_Max_Bed, &DGUSTxHandler::TempMax),
213
+  VP_HELPER_TX_AUTO(DGUS_Addr::TEMP_Current_H0,
214
+                    &thermalManager.temp_hotend[ExtUI::heater_t::H0].celsius,
215
+                    &DGUSTxHandler::ExtraToInteger<float>),
216
+  VP_HELPER_TX_AUTO(DGUS_Addr::TEMP_Target_H0,
217
+                    &thermalManager.temp_hotend[ExtUI::heater_t::H0].target,
218
+                    &DGUSTxHandler::ExtraToInteger<int16_t>),
219
+  VP_HELPER_TX(DGUS_Addr::TEMP_Max_H0, &DGUSTxHandler::TempMax),
220
+  #if HOTENDS > 1
221
+    VP_HELPER_TX_AUTO(DGUS_Addr::TEMP_Current_H1,
222
+                      &thermalManager.temp_hotend[ExtUI::heater_t::H1].celsius,
223
+                      &DGUSTxHandler::ExtraToInteger<float>),
224
+    VP_HELPER_TX_AUTO(DGUS_Addr::TEMP_Target_H1,
225
+                      &thermalManager.temp_hotend[ExtUI::heater_t::H1].target,
226
+                      &DGUSTxHandler::ExtraToInteger<int16_t>),
227
+    VP_HELPER_TX(DGUS_Addr::TEMP_Max_H1, &DGUSTxHandler::TempMax),
228
+  #endif
229
+
230
+  VP_HELPER_TX_AUTO(DGUS_Addr::STEPPER_Status,
231
+                    nullptr,
232
+                    &DGUSTxHandler::StepperStatus),
233
+
234
+  VP_HELPER_TX_AUTO(DGUS_Addr::LEVEL_OFFSET_Current,
235
+                    &probe.offset.z,
236
+                    (&DGUSTxHandler::ExtraToFixedPoint<float, 2>)),
237
+  VP_HELPER_TX_EXTRA(DGUS_Addr::LEVEL_OFFSET_StepIcons,
238
+                     &DGUSScreenHandler::offset_steps,
239
+                     &DGUSTxHandler::StepIcons),
240
+
241
+  VP_HELPER_TX_AUTO(DGUS_Addr::LEVEL_AUTO_DisableIcon,
242
+                    nullptr,
243
+                    &DGUSTxHandler::ABLDisableIcon),
244
+  VP_HELPER_TX(DGUS_Addr::LEVEL_AUTO_Grid, &DGUSTxHandler::ABLGrid),
245
+
246
+  VP_HELPER_TX_EXTRA(DGUS_Addr::LEVEL_PROBING_Icons1,
247
+                     &DGUSScreenHandler::probing_icons[0],
248
+                     &DGUSTxHandler::ExtraToInteger<uint16_t>),
249
+  VP_HELPER_TX_EXTRA(DGUS_Addr::LEVEL_PROBING_Icons2,
250
+                     &DGUSScreenHandler::probing_icons[1],
251
+                     &DGUSTxHandler::ExtraToInteger<uint16_t>),
252
+
253
+  VP_HELPER_TX(DGUS_Addr::FILAMENT_ExtruderIcons, &DGUSTxHandler::FilamentIcons),
254
+  VP_HELPER_TX_EXTRA(DGUS_Addr::FILAMENT_Length,
255
+                     &DGUSScreenHandler::filament_length,
256
+                     &DGUSTxHandler::ExtraToInteger<uint16_t>),
257
+
258
+  VP_HELPER_TX_AUTO(DGUS_Addr::MOVE_CurrentX,
259
+                    &current_position.x,
260
+                    (&DGUSTxHandler::ExtraToFixedPoint<float, 1>)),
261
+  VP_HELPER_TX_AUTO(DGUS_Addr::MOVE_CurrentY,
262
+                    &current_position.y,
263
+                    (&DGUSTxHandler::ExtraToFixedPoint<float, 1>)),
264
+  VP_HELPER_TX_AUTO(DGUS_Addr::MOVE_CurrentZ,
265
+                    &current_position.z,
266
+                    (&DGUSTxHandler::ExtraToFixedPoint<float, 1>)),
267
+  VP_HELPER_TX_EXTRA(DGUS_Addr::MOVE_StepIcons,
268
+                     &DGUSScreenHandler::move_steps,
269
+                     &DGUSTxHandler::StepIcons),
270
+
271
+  VP_HELPER_TX(DGUS_Addr::SETTINGS2_BLTouch, &DGUSTxHandler::BLTouch),
272
+
273
+  VP_HELPER_TX(DGUS_Addr::PID_HeaterIcons, &DGUSTxHandler::PIDIcons),
274
+  VP_HELPER_TX_EXTRA(DGUS_Addr::PID_Temp,
275
+                     &DGUSScreenHandler::pid_temp,
276
+                     &DGUSTxHandler::ExtraToInteger<uint16_t>),
277
+  VP_HELPER_DWORD(DGUS_Addr::PID_Kp,
278
+                  VPFLAG_AUTOUPLOAD,
279
+                  nullptr,
280
+                  nullptr,
281
+                  &DGUSTxHandler::PIDKp),
282
+  VP_HELPER_DWORD(DGUS_Addr::PID_Ki,
283
+                  VPFLAG_AUTOUPLOAD,
284
+                  nullptr,
285
+                  nullptr,
286
+                  &DGUSTxHandler::PIDKi),
287
+  VP_HELPER_DWORD(DGUS_Addr::PID_Kd,
288
+                  VPFLAG_AUTOUPLOAD,
289
+                  nullptr,
290
+                  nullptr,
291
+                  &DGUSTxHandler::PIDKd),
292
+
293
+  VP_HELPER(DGUS_Addr::INFOS_Machine,
294
+            DGUS_MACHINE_LEN,
295
+            VPFLAG_NONE,
296
+            (void*)DGUS_MACHINENAME,
297
+            nullptr,
298
+            &DGUSTxHandler::ExtraPGMToString),
299
+  VP_HELPER_TX_SIZE(DGUS_Addr::INFOS_BuildVolume,
300
+                    DGUS_BUILDVOLUME_LEN,
301
+                    &DGUSTxHandler::BuildVolume),
302
+  VP_HELPER(DGUS_Addr::INFOS_Version,
303
+            DGUS_VERSION_LEN,
304
+            VPFLAG_NONE,
305
+            (void*)DGUS_MARLINVERSION,
306
+            nullptr,
307
+            &DGUSTxHandler::ExtraPGMToString),
308
+  VP_HELPER_TX(DGUS_Addr::INFOS_TotalPrints, &DGUSTxHandler::TotalPrints),
309
+  VP_HELPER_TX(DGUS_Addr::INFOS_FinishedPrints, &DGUSTxHandler::FinishedPrints),
310
+  VP_HELPER_TX_SIZE(DGUS_Addr::INFOS_PrintTime,
311
+                    DGUS_PRINTTIME_LEN,
312
+                    &DGUSTxHandler::PrintTime),
313
+  VP_HELPER_TX_SIZE(DGUS_Addr::INFOS_LongestPrint,
314
+                    DGUS_LONGESTPRINT_LEN,
315
+                    &DGUSTxHandler::LongestPrint),
316
+  VP_HELPER_TX_SIZE(DGUS_Addr::INFOS_FilamentUsed,
317
+                    DGUS_FILAMENTUSED_LEN,
318
+                    &DGUSTxHandler::FilamentUsed),
319
+
320
+  VP_HELPER_TX(DGUS_Addr::WAIT_Icons, &DGUSTxHandler::WaitIcons),
321
+
322
+  // READ-WRITE VARIABLES
323
+
324
+  VP_HELPER(DGUS_Addr::FAN0_Speed,
325
+            2,
326
+            VPFLAG_AUTOUPLOAD,
327
+            nullptr,
328
+            &DGUSRxHandler::FanSpeed,
329
+            &DGUSTxHandler::FanSpeed),
330
+
331
+  VP_HELPER(DGUS_Addr::GCODE_Data,
332
+            DGUS_GCODE_LEN,
333
+            VPFLAG_RXSTRING,
334
+            (void*)DGUSScreenHandler::gcode,
335
+            &DGUSRxHandler::StringToExtra,
336
+            &DGUSTxHandler::ExtraToString),
337
+
338
+  VP_HELPER(DGUS_Addr::PID_Cycles,
339
+            2,
340
+            VPFLAG_NONE,
341
+            &DGUSScreenHandler::pid_cycles,
342
+            &DGUSRxHandler::IntegerToExtra<uint8_t>,
343
+            &DGUSTxHandler::ExtraToInteger<uint8_t>),
344
+
345
+  VP_HELPER(DGUS_Addr::VOLUME_Level,
346
+            2,
347
+            VPFLAG_NONE,
348
+            nullptr,
349
+            &DGUSRxHandler::Volume,
350
+            &DGUSTxHandler::Volume),
351
+
352
+  VP_HELPER(DGUS_Addr::BRIGHTNESS_Level,
353
+            2,
354
+            VPFLAG_NONE,
355
+            nullptr,
356
+            &DGUSRxHandler::Brightness,
357
+            &DGUSTxHandler::Brightness),
358
+
359
+  // SPECIAL CASES
360
+
361
+  VP_HELPER_TX(DGUS_Addr::STATUS_Percent_Complete, &DGUSTxHandler::Percent),
362
+  VP_HELPER_RX_NODATA(DGUS_Addr::INFOS_Debug, &DGUSRxHandler::Debug),
363
+
364
+  VP_HELPER((DGUS_Addr)0, 0, VPFLAG_NONE, nullptr, nullptr, nullptr)
365
+
366
+};
367
+
368
+#endif // DGUS_LCD_UI_RELOADED

+ 26
- 0
Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_VPList.h View File

@@ -0,0 +1,26 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "DGUS_VP.h"
25
+
26
+extern const struct DGUS_VP vp_list[];

+ 142
- 0
Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp View File

@@ -0,0 +1,142 @@
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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp
25
+ */
26
+
27
+#include "../../../inc/MarlinConfigPre.h"
28
+
29
+#if ENABLED(DGUS_LCD_UI_RELOADED)
30
+
31
+#include "../ui_api.h"
32
+#include "DGUSScreenHandler.h"
33
+
34
+namespace ExtUI {
35
+
36
+  void onStartup() { dgus_screen_handler.Init(); }
37
+
38
+  void onIdle() {
39
+    static bool processing = false;
40
+
41
+    // Prevent recursion
42
+    if (!processing) {
43
+      processing = true;
44
+      dgus_screen_handler.Loop();
45
+      processing = false;
46
+    }
47
+  }
48
+
49
+  void onPrinterKilled(PGM_P error, PGM_P component) {
50
+    dgus_screen_handler.PrinterKilled(error, component);
51
+  }
52
+
53
+  void onMediaInserted() { TERN_(SDSUPPORT, dgus_screen_handler.SDCardInserted()); }
54
+  void onMediaError()    { TERN_(SDSUPPORT, dgus_screen_handler.SDCardError()); }
55
+  void onMediaRemoved()  { TERN_(SDSUPPORT, dgus_screen_handler.SDCardRemoved()); }
56
+
57
+  void onPlayTone(const uint16_t frequency, const uint16_t duration) {
58
+    dgus_screen_handler.PlayTone(frequency, duration);
59
+  }
60
+
61
+  void onPrintTimerStarted() {
62
+    dgus_screen_handler.PrintTimerStarted();
63
+  }
64
+
65
+  void onPrintTimerPaused() {
66
+    dgus_screen_handler.PrintTimerPaused();
67
+  }
68
+
69
+  void onPrintTimerStopped() {
70
+    dgus_screen_handler.PrintTimerStopped();
71
+  }
72
+
73
+  void onFilamentRunout(const extruder_t extruder) {
74
+    dgus_screen_handler.FilamentRunout(extruder);
75
+  }
76
+
77
+  void onUserConfirmRequired(const char * const msg) {
78
+    dgus_screen_handler.UserConfirmRequired(msg);
79
+  }
80
+
81
+  void onStatusChanged(const char * const msg) {
82
+    dgus_screen_handler.SetStatusMessage(msg);
83
+  }
84
+
85
+  void onHomingStart() {}
86
+  void onHomingComplete() {}
87
+  void onPrintFinished() {}
88
+
89
+  void onFactoryReset() {
90
+    dgus_screen_handler.SettingsReset();
91
+  }
92
+
93
+  void onStoreSettings(char *buff) {
94
+    dgus_screen_handler.StoreSettings(buff);
95
+  }
96
+
97
+  void onLoadSettings(const char *buff) {
98
+    dgus_screen_handler.LoadSettings(buff);
99
+  }
100
+
101
+  void onPostprocessSettings() {}
102
+
103
+  void onConfigurationStoreWritten(bool success) {
104
+    dgus_screen_handler.ConfigurationStoreWritten(success);
105
+  }
106
+
107
+  void onConfigurationStoreRead(bool success) {
108
+    dgus_screen_handler.ConfigurationStoreRead(success);
109
+  }
110
+
111
+  #if HAS_MESH
112
+    void onMeshLevelingStart() {}
113
+
114
+    void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {
115
+      dgus_screen_handler.MeshUpdate(xpos, ypos);
116
+    }
117
+
118
+    void onMeshUpdate(const int8_t xpos, const int8_t ypos, const probe_state_t state) {
119
+      if (state == G29_POINT_FINISH)
120
+        dgus_screen_handler.MeshUpdate(xpos, ypos);
121
+    }
122
+  #endif
123
+
124
+  #if ENABLED(POWER_LOSS_RECOVERY)
125
+    void onPowerLossResume() {
126
+      // Called on resume from power-loss
127
+      dgus_screen_handler.PowerLossResume();
128
+    }
129
+  #endif
130
+
131
+  #if HAS_PID_HEATING
132
+    void onPidTuning(const result_t rst) {
133
+      // Called for temperature PID tuning result
134
+      dgus_screen_handler.PidTuning(rst);
135
+    }
136
+  #endif
137
+
138
+  void onSteppersDisabled() {}
139
+  void onSteppersEnabled()  {}
140
+}
141
+
142
+#endif // DGUS_LCD_UI_RELOADED

+ 2
- 1
ini/features.ini View File

@@ -78,7 +78,8 @@ HAS_MENU_TRAMMING                      = src_filter=+<src/lcd/menu/menu_tramming
78 78
 HAS_MENU_UBL                           = src_filter=+<src/lcd/menu/menu_ubl.cpp>
79 79
 ANYCUBIC_LCD_CHIRON                    = src_filter=+<src/lcd/extui/anycubic_chiron>
80 80
 ANYCUBIC_LCD_I3MEGA                    = src_filter=+<src/lcd/extui/anycubic_i3mega>
81
-HAS_DGUS_LCD                           = src_filter=+<src/lcd/extui/dgus>
81
+HAS_DGUS_LCD_CLASSIC                   = src_filter=+<src/lcd/extui/dgus>
82
+DGUS_LCD_UI_RELOADED                   = src_filter=+<src/lcd/extui/dgus_reloaded>
82 83
 DGUS_LCD_UI_FYSETC                     = src_filter=+<src/lcd/extui/dgus/fysetc>
83 84
 DGUS_LCD_UI_HIPRECY                    = src_filter=+<src/lcd/extui/dgus/hiprecy>
84 85
 DGUS_LCD_UI_MKS                        = src_filter=+<src/lcd/extui/dgus/mks>

+ 1
- 0
platformio.ini View File

@@ -77,6 +77,7 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
77 77
   -<src/lcd/extui/anycubic_chiron>
78 78
   -<src/lcd/extui/anycubic_i3mega>
79 79
   -<src/lcd/extui/dgus> -<src/lcd/extui/dgus/fysetc> -<src/lcd/extui/dgus/hiprecy> -<src/lcd/extui/dgus/mks> -<src/lcd/extui/dgus/origin>
80
+  -<src/lcd/extui/dgus_reloaded>
80 81
   -<src/lcd/extui/example>
81 82
   -<src/lcd/extui/ftdi_eve_touch_ui>
82 83
   -<src/lcd/extui/malyan>

Loading…
Cancel
Save