Sola пре 3 година
родитељ
комит
c76008bd6a
No account linked to committer's email address
33 измењених фајлова са 6313 додато и 719 уклоњено
  1. 1
    0
      Marlin/Configuration.h
  2. 3
    3
      Marlin/Configuration_adv.h
  3. 1
    1
      Marlin/src/HAL/STM32/eeprom_flash.cpp
  4. 1
    1
      Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp
  5. 7
    1
      Marlin/src/HAL/shared/eeprom_if_i2c.cpp
  6. 5
    0
      Marlin/src/MarlinCore.cpp
  7. 12
    3
      Marlin/src/gcode/sd/M24_M25.cpp
  8. 1
    1
      Marlin/src/inc/Conditionals_LCD.h
  9. 1
    1
      Marlin/src/inc/SanityCheck.h
  10. 2
    5
      Marlin/src/lcd/extui/dgus_lcd.cpp
  11. 23
    15
      Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp
  12. 6
    1
      Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h
  13. 7
    4
      Marlin/src/lcd/extui/lib/dgus/DGUSDisplayDef.h
  14. 95
    463
      Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp
  15. 25
    199
      Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.h
  16. 418
    0
      Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.cpp
  17. 240
    0
      Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.h
  18. 418
    0
      Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp
  19. 240
    0
      Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.h
  20. 795
    0
      Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp
  21. 908
    0
      Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h
  22. 2109
    0
      Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp
  23. 307
    0
      Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h
  24. 4
    2
      Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp
  25. 418
    0
      Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp
  26. 240
    0
      Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.h
  27. 2
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp
  28. 6
    8
      Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp
  29. 6
    6
      Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp
  30. 1
    1
      Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h
  31. 4
    4
      Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp
  32. 2
    0
      Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h
  33. 5
    0
      platformio.ini

+ 1
- 0
Marlin/Configuration.h Прегледај датотеку

@@ -2349,6 +2349,7 @@
2349 2349
 //#define DGUS_LCD_UI_ORIGIN
2350 2350
 //#define DGUS_LCD_UI_FYSETC
2351 2351
 //#define DGUS_LCD_UI_HIPRECY
2352
+//#define DGUS_LCD_UI_MKS
2352 2353
 
2353 2354
 //
2354 2355
 // Touch-screen LCD for Malyan M200/M300 printers

+ 3
- 3
Marlin/Configuration_adv.h Прегледај датотеку

@@ -1517,12 +1517,12 @@
1517 1517
 
1518 1518
   #define DGUS_UPDATE_INTERVAL_MS  500    // (ms) Interval between automatic screen updates
1519 1519
 
1520
-  #if EITHER(DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY)
1520
+  #if ANY(DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_MKS, DGUS_LCD_UI_HIPRECY)
1521 1521
     #define DGUS_PRINT_FILENAME           // Display the filename during printing
1522 1522
     #define DGUS_PREHEAT_UI               // Display a preheat screen during heatup
1523 1523
 
1524
-    #if ENABLED(DGUS_LCD_UI_FYSETC)
1525
-      //#define DGUS_UI_MOVE_DIS_OPTION   // Disabled by default for UI_FYSETC
1524
+    #if EITHER(DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_MKS)
1525
+      //#define DGUS_UI_MOVE_DIS_OPTION   // Disabled by default for FYSETC and MKS
1526 1526
     #else
1527 1527
       #define DGUS_UI_MOVE_DIS_OPTION     // Enabled by default for UI_HIPRECY
1528 1528
     #endif

+ 1
- 1
Marlin/src/HAL/STM32/eeprom_flash.cpp Прегледај датотеку

@@ -48,7 +48,7 @@
48 48
   #include "stm32_def.h"
49 49
 
50 50
   #define DEBUG_OUT ENABLED(EEPROM_CHITCHAT)
51
-  #include "src/core/debug_out.h"
51
+  #include "../../core/debug_out.h"
52 52
 
53 53
   #ifndef MARLIN_EEPROM_SIZE
54 54
     #define MARLIN_EEPROM_SIZE    0x1000 // 4KB

+ 1
- 1
Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp Прегледај датотеку

@@ -283,7 +283,7 @@ void CommonHandler_C(ContextStateFrame * frame, unsigned long lr, unsigned long
283 283
     savedFrame.CFSR = 0;
284 284
 
285 285
     frame->pc = (uint32_t)resume_from_fault; // Patch where to return to
286
-    frame->lr = 0xdeadbeef;  // If our handler returns (it shouldn't), let's make it trigger an exception immediately
286
+    frame->lr = 0xDEADBEEF;  // If our handler returns (it shouldn't), let's make it trigger an exception immediately
287 287
     frame->xpsr = _BV(24);   // Need to clean the PSR register to thumb II only
288 288
     MinSerial::force_using_default_output = true;
289 289
     return; // The CPU will resume in our handler hopefully, and we'll try to use default serial output

+ 7
- 1
Marlin/src/HAL/shared/eeprom_if_i2c.cpp Прегледај датотеку

@@ -32,7 +32,13 @@
32 32
 #include "eeprom_if.h"
33 33
 #include <Wire.h>
34 34
 
35
-void eeprom_init() { Wire.begin(); }
35
+void eeprom_init() {
36
+  Wire.begin(
37
+    #if PINS_EXIST(I2C_SCL, I2C_SDA)
38
+      uint8_t(I2C_SDA_PIN), uint8_t(I2C_SCL_PIN)
39
+    #endif
40
+  );
41
+}
36 42
 
37 43
 #if ENABLED(USE_SHARED_EEPROM)
38 44
 

+ 5
- 0
Marlin/src/MarlinCore.cpp Прегледај датотеку

@@ -231,6 +231,10 @@
231 231
   #include "feature/password/password.h"
232 232
 #endif
233 233
 
234
+#if ENABLED(DGUS_LCD_UI_MKS)
235
+  #include "lcd/extui/lib/dgus/DGUSScreenHandler.h"
236
+#endif
237
+
234 238
 PGMSTR(M112_KILL_STR, "M112 Shutdown");
235 239
 
236 240
 MarlinState marlin_state = MF_INITIALIZING;
@@ -388,6 +392,7 @@ void startOrResumeJob() {
388 392
     if (queue.enqueue_one_P(PSTR("M1001"))) {
389 393
       marlin_state = MF_RUNNING;
390 394
       TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine());
395
+      TERN_(DGUS_LCD_UI_MKS, ScreenHandler.SDPrintingFinished());
391 396
     }
392 397
   }
393 398
 

+ 12
- 3
Marlin/src/gcode/sd/M24_M25.cpp Прегледај датотеку

@@ -41,6 +41,10 @@
41 41
   #include "../../feature/powerloss.h"
42 42
 #endif
43 43
 
44
+#if ENABLED(DGUS_LCD_UI_MKS)
45
+  #include "../../lcd/extui/lib/dgus/DGUSDisplayDef.h"
46
+#endif
47
+
44 48
 #include "../../MarlinCore.h" // for startOrResumeJob
45 49
 
46 50
 /**
@@ -48,6 +52,11 @@
48 52
  */
49 53
 void GcodeSuite::M24() {
50 54
 
55
+  #if ENABLED(DGUS_LCD_UI_MKS)
56
+    if ((print_job_timer.isPaused() || print_job_timer.isRunning()) && !parser.seen("ST"))
57
+      MKS_resume_print_move();
58
+  #endif
59
+
51 60
   #if ENABLED(POWER_LOSS_RECOVERY)
52 61
     if (parser.seenval('S')) card.setIndex(parser.value_long());
53 62
     if (parser.seenval('T')) print_job_timer.resume(parser.value_long());
@@ -98,9 +107,9 @@ void GcodeSuite::M25() {
98 107
 
99 108
     print_job_timer.pause();
100 109
 
101
-    #if DISABLED(DWIN_CREALITY_LCD)
102
-      ui.reset_status();
103
-    #endif
110
+    TERN_(DGUS_LCD_UI_MKS, MKS_pause_print_move());
111
+
112
+    IF_DISABLED(DWIN_CREALITY_LCD, ui.reset_status());
104 113
 
105 114
     #if ENABLED(HOST_ACTION_COMMANDS)
106 115
       TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("Pause SD"), PSTR("Resume")));

+ 1
- 1
Marlin/src/inc/Conditionals_LCD.h Прегледај датотеку

@@ -451,7 +451,7 @@
451 451
 #endif
452 452
 
453 453
 // Aliases for LCD features
454
-#if ANY(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY)
454
+#if ANY(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY,DGUS_LCD_UI_MKS)
455 455
   #define HAS_DGUS_LCD 1
456 456
 #endif
457 457
 

+ 1
- 1
Marlin/src/inc/SanityCheck.h Прегледај датотеку

@@ -2324,7 +2324,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
2324 2324
   + (DISABLED(IS_LEGACY_TFT) && ENABLED(TFT_GENERIC)) \
2325 2325
   + (ENABLED(IS_LEGACY_TFT) && COUNT_ENABLED(TFT_320x240, TFT_320x240_SPI, TFT_480x320, TFT_480x320_SPI)) \
2326 2326
   + COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35) \
2327
-  + COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY) \
2327
+  + COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY,DGUS_LCD_UI_MKS) \
2328 2328
   + COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY, DWIN_CREALITY_LCD) \
2329 2329
   + 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) \
2330 2330
   + COUNT_ENABLED(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004) \

+ 2
- 5
Marlin/src/lcd/extui/dgus_lcd.cpp Прегледај датотеку

@@ -21,9 +21,7 @@
21 21
  */
22 22
 
23 23
 /**
24
- * dgus_lcd.cpp
25
- *
26
- * DGUS implementation for Marlin by coldtobi, Feb-May 2019
24
+ * lcd/extui/dgus_lcd.cpp
27 25
  */
28 26
 
29 27
 #include "../../inc/MarlinConfigPre.h"
@@ -125,11 +123,10 @@ namespace ExtUI {
125 123
   #if ENABLED(POWER_LOSS_RECOVERY)
126 124
     void onPowerLossResume() {
127 125
       // Called on resume from power-loss
128
-      ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POWER_LOSS);
126
+      IF_DISABLED(DGUS_LCD_UI_MKS, ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POWER_LOSS));
129 127
     }
130 128
   #endif
131 129
 
132
-
133 130
   #if HAS_PID_HEATING
134 131
     void onPidTuning(const result_t rst) {
135 132
       // Called for temperature PID tuning result

+ 23
- 15
Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp Прегледај датотеку

@@ -20,14 +20,12 @@
20 20
  *
21 21
  */
22 22
 
23
-/* DGUS implementation written by coldtobi in 2019 for Marlin */
24
-
25 23
 #include "../../../../inc/MarlinConfigPre.h"
26 24
 
27 25
 #if HAS_DGUS_LCD
28 26
 
29 27
 #if HOTENDS > 2
30
-  #error "More than 2 hotends not implemented on the Display UI design."
28
+  #warning "More than 2 hotends not implemented on DGUS Display UI."
31 29
 #endif
32 30
 
33 31
 #include "../../ui_api.h"
@@ -46,6 +44,8 @@
46 44
 #include "DGUSVPVariable.h"
47 45
 #include "DGUSDisplayDef.h"
48 46
 
47
+DGUSDisplay dgusdisplay;
48
+
49 49
 // Preamble... 2 Bytes, usually 0x5A 0xA5, but configurable
50 50
 constexpr uint8_t DGUS_HEADER1 = 0x5A;
51 51
 constexpr uint8_t DGUS_HEADER2 = 0xA5;
@@ -62,8 +62,10 @@ void DGUSDisplay::InitDisplay() {
62 62
     #define LCD_BAUDRATE 115200
63 63
   #endif
64 64
   LCD_SERIAL.begin(LCD_BAUDRATE);
65
-  if (TERN1(POWER_LOSS_RECOVERY, !recovery.valid()))
66
-    RequestScreen(TERN(SHOW_BOOTSCREEN, DGUSLCD_SCREEN_BOOT, DGUSLCD_SCREEN_MAIN));
65
+  #if BOTH(DGUS_LCD_UI_MKS, POWER_LOSS_RECOVERY)
66
+    if (!recovery.valid()) delay(LOGO_TIME_DELAY);
67
+  #endif
68
+  RequestScreen(TERN(SHOW_BOOTSCREEN, DGUSLCD_SCREEN_BOOT, DGUSLCD_SCREEN_MAIN));
67 69
 }
68 70
 
69 71
 void DGUSDisplay::WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr) {
@@ -82,12 +84,12 @@ void DGUSDisplay::WriteVariable(uint16_t adr, const void* values, uint8_t values
82 84
 }
83 85
 
84 86
 void DGUSDisplay::WriteVariable(uint16_t adr, uint16_t value) {
85
-  value = (value & 0xffU) << 8U | (value >> 8U);
87
+  value = (value & 0xFFU) << 8U | (value >> 8U);
86 88
   WriteVariable(adr, static_cast<const void*>(&value), sizeof(uint16_t));
87 89
 }
88 90
 
89 91
 void DGUSDisplay::WriteVariable(uint16_t adr, int16_t value) {
90
-  value = (value & 0xffU) << 8U | (value >> 8U);
92
+  value = (value & 0xFFU) << 8U | (value >> 8U);
91 93
   WriteVariable(adr, static_cast<const void*>(&value), sizeof(uint16_t));
92 94
 }
93 95
 
@@ -99,15 +101,21 @@ void DGUSDisplay::WriteVariable(uint16_t adr, int8_t value) {
99 101
   WriteVariable(adr, static_cast<const void*>(&value), sizeof(int8_t));
100 102
 }
101 103
 
104
+#if ENABLED(DGUS_LCD_UI_MKS)
105
+  void DGUSDisplay::MKS_WriteVariable(uint16_t adr, uint8_t value) {
106
+    WriteVariable(adr, static_cast<const void *>(&value), sizeof(uint8_t));
107
+  }
108
+#endif
109
+
102 110
 void DGUSDisplay::WriteVariable(uint16_t adr, long value) {
103
-    union { long l; char lb[4]; } endian;
104
-    char tmp[4];
105
-    endian.l = value;
106
-    tmp[0] = endian.lb[3];
107
-    tmp[1] = endian.lb[2];
108
-    tmp[2] = endian.lb[1];
109
-    tmp[3] = endian.lb[0];
110
-    WriteVariable(adr, static_cast<const void*>(&tmp), sizeof(long));
111
+  union { long l; char lb[4]; } endian;
112
+  char tmp[4];
113
+  endian.l = value;
114
+  tmp[0] = endian.lb[3];
115
+  tmp[1] = endian.lb[2];
116
+  tmp[2] = endian.lb[1];
117
+  tmp[3] = endian.lb[0];
118
+  WriteVariable(adr, static_cast<const void*>(&tmp), sizeof(long));
111 119
 }
112 120
 
113 121
 void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr) {

+ 6
- 1
Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h Прегледај датотеку

@@ -21,7 +21,9 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-/* DGUS implementation written by coldtobi in 2019 for Marlin */
24
+/**
25
+ * lcd/extui/lib/dgus/DGUSDisplay.h
26
+ */
25 27
 
26 28
 #include "../../../../inc/MarlinConfigPre.h"
27 29
 
@@ -34,6 +36,7 @@
34 36
 
35 37
 enum DGUSLCD_Screens : uint8_t;
36 38
 
39
+//#define DEBUG_DGUSLCD
37 40
 #define DEBUG_OUT ENABLED(DEBUG_DGUSLCD)
38 41
 #include "../../../../core/debug_out.h"
39 42
 
@@ -60,6 +63,8 @@ public:
60 63
   static void WriteVariable(uint16_t adr, uint8_t value);
61 64
   static void WriteVariable(uint16_t adr, int8_t value);
62 65
   static void WriteVariable(uint16_t adr, long value);
66
+  static void MKS_WriteVariable(uint16_t adr, uint8_t value);
67
+
63 68
 
64 69
   // Utility functions for bridging ui_api and dbus
65 70
   template<typename T, float(*Getter)(const T), T selector, typename WireType=uint16_t>

+ 7
- 4
Marlin/src/lcd/extui/lib/dgus/DGUSDisplayDef.h Прегледај датотеку

@@ -21,15 +21,16 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-/* DGUS implementation written by coldtobi in 2019 for Marlin */
24
+/**
25
+ * lcd/extui/lib/dgus/DGUSDisplayDef.h
26
+ * Defines the interaction between Marlin and the display firmware
27
+ */
25 28
 
26 29
 #include "DGUSVPVariable.h"
27 30
 
28 31
 #include <stdint.h>
29 32
 
30
-// This file defines the interaction between Marlin and the display firmware.
31
-
32
-// information on which screen which VP is displayed
33
+// Information on which screen which VP is displayed.
33 34
 // As this is a sparse table, two arrays are needed:
34 35
 // one to list the VPs of one screen and one to map screens to the lists.
35 36
 // (Strictly this would not be necessary, but allows to only send data the display needs and reducing load on Marlin)
@@ -47,6 +48,8 @@ extern const struct DGUS_VP_Variable ListOfVP[];
47 48
 
48 49
 #if ENABLED(DGUS_LCD_UI_ORIGIN)
49 50
   #include "origin/DGUSDisplayDef.h"
51
+#elif ENABLED(DGUS_LCD_UI_MKS)
52
+  #include "mks/DGUSDisplayDef.h"
50 53
 #elif ENABLED(DGUS_LCD_UI_FYSETC)
51 54
   #include "fysetc/DGUSDisplayDef.h"
52 55
 #elif ENABLED(DGUS_LCD_UI_HIPRECY)

+ 95
- 463
Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp Прегледај датотеку

@@ -25,35 +25,24 @@
25 25
 #if HAS_DGUS_LCD
26 26
 
27 27
 #include "DGUSScreenHandler.h"
28
-#include "DGUSDisplay.h"
29
-#include "DGUSVPVariable.h"
30
-#include "DGUSDisplayDef.h"
31 28
 
32
-#include "../../ui_api.h"
33 29
 #include "../../../../MarlinCore.h"
30
+#include "../../../../gcode/queue.h"
31
+#include "../../../../libs/duration_t.h"
32
+#include "../../../../module/settings.h"
34 33
 #include "../../../../module/temperature.h"
35 34
 #include "../../../../module/motion.h"
36
-#include "../../../../gcode/queue.h"
37 35
 #include "../../../../module/planner.h"
38
-#include "../../../../sd/cardreader.h"
39
-#include "../../../../libs/duration_t.h"
40 36
 #include "../../../../module/printcounter.h"
37
+#include "../../../../sd/cardreader.h"
41 38
 
42 39
 #if ENABLED(POWER_LOSS_RECOVERY)
43 40
   #include "../../../../feature/powerloss.h"
44 41
 #endif
45 42
 
46
-uint16_t DGUSScreenHandler::ConfirmVP;
47
-
48
-#if ENABLED(SDSUPPORT)
49
-  int16_t DGUSScreenHandler::top_file = 0;
50
-  int16_t DGUSScreenHandler::file_to_print = 0;
51
-  static ExtUI::FileList filelist;
52
-#endif
53
-
54
-void (*DGUSScreenHandler::confirm_action_cb)() = nullptr;
43
+DGUSScreenHandler ScreenHandler;
55 44
 
56
-//DGUSScreenHandler ScreenHandler;
45
+uint16_t DGUSScreenHandler::ConfirmVP;
57 46
 
58 47
 DGUSLCD_Screens DGUSScreenHandler::current_screen;
59 48
 DGUSLCD_Screens DGUSScreenHandler::past_screens[NUM_PAST_SCREENS];
@@ -61,10 +50,17 @@ uint8_t DGUSScreenHandler::update_ptr;
61 50
 uint16_t DGUSScreenHandler::skipVP;
62 51
 bool DGUSScreenHandler::ScreenComplete;
63 52
 
64
-//DGUSDisplay dgusdisplay;
53
+void (*DGUSScreenHandler::confirm_action_cb)() = nullptr;
65 54
 
66
-// endianness swap
67
-uint16_t swap16(const uint16_t value) { return (value & 0xffU) << 8U | (value >> 8U); }
55
+#if ENABLED(SDSUPPORT)
56
+  int16_t DGUSScreenHandler::top_file = 0,
57
+          DGUSScreenHandler::file_to_print = 0;
58
+  static ExtUI::FileList filelist;
59
+#endif
60
+
61
+#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
62
+  filament_data_t filament_data;
63
+#endif
68 64
 
69 65
 void DGUSScreenHandler::sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) {
70 66
   DGUS_VP_Variable ramcopy;
@@ -87,14 +83,12 @@ void DGUSScreenHandler::sendinfoscreen(const char* line1, const char* line2, con
87 83
 }
88 84
 
89 85
 void DGUSScreenHandler::HandleUserConfirmationPopUp(uint16_t VP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1, bool l2, bool l3, bool l4) {
90
-  if (current_screen == DGUSLCD_SCREEN_CONFIRM) {
91
-    // Already showing a pop up, so we need to cancel that first.
86
+  if (current_screen == DGUSLCD_SCREEN_CONFIRM) // Already showing a pop up, so we need to cancel that first.
92 87
     PopToOldScreen();
93
-  }
94 88
 
95 89
   ConfirmVP = VP;
96 90
   sendinfoscreen(line1, line2, line3, line4, l1, l2, l3, l4);
97
-  ScreenHandler.GotoScreen(DGUSLCD_SCREEN_CONFIRM);
91
+  GotoScreen(DGUSLCD_SCREEN_CONFIRM);
98 92
 }
99 93
 
100 94
 void DGUSScreenHandler::setstatusmessage(const char *msg) {
@@ -130,7 +124,7 @@ void DGUSScreenHandler::DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var) {
130 124
   if (var.memadr) {
131 125
     //DEBUG_ECHOPAIR(" DGUS_LCD_SendWordValueToDisplay ", var.VP);
132 126
     //DEBUG_ECHOLNPAIR(" data ", *(uint16_t *)var.memadr);
133
-    uint16_t tmp = *(uint8_t *) var.memadr +1 ; // +1 -> avoid rounding issues for the display.
127
+    uint16_t tmp = *(uint8_t *) var.memadr + 1; // +1 -> avoid rounding issues for the display.
134 128
     tmp = map(tmp, 0, 255, 0, 100);
135 129
     dgusdisplay.WriteVariable(var.VP, tmp);
136 130
   }
@@ -157,7 +151,9 @@ void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) {
157 151
 void DGUSScreenHandler::DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr) {
158 152
   if (var.memadr) {
159 153
     uint16_t value = swap16(*(uint16_t*)val_ptr);
154
+    DEBUG_ECHOLNPAIR("FAN value get:", value);
160 155
     *(uint8_t*)var.memadr = map(constrain(value, 0, 100), 0, 100, 0, 255);
156
+    DEBUG_ECHOLNPAIR("FAN value change:", *(uint8_t*)var.memadr);
161 157
   }
162 158
 }
163 159
 
@@ -234,6 +230,7 @@ void DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var) {
234 230
 
235 231
 // Send fan status value to the display.
236 232
 #if HAS_FAN
233
+
237 234
   void DGUSScreenHandler::DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var) {
238 235
     if (var.memadr) {
239 236
       DEBUG_ECHOPAIR(" DGUSLCD_SendFanStatusToDisplay ", var.VP);
@@ -243,6 +240,7 @@ void DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var) {
243 240
       dgusdisplay.WriteVariable(var.VP, data_to_send);
244 241
     }
245 242
   }
243
+
246 244
 #endif
247 245
 
248 246
 // Send heater status value to the display.
@@ -257,6 +255,7 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var)
257 255
 }
258 256
 
259 257
 #if ENABLED(DGUS_UI_WAITING)
258
+
260 259
   void DGUSScreenHandler::DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var) {
261 260
     // In FYSETC UI design there are 10 statuses to loop
262 261
     static uint16_t period = 0;
@@ -270,6 +269,7 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var)
270 269
       period = 0;
271 270
     }
272 271
   }
272
+
273 273
 #endif
274 274
 
275 275
 #if ENABLED(SDSUPPORT)
@@ -319,7 +319,7 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var)
319 319
       DEBUG_ECHOPAIR("new topfile adjusted:", top_file);
320 320
     }
321 321
     else if (!filelist.isAtRootDir()) {
322
-      filelist.upDir();
322
+      IF_DISABLED(DGUS_LCD_UI_MKS, filelist.upDir());
323 323
       top_file = 0;
324 324
       ForceCompleteUpdate();
325 325
     }
@@ -327,54 +327,6 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var)
327 327
     if (old_top != top_file) ForceCompleteUpdate();
328 328
   }
329 329
 
330
-  void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) {
331
-    uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file;
332
-    if (touched_nr > filelist.count()) return;
333
-    if (!filelist.seek(touched_nr)) return;
334
-    if (filelist.isDir()) {
335
-      filelist.changeDir(filelist.filename());
336
-      top_file = 0;
337
-      ForceCompleteUpdate();
338
-      return;
339
-    }
340
-
341
-    #if ENABLED(DGUS_PRINT_FILENAME)
342
-      // Send print filename
343
-      dgusdisplay.WriteVariable(VP_SD_Print_Filename, filelist.filename(), VP_SD_FileName_LEN, true);
344
-    #endif
345
-
346
-    // Setup Confirmation screen
347
-    file_to_print = touched_nr;
348
-    HandleUserConfirmationPopUp(VP_SD_FileSelectConfirm, nullptr, PSTR("Print file"), filelist.filename(), PSTR("from SD Card?"), true, true, false, true);
349
-  }
350
-
351
-  void DGUSScreenHandler::DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr) {
352
-    if (!filelist.seek(file_to_print)) return;
353
-    ExtUI::printFile(filelist.shortFilename());
354
-    ScreenHandler.GotoScreen(
355
-      #if ENABLED(DGUS_LCD_UI_ORIGIN)
356
-        DGUSLCD_SCREEN_STATUS
357
-      #else
358
-        DGUSLCD_SCREEN_SDPRINTMANIPULATION
359
-      #endif
360
-    );
361
-  }
362
-
363
-  void DGUSScreenHandler::DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr) {
364
-    if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes.
365
-    switch (swap16(*(uint16_t*)val_ptr)) {
366
-      case 0:  // Resume
367
-        if (ExtUI::isPrintingFromMediaPaused()) ExtUI::resumePrint();
368
-        break;
369
-      case 1:  // Pause
370
-        if (!ExtUI::isPrintingFromMediaPaused()) ExtUI::pausePrint();
371
-        break;
372
-      case 2:  // Abort
373
-        ScreenHandler.HandleUserConfirmationPopUp(VP_SD_AbortPrintConfirmed, nullptr, PSTR("Abort printing"), filelist.filename(), PSTR("?"), true, true, false, true);
374
-        break;
375
-    }
376
-  }
377
-
378 330
   void DGUSScreenHandler::DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr) {
379 331
     ExtUI::stopPrint();
380 332
     GotoScreen(DGUSLCD_SCREEN_MAIN);
@@ -385,36 +337,11 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var)
385 337
     GotoScreen(DGUSLCD_SCREEN_SDPRINTTUNE);
386 338
   }
387 339
 
388
-  void DGUSScreenHandler::DGUSLCD_SD_SendFilename(DGUS_VP_Variable& var) {
389
-    uint16_t target_line = (var.VP - VP_SD_FileName0) / VP_SD_FileName_LEN;
390
-    if (target_line > DGUS_SD_FILESPERSCREEN) return;
391
-    char tmpfilename[VP_SD_FileName_LEN + 1] = "";
392
-    var.memadr = (void*)tmpfilename;
393
-    if (filelist.seek(top_file + target_line))
394
-      snprintf_P(tmpfilename, VP_SD_FileName_LEN, PSTR("%s%c"), filelist.filename(), filelist.isDir() ? '/' : 0);
395
-    DGUSLCD_SendStringToDisplay(var);
396
-  }
397
-
398
-  void DGUSScreenHandler::SDCardInserted() {
399
-    top_file = 0;
400
-    filelist.refresh();
401
-    auto cs = ScreenHandler.getCurrentScreen();
402
-    if (cs == DGUSLCD_SCREEN_MAIN || cs == DGUSLCD_SCREEN_STATUS)
403
-      ScreenHandler.GotoScreen(DGUSLCD_SCREEN_SDFILELIST);
404
-  }
405
-
406
-  void DGUSScreenHandler::SDCardRemoved() {
407
-    if (current_screen == DGUSLCD_SCREEN_SDFILELIST
408
-        || (current_screen == DGUSLCD_SCREEN_CONFIRM && (ConfirmVP == VP_SD_AbortPrintConfirmed || ConfirmVP == VP_SD_FileSelectConfirm))
409
-        || current_screen == DGUSLCD_SCREEN_SDPRINTMANIPULATION
410
-    ) ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN);
411
-  }
412
-
413 340
   void DGUSScreenHandler::SDCardError() {
414 341
     DGUSScreenHandler::SDCardRemoved();
415
-    ScreenHandler.sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("SD card error"), nullptr, true, true, true, true);
416
-    ScreenHandler.SetupConfirmAction(nullptr);
417
-    ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POPUP);
342
+    sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("SD card error"), nullptr, true, true, true, true);
343
+    SetupConfirmAction(nullptr);
344
+    GotoScreen(DGUSLCD_SCREEN_POPUP);
418 345
   }
419 346
 
420 347
 #endif // SDSUPPORT
@@ -428,7 +355,7 @@ void DGUSScreenHandler::ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr)
428 355
 const uint16_t* DGUSLCD_FindScreenVPMapList(uint8_t screen) {
429 356
   const uint16_t *ret;
430 357
   const struct VPMapping *map = VPMap;
431
-  while (ret = (uint16_t*) pgm_read_ptr(&(map->VPList))) {
358
+  while ((ret = (uint16_t*) pgm_read_ptr(&(map->VPList)))) {
432 359
     if (pgm_read_byte(&(map->screen)) == screen) return ret;
433 360
     map++;
434 361
   }
@@ -455,31 +382,9 @@ void DGUSScreenHandler::ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_
455 382
   }
456 383
 }
457 384
 
458
-void DGUSScreenHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) {
459
-  uint8_t *tmp = (uint8_t*)val_ptr;
460
-
461
-  // The keycode in target is coded as <from-frame><to-frame>, so 0x0100A means
462
-  // from screen 1 (main) to 10 (temperature). DGUSLCD_SCREEN_POPUP is special,
463
-  // meaning "return to previous screen"
464
-  DGUSLCD_Screens target = (DGUSLCD_Screens)tmp[1];
465
-
466
-  if (target == DGUSLCD_SCREEN_POPUP) {
467
-    // special handling for popup is to return to previous menu
468
-    if (current_screen == DGUSLCD_SCREEN_POPUP && confirm_action_cb) confirm_action_cb();
469
-    PopToOldScreen();
470
-    return;
471
-  }
472
-
473
-  UpdateNewScreen(target);
474
-
475
-  #ifdef DEBUG_DGUSLCD
476
-    if (!DGUSLCD_FindScreenVPMapList(target)) DEBUG_ECHOLNPAIR("WARNING: No screen Mapping found for ", target);
477
-  #endif
478
-}
479
-
480 385
 void DGUSScreenHandler::HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr) {
481 386
   thermalManager.disable_all_heaters();
482
-  ScreenHandler.ForceCompleteUpdate(); // hint to send all data.
387
+  ForceCompleteUpdate(); // hint to send all data.
483 388
 }
484 389
 
485 390
 void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr) {
@@ -498,7 +403,7 @@ void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *va
498 403
       case VP_T_E1_Set:
499 404
         thermalManager.setTargetHotend(newvalue, 1);
500 405
         acceptedvalue = thermalManager.temp_hotend[1].target;
501
-      break;
406
+        break;
502 407
     #endif
503 408
     #if HAS_HEATED_BED
504 409
       case VP_T_Bed_Set:
@@ -510,7 +415,7 @@ void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *va
510 415
 
511 416
   // reply to display the new value to update the view if the new value was rejected by the Thermal Manager.
512 417
   if (newvalue != acceptedvalue && var.send_to_display_handler) var.send_to_display_handler(var);
513
-  ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
418
+  skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
514 419
 }
515 420
 
516 421
 void DGUSScreenHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr) {
@@ -528,7 +433,7 @@ void DGUSScreenHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_p
528 433
     }
529 434
 
530 435
     planner.set_flow(target_extruder, newvalue);
531
-    ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
436
+    skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
532 437
   #else
533 438
     UNUSED(var); UNUSED(val_ptr);
534 439
   #endif
@@ -563,97 +468,6 @@ void DGUSScreenHandler::HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr
563 468
   }
564 469
 #endif
565 470
 
566
-void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
567
-  DEBUG_ECHOLNPGM("HandleManualMove");
568
-
569
-  int16_t movevalue = swap16(*(uint16_t*)val_ptr);
570
-  #if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
571
-    if (movevalue) {
572
-      const uint16_t choice = *(uint16_t*)var.memadr;
573
-      movevalue = movevalue < 0 ? -choice : choice;
574
-    }
575
-  #endif
576
-  char axiscode;
577
-  unsigned int speed = 1500;  //FIXME: get default feedrate for manual moves, dont hardcode.
578
-
579
-  switch (var.VP) {
580
-    default: return;
581
-
582
-    case VP_MOVE_X:
583
-      axiscode = 'X';
584
-      if (!ExtUI::canMove(ExtUI::axis_t::X)) goto cannotmove;
585
-      break;
586
-
587
-    case VP_MOVE_Y:
588
-      axiscode = 'Y';
589
-      if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove;
590
-      break;
591
-
592
-    case VP_MOVE_Z:
593
-      axiscode = 'Z';
594
-      speed = 300; // default to 5mm/s
595
-      if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove;
596
-      break;
597
-
598
-    case VP_HOME_ALL: // only used for homing
599
-      axiscode = '\0';
600
-      movevalue = 0; // ignore value sent from display, this VP is _ONLY_ for homing.
601
-      break;
602
-  }
603
-
604
-  if (!movevalue) {
605
-    // homing
606
-    DEBUG_ECHOPAIR(" homing ", axiscode);
607
-    char buf[6] = "G28 X";
608
-    buf[4] = axiscode;
609
-    //DEBUG_ECHOPAIR(" ", buf);
610
-    queue.enqueue_one_now(buf);
611
-    //DEBUG_ECHOLNPGM(" ✓");
612
-    ScreenHandler.ForceCompleteUpdate();
613
-    return;
614
-  }
615
-  else {
616
-    //movement
617
-    DEBUG_ECHOPAIR(" move ", axiscode);
618
-    bool old_relative_mode = relative_mode;
619
-    if (!relative_mode) {
620
-      //DEBUG_ECHOPGM(" G91");
621
-      queue.enqueue_now_P(PSTR("G91"));
622
-      //DEBUG_ECHOPGM(" ✓ ");
623
-    }
624
-    char buf[32];  // G1 X9999.99 F12345
625
-    unsigned int backup_speed = MMS_TO_MMM(feedrate_mm_s);
626
-    char sign[]="\0";
627
-    int16_t value = movevalue / 100;
628
-    if (movevalue < 0) { value = -value; sign[0] = '-'; }
629
-    int16_t fraction = ABS(movevalue) % 100;
630
-    snprintf_P(buf, 32, PSTR("G0 %c%s%d.%02d F%d"), axiscode, sign, value, fraction, speed);
631
-    //DEBUG_ECHOPAIR(" ", buf);
632
-    queue.enqueue_one_now(buf);
633
-    //DEBUG_ECHOLNPGM(" ✓ ");
634
-    if (backup_speed != speed) {
635
-      snprintf_P(buf, 32, PSTR("G0 F%d"), backup_speed);
636
-      queue.enqueue_one_now(buf);
637
-      //DEBUG_ECHOPAIR(" ", buf);
638
-    }
639
-    //while (!enqueue_and_echo_command(buf)) idle();
640
-    //DEBUG_ECHOLNPGM(" ✓ ");
641
-    if (!old_relative_mode) {
642
-      //DEBUG_ECHOPGM("G90");
643
-      queue.enqueue_now_P(PSTR("G90"));
644
-      //DEBUG_ECHOPGM(" ✓ ");
645
-    }
646
-  }
647
-
648
-  ScreenHandler.ForceCompleteUpdate();
649
-  DEBUG_ECHOLNPGM("manmv done.");
650
-  return;
651
-
652
-  cannotmove:
653
-  DEBUG_ECHOLNPAIR(" cannot move ", axiscode);
654
-  return;
655
-}
656
-
657 471
 void DGUSScreenHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr) {
658 472
   DEBUG_ECHOLNPGM("HandleMotorLockUnlock");
659 473
 
@@ -665,22 +479,6 @@ void DGUSScreenHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_p
665 479
   queue.enqueue_one_now(buf);
666 480
 }
667 481
 
668
-#if ENABLED(POWER_LOSS_RECOVERY)
669
-
670
-  void DGUSScreenHandler::HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr) {
671
-    uint16_t value = swap16(*(uint16_t*)val_ptr);
672
-    if (value) {
673
-      queue.inject_P(PSTR("M1000"));
674
-      ScreenHandler.GotoScreen(DGUSLCD_SCREEN_SDPRINTMANIPULATION);
675
-    }
676
-    else {
677
-      recovery.cancel();
678
-      ScreenHandler.GotoScreen(DGUSLCD_SCREEN_STATUS);
679
-    }
680
-  }
681
-
682
-#endif
683
-
684 482
 void DGUSScreenHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) {
685 483
   DEBUG_ECHOLNPGM("HandleSettings");
686 484
   uint16_t value = swap16(*(uint16_t*)val_ptr);
@@ -688,10 +486,11 @@ void DGUSScreenHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) {
688 486
     default: break;
689 487
     case 1:
690 488
       TERN_(PRINTCOUNTER, print_job_timer.initStats());
691
-      queue.inject_P(PSTR("M502\nM500"));
489
+      settings.reset();
490
+      settings.save();
692 491
       break;
693
-    case 2: queue.inject_P(PSTR("M501")); break;
694
-    case 3: queue.inject_P(PSTR("M500")); break;
492
+    case 2: settings.load(); break;
493
+    case 3: settings.save(); break;
695 494
   }
696 495
 }
697 496
 
@@ -700,7 +499,7 @@ void DGUSScreenHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_
700 499
 
701 500
   uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
702 501
   DEBUG_ECHOLNPAIR("value_raw:", value_raw);
703
-  float value = (float)value_raw/10;
502
+  float value = (float)value_raw / 10;
704 503
   ExtUI::axis_t axis;
705 504
   switch (var.VP) {
706 505
     case VP_X_STEP_PER_MM: axis = ExtUI::axis_t::X; break;
@@ -711,7 +510,7 @@ void DGUSScreenHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_
711 510
   DEBUG_ECHOLNPAIR_F("value:", value);
712 511
   ExtUI::setAxisSteps_per_mm(value, axis);
713 512
   DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(axis));
714
-  ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
513
+  skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
715 514
   return;
716 515
 }
717 516
 
@@ -720,56 +519,24 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, vo
720 519
 
721 520
   uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
722 521
   DEBUG_ECHOLNPAIR("value_raw:", value_raw);
723
-  float value = (float)value_raw/10;
522
+  float value = (float)value_raw / 10;
724 523
   ExtUI::extruder_t extruder;
725 524
   switch (var.VP) {
726 525
     default: return;
727
-    #if HOTENDS >= 1
728
-      case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break;
729
-    #endif
730
-    #if HOTENDS >= 2
731
-      case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break;
732
-    #endif
733
-  }
734
-  DEBUG_ECHOLNPAIR_F("value:", value);
735
-  ExtUI::setAxisSteps_per_mm(value,extruder);
736
-  DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(extruder));
737
-  ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
738
-  return;
739
-}
740
-
741
-#if HAS_PID_HEATING
742
-  void DGUSScreenHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) {
743
-    uint16_t rawvalue = swap16(*(uint16_t*)val_ptr);
744
-    DEBUG_ECHOLNPAIR("V1:", rawvalue);
745
-    float value = (float)rawvalue / 10;
746
-    DEBUG_ECHOLNPAIR("V2:", value);
747
-    float newvalue = 0;
748
-
749
-    switch (var.VP) {
750
-      default: return;
751 526
       #if HOTENDS >= 1
752
-        case VP_E0_PID_P: newvalue = value; break;
753
-        case VP_E0_PID_I: newvalue = scalePID_i(value); break;
754
-        case VP_E0_PID_D: newvalue = scalePID_d(value); break;
527
+        case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break;
755 528
       #endif
756 529
       #if HOTENDS >= 2
757
-        case VP_E1_PID_P: newvalue = value; break;
758
-        case VP_E1_PID_I: newvalue = scalePID_i(value); break;
759
-        case VP_E1_PID_D: newvalue = scalePID_d(value); break;
530
+        case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break;
760 531
       #endif
761
-      #if HAS_HEATED_BED
762
-        case VP_BED_PID_P: newvalue = value; break;
763
-        case VP_BED_PID_I: newvalue = scalePID_i(value); break;
764
-        case VP_BED_PID_D: newvalue = scalePID_d(value); break;
765
-      #endif
766
-    }
767
-
768
-    DEBUG_ECHOLNPAIR_F("V3:", newvalue);
769
-    *(float *)var.memadr = newvalue;
770
-    ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
771 532
   }
533
+  DEBUG_ECHOLNPAIR_F("value:", value);
534
+  ExtUI::setAxisSteps_per_mm(value, extruder);
535
+  DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(extruder));
536
+  skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
537
+}
772 538
 
539
+#if HAS_PID_HEATING
773 540
   void DGUSScreenHandler::HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr) {
774 541
     DEBUG_ECHOLNPGM("HandlePIDAutotune");
775 542
 
@@ -777,23 +544,23 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, vo
777 544
 
778 545
     switch (var.VP) {
779 546
       default: break;
780
-      #if ENABLED(PIDTEMP)
781
-        #if HOTENDS >= 1
782
-          case VP_PID_AUTOTUNE_E0: // Autotune Extruder 0
783
-            sprintf(buf, "M303 E%d C5 S210 U1", ExtUI::extruder_t::E0);
784
-            break;
547
+        #if ENABLED(PIDTEMP)
548
+          #if HOTENDS >= 1
549
+            case VP_PID_AUTOTUNE_E0: // Autotune Extruder 0
550
+              sprintf_P(buf, PSTR("M303 E%d C5 S210 U1"), ExtUI::extruder_t::E0);
551
+              break;
552
+          #endif
553
+          #if HOTENDS >= 2
554
+            case VP_PID_AUTOTUNE_E1:
555
+              sprintf_P(buf, PSTR("M303 E%d C5 S210 U1"), ExtUI::extruder_t::E1);
556
+              break;
557
+          #endif
785 558
         #endif
786
-        #if HOTENDS >= 2
787
-          case VP_PID_AUTOTUNE_E1:
788
-            sprintf(buf, "M303 E%d C5 S210 U1", ExtUI::extruder_t::E1);
559
+        #if ENABLED(PIDTEMPBED)
560
+          case VP_PID_AUTOTUNE_BED:
561
+            sprintf_P(buf, PSTR("M303 E-1 C5 S70 U1"));
789 562
             break;
790 563
         #endif
791
-      #endif
792
-      #if ENABLED(PIDTEMPBED)
793
-        case VP_PID_AUTOTUNE_BED:
794
-          sprintf(buf, "M303 E-1 C5 S70 U1");
795
-          break;
796
-      #endif
797 564
     }
798 565
 
799 566
     if (buf[0]) queue.enqueue_one_now(buf);
@@ -803,7 +570,7 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, vo
803 570
       GotoScreen(DGUSLCD_SCREEN_WAITING);
804 571
     #endif
805 572
   }
806
-#endif
573
+#endif // HAS_PID_HEATING
807 574
 
808 575
 #if HAS_BED_PROBE
809 576
   void DGUSScreenHandler::HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr) {
@@ -811,19 +578,7 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, vo
811 578
 
812 579
     const float offset = float(int16_t(swap16(*(uint16_t*)val_ptr))) / 100.0f;
813 580
     ExtUI::setZOffset_mm(offset);
814
-    ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
815
-    return;
816
-  }
817
-#endif
818
-
819
-#if ENABLED(BABYSTEPPING)
820
-  void DGUSScreenHandler::HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr) {
821
-    DEBUG_ECHOLNPGM("HandleLiveAdjustZ");
822
-
823
-    int16_t flag = swap16(*(uint16_t*)val_ptr);
824
-    int16_t steps = flag ? -20 : 20;
825
-    ExtUI::smartAdjustAxis_steps(steps, ExtUI::axis_t::Z, true);
826
-    ScreenHandler.ForceCompleteUpdate();
581
+    skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
827 582
     return;
828 583
   }
829 584
 #endif
@@ -849,8 +604,8 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr
849 604
     #if HOTENDS >= 3
850 605
       case VP_E2_CONTROL:
851 606
     #endif
852
-      preheat_temp = PREHEAT_1_TEMP_HOTEND;
853
-      break;
607
+    preheat_temp = PREHEAT_1_TEMP_HOTEND;
608
+    break;
854 609
 
855 610
     case VP_BED_CONTROL:
856 611
       preheat_temp = PREHEAT_1_TEMP_BED;
@@ -900,149 +655,49 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr
900 655
 
901 656
     switch (var.VP) {
902 657
       default: return;
903
-      #if HOTENDS >= 1
904
-        case VP_E0_BED_PREHEAT:
905
-          thermalManager.setTargetHotend(e_temp, 0);
906
-          TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp));
907
-          break;
908
-      #endif
909
-      #if HOTENDS >= 2
910
-        case VP_E1_BED_PREHEAT:
911
-          thermalManager.setTargetHotend(e_temp, 1);
912
-          TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp));
913
-        break;
914
-      #endif
658
+        #if HOTENDS >= 1
659
+          case VP_E0_BED_PREHEAT:
660
+            thermalManager.setTargetHotend(e_temp, 0);
661
+            TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp));
662
+            break;
663
+        #endif
664
+        #if HOTENDS >= 2
665
+          case VP_E1_BED_PREHEAT:
666
+            thermalManager.setTargetHotend(e_temp, 1);
667
+            TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp));
668
+            break;
669
+        #endif
915 670
     }
916 671
 
917 672
     // Go to the preheat screen to show the heating progress
918 673
     GotoScreen(DGUSLCD_SCREEN_PREHEAT);
919 674
   }
920 675
 
921
-#endif
922
-
923
-#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
924
-
925
-  typedef struct  {
926
-    ExtUI::extruder_t extruder; // which extruder to operate
927
-    uint8_t action; // load or unload
928
-    bool heated; // heating done ?
929
-    float purge_length; // the length to extrude before unload, prevent filament jam
930
-  } filament_data_t;
931
-
932
-  static filament_data_t filament_data;
676
+#endif // DGUS_PREHEAT_UI
933 677
 
934
-  void DGUSScreenHandler::HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr) {
935
-    DEBUG_ECHOLNPGM("HandleFilamentOption");
936
-
937
-    uint8_t e_temp = 0;
938
-    filament_data.heated = false;
939
-    uint16_t preheat_option = swap16(*(uint16_t*)val_ptr);
940
-    if (preheat_option <= 8)          // Load filament type
941
-      filament_data.action = 1;
942
-    else if (preheat_option >= 10) {  // Unload filament type
943
-      preheat_option -= 10;
944
-      filament_data.action = 2;
945
-      filament_data.purge_length = DGUS_FILAMENT_PURGE_LENGTH;
946
-    }
947
-    else                              // Cancel filament operation
948
-      filament_data.action = 0;
949
-
950
-    switch (preheat_option) {
951
-      case 0: // Load PLA
952
-        #ifdef PREHEAT_1_TEMP_HOTEND
953
-          e_temp = PREHEAT_1_TEMP_HOTEND;
954
-        #endif
955
-        break;
956
-      case 1: // Load ABS
957
-        TERN_(PREHEAT_2_TEMP_HOTEND, e_temp = PREHEAT_2_TEMP_HOTEND);
958
-        break;
959
-      case 2: // Load PET
960
-        #ifdef PREHEAT_3_TEMP_HOTEND
961
-          e_temp = PREHEAT_3_TEMP_HOTEND;
962
-        #endif
963
-        break;
964
-      case 3: // Load FLEX
965
-        #ifdef PREHEAT_4_TEMP_HOTEND
966
-          e_temp = PREHEAT_4_TEMP_HOTEND;
967
-        #endif
968
-        break;
969
-      case 9: // Cool down
970
-      default:
971
-        e_temp = 0;
972
-        break;
973
-    }
678
+#if ENABLED(POWER_LOSS_RECOVERY)
974 679
 
975
-    if (filament_data.action == 0) { // Go back to utility screen
976
-      #if HOTENDS >= 1
977
-        thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0);
978
-      #endif
979
-      #if HOTENDS >= 2
980
-        thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1);
981
-      #endif
982
-      GotoScreen(DGUSLCD_SCREEN_UTILITY);
680
+  void DGUSScreenHandler::HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr) {
681
+    uint16_t value = swap16(*(uint16_t*)val_ptr);
682
+    if (value) {
683
+      queue.inject_P(PSTR("M1000"));
684
+      dgusdisplay.WriteVariable(VP_SD_Print_Filename, filelist.filename(), 32, true);
685
+      GotoScreen(PLR_SCREEN_RECOVER);
983 686
     }
984
-    else { // Go to the preheat screen to show the heating progress
985
-      switch (var.VP) {
986
-        default: return;
987
-        #if HOTENDS >= 1
988
-          case VP_E0_FILAMENT_LOAD_UNLOAD:
989
-            filament_data.extruder = ExtUI::extruder_t::E0;
990
-            thermalManager.setTargetHotend(e_temp, filament_data.extruder);
991
-            break;
992
-        #endif
993
-        #if HOTENDS >= 2
994
-          case VP_E1_FILAMENT_LOAD_UNLOAD:
995
-            filament_data.extruder = ExtUI::extruder_t::E1;
996
-            thermalManager.setTargetHotend(e_temp, filament_data.extruder);
997
-          break;
998
-        #endif
999
-      }
1000
-      GotoScreen(DGUSLCD_SCREEN_FILAMENT_HEATING);
687
+    else {
688
+      recovery.cancel();
689
+      GotoScreen(PLR_SCREEN_CANCEL);
1001 690
     }
1002 691
   }
1003 692
 
1004
-  void DGUSScreenHandler::HandleFilamentLoadUnload(DGUS_VP_Variable &var) {
1005
-    DEBUG_ECHOLNPGM("HandleFilamentLoadUnload");
1006
-    if (filament_data.action <= 0) return;
1007
-
1008
-    // If we close to the target temperature, we can start load or unload the filament
1009
-    if (thermalManager.hotEnoughToExtrude(filament_data.extruder) && \
1010
-       thermalManager.targetHotEnoughToExtrude(filament_data.extruder)) {
1011
-      float movevalue = DGUS_FILAMENT_LOAD_LENGTH_PER_TIME;
1012
-
1013
-      if (filament_data.action == 1) { // load filament
1014
-        if (!filament_data.heated) {
1015
-          GotoScreen(DGUSLCD_SCREEN_FILAMENT_LOADING);
1016
-          filament_data.heated = true;
1017
-        }
1018
-        movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder)+movevalue;
1019
-      }
1020
-      else { // unload filament
1021
-        if (!filament_data.heated) {
1022
-          GotoScreen(DGUSLCD_SCREEN_FILAMENT_UNLOADING);
1023
-          filament_data.heated = true;
1024
-        }
1025
-        // Before unloading extrude to prevent jamming
1026
-        if (filament_data.purge_length >= 0) {
1027
-          movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) + movevalue;
1028
-          filament_data.purge_length -= movevalue;
1029
-        }
1030
-        else
1031
-          movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) - movevalue;
1032
-      }
1033
-      ExtUI::setAxisPosition_mm(movevalue, filament_data.extruder);
1034
-    }
1035
-  }
1036 693
 #endif
1037 694
 
1038 695
 void DGUSScreenHandler::UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup) {
1039 696
   DEBUG_ECHOLNPAIR("SetNewScreen: ", newscreen);
1040
-
1041 697
   if (!popup) {
1042 698
     memmove(&past_screens[1], &past_screens[0], sizeof(past_screens) - 1);
1043 699
     past_screens[0] = current_screen;
1044 700
   }
1045
-
1046 701
   current_screen = newscreen;
1047 702
   skipVP = 0;
1048 703
   ForceCompleteUpdate();
@@ -1062,7 +717,7 @@ void DGUSScreenHandler::UpdateScreenVPData() {
1062 717
   if (!VPList) {
1063 718
     DEBUG_ECHOLNPAIR(" NO SCREEN FOR: ", current_screen);
1064 719
     ScreenComplete = true;
1065
-    return;  // nothing to do, likely a bug or boring screen.
720
+    return; // nothing to do, likely a bug or boring screen.
1066 721
   }
1067 722
 
1068 723
   // Round-robin updating of all VPs.
@@ -1076,14 +731,14 @@ void DGUSScreenHandler::UpdateScreenVPData() {
1076 731
       update_ptr = 0;
1077 732
       DEBUG_ECHOLNPGM(" UpdateScreenVPData done");
1078 733
       ScreenComplete = true;
1079
-      return;  // Screen completed.
734
+      return; // Screen completed.
1080 735
     }
1081 736
 
1082 737
     if (VP == skipVP) { skipVP = 0; continue; }
1083 738
 
1084 739
     DGUS_VP_Variable rcpy;
1085 740
     if (populate_VPVar(VP, &rcpy)) {
1086
-      uint8_t expected_tx = 6 + rcpy.size;  // expected overhead is 6 bytes + payload.
741
+      uint8_t expected_tx = 6 + rcpy.size; // expected overhead is 6 bytes + payload.
1087 742
       // Send the VP to the display, but try to avoid overrunning the Tx Buffer.
1088 743
       // But send at least one VP, to avoid getting stalled.
1089 744
       if (rcpy.send_to_display_handler && (!sent_one || expected_tx <= dgusdisplay.GetFreeTxBuffer())) {
@@ -1092,11 +747,11 @@ void DGUSScreenHandler::UpdateScreenVPData() {
1092 747
         rcpy.send_to_display_handler(rcpy);
1093 748
       }
1094 749
       else {
1095
-        //auto x=dgusdisplay.GetFreeTxBuffer();
750
+        // auto x=dgusdisplay.GetFreeTxBuffer();
1096 751
         //DEBUG_ECHOLNPAIR(" tx almost full: ", x);
1097 752
         //DEBUG_ECHOPAIR(" update_ptr ", update_ptr);
1098 753
         ScreenComplete = false;
1099
-        return;  // please call again!
754
+        return; // please call again!
1100 755
       }
1101 756
     }
1102 757
 
@@ -1108,29 +763,6 @@ void DGUSScreenHandler::GotoScreen(DGUSLCD_Screens screen, bool ispopup) {
1108 763
   UpdateNewScreen(screen, ispopup);
1109 764
 }
1110 765
 
1111
-bool DGUSScreenHandler::loop() {
1112
-  dgusdisplay.loop();
1113
-
1114
-  const millis_t ms = millis();
1115
-  static millis_t next_event_ms = 0;
1116
-
1117
-  if (!IsScreenComplete() || ELAPSED(ms, next_event_ms)) {
1118
-    next_event_ms = ms + DGUS_UPDATE_INTERVAL_MS;
1119
-    UpdateScreenVPData();
1120
-  }
1121
-
1122
-  #if ENABLED(SHOW_BOOTSCREEN)
1123
-    static bool booted = false;
1124
-    if (!booted && TERN0(POWER_LOSS_RECOVERY, recovery.valid()))
1125
-      booted = true;
1126
-    if (!booted && ELAPSED(ms, BOOTSCREEN_TIMEOUT)) {
1127
-      booted = true;
1128
-      GotoScreen(DGUSLCD_SCREEN_MAIN);
1129
-    }
1130
-  #endif
1131
-  return IsScreenComplete();
1132
-}
1133
-
1134 766
 void DGUSDisplay::RequestScreen(DGUSLCD_Screens screen) {
1135 767
   DEBUG_ECHOLNPAIR("GotoScreen ", screen);
1136 768
   const unsigned char gotoscreen[] = { 0x5A, 0x01, (unsigned char) (screen >> 8U), (unsigned char) (screen & 0xFFU) };

+ 25
- 199
Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.h Прегледај датотеку

@@ -21,212 +21,38 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-#include "DGUSDisplay.h"
25
-#include "DGUSVPVariable.h"
26
-
27
-#include "../../../../inc/MarlinConfig.h"
28
-
29
-enum DGUSLCD_Screens : uint8_t;
30
-
31
-class DGUSScreenHandler {
32
-public:
33
-  DGUSScreenHandler() = default;
34
-
35
-  static bool loop();
36
-
37
-  /// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
38
-  /// The bools specifing whether the strings are in RAM or FLASH.
39
-  static void sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
40
-
41
-  static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
42
-
43
-  /// "M117" Message -- msg is a RAM ptr.
44
-  static void setstatusmessage(const char* msg);
45
-  /// The same for messages from Flash
46
-  static void setstatusmessagePGM(PGM_P const msg);
47
-  // Callback for VP "Display wants to change screen on idle printer"
48
-  static void ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr);
49
-  // Callback for VP "Screen has been changed"
50
-  static void ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr);
51
-  // Callback for VP "All Heaters Off"
52
-  static void HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr);
53
-  // Hook for "Change this temperature"
54
-  static void HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr);
55
-  // Hook for "Change Flowrate"
56
-  static void HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr);
57
-  #if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
58
-    // Hook for manual move option
59
-    static void HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr);
60
-  #endif
61
-  // Hook for manual move.
62
-  static void HandleManualMove(DGUS_VP_Variable &var, void *val_ptr);
63
-  // Hook for manual extrude.
64
-  static void HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr);
65
-  // Hook for motor lock and unlook
66
-  static void HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr);
67
-  #if ENABLED(POWER_LOSS_RECOVERY)
68
-    // Hook for power loss recovery.
69
-    static void HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr);
70
-  #endif
71
-  // Hook for settings
72
-  static void HandleSettings(DGUS_VP_Variable &var, void *val_ptr);
73
-  static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr);
74
-  static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr);
75
-  #if HAS_PID_HEATING
76
-    // Hook for "Change this temperature PID para"
77
-    static void HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr);
78
-    // Hook for PID autotune
79
-    static void HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr);
80
-  #endif
81
-  #if HAS_BED_PROBE
82
-    // Hook for "Change probe offset z"
83
-    static void HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr);
84
-  #endif
85
-  #if ENABLED(BABYSTEPPING)
86
-    // Hook for live z adjust action
87
-    static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr);
88
-  #endif
89
-  #if HAS_FAN
90
-    // Hook for fan control
91
-    static void HandleFanControl(DGUS_VP_Variable &var, void *val_ptr);
92
-  #endif
93
-  // Hook for heater control
94
-  static void HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr);
95
-  #if ENABLED(DGUS_PREHEAT_UI)
96
-    // Hook for preheat
97
-    static void HandlePreheat(DGUS_VP_Variable &var, void *val_ptr);
98
-  #endif
99
-  #if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
100
-    // Hook for filament load and unload filament option
101
-    static void HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr);
102
-    // Hook for filament load and unload
103
-    static void HandleFilamentLoadUnload(DGUS_VP_Variable &var);
104
-  #endif
105
-
106
-  #if ENABLED(SDSUPPORT)
107
-    // Callback for VP "Display wants to change screen when there is a SD card"
108
-    static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr);
109
-    /// Scroll buttons on the file listing screen.
110
-    static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr);
111
-    /// File touched.
112
-    static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr);
113
-    /// start print after confirmation received.
114
-    static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr);
115
-    /// User hit the pause, resume or abort button.
116
-    static void DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr);
117
-    /// User confirmed the abort action
118
-    static void DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr);
119
-    /// User hit the tune button
120
-    static void DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr);
121
-    /// Send a single filename to the display.
122
-    static void DGUSLCD_SD_SendFilename(DGUS_VP_Variable &var);
123
-    /// Marlin informed us that a new SD has been inserted.
124
-    static void SDCardInserted();
125
-    /// Marlin informed us that the SD Card has been removed().
126
-    static void SDCardRemoved();
127
-    /// Marlin informed us about a bad SD Card.
128
-    static void SDCardError();
129
-  #endif
130
-
131
-  // OK Button the Confirm screen.
132
-  static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr);
133
-
134
-  // Update data after went to new screen (by display or by GotoScreen)
135
-  // remember: store the last-displayed screen, so it can get returned to.
136
-  // (e.g for pop up messages)
137
-  static void UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup=false);
138
-
139
-  // Recall the remembered screen.
140
-  static void PopToOldScreen();
141
-
142
-  // Make the display show the screen and update all VPs in it.
143
-  static void GotoScreen(DGUSLCD_Screens screen, bool ispopup = false);
144
-
145
-  static void UpdateScreenVPData();
146
-
147
-  // Helpers to convert and transfer data to the display.
148
-  static void DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var);
149
-  static void DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var);
150
-  static void DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var);
151
-  static void DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var);
152
-  static void DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var);
153
-  static void DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var);
154
-  static void DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var);
155
-  #if ENABLED(PRINTCOUNTER)
156
-    static void DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var);
157
-    static void DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var);
158
-  #endif
159
-  #if HAS_FAN
160
-    static void DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var);
161
-  #endif
162
-  static void DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var);
163
-  #if ENABLED(DGUS_UI_WAITING)
164
-    static void DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var);
165
-  #endif
166
-
167
-  /// Send a value from 0..100 to a variable with a range from 0..255
168
-  static void DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr);
169
-
170
-  template<typename T>
171
-  static void DGUSLCD_SetValueDirectly(DGUS_VP_Variable &var, void *val_ptr) {
172
-    if (!var.memadr) return;
173
-    union { unsigned char tmp[sizeof(T)]; T t; } x;
174
-    unsigned char *ptr = (unsigned char*)val_ptr;
175
-    LOOP_L_N(i, sizeof(T)) x.tmp[i] = ptr[sizeof(T) - i - 1];
176
-    *(T*)var.memadr = x.t;
177
-  }
178
-
179
-  /// Send a float value to the display.
180
-  /// Display will get a 4-byte integer scaled to the number of digits:
181
-  /// Tell the display the number of digits and it cheats by displaying a dot between...
182
-  template<unsigned int decimals>
183
-  static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) {
184
-    if (var.memadr) {
185
-      float f = *(float *)var.memadr;
186
-      f *= cpow(10, decimals);
187
-      dgusdisplay.WriteVariable(var.VP, (long)f);
188
-    }
189
-  }
190
-
191
-  /// Send a float value to the display.
192
-  /// Display will get a 2-byte integer scaled to the number of digits:
193
-  /// Tell the display the number of digits and it cheats by displaying a dot between...
194
-  template<unsigned int decimals>
195
-  static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) {
196
-    if (var.memadr) {
197
-      float f = *(float *)var.memadr;
198
-      DEBUG_ECHOLNPAIR_F(" >> ", f, 6);
199
-      f *= cpow(10, decimals);
200
-      dgusdisplay.WriteVariable(var.VP, (int16_t)f);
201
-    }
202
-  }
24
+/**
25
+ * lcd/extui/lib/dgus/DGUSScreenHandler.h
26
+ */
203 27
 
204
-  /// Force an update of all VP on the current screen.
205
-  static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; }
206
-  /// Has all VPs sent to the screen
207
-  static inline bool IsScreenComplete() { return ScreenComplete; }
28
+#include "../../../../inc/MarlinConfigPre.h"
208 29
 
209
-  static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; }
30
+#include "../../ui_api.h"
210 31
 
211
-  static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; }
32
+#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
212 33
 
213
-private:
214
-  static DGUSLCD_Screens current_screen;  ///< currently on screen
215
-  static constexpr uint8_t NUM_PAST_SCREENS = 4;
216
-  static DGUSLCD_Screens past_screens[NUM_PAST_SCREENS]; ///< LIFO with past screens for the "back" button.
34
+  typedef struct  {
35
+    ExtUI::extruder_t extruder; // which extruder to operate
36
+    uint8_t action; // load or unload
37
+    bool heated; // heating done ?
38
+    float purge_length; // the length to extrude before unload, prevent filament jam
39
+  } filament_data_t;
217 40
 
218
-  static uint8_t update_ptr;    ///< Last sent entry in the VPList for the actual screen.
219
-  static uint16_t skipVP;       ///< When updating the screen data, skip this one, because the user is interacting with it.
220
-  static bool ScreenComplete;   ///< All VPs sent to screen?
41
+  extern filament_data_t filament_data;
221 42
 
222
-  static uint16_t ConfirmVP;    ///< context for confirm screen (VP that will be emulated-sent on "OK").
43
+#endif
223 44
 
224
-  #if ENABLED(SDSUPPORT)
225
-    static int16_t top_file;    ///< file on top of file chooser
226
-    static int16_t file_to_print; ///< touched file to be confirmed
227
-  #endif
45
+// endianness swap
46
+inline uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (value >> 8U); }
228 47
 
229
-  static void (*confirm_action_cb)();
230
-};
48
+#if ENABLED(DGUS_LCD_UI_ORIGIN)
49
+  #include "origin/DGUSScreenHandler.h"
50
+#elif ENABLED(DGUS_LCD_UI_MKS)
51
+  #include "mks/DGUSScreenHandler.h"
52
+#elif ENABLED(DGUS_LCD_UI_FYSETC)
53
+  #include "fysetc/DGUSScreenHandler.h"
54
+#elif ENABLED(DGUS_LCD_UI_HIPRECY)
55
+  #include "hiprecy/DGUSScreenHandler.h"
56
+#endif
231 57
 
232 58
 extern DGUSScreenHandler ScreenHandler;

+ 418
- 0
Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.cpp Прегледај датотеку

@@ -0,0 +1,418 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "../../../../../inc/MarlinConfigPre.h"
24
+
25
+#if ENABLED(DGUS_LCD_UI_FYSETC)
26
+
27
+#include "../DGUSScreenHandler.h"
28
+
29
+#include "../../../../../MarlinCore.h"
30
+#include "../../../../../gcode/queue.h"
31
+#include "../../../../../libs/duration_t.h"
32
+#include "../../../../../module/settings.h"
33
+#include "../../../../../module/temperature.h"
34
+#include "../../../../../module/motion.h"
35
+#include "../../../../../module/planner.h"
36
+#include "../../../../../module/printcounter.h"
37
+#include "../../../../../sd/cardreader.h"
38
+
39
+#if ENABLED(POWER_LOSS_RECOVERY)
40
+  #include "../../../../feature/powerloss.h"
41
+#endif
42
+
43
+#if ENABLED(SDSUPPORT)
44
+
45
+  void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) {
46
+    uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file;
47
+    if (touched_nr > filelist.count()) return;
48
+    if (!filelist.seek(touched_nr)) return;
49
+
50
+    if (filelist.isDir()) {
51
+      filelist.changeDir(filelist.filename());
52
+      top_file = 0;
53
+      ForceCompleteUpdate();
54
+      return;
55
+    }
56
+
57
+    #if ENABLED(DGUS_PRINT_FILENAME)
58
+      // Send print filename
59
+      dgusdisplay.WriteVariable(VP_SD_Print_Filename, filelist.filename(), VP_SD_FileName_LEN, true);
60
+    #endif
61
+
62
+    // Setup Confirmation screen
63
+    file_to_print = touched_nr;
64
+
65
+    HandleUserConfirmationPopUp(VP_SD_FileSelectConfirm, nullptr, PSTR("Print file"), filelist.filename(), PSTR("from SD Card?"), true, true, false, true);
66
+  }
67
+
68
+  void DGUSScreenHandler::DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr) {
69
+    if (!filelist.seek(file_to_print)) return;
70
+    ExtUI::printFile(filelist.shortFilename());
71
+    GotoScreen(DGUSLCD_SCREEN_SDPRINTMANIPULATION);
72
+  }
73
+
74
+  void DGUSScreenHandler::DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr) {
75
+
76
+    if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes.
77
+    switch (swap16(*(uint16_t*)val_ptr)) {
78
+      case 0: { // Resume
79
+        if (ExtUI::isPrintingFromMediaPaused()) {
80
+          ExtUI::resumePrint();
81
+        }
82
+      } break;
83
+
84
+      case 1: // Pause
85
+
86
+        GotoScreen(MKSLCD_SCREEN_PAUSE);
87
+        if (!ExtUI::isPrintingFromMediaPaused()) {
88
+          ExtUI::pausePrint();
89
+          //ExtUI::mks_pausePrint();
90
+        }
91
+        break;
92
+      case 2: // Abort
93
+        HandleUserConfirmationPopUp(VP_SD_AbortPrintConfirmed, nullptr, PSTR("Abort printing"), filelist.filename(), PSTR("?"), true, true, false, true);
94
+        break;
95
+    }
96
+  }
97
+
98
+  void DGUSScreenHandler::DGUSLCD_SD_SendFilename(DGUS_VP_Variable& var) {
99
+    uint16_t target_line = (var.VP - VP_SD_FileName0) / VP_SD_FileName_LEN;
100
+    if (target_line > DGUS_SD_FILESPERSCREEN) return;
101
+    char tmpfilename[VP_SD_FileName_LEN + 1] = "";
102
+    var.memadr = (void*)tmpfilename;
103
+
104
+    if (filelist.seek(top_file + target_line)) {
105
+      snprintf_P(tmpfilename, VP_SD_FileName_LEN, PSTR("%s%c"), filelist.filename(), filelist.isDir() ? '/' : 0); // snprintf_P(tmpfilename, VP_SD_FileName_LEN, PSTR("%s"), filelist.filename());
106
+    }
107
+    DGUSLCD_SendStringToDisplay(var);
108
+  }
109
+
110
+  void DGUSScreenHandler::SDCardInserted() {
111
+    top_file = 0;
112
+    filelist.refresh();
113
+    auto cs = getCurrentScreen();
114
+    if (cs == DGUSLCD_SCREEN_MAIN || cs == DGUSLCD_SCREEN_STATUS)
115
+      GotoScreen(DGUSLCD_SCREEN_SDFILELIST);
116
+  }
117
+
118
+  void DGUSScreenHandler::SDCardRemoved() {
119
+    if (current_screen == DGUSLCD_SCREEN_SDFILELIST
120
+        || (current_screen == DGUSLCD_SCREEN_CONFIRM && (ConfirmVP == VP_SD_AbortPrintConfirmed || ConfirmVP == VP_SD_FileSelectConfirm))
121
+        || current_screen == DGUSLCD_SCREEN_SDPRINTMANIPULATION
122
+    ) GotoScreen(DGUSLCD_SCREEN_MAIN);
123
+  }
124
+
125
+#endif // SDSUPPORT
126
+
127
+void DGUSScreenHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) {
128
+  uint8_t *tmp = (uint8_t*)val_ptr;
129
+
130
+  // The keycode in target is coded as <from-frame><to-frame>, so 0x0100A means
131
+  // from screen 1 (main) to 10 (temperature). DGUSLCD_SCREEN_POPUP is special,
132
+  // meaning "return to previous screen"
133
+  DGUSLCD_Screens target = (DGUSLCD_Screens)tmp[1];
134
+
135
+  DEBUG_ECHOLNPAIR("\n DEBUG target", target);
136
+
137
+  if (target == DGUSLCD_SCREEN_POPUP) {
138
+    // Special handling for popup is to return to previous menu
139
+    if (current_screen == DGUSLCD_SCREEN_POPUP && confirm_action_cb) confirm_action_cb();
140
+    PopToOldScreen();
141
+    return;
142
+  }
143
+
144
+  UpdateNewScreen(target);
145
+
146
+  #ifdef DEBUG_DGUSLCD
147
+    if (!DGUSLCD_FindScreenVPMapList(target)) DEBUG_ECHOLNPAIR("WARNING: No screen Mapping found for ", target);
148
+  #endif
149
+}
150
+
151
+void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
152
+  DEBUG_ECHOLNPGM("HandleManualMove");
153
+
154
+  int16_t movevalue = swap16(*(uint16_t*)val_ptr);
155
+  #if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
156
+    if (movevalue) {
157
+      const uint16_t choice = *(uint16_t*)var.memadr;
158
+      movevalue = movevalue < 0 ? -choice : choice;
159
+    }
160
+  #endif
161
+  char axiscode;
162
+  unsigned int speed = 1500; // FIXME: get default feedrate for manual moves, dont hardcode.
163
+
164
+  switch (var.VP) {
165
+    default: return;
166
+
167
+    case VP_MOVE_X:
168
+      axiscode = 'X';
169
+      if (!ExtUI::canMove(ExtUI::axis_t::X)) goto cannotmove;
170
+      break;
171
+
172
+    case VP_MOVE_Y:
173
+      axiscode = 'Y';
174
+      if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove;
175
+      break;
176
+
177
+    case VP_MOVE_Z:
178
+      axiscode = 'Z';
179
+      speed = 300; // default to 5mm/s
180
+      if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove;
181
+      break;
182
+
183
+    case VP_HOME_ALL: // only used for homing
184
+      axiscode  = '\0';
185
+      movevalue = 0; // ignore value sent from display, this VP is _ONLY_ for homing.
186
+      break;
187
+  }
188
+
189
+  if (!movevalue) {
190
+    // homing
191
+    DEBUG_ECHOPAIR(" homing ", axiscode);
192
+    char buf[6] = "G28 X";
193
+    buf[4] = axiscode;
194
+    //DEBUG_ECHOPAIR(" ", buf);
195
+    queue.enqueue_one_now(buf);
196
+    //DEBUG_ECHOLNPGM(" ✓");
197
+    ForceCompleteUpdate();
198
+    return;
199
+  }
200
+  else {
201
+    // movement
202
+    DEBUG_ECHOPAIR(" move ", axiscode);
203
+    bool old_relative_mode = relative_mode;
204
+    if (!relative_mode) {
205
+      //DEBUG_ECHOPGM(" G91");
206
+      queue.enqueue_now_P(PSTR("G91"));
207
+      //DEBUG_ECHOPGM(" ✓ ");
208
+    }
209
+    char buf[32]; // G1 X9999.99 F12345
210
+    unsigned int backup_speed = MMS_TO_MMM(feedrate_mm_s);
211
+    char sign[] = "\0";
212
+    int16_t value = movevalue / 100;
213
+    if (movevalue < 0) { value = -value; sign[0] = '-'; }
214
+    int16_t fraction = ABS(movevalue) % 100;
215
+    snprintf_P(buf, 32, PSTR("G0 %c%s%d.%02d F%d"), axiscode, sign, value, fraction, speed);
216
+    //DEBUG_ECHOPAIR(" ", buf);
217
+    queue.enqueue_one_now(buf);
218
+    //DEBUG_ECHOLNPGM(" ✓ ");
219
+    if (backup_speed != speed) {
220
+      snprintf_P(buf, 32, PSTR("G0 F%d"), backup_speed);
221
+      queue.enqueue_one_now(buf);
222
+      //DEBUG_ECHOPAIR(" ", buf);
223
+    }
224
+    // while (!enqueue_and_echo_command(buf)) idle();
225
+    //DEBUG_ECHOLNPGM(" ✓ ");
226
+    if (!old_relative_mode) {
227
+      //DEBUG_ECHOPGM("G90");
228
+      queue.enqueue_now_P(PSTR("G90"));
229
+      //DEBUG_ECHOPGM(" ✓ ");
230
+    }
231
+  }
232
+
233
+  ForceCompleteUpdate();
234
+  DEBUG_ECHOLNPGM("manmv done.");
235
+  return;
236
+
237
+  cannotmove:
238
+    DEBUG_ECHOLNPAIR(" cannot move ", axiscode);
239
+    return;
240
+}
241
+
242
+#if HAS_PID_HEATING
243
+  void DGUSScreenHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) {
244
+    uint16_t rawvalue = swap16(*(uint16_t*)val_ptr);
245
+    DEBUG_ECHOLNPAIR("V1:", rawvalue);
246
+    float value = (float)rawvalue / 10;
247
+    DEBUG_ECHOLNPAIR("V2:", value);
248
+    float newvalue = 0;
249
+
250
+    switch (var.VP) {
251
+      default: return;
252
+        #if HOTENDS >= 1
253
+          case VP_E0_PID_P: newvalue = value; break;
254
+          case VP_E0_PID_I: newvalue = scalePID_i(value); break;
255
+          case VP_E0_PID_D: newvalue = scalePID_d(value); break;
256
+        #endif
257
+        #if HOTENDS >= 2
258
+          case VP_E1_PID_P: newvalue = value; break;
259
+          case VP_E1_PID_I: newvalue = scalePID_i(value); break;
260
+          case VP_E1_PID_D: newvalue = scalePID_d(value); break;
261
+        #endif
262
+        #if HAS_HEATED_BED
263
+          case VP_BED_PID_P: newvalue = value; break;
264
+          case VP_BED_PID_I: newvalue = scalePID_i(value); break;
265
+          case VP_BED_PID_D: newvalue = scalePID_d(value); break;
266
+        #endif
267
+    }
268
+
269
+    DEBUG_ECHOLNPAIR_F("V3:", newvalue);
270
+    *(float *)var.memadr = newvalue;
271
+
272
+    skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
273
+  }
274
+#endif // HAS_PID_HEATING
275
+
276
+#if ENABLED(BABYSTEPPING)
277
+  void DGUSScreenHandler::HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr) {
278
+    DEBUG_ECHOLNPGM("HandleLiveAdjustZ");
279
+    int16_t flag  = swap16(*(uint16_t*)val_ptr),
280
+            steps = flag ? -20 : 20;
281
+    ExtUI::smartAdjustAxis_steps(steps, ExtUI::axis_t::Z, true);
282
+    ForceCompleteUpdate();
283
+  }
284
+#endif
285
+
286
+#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
287
+
288
+  void DGUSScreenHandler::HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr) {
289
+    DEBUG_ECHOLNPGM("HandleFilamentOption");
290
+
291
+    uint8_t e_temp = 0;
292
+    filament_data.heated = false;
293
+    uint16_t preheat_option = swap16(*(uint16_t*)val_ptr);
294
+    if (preheat_option <= 8) {      // Load filament type
295
+      filament_data.action = 1;
296
+    }
297
+    else if (preheat_option >= 10) { // Unload filament type
298
+      preheat_option -= 10;
299
+      filament_data.action = 2;
300
+      filament_data.purge_length = DGUS_FILAMENT_PURGE_LENGTH;
301
+    }
302
+    else {                          // Cancel filament operation
303
+      filament_data.action = 0;
304
+    }
305
+
306
+    switch (preheat_option) {
307
+      case 0: // Load PLA
308
+        #ifdef PREHEAT_1_TEMP_HOTEND
309
+          e_temp = PREHEAT_1_TEMP_HOTEND;
310
+        #endif
311
+        break;
312
+      case 1: // Load ABS
313
+        TERN_(PREHEAT_2_TEMP_HOTEND, e_temp = PREHEAT_2_TEMP_HOTEND);
314
+        break;
315
+      case 2: // Load PET
316
+        #ifdef PREHEAT_3_TEMP_HOTEND
317
+          e_temp = PREHEAT_3_TEMP_HOTEND;
318
+        #endif
319
+        break;
320
+      case 3: // Load FLEX
321
+        #ifdef PREHEAT_4_TEMP_HOTEND
322
+          e_temp = PREHEAT_4_TEMP_HOTEND;
323
+        #endif
324
+        break;
325
+      case 9: // Cool down
326
+      default:
327
+        e_temp = 0;
328
+        break;
329
+    }
330
+
331
+    if (filament_data.action == 0) { // Go back to utility screen
332
+      #if HOTENDS >= 1
333
+        thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0);
334
+      #endif
335
+      #if HOTENDS >= 2
336
+        thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1);
337
+      #endif
338
+      GotoScreen(DGUSLCD_SCREEN_UTILITY);
339
+    }
340
+    else { // Go to the preheat screen to show the heating progress
341
+      switch (var.VP) {
342
+        default: return;
343
+          #if HOTENDS >= 1
344
+            case VP_E0_FILAMENT_LOAD_UNLOAD:
345
+              filament_data.extruder = ExtUI::extruder_t::E0;
346
+              thermalManager.setTargetHotend(e_temp, filament_data.extruder);
347
+              break;
348
+          #endif
349
+          #if HOTENDS >= 2
350
+            case VP_E1_FILAMENT_LOAD_UNLOAD:
351
+              filament_data.extruder = ExtUI::extruder_t::E1;
352
+              thermalManager.setTargetHotend(e_temp, filament_data.extruder);
353
+              break;
354
+          #endif
355
+      }
356
+      GotoScreen(DGUSLCD_SCREEN_FILAMENT_HEATING);
357
+    }
358
+  }
359
+
360
+  void DGUSScreenHandler::HandleFilamentLoadUnload(DGUS_VP_Variable &var) {
361
+    DEBUG_ECHOLNPGM("HandleFilamentLoadUnload");
362
+    if (filament_data.action <= 0) return;
363
+
364
+    // If we close to the target temperature, we can start load or unload the filament
365
+    if (thermalManager.hotEnoughToExtrude(filament_data.extruder) && \
366
+        thermalManager.targetHotEnoughToExtrude(filament_data.extruder)) {
367
+      float movevalue = DGUS_FILAMENT_LOAD_LENGTH_PER_TIME;
368
+
369
+      if (filament_data.action == 1) { // load filament
370
+        if (!filament_data.heated) {
371
+          //GotoScreen(DGUSLCD_SCREEN_FILAMENT_LOADING);
372
+          filament_data.heated = true;
373
+        }
374
+        movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) + movevalue;
375
+      }
376
+      else { // unload filament
377
+        if (!filament_data.heated) {
378
+          GotoScreen(DGUSLCD_SCREEN_FILAMENT_UNLOADING);
379
+          filament_data.heated = true;
380
+        }
381
+        // Before unloading extrude to prevent jamming
382
+        if (filament_data.purge_length >= 0) {
383
+          movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) + movevalue;
384
+          filament_data.purge_length -= movevalue;
385
+        }
386
+        else {
387
+          movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) - movevalue;
388
+        }
389
+      }
390
+      ExtUI::setAxisPosition_mm(movevalue, filament_data.extruder);
391
+    }
392
+  }
393
+#endif // DGUS_FILAMENT_LOADUNLOAD
394
+
395
+bool DGUSScreenHandler::loop() {
396
+  dgusdisplay.loop();
397
+
398
+  const millis_t ms = millis();
399
+  static millis_t next_event_ms = 0;
400
+
401
+  if (!IsScreenComplete() || ELAPSED(ms, next_event_ms)) {
402
+    next_event_ms = ms + DGUS_UPDATE_INTERVAL_MS;
403
+    UpdateScreenVPData();
404
+  }
405
+
406
+  #if ENABLED(SHOW_BOOTSCREEN)
407
+    static bool booted = false;
408
+
409
+    if (!booted && TERN0(POWER_LOSS_RECOVERY, recovery.valid()))
410
+      booted = true;
411
+
412
+    if (!booted && ELAPSED(ms, TERN(USE_MKS_GREEN_UI, 1000, BOOTSCREEN_TIMEOUT)))
413
+      booted = true;
414
+  #endif
415
+  return IsScreenComplete();
416
+}
417
+
418
+#endif // DGUS_LCD_UI_FYSETC

+ 240
- 0
Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.h Прегледај датотеку

@@ -0,0 +1,240 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "../DGUSDisplay.h"
25
+#include "../DGUSVPVariable.h"
26
+#include "../DGUSDisplayDef.h"
27
+
28
+#include "../../../../../inc/MarlinConfig.h"
29
+
30
+enum DGUSLCD_Screens : uint8_t;
31
+
32
+class DGUSScreenHandler {
33
+public:
34
+  DGUSScreenHandler() = default;
35
+
36
+  static bool loop();
37
+
38
+  // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
39
+  // The bools specifing whether the strings are in RAM or FLASH.
40
+  static void sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
41
+
42
+  static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
43
+
44
+  // "M117" Message -- msg is a RAM ptr.
45
+  static void setstatusmessage(const char* msg);
46
+  // The same for messages from Flash
47
+  static void setstatusmessagePGM(PGM_P const msg);
48
+  // Callback for VP "Display wants to change screen on idle printer"
49
+  static void ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr);
50
+  // Callback for VP "Screen has been changed"
51
+  static void ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr);
52
+
53
+  // Callback for VP "All Heaters Off"
54
+  static void HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr);
55
+  // Hook for "Change this temperature"
56
+  static void HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr);
57
+  // Hook for "Change Flowrate"
58
+  static void HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr);
59
+  #if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
60
+    // Hook for manual move option
61
+    static void HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr);
62
+  #endif
63
+
64
+  // Hook for manual move.
65
+  static void HandleManualMove(DGUS_VP_Variable &var, void *val_ptr);
66
+  // Hook for manual extrude.
67
+  static void HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr);
68
+  // Hook for motor lock and unlook
69
+  static void HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr);
70
+  #if ENABLED(POWER_LOSS_RECOVERY)
71
+    // Hook for power loss recovery.
72
+    static void HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr);
73
+  #endif
74
+  // Hook for settings
75
+  static void HandleSettings(DGUS_VP_Variable &var, void *val_ptr);
76
+  static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr);
77
+  static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr);
78
+
79
+  #if HAS_PID_HEATING
80
+    // Hook for "Change this temperature PID para"
81
+    static void HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr);
82
+    // Hook for PID autotune
83
+    static void HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr);
84
+  #endif
85
+  #if HAS_BED_PROBE
86
+    // Hook for "Change probe offset z"
87
+    static void HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr);
88
+  #endif
89
+  #if ENABLED(BABYSTEPPING)
90
+    // Hook for live z adjust action
91
+    static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr);
92
+  #endif
93
+  #if HAS_FAN
94
+    // Hook for fan control
95
+    static void HandleFanControl(DGUS_VP_Variable &var, void *val_ptr);
96
+  #endif
97
+  // Hook for heater control
98
+  static void HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr);
99
+  #if ENABLED(DGUS_PREHEAT_UI)
100
+    // Hook for preheat
101
+    static void HandlePreheat(DGUS_VP_Variable &var, void *val_ptr);
102
+  #endif
103
+  #if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
104
+    // Hook for filament load and unload filament option
105
+    static void HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr);
106
+    // Hook for filament load and unload
107
+    static void HandleFilamentLoadUnload(DGUS_VP_Variable &var);
108
+  #endif
109
+
110
+  #if ENABLED(SDSUPPORT)
111
+    // Callback for VP "Display wants to change screen when there is a SD card"
112
+    static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr);
113
+    // Scroll buttons on the file listing screen.
114
+    static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr);
115
+    // File touched.
116
+    static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr);
117
+    // start print after confirmation received.
118
+    static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr);
119
+    // User hit the pause, resume or abort button.
120
+    static void DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr);
121
+    // User confirmed the abort action
122
+    static void DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr);
123
+    // User hit the tune button
124
+    static void DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr);
125
+    // Send a single filename to the display.
126
+    static void DGUSLCD_SD_SendFilename(DGUS_VP_Variable &var);
127
+    // Marlin informed us that a new SD has been inserted.
128
+    static void SDCardInserted();
129
+    // Marlin informed us that the SD Card has been removed().
130
+    static void SDCardRemoved();
131
+    // Marlin informed us about a bad SD Card.
132
+    static void SDCardError();
133
+  #endif
134
+
135
+  // OK Button the Confirm screen.
136
+  static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr);
137
+
138
+  // Update data after went to new screen (by display or by GotoScreen)
139
+  // remember: store the last-displayed screen, so it can get returned to.
140
+  // (e.g for pop up messages)
141
+  static void UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup=false);
142
+
143
+  // Recall the remembered screen.
144
+  static void PopToOldScreen();
145
+
146
+  // Make the display show the screen and update all VPs in it.
147
+  static void GotoScreen(DGUSLCD_Screens screen, bool ispopup = false);
148
+
149
+  static void UpdateScreenVPData();
150
+
151
+  // Helpers to convert and transfer data to the display.
152
+  static void DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var);
153
+  static void DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var);
154
+  static void DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var);
155
+  static void DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var);
156
+  static void DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var);
157
+  static void DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var);
158
+  static void DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var);
159
+
160
+  #if ENABLED(PRINTCOUNTER)
161
+    static void DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var);
162
+    static void DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var);
163
+  #endif
164
+  #if HAS_FAN
165
+    static void DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var);
166
+  #endif
167
+  static void DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var);
168
+  #if ENABLED(DGUS_UI_WAITING)
169
+    static void DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var);
170
+  #endif
171
+
172
+  // Send a value from 0..100 to a variable with a range from 0..255
173
+  static void DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr);
174
+
175
+  template<typename T>
176
+  static void DGUSLCD_SetValueDirectly(DGUS_VP_Variable &var, void *val_ptr) {
177
+    if (!var.memadr) return;
178
+    union { unsigned char tmp[sizeof(T)]; T t; } x;
179
+    unsigned char *ptr = (unsigned char*)val_ptr;
180
+    LOOP_L_N(i, sizeof(T)) x.tmp[i] = ptr[sizeof(T) - i - 1];
181
+    *(T*)var.memadr = x.t;
182
+  }
183
+
184
+  // Send a float value to the display.
185
+  // Display will get a 4-byte integer scaled to the number of digits:
186
+  // Tell the display the number of digits and it cheats by displaying a dot between...
187
+  template<unsigned int decimals>
188
+  static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) {
189
+    if (var.memadr) {
190
+      float f = *(float *)var.memadr;
191
+      f *= cpow(10, decimals);
192
+      dgusdisplay.WriteVariable(var.VP, (long)f);
193
+    }
194
+  }
195
+
196
+  // Send a float value to the display.
197
+  // Display will get a 2-byte integer scaled to the number of digits:
198
+  // Tell the display the number of digits and it cheats by displaying a dot between...
199
+  template<unsigned int decimals>
200
+  static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) {
201
+    if (var.memadr) {
202
+      float f = *(float *)var.memadr;
203
+      DEBUG_ECHOLNPAIR_F(" >> ", f, 6);
204
+      f *= cpow(10, decimals);
205
+      dgusdisplay.WriteVariable(var.VP, (int16_t)f);
206
+    }
207
+  }
208
+
209
+  // Force an update of all VP on the current screen.
210
+  static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; }
211
+  // Has all VPs sent to the screen
212
+  static inline bool IsScreenComplete() { return ScreenComplete; }
213
+
214
+  static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; }
215
+
216
+  static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; }
217
+
218
+private:
219
+  static DGUSLCD_Screens current_screen;  //< currently on screen
220
+  static constexpr uint8_t NUM_PAST_SCREENS = 4;
221
+  static DGUSLCD_Screens past_screens[NUM_PAST_SCREENS]; //< LIFO with past screens for the "back" button.
222
+
223
+  static uint8_t update_ptr;      //< Last sent entry in the VPList for the actual screen.
224
+  static uint16_t skipVP;         //< When updating the screen data, skip this one, because the user is interacting with it.
225
+  static bool ScreenComplete;     //< All VPs sent to screen?
226
+
227
+  static uint16_t ConfirmVP;      //< context for confirm screen (VP that will be emulated-sent on "OK").
228
+
229
+  #if ENABLED(SDSUPPORT)
230
+    static int16_t top_file;      //< file on top of file chooser
231
+    static int16_t file_to_print; //< touched file to be confirmed
232
+  #endif
233
+
234
+  static void (*confirm_action_cb)();
235
+};
236
+
237
+#if ENABLED(POWER_LOSS_RECOVERY)
238
+  #define PLR_SCREEN_RECOVER DGUSLCD_SCREEN_SDPRINTMANIPULATION
239
+  #define PLR_SCREEN_CANCEL DGUSLCD_SCREEN_STATUS
240
+#endif

+ 418
- 0
Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp Прегледај датотеку

@@ -0,0 +1,418 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "../../../../../inc/MarlinConfigPre.h"
24
+
25
+#if ENABLED(DGUS_LCD_UI_HYPRECY)
26
+
27
+#include "../DGUSScreenHandler.h"
28
+
29
+#include "../../../../../MarlinCore.h"
30
+#include "../../../../../gcode/queue.h"
31
+#include "../../../../../libs/duration_t.h"
32
+#include "../../../../../module/settings.h"
33
+#include "../../../../../module/temperature.h"
34
+#include "../../../../../module/motion.h"
35
+#include "../../../../../module/planner.h"
36
+#include "../../../../../module/printcounter.h"
37
+#include "../../../../../sd/cardreader.h"
38
+
39
+#if ENABLED(POWER_LOSS_RECOVERY)
40
+  #include "../../../../feature/powerloss.h"
41
+#endif
42
+
43
+#if ENABLED(SDSUPPORT)
44
+
45
+  void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) {
46
+    uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file;
47
+    if (touched_nr > filelist.count()) return;
48
+    if (!filelist.seek(touched_nr)) return;
49
+
50
+    if (filelist.isDir()) {
51
+      filelist.changeDir(filelist.filename());
52
+      top_file = 0;
53
+      ForceCompleteUpdate();
54
+      return;
55
+    }
56
+
57
+    #if ENABLED(DGUS_PRINT_FILENAME)
58
+      // Send print filename
59
+      dgusdisplay.WriteVariable(VP_SD_Print_Filename, filelist.filename(), VP_SD_FileName_LEN, true);
60
+    #endif
61
+
62
+    // Setup Confirmation screen
63
+    file_to_print = touched_nr;
64
+
65
+    HandleUserConfirmationPopUp(VP_SD_FileSelectConfirm, nullptr, PSTR("Print file"), filelist.filename(), PSTR("from SD Card?"), true, true, false, true);
66
+  }
67
+
68
+  void DGUSScreenHandler::DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr) {
69
+    if (!filelist.seek(file_to_print)) return;
70
+    ExtUI::printFile(filelist.shortFilename());
71
+    GotoScreen(DGUSLCD_SCREEN_SDPRINTMANIPULATION);
72
+  }
73
+
74
+  void DGUSScreenHandler::DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr) {
75
+
76
+    if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes.
77
+    switch (swap16(*(uint16_t*)val_ptr)) {
78
+      case 0: { // Resume
79
+        if (ExtUI::isPrintingFromMediaPaused()) {
80
+          ExtUI::resumePrint();
81
+        }
82
+      } break;
83
+
84
+      case 1: // Pause
85
+
86
+        GotoScreen(MKSLCD_SCREEN_PAUSE);
87
+        if (!ExtUI::isPrintingFromMediaPaused()) {
88
+          ExtUI::pausePrint();
89
+          //ExtUI::mks_pausePrint();
90
+        }
91
+        break;
92
+      case 2: // Abort
93
+        HandleUserConfirmationPopUp(VP_SD_AbortPrintConfirmed, nullptr, PSTR("Abort printing"), filelist.filename(), PSTR("?"), true, true, false, true);
94
+        break;
95
+    }
96
+  }
97
+
98
+  void DGUSScreenHandler::DGUSLCD_SD_SendFilename(DGUS_VP_Variable& var) {
99
+    uint16_t target_line = (var.VP - VP_SD_FileName0) / VP_SD_FileName_LEN;
100
+    if (target_line > DGUS_SD_FILESPERSCREEN) return;
101
+    char tmpfilename[VP_SD_FileName_LEN + 1] = "";
102
+    var.memadr = (void*)tmpfilename;
103
+
104
+    if (filelist.seek(top_file + target_line)) {
105
+      snprintf_P(tmpfilename, VP_SD_FileName_LEN, PSTR("%s%c"), filelist.filename(), filelist.isDir() ? '/' : 0); // snprintf_P(tmpfilename, VP_SD_FileName_LEN, PSTR("%s"), filelist.filename());
106
+    }
107
+    DGUSLCD_SendStringToDisplay(var);
108
+  }
109
+
110
+  void DGUSScreenHandler::SDCardInserted() {
111
+    top_file = 0;
112
+    filelist.refresh();
113
+    auto cs = getCurrentScreen();
114
+    if (cs == DGUSLCD_SCREEN_MAIN || cs == DGUSLCD_SCREEN_STATUS)
115
+      GotoScreen(DGUSLCD_SCREEN_SDFILELIST);
116
+  }
117
+
118
+  void DGUSScreenHandler::SDCardRemoved() {
119
+    if (current_screen == DGUSLCD_SCREEN_SDFILELIST
120
+        || (current_screen == DGUSLCD_SCREEN_CONFIRM && (ConfirmVP == VP_SD_AbortPrintConfirmed || ConfirmVP == VP_SD_FileSelectConfirm))
121
+        || current_screen == DGUSLCD_SCREEN_SDPRINTMANIPULATION
122
+    ) GotoScreen(DGUSLCD_SCREEN_MAIN);
123
+  }
124
+
125
+#endif // SDSUPPORT
126
+
127
+void DGUSScreenHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) {
128
+  uint8_t *tmp = (uint8_t*)val_ptr;
129
+
130
+  // The keycode in target is coded as <from-frame><to-frame>, so 0x0100A means
131
+  // from screen 1 (main) to 10 (temperature). DGUSLCD_SCREEN_POPUP is special,
132
+  // meaning "return to previous screen"
133
+  DGUSLCD_Screens target = (DGUSLCD_Screens)tmp[1];
134
+
135
+  DEBUG_ECHOLNPAIR("\n DEBUG target", target);
136
+
137
+  if (target == DGUSLCD_SCREEN_POPUP) {
138
+    // Special handling for popup is to return to previous menu
139
+    if (current_screen == DGUSLCD_SCREEN_POPUP && confirm_action_cb) confirm_action_cb();
140
+    PopToOldScreen();
141
+    return;
142
+  }
143
+
144
+  UpdateNewScreen(target);
145
+
146
+  #ifdef DEBUG_DGUSLCD
147
+    if (!DGUSLCD_FindScreenVPMapList(target)) DEBUG_ECHOLNPAIR("WARNING: No screen Mapping found for ", target);
148
+  #endif
149
+}
150
+
151
+void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
152
+  DEBUG_ECHOLNPGM("HandleManualMove");
153
+
154
+  int16_t movevalue = swap16(*(uint16_t*)val_ptr);
155
+  #if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
156
+    if (movevalue) {
157
+      const uint16_t choice = *(uint16_t*)var.memadr;
158
+      movevalue = movevalue < 0 ? -choice : choice;
159
+    }
160
+  #endif
161
+  char axiscode;
162
+  unsigned int speed = 1500; // FIXME: get default feedrate for manual moves, dont hardcode.
163
+
164
+  switch (var.VP) {
165
+    default: return;
166
+
167
+    case VP_MOVE_X:
168
+      axiscode = 'X';
169
+      if (!ExtUI::canMove(ExtUI::axis_t::X)) goto cannotmove;
170
+      break;
171
+
172
+    case VP_MOVE_Y:
173
+      axiscode = 'Y';
174
+      if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove;
175
+      break;
176
+
177
+    case VP_MOVE_Z:
178
+      axiscode = 'Z';
179
+      speed = 300; // default to 5mm/s
180
+      if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove;
181
+      break;
182
+
183
+    case VP_HOME_ALL: // only used for homing
184
+      axiscode  = '\0';
185
+      movevalue = 0; // ignore value sent from display, this VP is _ONLY_ for homing.
186
+      break;
187
+  }
188
+
189
+  if (!movevalue) {
190
+    // homing
191
+    DEBUG_ECHOPAIR(" homing ", axiscode);
192
+    char buf[6] = "G28 X";
193
+    buf[4] = axiscode;
194
+    //DEBUG_ECHOPAIR(" ", buf);
195
+    queue.enqueue_one_now(buf);
196
+    //DEBUG_ECHOLNPGM(" ✓");
197
+    ForceCompleteUpdate();
198
+    return;
199
+  }
200
+  else {
201
+    // movement
202
+    DEBUG_ECHOPAIR(" move ", axiscode);
203
+    bool old_relative_mode = relative_mode;
204
+    if (!relative_mode) {
205
+      //DEBUG_ECHOPGM(" G91");
206
+      queue.enqueue_now_P(PSTR("G91"));
207
+      //DEBUG_ECHOPGM(" ✓ ");
208
+    }
209
+    char buf[32]; // G1 X9999.99 F12345
210
+    unsigned int backup_speed = MMS_TO_MMM(feedrate_mm_s);
211
+    char sign[] = "\0";
212
+    int16_t value = movevalue / 100;
213
+    if (movevalue < 0) { value = -value; sign[0] = '-'; }
214
+    int16_t fraction = ABS(movevalue) % 100;
215
+    snprintf_P(buf, 32, PSTR("G0 %c%s%d.%02d F%d"), axiscode, sign, value, fraction, speed);
216
+    //DEBUG_ECHOPAIR(" ", buf);
217
+    queue.enqueue_one_now(buf);
218
+    //DEBUG_ECHOLNPGM(" ✓ ");
219
+    if (backup_speed != speed) {
220
+      snprintf_P(buf, 32, PSTR("G0 F%d"), backup_speed);
221
+      queue.enqueue_one_now(buf);
222
+      //DEBUG_ECHOPAIR(" ", buf);
223
+    }
224
+    // while (!enqueue_and_echo_command(buf)) idle();
225
+    //DEBUG_ECHOLNPGM(" ✓ ");
226
+    if (!old_relative_mode) {
227
+      //DEBUG_ECHOPGM("G90");
228
+      queue.enqueue_now_P(PSTR("G90"));
229
+      //DEBUG_ECHOPGM(" ✓ ");
230
+    }
231
+  }
232
+
233
+  ForceCompleteUpdate();
234
+  DEBUG_ECHOLNPGM("manmv done.");
235
+  return;
236
+
237
+  cannotmove:
238
+    DEBUG_ECHOLNPAIR(" cannot move ", axiscode);
239
+    return;
240
+}
241
+
242
+#if HAS_PID_HEATING
243
+  void DGUSScreenHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) {
244
+    uint16_t rawvalue = swap16(*(uint16_t*)val_ptr);
245
+    DEBUG_ECHOLNPAIR("V1:", rawvalue);
246
+    float value = (float)rawvalue / 10;
247
+    DEBUG_ECHOLNPAIR("V2:", value);
248
+    float newvalue = 0;
249
+
250
+    switch (var.VP) {
251
+      default: return;
252
+        #if HOTENDS >= 1
253
+          case VP_E0_PID_P: newvalue = value; break;
254
+          case VP_E0_PID_I: newvalue = scalePID_i(value); break;
255
+          case VP_E0_PID_D: newvalue = scalePID_d(value); break;
256
+        #endif
257
+        #if HOTENDS >= 2
258
+          case VP_E1_PID_P: newvalue = value; break;
259
+          case VP_E1_PID_I: newvalue = scalePID_i(value); break;
260
+          case VP_E1_PID_D: newvalue = scalePID_d(value); break;
261
+        #endif
262
+        #if HAS_HEATED_BED
263
+          case VP_BED_PID_P: newvalue = value; break;
264
+          case VP_BED_PID_I: newvalue = scalePID_i(value); break;
265
+          case VP_BED_PID_D: newvalue = scalePID_d(value); break;
266
+        #endif
267
+    }
268
+
269
+    DEBUG_ECHOLNPAIR_F("V3:", newvalue);
270
+    *(float *)var.memadr = newvalue;
271
+
272
+    skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
273
+  }
274
+#endif // HAS_PID_HEATING
275
+
276
+#if ENABLED(BABYSTEPPING)
277
+  void DGUSScreenHandler::HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr) {
278
+    DEBUG_ECHOLNPGM("HandleLiveAdjustZ");
279
+    int16_t flag  = swap16(*(uint16_t*)val_ptr),
280
+            steps = flag ? -20 : 20;
281
+    ExtUI::smartAdjustAxis_steps(steps, ExtUI::axis_t::Z, true);
282
+    ForceCompleteUpdate();
283
+  }
284
+#endif
285
+
286
+#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
287
+
288
+  void DGUSScreenHandler::HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr) {
289
+    DEBUG_ECHOLNPGM("HandleFilamentOption");
290
+
291
+    uint8_t e_temp = 0;
292
+    filament_data.heated = false;
293
+    uint16_t preheat_option = swap16(*(uint16_t*)val_ptr);
294
+    if (preheat_option <= 8) {      // Load filament type
295
+      filament_data.action = 1;
296
+    }
297
+    else if (preheat_option >= 10) { // Unload filament type
298
+      preheat_option -= 10;
299
+      filament_data.action = 2;
300
+      filament_data.purge_length = DGUS_FILAMENT_PURGE_LENGTH;
301
+    }
302
+    else {                          // Cancel filament operation
303
+      filament_data.action = 0;
304
+    }
305
+
306
+    switch (preheat_option) {
307
+      case 0: // Load PLA
308
+        #ifdef PREHEAT_1_TEMP_HOTEND
309
+          e_temp = PREHEAT_1_TEMP_HOTEND;
310
+        #endif
311
+        break;
312
+      case 1: // Load ABS
313
+        TERN_(PREHEAT_2_TEMP_HOTEND, e_temp = PREHEAT_2_TEMP_HOTEND);
314
+        break;
315
+      case 2: // Load PET
316
+        #ifdef PREHEAT_3_TEMP_HOTEND
317
+          e_temp = PREHEAT_3_TEMP_HOTEND;
318
+        #endif
319
+        break;
320
+      case 3: // Load FLEX
321
+        #ifdef PREHEAT_4_TEMP_HOTEND
322
+          e_temp = PREHEAT_4_TEMP_HOTEND;
323
+        #endif
324
+        break;
325
+      case 9: // Cool down
326
+      default:
327
+        e_temp = 0;
328
+        break;
329
+    }
330
+
331
+    if (filament_data.action == 0) { // Go back to utility screen
332
+      #if HOTENDS >= 1
333
+        thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0);
334
+      #endif
335
+      #if HOTENDS >= 2
336
+        thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1);
337
+      #endif
338
+      GotoScreen(DGUSLCD_SCREEN_UTILITY);
339
+    }
340
+    else { // Go to the preheat screen to show the heating progress
341
+      switch (var.VP) {
342
+        default: return;
343
+          #if HOTENDS >= 1
344
+            case VP_E0_FILAMENT_LOAD_UNLOAD:
345
+              filament_data.extruder = ExtUI::extruder_t::E0;
346
+              thermalManager.setTargetHotend(e_temp, filament_data.extruder);
347
+              break;
348
+          #endif
349
+          #if HOTENDS >= 2
350
+            case VP_E1_FILAMENT_LOAD_UNLOAD:
351
+              filament_data.extruder = ExtUI::extruder_t::E1;
352
+              thermalManager.setTargetHotend(e_temp, filament_data.extruder);
353
+              break;
354
+          #endif
355
+      }
356
+      GotoScreen(DGUSLCD_SCREEN_FILAMENT_HEATING);
357
+    }
358
+  }
359
+
360
+  void DGUSScreenHandler::HandleFilamentLoadUnload(DGUS_VP_Variable &var) {
361
+    DEBUG_ECHOLNPGM("HandleFilamentLoadUnload");
362
+    if (filament_data.action <= 0) return;
363
+
364
+    // If we close to the target temperature, we can start load or unload the filament
365
+    if (thermalManager.hotEnoughToExtrude(filament_data.extruder) && \
366
+        thermalManager.targetHotEnoughToExtrude(filament_data.extruder)) {
367
+      float movevalue = DGUS_FILAMENT_LOAD_LENGTH_PER_TIME;
368
+
369
+      if (filament_data.action == 1) { // load filament
370
+        if (!filament_data.heated) {
371
+          //GotoScreen(DGUSLCD_SCREEN_FILAMENT_LOADING);
372
+          filament_data.heated = true;
373
+        }
374
+        movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) + movevalue;
375
+      }
376
+      else { // unload filament
377
+        if (!filament_data.heated) {
378
+          GotoScreen(DGUSLCD_SCREEN_FILAMENT_UNLOADING);
379
+          filament_data.heated = true;
380
+        }
381
+        // Before unloading extrude to prevent jamming
382
+        if (filament_data.purge_length >= 0) {
383
+          movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) + movevalue;
384
+          filament_data.purge_length -= movevalue;
385
+        }
386
+        else {
387
+          movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) - movevalue;
388
+        }
389
+      }
390
+      ExtUI::setAxisPosition_mm(movevalue, filament_data.extruder);
391
+    }
392
+  }
393
+#endif // DGUS_FILAMENT_LOADUNLOAD
394
+
395
+bool DGUSScreenHandler::loop() {
396
+  dgusdisplay.loop();
397
+
398
+  const millis_t ms = millis();
399
+  static millis_t next_event_ms = 0;
400
+
401
+  if (!IsScreenComplete() || ELAPSED(ms, next_event_ms)) {
402
+    next_event_ms = ms + DGUS_UPDATE_INTERVAL_MS;
403
+    UpdateScreenVPData();
404
+  }
405
+
406
+  #if ENABLED(SHOW_BOOTSCREEN)
407
+    static bool booted = false;
408
+
409
+    if (!booted && TERN0(POWER_LOSS_RECOVERY, recovery.valid()))
410
+      booted = true;
411
+
412
+    if (!booted && ELAPSED(ms, TERN(USE_MKS_GREEN_UI, 1000, BOOTSCREEN_TIMEOUT)))
413
+      booted = true;
414
+  #endif
415
+  return IsScreenComplete();
416
+}
417
+
418
+#endif // DGUS_LCD_UI_HYPRECY

+ 240
- 0
Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.h Прегледај датотеку

@@ -0,0 +1,240 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "../DGUSDisplay.h"
25
+#include "../DGUSVPVariable.h"
26
+#include "../DGUSDisplayDef.h"
27
+
28
+#include "../../../../../inc/MarlinConfig.h"
29
+
30
+enum DGUSLCD_Screens : uint8_t;
31
+
32
+class DGUSScreenHandler {
33
+public:
34
+  DGUSScreenHandler() = default;
35
+
36
+  static bool loop();
37
+
38
+  // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
39
+  // The bools specifing whether the strings are in RAM or FLASH.
40
+  static void sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
41
+
42
+  static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
43
+
44
+  // "M117" Message -- msg is a RAM ptr.
45
+  static void setstatusmessage(const char* msg);
46
+  // The same for messages from Flash
47
+  static void setstatusmessagePGM(PGM_P const msg);
48
+  // Callback for VP "Display wants to change screen on idle printer"
49
+  static void ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr);
50
+  // Callback for VP "Screen has been changed"
51
+  static void ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr);
52
+
53
+  // Callback for VP "All Heaters Off"
54
+  static void HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr);
55
+  // Hook for "Change this temperature"
56
+  static void HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr);
57
+  // Hook for "Change Flowrate"
58
+  static void HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr);
59
+  #if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
60
+    // Hook for manual move option
61
+    static void HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr);
62
+  #endif
63
+
64
+  // Hook for manual move.
65
+  static void HandleManualMove(DGUS_VP_Variable &var, void *val_ptr);
66
+  // Hook for manual extrude.
67
+  static void HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr);
68
+  // Hook for motor lock and unlook
69
+  static void HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr);
70
+  #if ENABLED(POWER_LOSS_RECOVERY)
71
+    // Hook for power loss recovery.
72
+    static void HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr);
73
+  #endif
74
+  // Hook for settings
75
+  static void HandleSettings(DGUS_VP_Variable &var, void *val_ptr);
76
+  static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr);
77
+  static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr);
78
+
79
+  #if HAS_PID_HEATING
80
+    // Hook for "Change this temperature PID para"
81
+    static void HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr);
82
+    // Hook for PID autotune
83
+    static void HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr);
84
+  #endif
85
+  #if HAS_BED_PROBE
86
+    // Hook for "Change probe offset z"
87
+    static void HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr);
88
+  #endif
89
+  #if ENABLED(BABYSTEPPING)
90
+    // Hook for live z adjust action
91
+    static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr);
92
+  #endif
93
+  #if HAS_FAN
94
+    // Hook for fan control
95
+    static void HandleFanControl(DGUS_VP_Variable &var, void *val_ptr);
96
+  #endif
97
+  // Hook for heater control
98
+  static void HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr);
99
+  #if ENABLED(DGUS_PREHEAT_UI)
100
+    // Hook for preheat
101
+    static void HandlePreheat(DGUS_VP_Variable &var, void *val_ptr);
102
+  #endif
103
+  #if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
104
+    // Hook for filament load and unload filament option
105
+    static void HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr);
106
+    // Hook for filament load and unload
107
+    static void HandleFilamentLoadUnload(DGUS_VP_Variable &var);
108
+  #endif
109
+
110
+  #if ENABLED(SDSUPPORT)
111
+    // Callback for VP "Display wants to change screen when there is a SD card"
112
+    static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr);
113
+    // Scroll buttons on the file listing screen.
114
+    static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr);
115
+    // File touched.
116
+    static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr);
117
+    // start print after confirmation received.
118
+    static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr);
119
+    // User hit the pause, resume or abort button.
120
+    static void DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr);
121
+    // User confirmed the abort action
122
+    static void DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr);
123
+    // User hit the tune button
124
+    static void DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr);
125
+    // Send a single filename to the display.
126
+    static void DGUSLCD_SD_SendFilename(DGUS_VP_Variable &var);
127
+    // Marlin informed us that a new SD has been inserted.
128
+    static void SDCardInserted();
129
+    // Marlin informed us that the SD Card has been removed().
130
+    static void SDCardRemoved();
131
+    // Marlin informed us about a bad SD Card.
132
+    static void SDCardError();
133
+  #endif
134
+
135
+  // OK Button the Confirm screen.
136
+  static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr);
137
+
138
+  // Update data after went to new screen (by display or by GotoScreen)
139
+  // remember: store the last-displayed screen, so it can get returned to.
140
+  // (e.g for pop up messages)
141
+  static void UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup=false);
142
+
143
+  // Recall the remembered screen.
144
+  static void PopToOldScreen();
145
+
146
+  // Make the display show the screen and update all VPs in it.
147
+  static void GotoScreen(DGUSLCD_Screens screen, bool ispopup = false);
148
+
149
+  static void UpdateScreenVPData();
150
+
151
+  // Helpers to convert and transfer data to the display.
152
+  static void DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var);
153
+  static void DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var);
154
+  static void DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var);
155
+  static void DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var);
156
+  static void DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var);
157
+  static void DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var);
158
+  static void DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var);
159
+
160
+  #if ENABLED(PRINTCOUNTER)
161
+    static void DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var);
162
+    static void DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var);
163
+  #endif
164
+  #if HAS_FAN
165
+    static void DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var);
166
+  #endif
167
+  static void DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var);
168
+  #if ENABLED(DGUS_UI_WAITING)
169
+    static void DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var);
170
+  #endif
171
+
172
+  // Send a value from 0..100 to a variable with a range from 0..255
173
+  static void DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr);
174
+
175
+  template<typename T>
176
+  static void DGUSLCD_SetValueDirectly(DGUS_VP_Variable &var, void *val_ptr) {
177
+    if (!var.memadr) return;
178
+    union { unsigned char tmp[sizeof(T)]; T t; } x;
179
+    unsigned char *ptr = (unsigned char*)val_ptr;
180
+    LOOP_L_N(i, sizeof(T)) x.tmp[i] = ptr[sizeof(T) - i - 1];
181
+    *(T*)var.memadr = x.t;
182
+  }
183
+
184
+  // Send a float value to the display.
185
+  // Display will get a 4-byte integer scaled to the number of digits:
186
+  // Tell the display the number of digits and it cheats by displaying a dot between...
187
+  template<unsigned int decimals>
188
+  static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) {
189
+    if (var.memadr) {
190
+      float f = *(float *)var.memadr;
191
+      f *= cpow(10, decimals);
192
+      dgusdisplay.WriteVariable(var.VP, (long)f);
193
+    }
194
+  }
195
+
196
+  // Send a float value to the display.
197
+  // Display will get a 2-byte integer scaled to the number of digits:
198
+  // Tell the display the number of digits and it cheats by displaying a dot between...
199
+  template<unsigned int decimals>
200
+  static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) {
201
+    if (var.memadr) {
202
+      float f = *(float *)var.memadr;
203
+      DEBUG_ECHOLNPAIR_F(" >> ", f, 6);
204
+      f *= cpow(10, decimals);
205
+      dgusdisplay.WriteVariable(var.VP, (int16_t)f);
206
+    }
207
+  }
208
+
209
+  // Force an update of all VP on the current screen.
210
+  static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; }
211
+  // Has all VPs sent to the screen
212
+  static inline bool IsScreenComplete() { return ScreenComplete; }
213
+
214
+  static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; }
215
+
216
+  static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; }
217
+
218
+private:
219
+  static DGUSLCD_Screens current_screen;  //< currently on screen
220
+  static constexpr uint8_t NUM_PAST_SCREENS = 4;
221
+  static DGUSLCD_Screens past_screens[NUM_PAST_SCREENS]; //< LIFO with past screens for the "back" button.
222
+
223
+  static uint8_t update_ptr;      //< Last sent entry in the VPList for the actual screen.
224
+  static uint16_t skipVP;         //< When updating the screen data, skip this one, because the user is interacting with it.
225
+  static bool ScreenComplete;     //< All VPs sent to screen?
226
+
227
+  static uint16_t ConfirmVP;      //< context for confirm screen (VP that will be emulated-sent on "OK").
228
+
229
+  #if ENABLED(SDSUPPORT)
230
+    static int16_t top_file;      //< file on top of file chooser
231
+    static int16_t file_to_print; //< touched file to be confirmed
232
+  #endif
233
+
234
+  static void (*confirm_action_cb)();
235
+};
236
+
237
+#if ENABLED(POWER_LOSS_RECOVERY)
238
+  #define PLR_SCREEN_RECOVER DGUSLCD_SCREEN_SDPRINTMANIPULATION
239
+  #define PLR_SCREEN_CANCEL DGUSLCD_SCREEN_STATUS
240
+#endif

+ 795
- 0
Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp Прегледај датотеку

@@ -0,0 +1,795 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "../../../../../inc/MarlinConfigPre.h"
24
+
25
+#if ENABLED(DGUS_LCD_UI_MKS)
26
+
27
+#include "DGUSDisplayDef.h"
28
+#include "../DGUSDisplay.h"
29
+#include "../DGUSScreenHandler.h"
30
+
31
+#include "../../../../../module/temperature.h"
32
+#include "../../../../../module/motion.h"
33
+#include "../../../../../module/planner.h"
34
+
35
+#include "../../../ui_api.h"
36
+#include "../../../../marlinui.h"
37
+
38
+#if ENABLED(HAS_STEALTHCHOP)
39
+  #include "../../../../module/stepper/trinamic.h"
40
+#endif
41
+
42
+#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
43
+  uint16_t distanceToMove = 10;
44
+#endif
45
+
46
+uint16_t distanceMove = 1;
47
+float distanceFilament = 10;
48
+uint16_t FilamentSpeed = 25;
49
+float ZOffset_distance = 0.1;
50
+float mesh_adj_distance = 0.1;
51
+float Z_distance = 0.1;
52
+
53
+int16_t level_1_x_point = 20;
54
+int16_t level_1_y_point = 20;
55
+
56
+int16_t level_2_x_point = 20;
57
+int16_t level_2_y_point = 20;
58
+
59
+int16_t level_3_x_point = 20;
60
+int16_t level_3_y_point = 20;
61
+
62
+int16_t level_4_x_point = 20;
63
+int16_t level_4_y_point = 20;
64
+int16_t level_5_x_point = X_MAX_POS / 2;
65
+int16_t level_5_y_point = Y_MAX_POS / 2;
66
+
67
+uint16_t tim_h;
68
+uint16_t tim_m;
69
+uint16_t tim_s;
70
+
71
+uint16_t x_park_pos = 20;
72
+uint16_t y_park_pos = 20;
73
+uint16_t z_park_pos = 10;
74
+
75
+xyz_pos_t position_before_pause;
76
+
77
+void MKS_pause_print_move() {
78
+  planner.synchronize();
79
+  position_before_pause = current_position;
80
+  do_blocking_move_to(X_MIN_POS + x_park_pos, Y_MIN_POS + y_park_pos, current_position.z + z_park_pos);
81
+}
82
+
83
+void MKS_resume_print_move() { do_blocking_move_to(position_before_pause); }
84
+
85
+uint16_t min_ex_temp = 0;
86
+
87
+float z_offset_add = 0;
88
+
89
+#if ENABLED(SENSORLESS_HOMING)
90
+  uint16_t tmc_x_step = 0;
91
+  uint16_t tmc_y_step = 0;
92
+  uint16_t tmc_z_step = 0;
93
+#else
94
+  uint16_t tmc_x_step = 0;
95
+  uint16_t tmc_y_step = 0;
96
+  uint16_t tmc_z_step = 0;
97
+#endif
98
+
99
+uint16_t lcd_default_light = 50;
100
+
101
+EX_FILAMENT_DEF ex_filament;
102
+RUNOUT_MKS_DEF runout_mks;
103
+NOZZLE_PARK_DEF nozzle_park_mks;
104
+
105
+const uint16_t VPList_Boot[] PROGMEM = {
106
+  VP_MARLIN_VERSION,
107
+  0x0000
108
+};
109
+
110
+#define MKSLIST_E_ITEM(N) VP_T_E##N##_Is, VP_T_E##N##_Set,
111
+
112
+const uint16_t VPList_Main[] PROGMEM = {
113
+  // VP_M117, for completeness, but it cannot be auto-uploaded.
114
+  #if HOTENDS >= 1
115
+    MKSLIST_E_ITEM(0) VP_E0_STATUS,
116
+  #endif
117
+  #if HOTENDS >= 2
118
+    MKSLIST_E_ITEM(1)
119
+  #endif
120
+  #if HAS_HEATED_BED
121
+    VP_T_Bed_Is, VP_T_Bed_Set, VP_BED_STATUS,
122
+  #endif
123
+  #if HAS_FAN
124
+    VP_Fan0_Percentage, VP_FAN0_STATUS,
125
+  #endif
126
+  VP_XPos, VP_YPos, VP_ZPos,
127
+  VP_Fan0_Percentage,
128
+  VP_Feedrate_Percentage,
129
+  #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
130
+    VP_PrintProgress_Percentage,
131
+  #endif
132
+  0x0000
133
+};
134
+
135
+const uint16_t MKSList_Home[] PROGMEM = {
136
+  // E Temp
137
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
138
+  // HB Temp
139
+  VP_T_Bed_Is, VP_T_Bed_Set,
140
+  // FAN
141
+  VP_Fan0_Percentage,
142
+  // Language
143
+  // VP_HOME_Dis,
144
+
145
+  0x0000
146
+};
147
+
148
+const uint16_t MKSList_Setting[] PROGMEM = {
149
+  // E Temp
150
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
151
+  // HB Temp
152
+  VP_T_Bed_Is, VP_T_Bed_Set,
153
+  // FAN
154
+  VP_Fan0_Percentage,
155
+  // Language
156
+  VP_Setting_Dis,
157
+  0x0000
158
+};
159
+
160
+const uint16_t MKSList_Tool[] PROGMEM = {
161
+  // E Temp
162
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
163
+  // HB Temp
164
+  VP_T_Bed_Is, VP_T_Bed_Set,
165
+  // FAN
166
+  VP_Fan0_Percentage,
167
+  // Language
168
+  VP_Tool_Dis,
169
+  // LCD BLK
170
+  VP_LCD_BLK,
171
+  0x0000
172
+};
173
+
174
+const uint16_t MKSList_EXTRUE[] PROGMEM = {
175
+  // E Temp
176
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
177
+  // HB Temp
178
+  VP_T_Bed_Is, VP_T_Bed_Set,
179
+  // FAN
180
+  VP_Fan0_Percentage,
181
+
182
+  VP_Filament_distance,
183
+  VP_Filament_speed,
184
+
185
+  0x0000
186
+};
187
+
188
+const uint16_t MKSList_LEVEL[] PROGMEM = {
189
+  // E Temp
190
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
191
+  // HB Temp
192
+  VP_T_Bed_Is, VP_T_Bed_Set,
193
+  // FAN
194
+  VP_Fan0_Percentage,
195
+
196
+  0x0000
197
+};
198
+
199
+const uint16_t MKSList_MOVE[] PROGMEM = {
200
+  // E Temp
201
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
202
+  // HB Temp
203
+  VP_T_Bed_Is, VP_T_Bed_Set,
204
+  // FAN
205
+  VP_Fan0_Percentage,
206
+
207
+  0x0000
208
+};
209
+
210
+const uint16_t MKSList_Print[] PROGMEM = {
211
+  // E Temp
212
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
213
+  // HB Temp
214
+  VP_T_Bed_Is, VP_T_Bed_Set,
215
+  // FAN
216
+  VP_Fan0_Percentage,
217
+  // Print Percent
218
+  VP_PrintProgress_Percentage,
219
+
220
+  VP_PrintTime,
221
+
222
+  VP_Flowrate_E0,
223
+  VP_Flowrate_E1,
224
+  VP_Feedrate_Percentage,
225
+
226
+  VP_PrintTime_H,
227
+  VP_PrintTime_M,
228
+  VP_PrintTime_S,
229
+
230
+  VP_XPos,
231
+  VP_YPos,
232
+  VP_ZPos,
233
+
234
+  0x0000
235
+};
236
+
237
+const uint16_t MKSList_SD_File[] PROGMEM = {
238
+  VP_SD_FileName0, VP_SD_FileName1,
239
+  VP_SD_FileName2, VP_SD_FileName3,
240
+  VP_SD_FileName4, VP_SD_FileName5,
241
+  VP_SD_FileName6, VP_SD_FileName7,
242
+  VP_SD_FileName8, VP_SD_FileName9,
243
+
244
+  0x0000
245
+};
246
+
247
+const uint16_t MKSList_TempOnly[] PROGMEM = {
248
+  // E Temp
249
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
250
+  // HB Temp
251
+  VP_T_Bed_Is, VP_T_Bed_Set,
252
+  // FAN
253
+  VP_Fan0_Percentage,
254
+  // LCD BLK
255
+  VP_LCD_BLK,
256
+  0x0000
257
+};
258
+
259
+const uint16_t MKSList_Pluse[] PROGMEM = {
260
+  // E Temp
261
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
262
+  // HB Temp
263
+  VP_T_Bed_Is, VP_T_Bed_Set,
264
+  // FAN
265
+  VP_Fan0_Percentage,
266
+
267
+  // Pluse
268
+  VP_X_STEP_PER_MM,
269
+  VP_Y_STEP_PER_MM,
270
+  VP_Z_STEP_PER_MM,
271
+  VP_E0_STEP_PER_MM,
272
+  VP_E1_STEP_PER_MM,
273
+
274
+  0x0000
275
+};
276
+
277
+const uint16_t MKSList_MaxSpeed[] PROGMEM = {
278
+  // E Temp
279
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
280
+  // HB Temp
281
+  VP_T_Bed_Is, VP_T_Bed_Set,
282
+  // FAN
283
+  VP_Fan0_Percentage,
284
+
285
+  // Pluse
286
+  VP_X_MAX_SPEED,
287
+  VP_Y_MAX_SPEED,
288
+  VP_Z_MAX_SPEED,
289
+  VP_E0_MAX_SPEED,
290
+  VP_E1_MAX_SPEED,
291
+
292
+  0x0000
293
+};
294
+
295
+const uint16_t MKSList_MaxAcc[] PROGMEM = {
296
+  // E Temp
297
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
298
+  // HB Temp
299
+  VP_T_Bed_Is, VP_T_Bed_Set,
300
+  // FAN
301
+  VP_Fan0_Percentage,
302
+
303
+  // ACC
304
+  VP_ACC_SPEED,
305
+  VP_X_ACC_MAX_SPEED,
306
+  VP_Y_ACC_MAX_SPEED,
307
+  VP_Z_ACC_MAX_SPEED,
308
+  VP_E0_ACC_MAX_SPEED,
309
+  VP_E1_ACC_MAX_SPEED,
310
+
311
+  0x0000
312
+};
313
+
314
+const uint16_t MKSList_PID[] PROGMEM = {
315
+  // E Temp
316
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
317
+  // HB Temp
318
+  VP_T_Bed_Is, VP_T_Bed_Set,
319
+  // FAN
320
+  VP_Fan0_Percentage,
321
+
322
+  // PID
323
+  VP_E0_PID_P,
324
+  VP_E0_PID_I,
325
+  VP_E0_PID_D,
326
+
327
+  0x0000
328
+};
329
+
330
+const uint16_t MKSList_Level_Point[] PROGMEM = {
331
+  // E Temp
332
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
333
+  // HB Temp
334
+  VP_T_Bed_Is, VP_T_Bed_Set,
335
+  // FAN
336
+  VP_Fan0_Percentage,
337
+
338
+  // Level Point
339
+  VP_Level_Point_One_X,
340
+  VP_Level_Point_One_Y,
341
+  VP_Level_Point_Two_X,
342
+  VP_Level_Point_Two_Y,
343
+  VP_Level_Point_Three_X,
344
+  VP_Level_Point_Three_Y,
345
+  VP_Level_Point_Four_X,
346
+  VP_Level_Point_Four_Y,
347
+  VP_Level_Point_Five_X,
348
+  VP_Level_Point_Five_Y,
349
+
350
+  0x0000
351
+};
352
+
353
+const uint16_t MKSList_Level_PrintConfig[] PROGMEM = {
354
+  VP_T_E0_Set,
355
+  VP_T_E1_Set,
356
+  VP_T_Bed_Set,
357
+  VP_Flowrate_E0,
358
+  VP_Flowrate_E1,
359
+  VP_Fan0_Percentage,
360
+  VP_Feedrate_Percentage,
361
+
362
+  0x0000
363
+};
364
+
365
+const uint16_t MKSList_PrintPauseConfig[] PROGMEM = {
366
+  // E Temp
367
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
368
+  // HB Temp
369
+  VP_T_Bed_Is, VP_T_Bed_Set,
370
+
371
+  VP_X_PARK_POS,
372
+  VP_Y_PARK_POS,
373
+  VP_Z_PARK_POS,
374
+
375
+  0x0000
376
+};
377
+
378
+const uint16_t MKSList_MotoConfig[] PROGMEM = {
379
+  // E Temp
380
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
381
+  // HB Temp
382
+  VP_T_Bed_Is, VP_T_Bed_Set,
383
+
384
+  VP_TRAVEL_SPEED,
385
+  VP_FEEDRATE_MIN_SPEED,
386
+  VP_T_F_SPEED,
387
+
388
+  0x0000
389
+};
390
+
391
+const uint16_t MKSList_EX_Config[] PROGMEM = {
392
+  // E Temp
393
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
394
+  // HB Temp
395
+  VP_T_Bed_Is, VP_T_Bed_Set,
396
+  VP_MIN_EX_T,VP_Min_EX_T_E,
397
+  0x0000
398
+};
399
+
400
+const uint16_t MKSTMC_Config[] PROGMEM = {
401
+  // E Temp
402
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
403
+  // HB Temp
404
+  VP_T_Bed_Is, VP_T_Bed_Set,
405
+  VP_MIN_EX_T,
406
+
407
+  VP_TMC_X_STEP,
408
+  VP_TMC_Y_STEP,
409
+  VP_TMC_Z_STEP,
410
+  VP_TMC_X1_Current,
411
+  VP_TMC_Y1_Current,
412
+  VP_TMC_X_Current,
413
+  VP_TMC_Y_Current,
414
+  VP_TMC_Z_Current,
415
+  VP_TMC_E0_Current,
416
+  VP_TMC_E1_Current,
417
+  VP_TMC_Z1_Current,
418
+
419
+  0x0000
420
+};
421
+
422
+const uint16_t MKSAuto_Level[] PROGMEM = {
423
+  VP_MESH_LEVEL_POINT_DIS,
424
+  VP_ZPos,
425
+  0x0000
426
+};
427
+
428
+const uint16_t MKSOffset_Config[] PROGMEM = {
429
+  // E Temp
430
+  REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
431
+  VP_OFFSET_X,
432
+  VP_OFFSET_Y,
433
+  VP_OFFSET_Z,
434
+  0x0000
435
+};
436
+
437
+const uint16_t MKSBabyStep[] PROGMEM = {
438
+  VP_ZOffset_DE_DIS,
439
+  0x0000
440
+};
441
+
442
+const uint16_t MKSList_About[] PROGMEM = {
443
+  // Marlin version
444
+  VP_MARLIN_VERSION,
445
+  // H43 Version
446
+  VP_MKS_H43_VERSION,
447
+  VP_MKS_H43_UpdataVERSION,
448
+  0x0000
449
+};
450
+
451
+// Page data updata
452
+const struct VPMapping VPMap[] PROGMEM = {
453
+  { MKSLCD_SCREEN_BOOT, VPList_Boot },                        // Boot Page to show logo  0
454
+  { MKSLCD_SCREEN_HOME, MKSList_Home },                       // Home, Page 1
455
+  { MKSLCD_SCREEN_SETTING, MKSList_Setting },                 // Setting, Page 2
456
+  { MKSLCD_SCREEM_TOOL, MKSList_Tool },                       // Page 3
457
+  { MKSLCD_SCREEN_EXTRUDE_P1, MKSList_EXTRUE },               // Page 4
458
+  { MKSLCD_SCREEN_EXTRUDE_P2, MKSList_EXTRUE },               // Page 11
459
+  { MKSLCD_PAUSE_SETTING_EX, MKSList_EXTRUE },                // Page 57
460
+  { MKSLCD_PAUSE_SETTING_EX2, MKSList_EXTRUE },               // Page 61
461
+  { MKSLCD_SCREEN_LEVEL, MKSList_LEVEL },                     // Page 5
462
+  { MKSLCD_SCREEN_MOVE, MKSList_MOVE },                       // Page 6
463
+  { MKSLCD_SCREEN_PRINT, MKSList_Print },                     // Page 7
464
+  { MKSLCD_SCREEN_PAUSE, MKSList_Print },                     // Page 26
465
+  { MKSLCD_SCREEN_CHOOSE_FILE, MKSList_SD_File },             // Page 15
466
+  { MKSLCD_SCREEN_MOTOR_PLUSE, MKSList_Pluse },               // Page 51
467
+  { MKSLCD_SCREEN_MOTOR_SPEED, MKSList_MaxSpeed },            // Page 55
468
+  { MKSLCD_SCREEN_MOTOR_ACC_MAX, MKSList_MaxAcc },            // Page 53
469
+  { MKSLCD_SCREEN_LEVEL_DATA, MKSList_Level_Point },          // Page 48
470
+  { MKSLCD_PrintPause_SET, MKSList_PrintPauseConfig },        // Page 49
471
+  { MKSLCD_FILAMENT_DATA, MKSList_SD_File },                  // Page 50
472
+  { MKSLCD_SCREEN_Config, MKSList_TempOnly },                 // Page 46
473
+  { MKSLCD_SCREEN_Config_MOTOR, MKSList_MotoConfig },         // Page 47
474
+  { MKSLCD_PID, MKSList_PID },                                // Page 56
475
+  { MKSLCD_ABOUT, MKSList_About },                            // Page 36
476
+  { MKSLCD_SCREEN_PRINT_CONFIG, MKSList_Level_PrintConfig },  // Page 60
477
+  { MKSLCD_SCREEN_EX_CONFIG, MKSList_EX_Config },             // Page 65
478
+  { MKSLCD_SCREEN_TMC_Config, MKSTMC_Config },                // Page 70
479
+  { MKSLCD_AUTO_LEVEL, MKSAuto_Level },                       // Page 73
480
+  { MKSLCD_Screen_Offset_Config, MKSOffset_Config },          // Page 30
481
+  { MKSLCD_Screen_PMove, MKSList_MOVE },                      // Page 64
482
+  { MKSLCD_Screen_Baby, MKSBabyStep },                        // Page 71
483
+  //{ MKSLCD_SCREEN_LEVEL_DATA, MKSList_SD_File},
484
+  //{ MKSLCD_SCREEN_HOME, VPList_Boot },
485
+  { 0, nullptr } // List is terminated with an nullptr as table entry.
486
+};
487
+
488
+const char MarlinVersion[] PROGMEM = SHORT_BUILD_VERSION;
489
+const char H43Version[] PROGMEM = "MKS H43_V1.30";
490
+const char Updata_Time[] PROGMEM = STRING_DISTRIBUTION_DATE;
491
+
492
+// Helper to define a DGUS_VP_Variable for common use cases.
493
+#define VPHELPER(VPADR, VPADRVAR, RXFPTR, TXFPTR)                       \
494
+  {                                                                     \
495
+    .VP = VPADR, .memadr = VPADRVAR, .size = sizeof(VPADRVAR),          \
496
+    .set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR \
497
+  }
498
+
499
+// Helper to define a DGUS_VP_Variable when the sizeo of the var cannot be determined automaticalyl (eg. a string)
500
+#define VPHELPER_STR(VPADR, VPADRVAR, STRLEN, RXFPTR, TXFPTR)           \
501
+  {                                                                     \
502
+    .VP = VPADR, .memadr = VPADRVAR, .size = STRLEN,                    \
503
+    .set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR \
504
+  }
505
+
506
+const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
507
+  // Helper to detect touch events
508
+  VPHELPER(VP_SCREENCHANGE, nullptr, ScreenHandler.ScreenChangeHook, nullptr),
509
+  VPHELPER(VP_SCREENCHANGE_ASK, nullptr, ScreenHandler.ScreenChangeHookIfIdle, nullptr),
510
+  #if ENABLED(SDSUPPORT)
511
+    VPHELPER(VP_SCREENCHANGE_WHENSD, nullptr, ScreenHandler.ScreenChangeHookIfSD, nullptr),
512
+  #endif
513
+  VPHELPER(VP_CONFIRMED, nullptr, ScreenHandler.ScreenConfirmedOK, nullptr),
514
+
515
+  // Back Button
516
+  VPHELPER(VP_BACK_PAGE, nullptr, &ScreenHandler.ScreenBackChange, nullptr),
517
+  VPHELPER(VP_TEMP_ALL_OFF, nullptr, &ScreenHandler.HandleAllHeatersOff, nullptr),
518
+
519
+  VPHELPER(VP_MOVE_X, nullptr, &ScreenHandler.HandleManualMove, nullptr),
520
+  VPHELPER(VP_MOVE_Y, nullptr, &ScreenHandler.HandleManualMove, nullptr),
521
+  VPHELPER(VP_MOVE_Z, nullptr, &ScreenHandler.HandleManualMove, nullptr),
522
+  VPHELPER(VP_HOME_ALL, nullptr, &ScreenHandler.HandleManualMove, nullptr),
523
+
524
+  VPHELPER(VP_X_HOME, nullptr, &ScreenHandler.HandleManualMove, nullptr),
525
+  VPHELPER(VP_Y_HOME, nullptr, &ScreenHandler.HandleManualMove, nullptr),
526
+  VPHELPER(VP_Z_HOME, nullptr, &ScreenHandler.HandleManualMove, nullptr),
527
+
528
+  VPHELPER(VP_MOVE_DISTANCE, &distanceMove, &ScreenHandler.GetManualMovestep, nullptr),
529
+
530
+  VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, &ScreenHandler.HandleManualMove, nullptr),
531
+  VPHELPER(VP_LEVEL_POINT, nullptr, &ScreenHandler.ManualAssistLeveling, nullptr),
532
+
533
+  #if ENABLED(POWER_LOSS_RECOVERY)
534
+    VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, &ScreenHandler.HandlePowerLossRecovery, nullptr),
535
+  #endif
536
+  VPHELPER(VP_SETTINGS, nullptr, &ScreenHandler.HandleSettings, nullptr),
537
+  #if ENABLED(SINGLE_Z_CALIBRATION)
538
+    VPHELPER(VP_Z_CALIBRATE, nullptr, &ScreenHandler.HandleZCalibration, nullptr),
539
+  #endif
540
+  #if ENABLED(FIRST_LAYER_CAL)
541
+    VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, &ScreenHandler.HandleFirstLayerCal, nullptr),
542
+  #endif
543
+  {.VP = VP_MARLIN_VERSION, .memadr = (void *)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM},
544
+  // M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr
545
+  {.VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplay},
546
+  {.VP = VP_MKS_H43_VERSION, .memadr = (void *)H43Version, .size = VP_MKS_H43_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM},
547
+  {.VP = VP_MKS_H43_UpdataVERSION, .memadr = (void *)Updata_Time, .size = VP_MKS_H43_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM},
548
+
549
+  // Temperature Data
550
+  #if HOTENDS >= 1
551
+    VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
552
+    VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
553
+    VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
554
+    VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
555
+    VPHELPER(VP_MOVE_E0, nullptr, &ScreenHandler.HandleManualExtrude, nullptr),
556
+    VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, &ScreenHandler.HandleHeaterControl, nullptr),
557
+    VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
558
+    #if ENABLED(DGUS_PREHEAT_UI)
559
+      VPHELPER(VP_E0_BED_PREHEAT, nullptr, &ScreenHandler.HandlePreheat, nullptr),
560
+    #endif
561
+    #if ENABLED(PIDTEMP)
562
+      VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
563
+      VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
564
+      VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
565
+      VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr),
566
+    #endif
567
+    #if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
568
+      VPHELPER(VP_LOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentLoad, nullptr),
569
+      VPHELPER(VP_UNLOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentUnLoad, nullptr),
570
+      VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
571
+      VPHELPER(VP_Filament_speed, &FilamentSpeed, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
572
+    #endif
573
+  #endif
574
+
575
+  #if HOTENDS >= 2
576
+    VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
577
+    VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
578
+    VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
579
+    VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr),
580
+    VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, &ScreenHandler.HandleHeaterControl, nullptr),
581
+    VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
582
+
583
+    #if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
584
+      VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
585
+      VPHELPER(VP_Filament_speed, &FilamentSpeed, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
586
+    #endif
587
+
588
+    #if ENABLED(PIDTEMP)
589
+      VPHELPER(VP_PID_AUTOTUNE_E1, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr),
590
+    #endif
591
+
592
+    VPHELPER(VP_E1_FILAMENT_LOAD_UNLOAD, nullptr, &ScreenHandler.HandleFilamentOption, &ScreenHandler.HandleFilamentLoadUnload),
593
+  #endif
594
+
595
+  #if HAS_HEATED_BED
596
+    VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
597
+    VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
598
+    VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr),
599
+    VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
600
+    #if ENABLED(PIDTEMPBED)
601
+      VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
602
+      VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
603
+      VPHELPER(VP_BED_PID_D, &thermalManager.temp_bed.pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
604
+      VPHELPER(VP_PID_AUTOTUNE_BED, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr),
605
+    #endif
606
+  #endif
607
+
608
+  // Fan Data
609
+  #if HAS_FAN
610
+    #define FAN_VPHELPER(N)                                                                                                                    \
611
+      VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_SetUint8, &ScreenHandler.DGUSLCD_SendFanToDisplay), \
612
+      VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], &ScreenHandler.HandleFanControl, nullptr),                               \
613
+      VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, &ScreenHandler.DGUSLCD_SendFanStatusToDisplay),
614
+    REPEAT(FAN_COUNT, FAN_VPHELPER)
615
+  #endif
616
+
617
+  // Feedrate
618
+  VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
619
+
620
+  // Position Data
621
+  VPHELPER(VP_XPos, &current_position.x, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
622
+  VPHELPER(VP_YPos, &current_position.y, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
623
+  VPHELPER(VP_ZPos, &current_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
624
+
625
+  // Level Point Set
626
+  VPHELPER(VP_Level_Point_One_X, &level_1_x_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
627
+  VPHELPER(VP_Level_Point_One_Y, &level_1_y_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
628
+  VPHELPER(VP_Level_Point_Two_X, &level_2_x_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
629
+  VPHELPER(VP_Level_Point_Two_Y, &level_2_y_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
630
+  VPHELPER(VP_Level_Point_Three_X, &level_3_x_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
631
+  VPHELPER(VP_Level_Point_Three_Y, &level_3_y_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
632
+  VPHELPER(VP_Level_Point_Four_X, &level_4_x_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
633
+  VPHELPER(VP_Level_Point_Four_Y, &level_4_y_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
634
+  VPHELPER(VP_Level_Point_Five_X, &level_5_x_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
635
+  VPHELPER(VP_Level_Point_Five_Y, &level_5_y_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
636
+
637
+  // Print Progress
638
+  VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay),
639
+
640
+  //LCD Control
641
+  VPHELPER(VP_LCD_BLK, &lcd_default_light, &ScreenHandler.LCD_BLK_Adjust, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
642
+
643
+  // Print Time
644
+  VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay_MKS),
645
+
646
+  #if ENABLED(PRINTCOUNTER)
647
+    VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintAccTimeToDisplay),
648
+    VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintsTotalToDisplay),
649
+  #endif
650
+
651
+  VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], ScreenHandler.HandleStepPerMMChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
652
+  VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
653
+  VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
654
+
655
+  VPHELPER(VP_X_MAX_SPEED, &planner.settings.max_feedrate_mm_s[X_AXIS], ScreenHandler.HandleMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
656
+  VPHELPER(VP_Y_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Y_AXIS], ScreenHandler.HandleMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
657
+  VPHELPER(VP_Z_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Z_AXIS], ScreenHandler.HandleMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
658
+
659
+  #if HOTENDS >= 1
660
+    VPHELPER(VP_E0_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E0_AXIS], ScreenHandler.HandleExtruderMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
661
+  #endif
662
+  #if HOTENDS >= 2
663
+    VPHELPER(VP_E1_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E1_AXIS], ScreenHandler.HandleExtruderMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
664
+  #endif
665
+
666
+  VPHELPER(VP_X_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[X_AXIS], ScreenHandler.HandleMaxAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
667
+  VPHELPER(VP_Y_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[Y_AXIS], ScreenHandler.HandleMaxAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
668
+  VPHELPER(VP_Z_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[Z_AXIS], ScreenHandler.HandleMaxAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
669
+
670
+  #if HOTENDS >= 1
671
+    VPHELPER(VP_E0_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E0_AXIS], ScreenHandler.HandleExtruderAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
672
+  #endif
673
+  #if HOTENDS >= 2
674
+    VPHELPER(VP_E1_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E1_AXIS], ScreenHandler.HandleExtruderAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
675
+  #endif
676
+
677
+  VPHELPER(VP_TRAVEL_SPEED, (uint16_t *)&planner.settings.travel_acceleration, ScreenHandler.HandleTravelAccChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
678
+  VPHELPER(VP_FEEDRATE_MIN_SPEED, (uint16_t *)&planner.settings.min_feedrate_mm_s, ScreenHandler.HandleFeedRateMinChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
679
+  VPHELPER(VP_T_F_SPEED, (uint16_t *)&planner.settings.min_travel_feedrate_mm_s, ScreenHandler.HandleMin_T_F_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
680
+  VPHELPER(VP_ACC_SPEED, (uint16_t *)&planner.settings.acceleration, ScreenHandler.HandleAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
681
+
682
+  VPHELPER(VP_X_PARK_POS, &x_park_pos, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
683
+  VPHELPER(VP_Y_PARK_POS, &y_park_pos, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
684
+  VPHELPER(VP_Z_PARK_POS, &z_park_pos, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
685
+  VPHELPER(VP_MIN_EX_T, &thermalManager.extrude_min_temp, ScreenHandler.HandleGetExMinTemp_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
686
+
687
+  #if ENABLED(SENSORLESS_HOMING)  // TMC SENSORLESS Setting
688
+    #if AXIS_HAS_STEALTHCHOP(X)
689
+      VPHELPER(VP_TMC_X_STEP, &tmc_x_step, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
690
+    #endif
691
+    #if AXIS_HAS_STEALTHCHOP(Y)
692
+      VPHELPER(VP_TMC_Y_STEP, &tmc_y_step, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
693
+    #endif
694
+    #if AXIS_HAS_STEALTHCHOP(Z)
695
+      VPHELPER(VP_TMC_Z_STEP, &tmc_z_step, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
696
+    #endif
697
+  #endif
698
+
699
+  #if HAS_TRINAMIC_CONFIG   // TMC Current Setting
700
+    #if AXIS_IS_TMC(X)
701
+      VPHELPER(VP_TMC_X_Current, &stepperX.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
702
+    #endif
703
+    #if AXIS_IS_TMC(Y)
704
+      VPHELPER(VP_TMC_Y_Current, &stepperY.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
705
+    #endif
706
+    #if AXIS_IS_TMC(Z)
707
+      VPHELPER(VP_TMC_Z_Current, &stepperZ.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
708
+    #endif
709
+    #if AXIS_IS_TMC(E0)
710
+      VPHELPER(VP_TMC_E0_Current, &stepperE0.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
711
+    #endif
712
+    #if AXIS_IS_TMC(E1)
713
+      VPHELPER(VP_TMC_E1_Current, &stepperE1.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
714
+    #endif
715
+    #if AXIS_IS_TMC(X2)
716
+      VPHELPER(VP_TMC_X1_Current, &stepperX2.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
717
+    #endif
718
+    #if AXIS_IS_TMC(Y2)
719
+      VPHELPER(VP_TMC_Y1_Current, &stepperY2.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
720
+    #endif
721
+    #if AXIS_IS_TMC(Z2)
722
+      VPHELPER(VP_TMC_Z1_Current, &stepperZ2.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
723
+    #endif
724
+  #endif
725
+
726
+  VPHELPER(VP_EEPROM_CTRL, nullptr, ScreenHandler.EEPROM_CTRL, nullptr),
727
+  VPHELPER(VP_LEVEL_BUTTON, nullptr, ScreenHandler.Level_Ctrl_MKS, nullptr),
728
+  VPHELPER(VP_LANGUAGE_CHANGE, nullptr, ScreenHandler.LanguageChange_MKS, nullptr),
729
+
730
+  //VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, nullptr),
731
+
732
+  VPHELPER(VP_SD_Print_LiveAdjustZ_Confirm, nullptr, ScreenHandler.ZoffsetConfirm, nullptr),
733
+
734
+  VPHELPER(VP_ZOffset_Distance,nullptr ,ScreenHandler.GetZoffsetDistance, nullptr),
735
+  VPHELPER(VP_MESH_LEVEL_ADJUST, nullptr, ScreenHandler.MeshLevelDistanceConfig, nullptr),
736
+  VPHELPER(VP_MESH_LEVEL_POINT,nullptr, ScreenHandler.MeshLevel,nullptr),
737
+  VPHELPER(VP_Min_EX_T_E, &thermalManager.extrude_min_temp, &ScreenHandler.GetMinExtrudeTemp, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
738
+  VPHELPER(VP_AutoTurnOffSw, nullptr, &ScreenHandler.GetTurnOffCtrl, nullptr),
739
+
740
+  #if HOTENDS >= 1
741
+    VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
742
+  #endif
743
+  #if HOTENDS >= 2
744
+    VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
745
+  #endif
746
+
747
+
748
+  // SDCard File listing
749
+  #if ENABLED(SDSUPPORT)
750
+    VPHELPER(VP_SD_ScrollEvent, nullptr, ScreenHandler.DGUSLCD_SD_ScrollFilelist, nullptr),
751
+    VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr),
752
+    VPHELPER(VP_SD_FileSelectConfirm, nullptr, ScreenHandler.DGUSLCD_SD_StartPrint, nullptr),
753
+    VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
754
+    VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
755
+    VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
756
+    VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
757
+    VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
758
+    VPHELPER_STR(VP_SD_FileName5, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
759
+    VPHELPER_STR(VP_SD_FileName6, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
760
+    VPHELPER_STR(VP_SD_FileName7, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
761
+    VPHELPER_STR(VP_SD_FileName8, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
762
+    VPHELPER_STR(VP_SD_FileName9, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
763
+    VPHELPER(VP_SD_ResumePauseAbort, nullptr, ScreenHandler.DGUSLCD_SD_ResumePauseAbort, nullptr),
764
+    VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr),
765
+    VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr),
766
+    #if ENABLED(BABYSTEPPING)
767
+      VPHELPER(VP_SD_Print_LiveAdjustZ,nullptr, ScreenHandler.HandleLiveAdjustZ, &ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),
768
+      VPHELPER(VP_ZOffset_DE_DIS,&z_offset_add,nullptr, &ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
769
+    #endif
770
+    #if HAS_BED_PROBE
771
+      VPHELPER(VP_OFFSET_X, &probe.offset.x, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
772
+      VPHELPER(VP_OFFSET_Y, &probe.offset.y, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
773
+      VPHELPER(VP_OFFSET_Z, &probe.offset.z, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
774
+    #endif
775
+  #endif
776
+
777
+  #if ENABLED(DGUS_UI_WAITING)
778
+    VPHELPER(VP_WAITING_STATUS, nullptr, nullptr, ScreenHandler.DGUSLCD_SendWaitingStatusToDisplay),
779
+  #endif
780
+
781
+  // Messages for the User, shared by the popup and the kill screen. They cant be autouploaded as we do not buffer content.
782
+  //{.VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM},
783
+  //{.VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM},
784
+  //{.VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM},
785
+  //{.VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM},
786
+
787
+  {.VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS},
788
+  {.VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS},
789
+  {.VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS},
790
+  {.VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS},
791
+
792
+  VPHELPER(0, 0, 0, 0) // must be last entry.
793
+};
794
+
795
+#endif // DGUS_LCD_UI_MKS

+ 908
- 0
Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h Прегледај датотеку

@@ -0,0 +1,908 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "../DGUSDisplayDef.h"
25
+
26
+//#define USE_MKS_GREEN_UI
27
+//#define DGUS_MKS_RUNOUT_SENSOR
28
+
29
+#define LOGO_TIME_DELAY TERN(USE_MKS_GREEN_UI, 5000, 1500)
30
+
31
+#if ENABLED(DGUS_MKS_RUNOUT_SENSOR)
32
+  #define MT_DET_1_PIN         1
33
+  #define MT_DET_2_PIN         2
34
+  #define MT_DET_PIN_INVERTING false
35
+#endif
36
+
37
+#define MKS_FINSH
38
+
39
+extern uint16_t distanceMove;
40
+extern float    distanceFilament;
41
+extern uint16_t FilamentSpeed;
42
+extern float    ZOffset_distance;
43
+extern float    mesh_adj_distance;
44
+extern float    Z_distance;
45
+
46
+extern int16_t level_1_x_point;
47
+extern int16_t level_1_y_point;
48
+extern int16_t level_2_x_point;
49
+extern int16_t level_2_y_point;
50
+extern int16_t level_3_x_point;
51
+extern int16_t level_3_y_point;
52
+extern int16_t level_4_x_point;
53
+extern int16_t level_4_y_point;
54
+extern int16_t level_5_x_point;
55
+extern int16_t level_5_y_point;
56
+
57
+extern uint16_t tim_h;
58
+extern uint16_t tim_m;
59
+extern uint16_t tim_s;
60
+
61
+extern uint16_t x_park_pos;
62
+extern uint16_t y_park_pos;
63
+extern uint16_t z_park_pos;
64
+
65
+extern xyz_pos_t position_before_pause;
66
+void MKS_pause_print_move();
67
+void MKS_resume_print_move();
68
+
69
+extern uint16_t min_ex_temp;
70
+
71
+extern float z_offset_add;
72
+
73
+extern uint16_t tmc_x_step;
74
+extern uint16_t tmc_y_step;
75
+extern uint16_t tmc_z_step;
76
+
77
+extern uint16_t lcd_default_light;
78
+
79
+#if AXIS_HAS_STEALTHCHOP(X)
80
+  extern uint16_t tmc_x_current;
81
+#endif
82
+#if AXIS_HAS_STEALTHCHOP(Y)
83
+  extern uint16_t tmc_y_current;
84
+#endif
85
+#if AXIS_HAS_STEALTHCHOP(Z)
86
+  extern uint16_t tmc_z_current;
87
+#endif
88
+#if AXIS_HAS_STEALTHCHOP(E0)
89
+  extern uint16_t tmc_e0_current;
90
+#endif
91
+#if AXIS_HAS_STEALTHCHOP(E1)
92
+  extern uint16_t tmc_e1_current;
93
+#endif
94
+
95
+typedef enum {
96
+  EX_HEATING,
97
+  EX_HEAT_STARUS,
98
+  EX_CHANGING,
99
+  EX_CHANGE_STATUS,
100
+  EX_NONE,
101
+} EX_STATUS_DEF;
102
+
103
+typedef struct {
104
+  //uint8_t ex_change_flag:1;
105
+  //uint8_t ex_heat_flag:1;
106
+  uint8_t ex_load_unload_flag:1;  //0:unload  1:load
107
+  EX_STATUS_DEF ex_status;
108
+  uint32_t ex_tick_start;
109
+  uint32_t ex_tick_end;
110
+  uint32_t ex_speed;
111
+  uint32_t ex_length;
112
+  uint32_t ex_need_time;
113
+} EX_FILAMENT_DEF;
114
+
115
+extern EX_FILAMENT_DEF ex_filament;
116
+
117
+typedef enum {
118
+  UNRUNOUT_STATUS,
119
+  RUNOUT_STATUS,
120
+  RUNOUT_WAITTING_STATUS,
121
+  RUNOUT_BEGIN_STATUS,
122
+} RUNOUT_MKS_STATUS_DEF;
123
+
124
+typedef struct {
125
+  RUNOUT_MKS_STATUS_DEF runout_status;
126
+  uint8_t pin_status;
127
+  uint8_t de_count;
128
+  uint8_t de_times;
129
+} RUNOUT_MKS_DEF;
130
+
131
+extern RUNOUT_MKS_DEF runout_mks;
132
+
133
+typedef struct {
134
+  uint8_t print_pause_start_flag:1;
135
+  uint8_t runout_flag:1;
136
+  bool blstatus;
137
+  uint16_t x_pos;
138
+  uint16_t y_pos;
139
+  uint16_t z_pos;
140
+} NOZZLE_PARK_DEF;
141
+
142
+extern NOZZLE_PARK_DEF nozzle_park_mks;
143
+
144
+enum DGUSLCD_Screens : uint8_t {
145
+  #if ENABLED(USE_MKS_GREEN_UI)
146
+
147
+    DGUSLCD_SCREEN_BOOT                 =  33,
148
+    DGUSLCD_SCREEN_MAIN                 =  60,
149
+    DGUSLCD_SCREEN_STATUS               =  60,
150
+    DGUSLCD_SCREEN_STATUS2              =  60,
151
+    DGUSLCD_SCREEN_PREHEAT              =  18,
152
+    DGUSLCD_SCREEN_POWER_LOSS           = 100,
153
+    DGUSLCD_SCREEN_MANUALMOVE           = 192,
154
+    DGUSLCD_SCREEN_UTILITY              = 120,
155
+    DGUSLCD_SCREEN_FILAMENT_UNLOADING   = 158,
156
+    DGUSLCD_SCREEN_SDFILELIST           =  15,
157
+    DGUSLCD_SCREEN_SDPRINTMANIPULATION  =  15,
158
+    DGUSLCD_SCREEN_SDPRINTTUNE          =  17,
159
+
160
+    MKSLCD_SCREEN_BOOT                  =  33,
161
+    MKSLCD_SCREEN_HOME                  =  60,   // MKS main page
162
+    MKSLCD_SCREEN_SETTING               =  62,   // MKS Setting page / no wifi whit
163
+    MKSLCD_SCREEM_TOOL                  =  64,   // MKS Tool page
164
+    MKSLCD_SCREEN_EXTRUDE_P1            =  75,
165
+    MKSLCD_SCREEN_EXTRUDE_P2            =  77,
166
+    MKSLCD_SCREEN_LEVEL                 =  73,
167
+    MKSLCD_AUTO_LEVEL                   =  81,
168
+    MKSLCD_SCREEN_MOVE                  =  66,
169
+    MKSLCD_SCREEN_PRINT                 =  68,
170
+    MKSLCD_SCREEN_PAUSE                 =  70,
171
+    MKSLCD_SCREEN_CHOOSE_FILE           =  87,
172
+    MKSLCD_SCREEN_NO_CHOOSE_FILE        =  88,
173
+    MKSLCD_SCREEN_Config                = 101,
174
+    MKSLCD_SCREEN_Config_MOTOR          = 103,
175
+    MKSLCD_SCREEN_MOTOR_PLUSE           = 104,
176
+    MKSLCD_SCREEN_MOTOR_SPEED           = 102,
177
+    MKSLCD_SCREEN_MOTOR_ACC_MAX         = 105,
178
+    MKSLCD_SCREEN_PRINT_CONFIG          =  72,
179
+    MKSLCD_SCREEN_LEVEL_DATA            = 106,
180
+    MKSLCD_PrintPause_SET               = 107,
181
+    //MKSLCD_FILAMENT_DATA                =  50,
182
+    MKSLCD_ABOUT                        =  83,
183
+    MKSLCD_PID                          = 108,
184
+    MKSLCD_PAUSE_SETTING_MOVE           =  98,
185
+    MKSLCD_PAUSE_SETTING_EX             =  96,
186
+    MKSLCD_PAUSE_SETTING_EX2            =  97,
187
+    MKSLCD_SCREEN_PRINT_CONFIRM         =  94,
188
+    MKSLCD_SCREEN_EX_CONFIG             = 112,
189
+    MKSLCD_SCREEN_EEP_Config            =  89,
190
+    MKSLCD_SCREEN_PrintDone             =  92,
191
+    MKSLCD_SCREEN_TMC_Config            = 111,
192
+    MKSLCD_Screen_Offset_Config         = 109,
193
+    MKSLCD_Screen_PMove                 =  98,
194
+    MKSLCD_Screen_Baby                  =  79,
195
+
196
+  #else
197
+
198
+    DGUSLCD_SCREEN_BOOT                 = 120,
199
+    DGUSLCD_SCREEN_MAIN                 =   1,
200
+
201
+    DGUSLCD_SCREEN_STATUS               =   1,
202
+    DGUSLCD_SCREEN_STATUS2              =   1,
203
+    DGUSLCD_SCREEN_PREHEAT              =  18,
204
+    DGUSLCD_SCREEN_POWER_LOSS           = 100,
205
+    DGUSLCD_SCREEN_MANUALMOVE           = 192,
206
+    DGUSLCD_SCREEN_UTILITY              = 120,
207
+    DGUSLCD_SCREEN_FILAMENT_UNLOADING   = 158,
208
+    DGUSLCD_SCREEN_SDFILELIST           =  15,
209
+    DGUSLCD_SCREEN_SDPRINTMANIPULATION  =  15,
210
+    DGUSLCD_SCREEN_SDPRINTTUNE          =  17,
211
+
212
+    MKSLCD_SCREEN_BOOT                  =   0,
213
+    MKSLCD_SCREEN_HOME                  =   1,   // MKS main page
214
+    MKSLCD_SCREEN_SETTING               =   2,   // MKS Setting page / no wifi whit
215
+    MKSLCD_SCREEM_TOOL                  =   3,   // MKS Tool page
216
+    MKSLCD_SCREEN_EXTRUDE_P1            =   4,
217
+    MKSLCD_SCREEN_EXTRUDE_P2            =  11,
218
+    MKSLCD_SCREEN_LEVEL                 =   5,
219
+    MKSLCD_AUTO_LEVEL                   =  73,
220
+    MKSLCD_SCREEN_LEVEL_PRESS           =   9,
221
+    MKSLCD_SCREEN_MOVE                  =   6,
222
+    MKSLCD_SCREEN_PRINT                 =   7,
223
+    MKSLCD_SCREEN_PRINT_PRESS           =  13,
224
+    MKSLCD_SCREEN_PAUSE                 =  26,
225
+    MKSLCD_SCREEN_PAUSE_PRESS           =  26,
226
+    MKSLCD_SCREEN_CHOOSE_FILE           =  15,
227
+    MKSLCD_SCREEN_NO_CHOOSE_FILE        =  17,
228
+    MKSLCD_SCREEN_Config                =  46,
229
+    MKSLCD_SCREEN_Config_MOTOR          =  47,
230
+    MKSLCD_SCREEN_MOTOR_PLUSE           =  51,
231
+    MKSLCD_SCREEN_MOTOR_SPEED           =  55,
232
+    MKSLCD_SCREEN_MOTOR_ACC_MAX         =  53,
233
+    MKSLCD_SCREEN_PRINT_CONFIG          =  60,
234
+    MKSLCD_SCREEN_LEVEL_DATA            =  48,
235
+    MKSLCD_PrintPause_SET               =  49,
236
+    MKSLCD_FILAMENT_DATA                =  50,
237
+    MKSLCD_ABOUT                        =  36,
238
+    MKSLCD_PID                          =  56,
239
+    MKSLCD_PAUSE_SETTING_MOVE           =  58,
240
+    MKSLCD_PAUSE_SETTING_EX             =  57,
241
+    MKSLCD_PAUSE_SETTING_EX2            =  61,
242
+    MKSLCD_SCREEN_NO_FILE               =  42,
243
+    MKSLCD_SCREEN_PRINT_CONFIRM         =  43,
244
+    MKSLCD_SCREEN_EX_CONFIG             =  65,
245
+    MKSLCD_SCREEN_EEP_Config            =  20,
246
+    MKSLCD_SCREEN_PrintDone             =  25,
247
+    MKSLCD_SCREEN_TMC_Config            =  70,
248
+    MKSLCD_Screen_Offset_Config         =  30,
249
+    MKSLCD_Screen_PMove                 =  64,
250
+    MKSLCD_Screen_Baby                  =  71,
251
+
252
+  #endif
253
+
254
+  DGUSLCD_SCREEN_CONFIRM                = 240,
255
+  DGUSLCD_SCREEN_KILL                   = 250, ///< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version")
256
+  DGUSLCD_SCREEN_WAITING                = 251,
257
+  DGUSLCD_SCREEN_POPUP                  = 252, ///< special target, popup screen will also return this code to say "return to previous screen"
258
+  DGUSLDC_SCREEN_UNUSED                 = 255
259
+};
260
+
261
+// Display Memory layout used (T5UID)
262
+// Except system variables this is arbitrary, just to organize stuff....
263
+
264
+// 0x0000 .. 0x0FFF  -- System variables and reserved by the display
265
+// 0x1000 .. 0x1FFF  -- Variables to never change location, regardless of UI Version
266
+// 0x2000 .. 0x2FFF  -- Controls (VPs that will trigger some action)
267
+// 0x3000 .. 0x4FFF  -- Marlin Data to be displayed
268
+// 0x5000 ..         -- SPs (if we want to modify display elements, e.g change color or like) -- currently unused
269
+
270
+// As there is plenty of space (at least most displays have >8k RAM), we do not pack them too tight,
271
+// so that we can keep variables nicely together in the address space.
272
+
273
+// UI Version always on 0x1000...0x1002 so that the firmware can check this and bail out.
274
+
275
+// constexpr uint16_t VP_UI_VERSION_MAJOR = 0x1000;  // Major -- incremented when incompatible
276
+// constexpr uint16_t VP_UI_VERSION_MINOR = 0x1001;  // Minor -- incremented on new features, but compatible
277
+// constexpr uint16_t VP_UI_VERSION_PATCH = 0x1002;  // Patch -- fixed which do not change functionality.
278
+// constexpr uint16_t VP_UI_FLAVOUR       = 0x1010;  // lets reserve 16 bytes here to determine if UI is suitable for this Marlin. tbd.
279
+
280
+// Storage space for the Killscreen messages. 0x1100 - 0x1200 . Reused for the popup.
281
+// constexpr uint16_t VP_MSGSTR1 = 0x1100;
282
+// constexpr uint8_t VP_MSGSTR1_LEN = 0x20;  // might be more place for it...
283
+// constexpr uint16_t VP_MSGSTR2 = 0x1140;
284
+// constexpr uint8_t VP_MSGSTR2_LEN = 0x20;
285
+// constexpr uint16_t VP_MSGSTR3 = 0x1180;
286
+// constexpr uint8_t VP_MSGSTR3_LEN = 0x20;
287
+// constexpr uint16_t VP_MSGSTR4 = 0x11C0;
288
+// constexpr uint8_t VP_MSGSTR4_LEN = 0x20;
289
+
290
+// Screenchange request for screens that only make sense when printer is idle.
291
+// e.g movement is only allowed if printer is not printing.
292
+// Marlin must confirm by setting the screen manually.
293
+// constexpr uint16_t VP_SCREENCHANGE_ASK = 0x2000;
294
+// constexpr uint16_t VP_SCREENCHANGE = 0x2001;   // Key-Return button to new menu pressed. Data contains target screen in low byte and info in high byte.
295
+// constexpr uint16_t VP_TEMP_ALL_OFF = 0x2002;   // Turn all heaters off. Value arbitrary ;)=
296
+// constexpr uint16_t VP_SCREENCHANGE_WHENSD = 0x2003; // "Print" Button touched -- go only there if there is an SD Card.
297
+// constexpr uint16_t VP_CONFIRMED = 0x2010; // OK on confirm screen.
298
+
299
+// // Buttons on the SD-Card File listing.
300
+// constexpr uint16_t VP_SD_ScrollEvent = 0x2020; // Data: 0 for "up a directory", numbers are the amount to scroll, e.g -1 one up, 1 one down
301
+// constexpr uint16_t VP_SD_FileSelected = 0x2022; // Number of file field selected.
302
+// constexpr uint16_t VP_SD_FileSelectConfirm = 0x2024; // (This is a virtual VP and emulated by the Confirm Screen when a file has been confirmed)
303
+
304
+// constexpr uint16_t VP_SD_ResumePauseAbort = 0x2026; // Resume(Data=0), Pause(Data=1), Abort(Data=2) SD Card prints
305
+// constexpr uint16_t VP_SD_AbortPrintConfirmed = 0x2028; // Abort print confirmation (virtual, will be injected by the confirm dialog)
306
+// constexpr uint16_t VP_SD_Print_Setting = 0x2040;
307
+// constexpr uint16_t VP_SD_Print_LiveAdjustZ = 0x2050; // Data: 0 down, 1 up
308
+
309
+// Controls for movement (we can't use the incremental / decremental feature of the display at this feature works only with 16 bit values
310
+// (which would limit us to 655.35mm, which is likely not a problem for common setups, but i don't want to rule out hangprinters support)
311
+// A word about the coding: The VP will be per axis and the return code will be an signed 16 bit value in 0.01 mm resolution, telling us
312
+// the relative travel amount t he user wants to do. So eg. if the display sends us VP=2100 with value 100, the user wants us to move X by +1 mm.
313
+// constexpr uint16_t VP_MOVE_X = 0x2100;
314
+// constexpr uint16_t VP_MOVE_Y = 0x2102;
315
+// constexpr uint16_t VP_MOVE_Z = 0x2104;
316
+// constexpr uint16_t VP_MOVE_E0 = 0x2110;
317
+// constexpr uint16_t VP_MOVE_E1 = 0x2112;
318
+// //constexpr uint16_t VP_MOVE_E2 = 0x2114;
319
+// //constexpr uint16_t VP_MOVE_E3 = 0x2116;
320
+// //constexpr uint16_t VP_MOVE_E4 = 0x2118;
321
+// //constexpr uint16_t VP_MOVE_E5 = 0x211A;
322
+// constexpr uint16_t VP_HOME_ALL = 0x2120;
323
+// constexpr uint16_t VP_MOTOR_LOCK_UNLOK = 0x2130;
324
+// constexpr uint16_t VP_XYZ_HOME = 0x2132;
325
+
326
+// Power loss recovery
327
+// constexpr uint16_t VP_POWER_LOSS_RECOVERY = 0x2180;
328
+
329
+// // Fan Control Buttons , switch between "off" and "on"
330
+// constexpr uint16_t VP_FAN0_CONTROL = 0x2200;
331
+// constexpr uint16_t VP_FAN1_CONTROL = 0x2202;
332
+// constexpr uint16_t VP_FAN2_CONTROL = 0x2204;
333
+// constexpr uint16_t VP_FAN3_CONTROL = 0x2206;
334
+
335
+// // Heater Control Buttons , triged between "cool down" and "heat PLA" state
336
+// constexpr uint16_t VP_E0_CONTROL = 0x2210;
337
+// constexpr uint16_t VP_E1_CONTROL = 0x2212;
338
+// //constexpr uint16_t VP_E2_CONTROL = 0x2214;
339
+// //constexpr uint16_t VP_E3_CONTROL = 0x2216;
340
+// //constexpr uint16_t VP_E4_CONTROL = 0x2218;
341
+// //constexpr uint16_t VP_E5_CONTROL = 0x221A;
342
+// constexpr uint16_t VP_BED_CONTROL = 0x221C;
343
+
344
+// // Preheat
345
+// constexpr uint16_t VP_E0_BED_PREHEAT = 0x2220;
346
+// constexpr uint16_t VP_E1_BED_PREHEAT = 0x2222;
347
+// //constexpr uint16_t VP_E2_BED_PREHEAT = 0x2224;
348
+// //constexpr uint16_t VP_E3_BED_PREHEAT = 0x2226;
349
+// //constexpr uint16_t VP_E4_BED_PREHEAT = 0x2228;
350
+// //constexpr uint16_t VP_E5_BED_PREHEAT = 0x222A;
351
+
352
+// // Filament load and unload
353
+// // constexpr uint16_t VP_E0_FILAMENT_LOAD_UNLOAD = 0x2300;
354
+// // constexpr uint16_t VP_E1_FILAMENT_LOAD_UNLOAD = 0x2302;
355
+
356
+// // Settings store , reset
357
+
358
+// // PID autotune
359
+// constexpr uint16_t VP_PID_AUTOTUNE_E0 = 0x2410;
360
+// constexpr uint16_t VP_PID_AUTOTUNE_E1 = 0x2412;
361
+// //constexpr uint16_t VP_PID_AUTOTUNE_E2 = 0x2414;
362
+// //constexpr uint16_t VP_PID_AUTOTUNE_E3 = 0x2416;
363
+// //constexpr uint16_t VP_PID_AUTOTUNE_E4 = 0x2418;
364
+// //constexpr uint16_t VP_PID_AUTOTUNE_E5 = 0x241A;
365
+// constexpr uint16_t VP_PID_AUTOTUNE_BED = 0x2420;
366
+// // Calibrate Z
367
+// constexpr uint16_t VP_Z_CALIBRATE = 0x2430;
368
+
369
+// First layer cal
370
+// constexpr uint16_t VP_Z_FIRST_LAYER_CAL = 0x2500; // Data: 0 - Cancel first layer cal progress, >0 filament type have loaded
371
+
372
+// Firmware version on the boot screen.
373
+// constexpr uint16_t VP_MARLIN_VERSION = 0x3000;
374
+// constexpr uint8_t VP_MARLIN_VERSION_LEN = 16;   // there is more space on the display, if needed.
375
+
376
+// Place for status messages.
377
+constexpr uint16_t VP_M117 = 0x7020;
378
+constexpr uint8_t VP_M117_LEN = 0x20;
379
+
380
+// // Temperatures.
381
+// constexpr uint16_t VP_T_E0_Is = 0x3060;  // 4 Byte Integer
382
+// constexpr uint16_t VP_T_E0_Set = 0x3062; // 2 Byte Integer
383
+// constexpr uint16_t VP_T_E1_Is = 0x3064;  // 4 Byte Integer
384
+// // reserved to support up to 6 Extruders:
385
+// constexpr uint16_t VP_T_E1_Set = 0x3066; // 2 Byte Integer
386
+// constexpr uint16_t VP_T_E2_Is = 0x3068;  // 4 Byte Integer
387
+// constexpr uint16_t VP_T_E2_Set = 0x306A; // 2 Byte Integer
388
+// constexpr uint16_t VP_T_E3_Is = 0x306C;  // 4 Byte Integer
389
+// constexpr uint16_t VP_T_E3_Set = 0x306E; // 2 Byte Integer
390
+// constexpr uint16_t VP_T_E4_Is = 0x3070;  // 4 Byte Integer
391
+// constexpr uint16_t VP_T_E4_Set = 0x3072; // 2 Byte Integer
392
+// constexpr uint16_t VP_T_E5_Is = 0x3074;  // 4 Byte Integer
393
+// constexpr uint16_t VP_T_E5_Set = 0x3076; // 2 Byte Integer
394
+// constexpr uint16_t VP_T_E6_Is = 0x3078;  // 4 Byte Integer
395
+// constexpr uint16_t VP_T_E6_Set = 0x307A; // 2 Byte Integer
396
+// constexpr uint16_t VP_T_E7_Is = 0x3078;  // 4 Byte Integer
397
+// constexpr uint16_t VP_T_E7_Set = 0x307A; // 2 Byte Integer
398
+
399
+
400
+// constexpr uint16_t VP_T_Bed_Is = 0x3080;  // 4 Byte Integer
401
+// constexpr uint16_t VP_T_Bed_Set = 0x3082; // 2 Byte Integer
402
+
403
+// constexpr uint16_t VP_Flowrate_E0 = 0x3090; // 2 Byte Integer
404
+// constexpr uint16_t VP_Flowrate_E1 = 0x3092; // 2 Byte Integer
405
+// // reserved for up to 6 Extruders:
406
+// constexpr uint16_t VP_Flowrate_E2 = 0x3094;
407
+// constexpr uint16_t VP_Flowrate_E3 = 0x3096;
408
+// constexpr uint16_t VP_Flowrate_E4 = 0x3098;
409
+// constexpr uint16_t VP_Flowrate_E5 = 0x309A;
410
+
411
+// constexpr uint16_t VP_Fan0_Percentage = 0x3100;  // 2 Byte Integer (0..100)
412
+// constexpr uint16_t VP_Fan1_Percentage = 0x3102;  // 2 Byte Integer (0..100)
413
+// constexpr uint16_t VP_Fan2_Percentage = 0x3104;  // 2 Byte Integer (0..100)
414
+// constexpr uint16_t VP_Fan3_Percentage = 0x3106;  // 2 Byte Integer (0..100)
415
+// constexpr uint16_t VP_Feedrate_Percentage = 0x3108; // 2 Byte Integer (0..100)
416
+
417
+// Actual Position
418
+// constexpr uint16_t VP_XPos = 0x3110;  // 4 Byte Fixed point number; format xxx.yy
419
+// constexpr uint16_t VP_YPos = 0x3112;  // 4 Byte Fixed point number; format xxx.yy
420
+// constexpr uint16_t VP_ZPos = 0x3114;  // 4 Byte Fixed point number; format xxx.yy
421
+// constexpr uint16_t VP_EPos = 0x3120;  // 4 Byte Fixed point number; format xxx.yy
422
+
423
+// constexpr uint16_t VP_PrintProgress_Percentage = 0x3130; // 2 Byte Integer (0..100)
424
+
425
+// constexpr uint16_t VP_PrintTime = 0x3140;
426
+// constexpr uint16_t VP_PrintTime_LEN = 32;
427
+
428
+// constexpr uint16_t VP_PrintAccTime = 0x3160;
429
+// constexpr uint16_t VP_PrintAccTime_LEN = 32;
430
+
431
+// constexpr uint16_t VP_PrintsTotal = 0x3180;
432
+// constexpr uint16_t VP_PrintsTotal_LEN = 16;
433
+
434
+// // SDCard File Listing
435
+// constexpr uint16_t VP_SD_FileName_LEN = 32; // LEN is shared for all entries.
436
+// constexpr uint16_t DGUS_SD_FILESPERSCREEN = 8; // FIXME move that info to the display and read it from there.
437
+// constexpr uint16_t VP_SD_FileName0 = 0x3200;
438
+// constexpr uint16_t VP_SD_FileName1 = 0x3220;
439
+// constexpr uint16_t VP_SD_FileName2 = 0x3240;
440
+// constexpr uint16_t VP_SD_FileName3 = 0x3260;
441
+// constexpr uint16_t VP_SD_FileName4 = 0x3280;
442
+// constexpr uint16_t VP_SD_FileName5 = 0x32A0;
443
+// constexpr uint16_t VP_SD_FileName6 = 0x32C0;
444
+// constexpr uint16_t VP_SD_FileName7 = 0x32E0;
445
+
446
+// Heater status
447
+constexpr uint16_t VP_E0_STATUS = 0x3410;
448
+constexpr uint16_t VP_E1_STATUS = 0x3412;
449
+//constexpr uint16_t VP_E2_STATUS = 0x3414;
450
+//constexpr uint16_t VP_E3_STATUS = 0x3416;
451
+//constexpr uint16_t VP_E4_STATUS = 0x3418;
452
+//constexpr uint16_t VP_E5_STATUS = 0x341A;
453
+constexpr uint16_t VP_MOVE_OPTION = 0x3500;
454
+
455
+// // PIDs
456
+// constexpr uint16_t VP_E0_PID_P = 0x3700; // at the moment , 2 byte unsigned int , 0~1638.4
457
+// constexpr uint16_t VP_E0_PID_I = 0x3702;
458
+// constexpr uint16_t VP_E0_PID_D = 0x3704;
459
+// constexpr uint16_t VP_E1_PID_P = 0x3706; // at the moment , 2 byte unsigned int , 0~1638.4
460
+// constexpr uint16_t VP_E1_PID_I = 0x3708;
461
+// constexpr uint16_t VP_E1_PID_D = 0x370A;
462
+// constexpr uint16_t VP_BED_PID_P = 0x3710;
463
+// constexpr uint16_t VP_BED_PID_I = 0x3712;
464
+// constexpr uint16_t VP_BED_PID_D = 0x3714;
465
+
466
+// Wating screen status
467
+constexpr uint16_t VP_WAITING_STATUS = 0x3800;
468
+
469
+// SPs for certain variables...
470
+// located at 0x5000 and up
471
+// Not used yet!
472
+// This can be used e.g to make controls / data display invisible
473
+constexpr uint16_t SP_T_E0_Is     = 0x5000;
474
+constexpr uint16_t SP_T_E0_Set    = 0x5010;
475
+constexpr uint16_t SP_T_E1_Is     = 0x5020;
476
+constexpr uint16_t SP_T_Bed_Is    = 0x5030;
477
+constexpr uint16_t SP_T_Bed_Set   = 0x5040;
478
+
479
+/*************************************************************************************************************************
480
+ *************************************************************************************************************************
481
+ *                                                 DGUS for MKS Mem layout
482
+ ************************************************************************************************************************
483
+ ************************************************************************************************************************/
484
+
485
+#if ENABLED(MKS_FINSH)
486
+  /* -------------------------------0x1000-0x1FFF------------------------------- */
487
+  constexpr uint16_t VP_MSGSTR1                       = 0x1100;
488
+  constexpr uint8_t  VP_MSGSTR1_LEN                   = 0x20;  // might be more place for it...
489
+  constexpr uint16_t VP_MSGSTR2                       = 0x1140;
490
+  constexpr uint8_t  VP_MSGSTR2_LEN                   = 0x20;
491
+  constexpr uint16_t VP_MSGSTR3                       = 0x1180;
492
+  constexpr uint8_t  VP_MSGSTR3_LEN                   = 0x20;
493
+  constexpr uint16_t VP_MSGSTR4                       = 0x11C0;
494
+  constexpr uint8_t  VP_MSGSTR4_LEN                   = 0x20;
495
+
496
+  constexpr uint16_t VP_MARLIN_VERSION                = 0x1A00;
497
+  constexpr uint8_t VP_MARLIN_VERSION_LEN             = 16;       // there is more space on the display, if needed.
498
+
499
+
500
+  constexpr uint16_t VP_SCREENCHANGE_ASK              = 0x1500;
501
+  constexpr uint16_t VP_SCREENCHANGE                  = 0x1501;   // Key-Return button to new menu pressed. Data contains target screen in low byte and info in high byte.
502
+  constexpr uint16_t VP_TEMP_ALL_OFF                  = 0x1502;   // Turn all heaters off. Value arbitrary ;)=
503
+  constexpr uint16_t VP_SCREENCHANGE_WHENSD           = 0x1503;   // "Print" Button touched -- go only there if there is an SD Card.
504
+  constexpr uint16_t VP_CONFIRMED                     = 0x1510;   // OK on confirm screen.
505
+
506
+  constexpr uint16_t VP_BACK_PAGE                     = 0x1600;
507
+  constexpr uint16_t VP_SETTINGS                      = 0x1620;
508
+  // Power loss recovery
509
+  constexpr uint16_t VP_POWER_LOSS_RECOVERY           = 0x1680;
510
+  /* -------------------------------0x2000-0x2FFF------------------------------- */
511
+  // Temperatures.
512
+  constexpr uint16_t VP_T_E0_Is                       = 0x2000;   // 4 Byte Integer
513
+  constexpr uint16_t VP_T_E0_Set                      = 0x2004;   // 2 Byte Integer
514
+  constexpr uint16_t VP_T_E1_Is                       = 0x2008;   // 4 Byte Integer
515
+  constexpr uint16_t VP_T_E1_Set                      = 0x200B;   // 2 Byte Integer
516
+  constexpr uint16_t VP_T_E2_Is                       = 0x2010;   // 4 Byte Integer
517
+  constexpr uint16_t VP_T_E2_Set                      = 0x2014;   // 2 Byte Integer
518
+  constexpr uint16_t VP_T_E3_Is                       = 0x2018;   // 4 Byte Integer
519
+  constexpr uint16_t VP_T_E3_Set                      = 0x201B;   // 2 Byte Integer
520
+  constexpr uint16_t VP_T_E4_Is                       = 0x2020;   // 4 Byte Integer
521
+  constexpr uint16_t VP_T_E4_Set                      = 0x2024;   // 2 Byte Integer
522
+  constexpr uint16_t VP_T_E5_Is                       = 0x2028;   // 4 Byte Integer
523
+  constexpr uint16_t VP_T_E5_Set                      = 0x202B;   // 2 Byte Integer
524
+  constexpr uint16_t VP_T_E6_Is                       = 0x2030;   // 4 Byte Integer
525
+  constexpr uint16_t VP_T_E6_Set                      = 0x2034;   // 2 Byte Integer
526
+  constexpr uint16_t VP_T_E7_Is                       = 0x2038;   // 4 Byte Integer
527
+  constexpr uint16_t VP_T_E7_Set                      = 0x203B;   // 2 Byte Integer
528
+
529
+  constexpr uint16_t VP_T_Bed_Is                      = 0x2040;   // 4 Byte Integer
530
+  constexpr uint16_t VP_T_Bed_Set                     = 0x2044;   // 2 Byte Integer
531
+
532
+  constexpr uint16_t VP_Min_EX_T_E                    = 0x2100;
533
+
534
+  constexpr uint16_t VP_Flowrate_E0                   = 0x2200;   // 2 Byte Integer
535
+  constexpr uint16_t VP_Flowrate_E1                   = 0x2202;   // 2 Byte Integer
536
+  constexpr uint16_t VP_Flowrate_E2                   = 0x2204;
537
+  constexpr uint16_t VP_Flowrate_E3                   = 0x2206;
538
+  constexpr uint16_t VP_Flowrate_E4                   = 0x2208;
539
+  constexpr uint16_t VP_Flowrate_E5                   = 0x220A;
540
+  constexpr uint16_t VP_Flowrate_E6                   = 0x220C;
541
+  constexpr uint16_t VP_Flowrate_E7                   = 0x220E;
542
+
543
+  // Move
544
+  constexpr uint16_t VP_MOVE_X                        = 0x2300;
545
+  constexpr uint16_t VP_MOVE_Y                        = 0x2302;
546
+  constexpr uint16_t VP_MOVE_Z                        = 0x2304;
547
+  constexpr uint16_t VP_MOVE_E0                       = 0x2310;
548
+  constexpr uint16_t VP_MOVE_E1                       = 0x2312;
549
+  constexpr uint16_t VP_MOVE_E2                       = 0x2314;
550
+  constexpr uint16_t VP_MOVE_E3                       = 0x2316;
551
+  constexpr uint16_t VP_MOVE_E4                       = 0x2318;
552
+  constexpr uint16_t VP_MOVE_E5                       = 0x231A;
553
+  constexpr uint16_t VP_MOVE_E6                       = 0x231C;
554
+  constexpr uint16_t VP_MOVE_E7                       = 0x231E;
555
+  constexpr uint16_t VP_HOME_ALL                      = 0x2320;
556
+  constexpr uint16_t VP_MOTOR_LOCK_UNLOK              = 0x2330;
557
+  constexpr uint16_t VP_MOVE_DISTANCE                 = 0x2334;
558
+  constexpr uint16_t VP_X_HOME                        = 0x2336;
559
+  constexpr uint16_t VP_Y_HOME                        = 0x2338;
560
+  constexpr uint16_t VP_Z_HOME                        = 0x233A;
561
+
562
+  // Fan Control Buttons , switch between "off" and "on"
563
+  constexpr uint16_t VP_FAN0_CONTROL                  = 0x2350;
564
+  constexpr uint16_t VP_FAN1_CONTROL                  = 0x2352;
565
+  constexpr uint16_t VP_FAN2_CONTROL                  = 0x2354;
566
+  constexpr uint16_t VP_FAN3_CONTROL                  = 0x2356;
567
+  constexpr uint16_t VP_FAN4_CONTROL                  = 0x2358;
568
+  constexpr uint16_t VP_FAN5_CONTROL                  = 0x235A;
569
+
570
+  constexpr uint16_t VP_LANGUAGE_CHANGE               = 0x2380;
571
+  constexpr uint16_t VP_LANGUAGE_CHANGE1              = 0x2382;
572
+  constexpr uint16_t VP_LANGUAGE_CHANGE2              = 0x2384;
573
+  constexpr uint16_t VP_LANGUAGE_CHANGE3              = 0x2386;
574
+  constexpr uint16_t VP_LANGUAGE_CHANGE4              = 0x2388;
575
+  constexpr uint16_t VP_LANGUAGE_CHANGE5              = 0x238A;
576
+
577
+  // LEVEL
578
+  constexpr uint16_t VP_LEVEL_POINT                   = 0x2400;
579
+  constexpr uint16_t VP_MESH_LEVEL_POINT              = 0x2410;
580
+  constexpr uint16_t VP_MESH_LEVEL_ADJUST             = 0x2412;
581
+  constexpr uint16_t VP_MESH_LEVEL_DIP                = 0x2414;
582
+  constexpr uint16_t VP_MESH_LEVEL_POINT_X            = 0x2416;
583
+  constexpr uint16_t VP_MESH_LEVEL_POINT_Y            = 0x2418;
584
+  constexpr uint16_t VP_LEVEL_BUTTON                  = 0x2420;
585
+  constexpr uint16_t VP_MESH_LEVEL_POINT_DIS          = 0x2422;
586
+  constexpr uint16_t VP_MESH_LEVEL_BACK               = 0x2424;
587
+
588
+  constexpr uint16_t VP_E0_FILAMENT_LOAD_UNLOAD       = 0x2500;
589
+  constexpr uint16_t VP_E1_FILAMENT_LOAD_UNLOAD       = 0x2504;
590
+  constexpr uint16_t VP_LOAD_Filament                 = 0x2508;
591
+  // constexpr uint16_t VP_LOAD_UNLOAD_Cancle            = 0x250A;
592
+  constexpr uint16_t VP_UNLOAD_Filament               = 0x250B;
593
+  constexpr uint16_t VP_Filament_distance             = 0x2600;
594
+  constexpr uint16_t VP_Filament_speed                = 0x2604;
595
+  constexpr uint16_t VP_MIN_EX_T                      = 0x2606;
596
+
597
+  constexpr uint16_t VP_E1_Filament_distance          = 0x2614;
598
+  constexpr uint16_t VP_E1_Filament_speed             = 0x2616;
599
+  constexpr uint16_t VP_E1_MIN_EX_T                   = 0x2618;
600
+
601
+  constexpr uint16_t VP_Fan0_Percentage               = 0x2700;   // 2 Byte Integer (0..100)
602
+  constexpr uint16_t VP_Fan1_Percentage               = 0x2702;   // 2 Byte Integer (0..100)
603
+  constexpr uint16_t VP_Fan2_Percentage               = 0x2704;   // 2 Byte Integer (0..100)
604
+  constexpr uint16_t VP_Fan3_Percentage               = 0x2706;   // 2 Byte Integer (0..100)
605
+  constexpr uint16_t VP_Feedrate_Percentage           = 0x2708;   // 2 Byte Integer (0..100)
606
+
607
+  // Fan status
608
+  constexpr uint16_t VP_FAN0_STATUS                   = 0x2710;
609
+  constexpr uint16_t VP_FAN1_STATUS                   = 0x2712;
610
+  constexpr uint16_t VP_FAN2_STATUS                   = 0x2714;
611
+  constexpr uint16_t VP_FAN3_STATUS                   = 0x2716;
612
+
613
+  // Step per mm
614
+  constexpr uint16_t VP_X_STEP_PER_MM                 = 0x2900;   // at the moment , 2 byte unsigned int , 0~1638.4
615
+  constexpr uint16_t VP_Y_STEP_PER_MM                 = 0x2904;
616
+  constexpr uint16_t VP_Z_STEP_PER_MM                 = 0x2908;
617
+  constexpr uint16_t VP_E0_STEP_PER_MM                = 0x2910;
618
+  constexpr uint16_t VP_E1_STEP_PER_MM                = 0x2912;
619
+  constexpr uint16_t VP_E2_STEP_PER_MM                = 0x2914;
620
+  constexpr uint16_t VP_E3_STEP_PER_MM                = 0x2916;
621
+  constexpr uint16_t VP_E4_STEP_PER_MM                = 0x2918;
622
+  constexpr uint16_t VP_E5_STEP_PER_MM                = 0x291A;
623
+  constexpr uint16_t VP_E6_STEP_PER_MM                = 0x291C;
624
+  constexpr uint16_t VP_E7_STEP_PER_MM                = 0x291E;
625
+
626
+  constexpr uint16_t VP_X_MAX_SPEED                   = 0x2A00;
627
+  constexpr uint16_t VP_Y_MAX_SPEED                   = 0x2A04;
628
+  constexpr uint16_t VP_Z_MAX_SPEED                   = 0x2A08;
629
+  constexpr uint16_t VP_E0_MAX_SPEED                  = 0x2A0C;
630
+  constexpr uint16_t VP_E1_MAX_SPEED                  = 0x2A10;
631
+
632
+  constexpr uint16_t VP_X_ACC_MAX_SPEED               = 0x2A28;
633
+  constexpr uint16_t VP_Y_ACC_MAX_SPEED               = 0x2A2C;
634
+  constexpr uint16_t VP_Z_ACC_MAX_SPEED               = 0x2A30;
635
+  constexpr uint16_t VP_E0_ACC_MAX_SPEED              = 0x2A34;
636
+  constexpr uint16_t VP_E1_ACC_MAX_SPEED              = 0x2A38;
637
+
638
+  constexpr uint16_t VP_TRAVEL_SPEED                  = 0x2A3C;
639
+  constexpr uint16_t VP_FEEDRATE_MIN_SPEED            = 0x2A40;
640
+  constexpr uint16_t VP_T_F_SPEED                     = 0x2A44;
641
+  constexpr uint16_t VP_ACC_SPEED                     = 0x2A48;
642
+
643
+  /* -------------------------------0x3000-0x3FFF------------------------------- */
644
+  // Buttons on the SD-Card File listing.
645
+  constexpr uint16_t VP_SD_ScrollEvent                = 0x3020; // Data: 0 for "up a directory", numbers are the amount to scroll, e.g -1 one up, 1 one down
646
+  constexpr uint16_t VP_SD_FileSelected               = 0x3022; // Number of file field selected.
647
+  constexpr uint16_t VP_SD_FileSelectConfirm          = 0x3024; // (This is a virtual VP and emulated by the Confirm Screen when a file has been confirmed)
648
+  constexpr uint16_t VP_SD_ResumePauseAbort           = 0x3026; // Resume(Data=0), Pause(Data=1), Abort(Data=2) SD Card prints
649
+  constexpr uint16_t VP_SD_AbortPrintConfirmed        = 0x3028; // Abort print confirmation (virtual, will be injected by the confirm dialog)
650
+  constexpr uint16_t VP_SD_Print_Setting              = 0x3040;
651
+  constexpr uint16_t VP_SD_Print_LiveAdjustZ          = 0x3050; // Data: 0 down, 1 up
652
+  constexpr uint16_t VP_SD_Print_LiveAdjustZ_Confirm  = 0x3060;
653
+  constexpr uint16_t VP_ZOffset_Distance              = 0x3070;
654
+  constexpr uint16_t VP_ZOffset_DE_DIS                = 0x3080;
655
+  // SDCard File Listing
656
+  constexpr uint16_t VP_SD_FileName_LEN = 32;                   // LEN is shared for all entries.
657
+  constexpr uint16_t DGUS_SD_FILESPERSCREEN = 10;               // FIXME move that info to the display and read it from there.
658
+  constexpr uint16_t VP_SD_FileName0                  = 0x3100;
659
+  constexpr uint16_t VP_SD_FileName1                  = 0x3120;
660
+  constexpr uint16_t VP_SD_FileName2                  = 0x3140;
661
+  constexpr uint16_t VP_SD_FileName3                  = 0x3160;
662
+  constexpr uint16_t VP_SD_FileName4                  = 0x3180;
663
+  constexpr uint16_t VP_SD_FileName5                  = 0x31A0;
664
+  constexpr uint16_t VP_SD_FileName6                  = 0x31C0;
665
+  constexpr uint16_t VP_SD_FileName7                  = 0x31E0;
666
+  constexpr uint16_t VP_SD_FileName8                  = 0x3200;
667
+  constexpr uint16_t VP_SD_FileName9                  = 0x3220;
668
+
669
+  constexpr uint16_t VP_SD_Print_ProbeOffsetZ         = 0x32A0;
670
+  constexpr uint16_t VP_SD_Print_Baby                 = 0x32B0;
671
+  constexpr uint16_t VP_SD_Print_Filename             = 0x32C0;
672
+
673
+  // X Y Z Point
674
+  constexpr uint16_t VP_XPos = 0x3300;  // 4 Byte Fixed point number; format xxx.yy
675
+  constexpr uint16_t VP_YPos = 0x3302;  // 4 Byte Fixed point number; format xxx.yy
676
+  constexpr uint16_t VP_ZPos = 0x3304;  // 4 Byte Fixed point number; format xxx.yy
677
+  constexpr uint16_t VP_EPos = 0x3306;  // 4 Byte Fixed point number; format xxx.yy
678
+
679
+  // Print
680
+  constexpr uint16_t VP_PrintProgress_Percentage      = 0x3330; // 2 Byte Integer (0..100)
681
+  constexpr uint16_t VP_PrintTime                     = 0x3340;
682
+  constexpr uint16_t VP_PrintTime_LEN                 = 32;
683
+  constexpr uint16_t VP_PrintAccTime                  = 0x3360;
684
+  constexpr uint16_t VP_PrintAccTime_LEN              = 32;
685
+  constexpr uint16_t VP_PrintsTotal                   = 0x3380;
686
+  constexpr uint16_t VP_PrintsTotal_LEN               = 16;
687
+
688
+  constexpr uint16_t VP_File_Pictutr0                 = 0x3400;
689
+  constexpr uint16_t VP_File_Pictutr1                 = 0x3402;
690
+  constexpr uint16_t VP_File_Pictutr2                 = 0x3404;
691
+  constexpr uint16_t VP_File_Pictutr3                 = 0x3406;
692
+  constexpr uint16_t VP_File_Pictutr4                 = 0x3408;
693
+  constexpr uint16_t VP_File_Pictutr5                 = 0x340A;
694
+  constexpr uint16_t VP_File_Pictutr6                 = 0x340C;
695
+  constexpr uint16_t VP_File_Pictutr7                 = 0x340E;
696
+  constexpr uint16_t VP_File_Pictutr8                 = 0x3410;
697
+  constexpr uint16_t VP_File_Pictutr9                 = 0x3412;
698
+
699
+  constexpr uint16_t VP_BED_STATUS                    = 0x341C;
700
+
701
+  constexpr uint16_t VP_TMC_X_STEP                    = 0x3430;
702
+  constexpr uint16_t VP_TMC_Y_STEP                    = 0x3432;
703
+  constexpr uint16_t VP_TMC_Z_STEP                    = 0x3434;
704
+
705
+  constexpr uint16_t VP_TMC_X1_Current                = 0x3436;
706
+  constexpr uint16_t VP_TMC_Y1_Current                = 0x3438;
707
+  constexpr uint16_t VP_TMC_X_Current                 = 0x343A;
708
+  constexpr uint16_t VP_TMC_Y_Current                 = 0x343C;
709
+  constexpr uint16_t VP_TMC_Z_Current                 = 0x343E;
710
+  constexpr uint16_t VP_TMC_E0_Current                = 0x3440;
711
+  constexpr uint16_t VP_TMC_E1_Current                = 0x3442;
712
+  constexpr uint16_t VP_TMC_Z1_Current                = 0x3444;
713
+
714
+
715
+  constexpr uint16_t VP_PrintTime_H                   = 0x3500;
716
+  constexpr uint16_t VP_PrintTime_M                   = 0x3502;
717
+  constexpr uint16_t VP_PrintTime_S                   = 0x3504;
718
+
719
+  // PIDs
720
+  constexpr uint16_t VP_E0_PID_P = 0x3700; // at the moment , 2 byte unsigned int , 0~1638.4
721
+  constexpr uint16_t VP_E0_PID_I = 0x3702;
722
+  constexpr uint16_t VP_E0_PID_D = 0x3704;
723
+  constexpr uint16_t VP_E1_PID_P = 0x3706; // at the moment , 2 byte unsigned int , 0~1638.4
724
+  constexpr uint16_t VP_E1_PID_I = 0x3708;
725
+  constexpr uint16_t VP_E1_PID_D = 0x370A;
726
+  constexpr uint16_t VP_BED_PID_P = 0x3710;
727
+  constexpr uint16_t VP_BED_PID_I = 0x3712;
728
+  constexpr uint16_t VP_BED_PID_D = 0x3714;
729
+
730
+  constexpr uint16_t VP_EEPROM_CTRL = 0x3720;
731
+
732
+  constexpr uint16_t VP_OFFSET_X = 0x3724;
733
+  constexpr uint16_t VP_OFFSET_Y = 0x3728;
734
+  constexpr uint16_t VP_OFFSET_Z = 0x372B;
735
+
736
+  // PID autotune
737
+  constexpr uint16_t VP_PID_AUTOTUNE_E0 = 0x3800;
738
+  constexpr uint16_t VP_PID_AUTOTUNE_E1 = 0x3802;
739
+  constexpr uint16_t VP_PID_AUTOTUNE_E2 = 0x3804;
740
+  constexpr uint16_t VP_PID_AUTOTUNE_E3 = 0x3806;
741
+  constexpr uint16_t VP_PID_AUTOTUNE_E4 = 0x3808;
742
+  constexpr uint16_t VP_PID_AUTOTUNE_E5 = 0x380A;
743
+  constexpr uint16_t VP_PID_AUTOTUNE_BED = 0x380C;
744
+  // Calibrate Z
745
+  constexpr uint16_t VP_Z_CALIBRATE = 0x3810;
746
+
747
+  constexpr uint16_t VP_AutoTurnOffSw = 0x3812;
748
+  constexpr uint16_t VP_LCD_BLK = 0x3814;
749
+
750
+  constexpr uint16_t VP_X_PARK_POS = 0x3900;
751
+  constexpr uint16_t VP_Y_PARK_POS = 0x3902;
752
+  constexpr uint16_t VP_Z_PARK_POS = 0x3904;
753
+
754
+  /* -------------------------------0x4000-0x4FFF------------------------------- */
755
+  // Heater Control Buttons , triged between "cool down" and "heat PLA" state
756
+  constexpr uint16_t VP_E0_CONTROL = 0x4010;
757
+  constexpr uint16_t VP_E1_CONTROL = 0x4012;
758
+  //constexpr uint16_t VP_E2_CONTROL = 0x2214;
759
+  //constexpr uint16_t VP_E3_CONTROL = 0x2216;
760
+  //constexpr uint16_t VP_E4_CONTROL = 0x2218;
761
+  //constexpr uint16_t VP_E5_CONTROL = 0x221A;
762
+  constexpr uint16_t VP_BED_CONTROL = 0x401C;
763
+
764
+  // Preheat
765
+  constexpr uint16_t VP_E0_BED_PREHEAT = 0x4020;
766
+  constexpr uint16_t VP_E1_BED_PREHEAT = 0x4022;
767
+  //constexpr uint16_t VP_E2_BED_PREHEAT = 0x4024;
768
+  //constexpr uint16_t VP_E3_BED_PREHEAT = 0x4026;
769
+  //constexpr uint16_t VP_E4_BED_PREHEAT = 0x4028;
770
+  //constexpr uint16_t VP_E5_BED_PREHEAT = 0x402A;
771
+
772
+  // Filament load and unload
773
+  // constexpr uint16_t VP_E0_FILAMENT_LOAD_UNLOAD = 0x4030;
774
+  // constexpr uint16_t VP_E1_FILAMENT_LOAD_UNLOAD = 0x4032;
775
+
776
+  // Settings store , reset
777
+
778
+  // Level data
779
+  constexpr uint16_t VP_Level_Point_One_X              = 0x4100;
780
+  constexpr uint16_t VP_Level_Point_One_Y              = 0x4102;
781
+  constexpr uint16_t VP_Level_Point_Two_X              = 0x4104;
782
+  constexpr uint16_t VP_Level_Point_Two_Y              = 0x4106;
783
+  constexpr uint16_t VP_Level_Point_Three_X            = 0x4108;
784
+  constexpr uint16_t VP_Level_Point_Three_Y            = 0x410A;
785
+  constexpr uint16_t VP_Level_Point_Four_X             = 0x410C;
786
+  constexpr uint16_t VP_Level_Point_Four_Y             = 0x410E;
787
+  constexpr uint16_t VP_Level_Point_Five_X             = 0x4110;
788
+  constexpr uint16_t VP_Level_Point_Five_Y             = 0x4112;
789
+
790
+
791
+  /* H43 Version */
792
+  constexpr uint16_t VP_MKS_H43_VERSION                = 0x4A00;   // MKS H43 V1.0.0
793
+  constexpr uint16_t VP_MKS_H43_VERSION_LEN            = 16;
794
+  constexpr uint16_t VP_MKS_H43_UpdataVERSION          = 0x4A10;   // MKS H43 V1.0.0
795
+  constexpr uint16_t VP_MKS_H43_UpdataVERSION_LEN      = 16;
796
+
797
+  /* -------------------------------0x5000-0xFFFF------------------------------- */
798
+  constexpr uint16_t VP_HOME_Dis                      = 0x5000;
799
+  constexpr uint16_t VP_Setting_Dis                   = 0x5010;
800
+  constexpr uint16_t VP_Tool_Dis                      = 0x5020;
801
+  constexpr uint16_t VP_Printing_Dis                  = 0x5030;
802
+
803
+  constexpr uint16_t VP_Language_Dis                  = 0x5080;
804
+  constexpr uint16_t VP_LossPoint_Dis                 = 0x5090;
805
+
806
+  constexpr uint16_t VP_PrintPauseConfig_Dis          = 0x5120;
807
+  constexpr uint16_t VP_MotorPluse_Dis                = 0x5140;
808
+  constexpr uint16_t VP_MotorMaxSpeed_Dis             = 0x5150;
809
+  constexpr uint16_t VP_MotorMaxAcc_Dis               = 0x5160;
810
+
811
+  constexpr uint16_t VP_X_Pluse_Dis                   = 0x5170;
812
+  constexpr uint16_t VP_Y_Pluse_Dis                   = 0x5180;
813
+  constexpr uint16_t VP_Z_Pluse_Dis                   = 0x5190;
814
+  constexpr uint16_t VP_E0_Pluse_Dis                  = 0x51A0;
815
+  constexpr uint16_t VP_E1_Pluse_Dis                  = 0x51B0;
816
+
817
+  constexpr uint16_t VP_X_Max_Speed_Dis               = 0x5280;
818
+  constexpr uint16_t VP_Y_Max_Speed_Dis               = 0x5290;
819
+  constexpr uint16_t VP_Z_Max_Speed_Dis               = 0x52A0;
820
+  constexpr uint16_t VP_E0_Max_Speed_Dis              = 0x52B0;
821
+  constexpr uint16_t VP_E1_Max_Speed_Dis              = 0x52C0;
822
+
823
+  constexpr uint16_t VP_X_Max_Acc_Speed_Dis           = 0x51E0;
824
+  constexpr uint16_t VP_Y_Max_Acc_Speed_Dis           = 0x51F0;
825
+  constexpr uint16_t VP_Z_Max_Acc_Speed_Dis           = 0x5200;
826
+  constexpr uint16_t VP_E0_Max_Acc_Speed_Dis          = 0x5210;
827
+  constexpr uint16_t VP_E1_Max_Acc_Speed_Dis          = 0x5220;
828
+
829
+
830
+  constexpr uint16_t VP_PrintTime_Dis                 = 0x5470;
831
+  constexpr uint16_t VP_E0_Temp_Dis                   = 0x5310;
832
+  constexpr uint16_t VP_E1_Temp_Dis                   = 0x5320;
833
+  constexpr uint16_t VP_HB_Temp_Dis                   = 0x5330;
834
+  constexpr uint16_t VP_Feedrate_Dis                  = 0x5350;
835
+  constexpr uint16_t VP_PrintAcc_Dis                  = 0x5340;
836
+  constexpr uint16_t VP_Fan_Speed_Dis                 = 0x5360;
837
+
838
+  constexpr uint16_t VP_Min_Ex_Temp_Dis               = 0x5380;
839
+
840
+
841
+  constexpr uint16_t VP_X_PARK_POS_Dis                = 0x53E0;
842
+  constexpr uint16_t VP_Y_PARK_POS_Dis                = 0x53F0;
843
+  constexpr uint16_t VP_Z_PARK_POS_Dis                = 0x5400;
844
+
845
+
846
+  constexpr uint16_t VP_TravelAcc_Dis                 = 0x5440;
847
+  constexpr uint16_t VP_FeedRateMin_Dis               = 0x5450;
848
+  constexpr uint16_t VP_TravelFeeRateMin_Dis          = 0x5460;
849
+  constexpr uint16_t VP_ACC_Dis                       = 0x5480;
850
+
851
+  constexpr uint16_t VP_Extrusion_Dis                 = 0x5230;
852
+  constexpr uint16_t VP_HeatBed_Dis                   = 0x5240;
853
+
854
+  constexpr uint16_t VP_Printting_Dis                 = 0x5430;
855
+  constexpr uint16_t VP_FactoryDefaults_Dis           = 0x54C0;
856
+  constexpr uint16_t VP_StoreSetting_Dis              = 0x54B0;
857
+  constexpr uint16_t VP_Info_EEPROM_2_Dis             = 0x54D0;
858
+  constexpr uint16_t VP_Info_EEPROM_1_Dis             = 0x54E0;
859
+
860
+  constexpr uint16_t VP_AutoLevel_1_Dis               = 0x55F0;
861
+
862
+  constexpr uint16_t VP_TMC_X_Step_Dis                = 0x5530;
863
+  constexpr uint16_t VP_TMC_Y_Step_Dis                = 0x5540;
864
+  constexpr uint16_t VP_TMC_Z_Step_Dis                = 0x5550;
865
+  constexpr uint16_t VP_TMC_X1_Current_Dis            = 0x5560;
866
+  constexpr uint16_t VP_TMC_Y1_Current_Dis            = 0x5570;
867
+  constexpr uint16_t VP_TMC_X_Current_Dis             = 0x5580;
868
+  constexpr uint16_t VP_TMC_Y_Current_Dis             = 0x5590;
869
+  constexpr uint16_t VP_TMC_Z_Current_Dis             = 0x55A0;
870
+  constexpr uint16_t VP_TMC_E0_Current_Dis            = 0x55B0;
871
+  constexpr uint16_t VP_TMC_E1_Current_Dis            = 0x55C0;
872
+  constexpr uint16_t VP_TMC_Z1_Current_Dis            = 0x55E0;
873
+
874
+  constexpr uint16_t VP_AutoLEVEL_INFO1               = 0x5600;
875
+  constexpr uint16_t VP_EX_TEMP_INFO1_Dis             = 0x5610;
876
+  constexpr uint16_t VP_EX_TEMP_INFO2_Dis             = 0x5620;
877
+  constexpr uint16_t VP_EX_TEMP_INFO3_Dis             = 0x5630;
878
+  constexpr uint16_t VP_LCD_BLK_Dis                   = 0x56A0;
879
+  constexpr uint16_t VP_Info_PrinfFinsh_1_Dis         = 0x5C00;
880
+  constexpr uint16_t VP_Info_PrinfFinsh_2_Dis         = 0x5C10;
881
+
882
+  constexpr uint16_t VP_Length_Dis                    = 0x5B00;
883
+
884
+  constexpr uint16_t VP_PrintConfrim_Info_Dis         = 0x5B90;
885
+  constexpr uint16_t VP_StopPrintConfrim_Info_Dis     = 0x5B80;
886
+
887
+  constexpr uint16_t VP_Point_One_Dis                 = 0x5BA0;
888
+  constexpr uint16_t VP_Point_Two_Dis                 = 0x5BB0;
889
+  constexpr uint16_t VP_Point_Three_Dis               = 0x5BC0;
890
+  constexpr uint16_t VP_Point_Four_Dis                = 0x5BD0;
891
+  constexpr uint16_t VP_Point_Five_Dis                = 0x5BE0;
892
+
893
+  constexpr uint16_t VP_Print_Dis                     = 0x5250;
894
+
895
+  constexpr uint16_t VP_About_Dis                     = 0x5A00;
896
+  constexpr uint16_t VP_Config_Dis                    = 0x5A10;
897
+  constexpr uint16_t VP_Filament_Dis                  = 0x5A20;
898
+  constexpr uint16_t VP_Move_Dis                      = 0x5A30;
899
+  constexpr uint16_t VP_Level_Dis                     = 0x5A50;
900
+  constexpr uint16_t VP_Speed_Dis                     = 0x5A70;
901
+  constexpr uint16_t VP_InOut_Dis                     = 0x5A80;
902
+
903
+  constexpr uint16_t VP_MotorConfig_Dis               = 0x5100;
904
+  constexpr uint16_t VP_LevelConfig_Dis               = 0x5110;
905
+  constexpr uint16_t VP_Advance_Dis                   = 0x5130;
906
+  constexpr uint16_t VP_TemperatureConfig_Dis         = 0x5390;
907
+
908
+#endif // MKS_FINSH

+ 2109
- 0
Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 307
- 0
Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h Прегледај датотеку

@@ -0,0 +1,307 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "../DGUSDisplay.h"
25
+#include "../DGUSVPVariable.h"
26
+#include "../DGUSDisplayDef.h"
27
+
28
+#include "../../../../../inc/MarlinConfig.h"
29
+
30
+enum DGUSLCD_Screens : uint8_t;
31
+
32
+class DGUSScreenHandler {
33
+public:
34
+  DGUSScreenHandler() = default;
35
+
36
+  static bool loop();
37
+
38
+  // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
39
+  // The bools specifing whether the strings are in RAM or FLASH.
40
+  static void sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
41
+
42
+  static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
43
+
44
+  static void sendinfoscreen_ch_mks(const uint16_t* line1, const uint16_t* line2, const uint16_t* line3, const uint16_t* line4);
45
+  static void sendinfoscreen_en_mks(const char* line1, const char* line2, const char* line3, const char* line4) ;
46
+  static void sendinfoscreen_mks(const void* line1, const void* line2, const void* line3, const void* line4,uint16_t language);
47
+
48
+  // "M117" Message -- msg is a RAM ptr.
49
+  static void setstatusmessage(const char* msg);
50
+  // The same for messages from Flash
51
+  static void setstatusmessagePGM(PGM_P const msg);
52
+  // Callback for VP "Display wants to change screen on idle printer"
53
+  static void ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr);
54
+  // Callback for VP "Screen has been changed"
55
+  static void ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr);
56
+
57
+  static void ScreenBackChange(DGUS_VP_Variable &var, void *val_ptr);
58
+
59
+  // Callback for VP "All Heaters Off"
60
+  static void HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr);
61
+  // Hook for "Change this temperature"
62
+  static void HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr);
63
+  // Hook for "Change Flowrate"
64
+  static void HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr);
65
+  #if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
66
+    // Hook for manual move option
67
+    static void HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr);
68
+  #endif
69
+
70
+  static void EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr);
71
+  static void LanguageChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
72
+  static void GetOffsetValue(DGUS_VP_Variable &var, void *val_ptr);
73
+  static void Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr);
74
+  static void MeshLevel(DGUS_VP_Variable &var, void *val_ptr);
75
+  static void MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val_ptr);
76
+  static void ManualAssistLeveling(DGUS_VP_Variable &var, void *val_ptr);
77
+  static void ZoffsetConfirm(DGUS_VP_Variable &var, void *val_ptr);
78
+  static void Z_offset_select(DGUS_VP_Variable &var, void *val_ptr);
79
+  static void GetManualMovestep(DGUS_VP_Variable &var, void *val_ptr);
80
+  static void GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr);
81
+  static void GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr);
82
+  static void GetParkPos_MKS(DGUS_VP_Variable &var, void *val_ptr);
83
+  static void HandleGetExMinTemp_MKS(DGUS_VP_Variable &var, void *val_ptr);
84
+  static void DGUS_LanguageDisplay(uint8_t var);
85
+  static void TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr);
86
+  static void GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr);
87
+  static void LanguagePInit(void);
88
+  static void DGUS_Runout_Idle(void);
89
+  static void DGUS_RunoutInit(void);
90
+  static void DGUS_ExtrudeLoadInit(void);
91
+  static void LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr);
92
+
93
+  // Hook for manual move.
94
+  static void HandleManualMove(DGUS_VP_Variable &var, void *val_ptr);
95
+  // Hook for manual extrude.
96
+  static void HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr);
97
+  // Hook for motor lock and unlook
98
+  static void HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr);
99
+  #if ENABLED(POWER_LOSS_RECOVERY)
100
+    // Hook for power loss recovery.
101
+    static void HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr);
102
+  #endif
103
+  // Hook for settings
104
+  static void HandleSettings(DGUS_VP_Variable &var, void *val_ptr);
105
+  static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr);
106
+  static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr);
107
+
108
+  static void HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void *val_ptr);
109
+  static void HandleStepPerMMExtruderChanged_MKS(DGUS_VP_Variable &var, void *val_ptr);
110
+  static void HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
111
+  static void HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
112
+  static void HandleAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
113
+  static void HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
114
+  static void HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
115
+  static void HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void *val_ptr);
116
+  static void HandleTravelAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
117
+  static void HandleFeedRateMinChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
118
+  static void HandleMin_T_F_MKS(DGUS_VP_Variable &var, void *val_ptr);
119
+
120
+  #if HAS_PID_HEATING
121
+    // Hook for "Change this temperature PID para"
122
+    static void HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr);
123
+    // Hook for PID autotune
124
+    static void HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr);
125
+  #endif
126
+  #if HAS_BED_PROBE
127
+    // Hook for "Change probe offset z"
128
+    static void HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr);
129
+  #endif
130
+  #if ENABLED(BABYSTEPPING)
131
+    // Hook for live z adjust action
132
+    static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr);
133
+  #endif
134
+  #if HAS_FAN
135
+    // Hook for fan control
136
+    static void HandleFanControl(DGUS_VP_Variable &var, void *val_ptr);
137
+  #endif
138
+  // Hook for heater control
139
+  static void HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr);
140
+  #if ENABLED(DGUS_PREHEAT_UI)
141
+    // Hook for preheat
142
+    static void HandlePreheat(DGUS_VP_Variable &var, void *val_ptr);
143
+  #endif
144
+  #if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
145
+    // Hook for filament load and unload filament option
146
+    static void HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr);
147
+    // Hook for filament load and unload
148
+    static void HandleFilamentLoadUnload(DGUS_VP_Variable &var);
149
+
150
+    static void MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr);
151
+    static void MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr);
152
+    static void MKS_LOAD_UNLOAD_IDLE();
153
+    static void MKS_LOAD_Cancle(DGUS_VP_Variable &var, void *val_ptr);
154
+    static void GetManualFilament(DGUS_VP_Variable &var, void *val_ptr);
155
+    static void GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr);
156
+  #endif
157
+
158
+  #if ENABLED(SDSUPPORT)
159
+    // Callback for VP "Display wants to change screen when there is a SD card"
160
+    static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr);
161
+    // Scroll buttons on the file listing screen.
162
+    static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr);
163
+    // File touched.
164
+    static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr);
165
+    // start print after confirmation received.
166
+    static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr);
167
+    // User hit the pause, resume or abort button.
168
+    static void DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr);
169
+    // User confirmed the abort action
170
+    static void DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr);
171
+    // User hit the tune button
172
+    static void DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr);
173
+    // Send a single filename to the display.
174
+    static void DGUSLCD_SD_SendFilename(DGUS_VP_Variable &var);
175
+    // Marlin informed us that a new SD has been inserted.
176
+    static void SDCardInserted();
177
+    // Marlin informed us that the SD Card has been removed().
178
+    static void SDCardRemoved();
179
+    // Marlin informed us about a bad SD Card.
180
+    static void SDCardError();
181
+    // Marlin informed us about SD print completion.
182
+    static void SDPrintingFinished();
183
+  #endif
184
+
185
+  // OK Button the Confirm screen.
186
+  static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr);
187
+
188
+  // Update data after went to new screen (by display or by GotoScreen)
189
+  // remember: store the last-displayed screen, so it can get returned to.
190
+  // (e.g for pop up messages)
191
+  static void UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup=false);
192
+
193
+  // Recall the remembered screen.
194
+  static void PopToOldScreen();
195
+
196
+  // Make the display show the screen and update all VPs in it.
197
+  static void GotoScreen(DGUSLCD_Screens screen, bool ispopup = false);
198
+
199
+  static void UpdateScreenVPData();
200
+
201
+  // Helpers to convert and transfer data to the display.
202
+  static void DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var);
203
+  static void DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var);
204
+  static void DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var);
205
+  static void DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var);
206
+  static void DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var);
207
+  static void DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var);
208
+  static void DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var);
209
+
210
+  static void DGUSLCD_SendPrintTimeToDisplay_MKS(DGUS_VP_Variable &var);
211
+  static void DGUSLCD_SendBabyStepToDisplay_MKS(DGUS_VP_Variable &var);
212
+  static void DGUSLCD_SendFanToDisplay(DGUS_VP_Variable &var);
213
+  static void DGUSLCD_SendGbkToDisplay(DGUS_VP_Variable &var);
214
+  static void DGUSLCD_SendStringToDisplay_Language_MKS(DGUS_VP_Variable &var);
215
+  static void DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var);
216
+
217
+  #if ENABLED(PRINTCOUNTER)
218
+    static void DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var);
219
+    static void DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var);
220
+  #endif
221
+  #if HAS_FAN
222
+    static void DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var);
223
+  #endif
224
+  static void DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var);
225
+  #if ENABLED(DGUS_UI_WAITING)
226
+    static void DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var);
227
+  #endif
228
+
229
+  // Send a value from 0..100 to a variable with a range from 0..255
230
+  static void DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr);
231
+
232
+  static void DGUSLCD_SetUint8(DGUS_VP_Variable &var, void *val_ptr);
233
+
234
+  template<typename T>
235
+  static void DGUSLCD_SetValueDirectly(DGUS_VP_Variable &var, void *val_ptr) {
236
+    if (!var.memadr) return;
237
+    union { unsigned char tmp[sizeof(T)]; T t; } x;
238
+    unsigned char *ptr = (unsigned char*)val_ptr;
239
+    LOOP_L_N(i, sizeof(T)) x.tmp[i] = ptr[sizeof(T) - i - 1];
240
+    *(T*)var.memadr = x.t;
241
+  }
242
+
243
+  // Send a float value to the display.
244
+  // Display will get a 4-byte integer scaled to the number of digits:
245
+  // Tell the display the number of digits and it cheats by displaying a dot between...
246
+  template<unsigned int decimals>
247
+  static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) {
248
+    if (var.memadr) {
249
+      float f = *(float *)var.memadr;
250
+      f *= cpow(10, decimals);
251
+      dgusdisplay.WriteVariable(var.VP, (long)f);
252
+    }
253
+  }
254
+
255
+  // Send a float value to the display.
256
+  // Display will get a 2-byte integer scaled to the number of digits:
257
+  // Tell the display the number of digits and it cheats by displaying a dot between...
258
+  template<unsigned int decimals>
259
+  static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) {
260
+    if (var.memadr) {
261
+      float f = *(float *)var.memadr;
262
+      DEBUG_ECHOLNPAIR_F(" >> ", f, 6);
263
+      f *= cpow(10, decimals);
264
+      dgusdisplay.WriteVariable(var.VP, (int16_t)f);
265
+    }
266
+  }
267
+
268
+  // Force an update of all VP on the current screen.
269
+  static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; }
270
+  // Has all VPs sent to the screen
271
+  static inline bool IsScreenComplete() { return ScreenComplete; }
272
+
273
+  static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; }
274
+
275
+  static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; }
276
+
277
+private:
278
+  static DGUSLCD_Screens current_screen;  //< currently on screen
279
+  static constexpr uint8_t NUM_PAST_SCREENS = 4;
280
+  static DGUSLCD_Screens past_screens[NUM_PAST_SCREENS]; //< LIFO with past screens for the "back" button.
281
+
282
+  static uint8_t update_ptr;      //< Last sent entry in the VPList for the actual screen.
283
+  static uint16_t skipVP;         //< When updating the screen data, skip this one, because the user is interacting with it.
284
+  static bool ScreenComplete;     //< All VPs sent to screen?
285
+
286
+  static uint16_t ConfirmVP;      //< context for confirm screen (VP that will be emulated-sent on "OK").
287
+
288
+  #if ENABLED(SDSUPPORT)
289
+    static int16_t top_file;      //< file on top of file chooser
290
+    static int16_t file_to_print; //< touched file to be confirmed
291
+  #endif
292
+
293
+  static void (*confirm_action_cb)();
294
+};
295
+
296
+#define MKS_Language_Choose   0x00
297
+#define MKS_Language_NoChoose 0x01
298
+
299
+#define MKS_SimpleChinese     0
300
+#define MKS_English           1
301
+extern uint8_t DGUSLanguageSwitch;
302
+extern bool DGUSAutoTurnOff;
303
+
304
+#if ENABLED(POWER_LOSS_RECOVERY)
305
+  #define PLR_SCREEN_RECOVER MKSLCD_SCREEN_PRINT
306
+  #define PLR_SCREEN_CANCEL MKSLCD_SCREEN_HOME
307
+#endif

+ 4
- 2
Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp Прегледај датотеку

@@ -20,7 +20,9 @@
20 20
  *
21 21
  */
22 22
 
23
-/* DGUS implementation written by coldtobi in 2019 for Marlin */
23
+/**
24
+ * lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp
25
+ */
24 26
 
25 27
 #include "../../../../../inc/MarlinConfigPre.h"
26 28
 
@@ -87,7 +89,7 @@ const uint16_t VPList_Status[] PROGMEM = {
87 89
 };
88 90
 
89 91
 const uint16_t VPList_Status2[] PROGMEM = {
90
-  /* VP_M117, for completeness, but it cannot be auto-uploaded */
92
+  // VP_M117, for completeness, but it cannot be auto-uploaded
91 93
   #if HOTENDS >= 1
92 94
     VP_Flowrate_E0,
93 95
   #endif

+ 418
- 0
Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp Прегледај датотеку

@@ -0,0 +1,418 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "../../../../../inc/MarlinConfigPre.h"
24
+
25
+#if ENABLED(DGUS_LCD_UI_ORIGIN)
26
+
27
+#include "../DGUSScreenHandler.h"
28
+
29
+#include "../../../../../MarlinCore.h"
30
+#include "../../../../../gcode/queue.h"
31
+#include "../../../../../libs/duration_t.h"
32
+#include "../../../../../module/settings.h"
33
+#include "../../../../../module/temperature.h"
34
+#include "../../../../../module/motion.h"
35
+#include "../../../../../module/planner.h"
36
+#include "../../../../../module/printcounter.h"
37
+#include "../../../../../sd/cardreader.h"
38
+
39
+#if ENABLED(POWER_LOSS_RECOVERY)
40
+  #include "../../../../feature/powerloss.h"
41
+#endif
42
+
43
+#if ENABLED(SDSUPPORT)
44
+
45
+  void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) {
46
+    uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file;
47
+    if (touched_nr > filelist.count()) return;
48
+    if (!filelist.seek(touched_nr)) return;
49
+
50
+    if (filelist.isDir()) {
51
+      filelist.changeDir(filelist.filename());
52
+      top_file = 0;
53
+      ForceCompleteUpdate();
54
+      return;
55
+    }
56
+
57
+    #if ENABLED(DGUS_PRINT_FILENAME)
58
+      // Send print filename
59
+      dgusdisplay.WriteVariable(VP_SD_Print_Filename, filelist.filename(), VP_SD_FileName_LEN, true);
60
+    #endif
61
+
62
+    // Setup Confirmation screen
63
+    file_to_print = touched_nr;
64
+
65
+    HandleUserConfirmationPopUp(VP_SD_FileSelectConfirm, nullptr, PSTR("Print file"), filelist.filename(), PSTR("from SD Card?"), true, true, false, true);
66
+  }
67
+
68
+  void DGUSScreenHandler::DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr) {
69
+    if (!filelist.seek(file_to_print)) return;
70
+    ExtUI::printFile(filelist.shortFilename());
71
+    GotoScreen(DGUSLCD_SCREEN_STATUS);
72
+  }
73
+
74
+  void DGUSScreenHandler::DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr) {
75
+
76
+    if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes.
77
+    switch (swap16(*(uint16_t*)val_ptr)) {
78
+      case 0: { // Resume
79
+        if (ExtUI::isPrintingFromMediaPaused()) {
80
+          ExtUI::resumePrint();
81
+        }
82
+      } break;
83
+
84
+      case 1: // Pause
85
+
86
+        GotoScreen(MKSLCD_SCREEN_PAUSE);
87
+        if (!ExtUI::isPrintingFromMediaPaused()) {
88
+          ExtUI::pausePrint();
89
+          //ExtUI::mks_pausePrint();
90
+        }
91
+        break;
92
+      case 2: // Abort
93
+        HandleUserConfirmationPopUp(VP_SD_AbortPrintConfirmed, nullptr, PSTR("Abort printing"), filelist.filename(), PSTR("?"), true, true, false, true);
94
+        break;
95
+    }
96
+  }
97
+
98
+  void DGUSScreenHandler::DGUSLCD_SD_SendFilename(DGUS_VP_Variable& var) {
99
+    uint16_t target_line = (var.VP - VP_SD_FileName0) / VP_SD_FileName_LEN;
100
+    if (target_line > DGUS_SD_FILESPERSCREEN) return;
101
+    char tmpfilename[VP_SD_FileName_LEN + 1] = "";
102
+    var.memadr = (void*)tmpfilename;
103
+
104
+    if (filelist.seek(top_file + target_line)) {
105
+      snprintf_P(tmpfilename, VP_SD_FileName_LEN, PSTR("%s%c"), filelist.filename(), filelist.isDir() ? '/' : 0); // snprintf_P(tmpfilename, VP_SD_FileName_LEN, PSTR("%s"), filelist.filename());
106
+    }
107
+    DGUSLCD_SendStringToDisplay(var);
108
+  }
109
+
110
+  void DGUSScreenHandler::SDCardInserted() {
111
+    top_file = 0;
112
+    filelist.refresh();
113
+    auto cs = getCurrentScreen();
114
+    if (cs == DGUSLCD_SCREEN_MAIN || cs == DGUSLCD_SCREEN_STATUS)
115
+      GotoScreen(DGUSLCD_SCREEN_SDFILELIST);
116
+  }
117
+
118
+  void DGUSScreenHandler::SDCardRemoved() {
119
+    if (current_screen == DGUSLCD_SCREEN_SDFILELIST
120
+        || (current_screen == DGUSLCD_SCREEN_CONFIRM && (ConfirmVP == VP_SD_AbortPrintConfirmed || ConfirmVP == VP_SD_FileSelectConfirm))
121
+        || current_screen == DGUSLCD_SCREEN_SDPRINTMANIPULATION
122
+    ) GotoScreen(DGUSLCD_SCREEN_MAIN);
123
+  }
124
+
125
+#endif // SDSUPPORT
126
+
127
+void DGUSScreenHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) {
128
+  uint8_t *tmp = (uint8_t*)val_ptr;
129
+
130
+  // The keycode in target is coded as <from-frame><to-frame>, so 0x0100A means
131
+  // from screen 1 (main) to 10 (temperature). DGUSLCD_SCREEN_POPUP is special,
132
+  // meaning "return to previous screen"
133
+  DGUSLCD_Screens target = (DGUSLCD_Screens)tmp[1];
134
+
135
+  DEBUG_ECHOLNPAIR("\n DEBUG target", target);
136
+
137
+  if (target == DGUSLCD_SCREEN_POPUP) {
138
+    // Special handling for popup is to return to previous menu
139
+    if (current_screen == DGUSLCD_SCREEN_POPUP && confirm_action_cb) confirm_action_cb();
140
+    PopToOldScreen();
141
+    return;
142
+  }
143
+
144
+  UpdateNewScreen(target);
145
+
146
+  #ifdef DEBUG_DGUSLCD
147
+    if (!DGUSLCD_FindScreenVPMapList(target)) DEBUG_ECHOLNPAIR("WARNING: No screen Mapping found for ", target);
148
+  #endif
149
+}
150
+
151
+void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
152
+  DEBUG_ECHOLNPGM("HandleManualMove");
153
+
154
+  int16_t movevalue = swap16(*(uint16_t*)val_ptr);
155
+  #if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
156
+    if (movevalue) {
157
+      const uint16_t choice = *(uint16_t*)var.memadr;
158
+      movevalue = movevalue < 0 ? -choice : choice;
159
+    }
160
+  #endif
161
+  char axiscode;
162
+  unsigned int speed = 1500; // FIXME: get default feedrate for manual moves, dont hardcode.
163
+
164
+  switch (var.VP) {
165
+    default: return;
166
+
167
+    case VP_MOVE_X:
168
+      axiscode = 'X';
169
+      if (!ExtUI::canMove(ExtUI::axis_t::X)) goto cannotmove;
170
+      break;
171
+
172
+    case VP_MOVE_Y:
173
+      axiscode = 'Y';
174
+      if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove;
175
+      break;
176
+
177
+    case VP_MOVE_Z:
178
+      axiscode = 'Z';
179
+      speed = 300; // default to 5mm/s
180
+      if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove;
181
+      break;
182
+
183
+    case VP_HOME_ALL: // only used for homing
184
+      axiscode  = '\0';
185
+      movevalue = 0; // ignore value sent from display, this VP is _ONLY_ for homing.
186
+      break;
187
+  }
188
+
189
+  if (!movevalue) {
190
+    // homing
191
+    DEBUG_ECHOPAIR(" homing ", axiscode);
192
+    char buf[6] = "G28 X";
193
+    buf[4] = axiscode;
194
+    //DEBUG_ECHOPAIR(" ", buf);
195
+    queue.enqueue_one_now(buf);
196
+    //DEBUG_ECHOLNPGM(" ✓");
197
+    ForceCompleteUpdate();
198
+    return;
199
+  }
200
+  else {
201
+    // movement
202
+    DEBUG_ECHOPAIR(" move ", axiscode);
203
+    bool old_relative_mode = relative_mode;
204
+    if (!relative_mode) {
205
+      //DEBUG_ECHOPGM(" G91");
206
+      queue.enqueue_now_P(PSTR("G91"));
207
+      //DEBUG_ECHOPGM(" ✓ ");
208
+    }
209
+    char buf[32]; // G1 X9999.99 F12345
210
+    unsigned int backup_speed = MMS_TO_MMM(feedrate_mm_s);
211
+    char sign[] = "\0";
212
+    int16_t value = movevalue / 100;
213
+    if (movevalue < 0) { value = -value; sign[0] = '-'; }
214
+    int16_t fraction = ABS(movevalue) % 100;
215
+    snprintf_P(buf, 32, PSTR("G0 %c%s%d.%02d F%d"), axiscode, sign, value, fraction, speed);
216
+    //DEBUG_ECHOPAIR(" ", buf);
217
+    queue.enqueue_one_now(buf);
218
+    //DEBUG_ECHOLNPGM(" ✓ ");
219
+    if (backup_speed != speed) {
220
+      snprintf_P(buf, 32, PSTR("G0 F%d"), backup_speed);
221
+      queue.enqueue_one_now(buf);
222
+      //DEBUG_ECHOPAIR(" ", buf);
223
+    }
224
+    // while (!enqueue_and_echo_command(buf)) idle();
225
+    //DEBUG_ECHOLNPGM(" ✓ ");
226
+    if (!old_relative_mode) {
227
+      //DEBUG_ECHOPGM("G90");
228
+      queue.enqueue_now_P(PSTR("G90"));
229
+      //DEBUG_ECHOPGM(" ✓ ");
230
+    }
231
+  }
232
+
233
+  ForceCompleteUpdate();
234
+  DEBUG_ECHOLNPGM("manmv done.");
235
+  return;
236
+
237
+  cannotmove:
238
+    DEBUG_ECHOLNPAIR(" cannot move ", axiscode);
239
+    return;
240
+}
241
+
242
+#if HAS_PID_HEATING
243
+  void DGUSScreenHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) {
244
+    uint16_t rawvalue = swap16(*(uint16_t*)val_ptr);
245
+    DEBUG_ECHOLNPAIR("V1:", rawvalue);
246
+    float value = (float)rawvalue / 10;
247
+    DEBUG_ECHOLNPAIR("V2:", value);
248
+    float newvalue = 0;
249
+
250
+    switch (var.VP) {
251
+      default: return;
252
+        #if HOTENDS >= 1
253
+          case VP_E0_PID_P: newvalue = value; break;
254
+          case VP_E0_PID_I: newvalue = scalePID_i(value); break;
255
+          case VP_E0_PID_D: newvalue = scalePID_d(value); break;
256
+        #endif
257
+        #if HOTENDS >= 2
258
+          case VP_E1_PID_P: newvalue = value; break;
259
+          case VP_E1_PID_I: newvalue = scalePID_i(value); break;
260
+          case VP_E1_PID_D: newvalue = scalePID_d(value); break;
261
+        #endif
262
+        #if HAS_HEATED_BED
263
+          case VP_BED_PID_P: newvalue = value; break;
264
+          case VP_BED_PID_I: newvalue = scalePID_i(value); break;
265
+          case VP_BED_PID_D: newvalue = scalePID_d(value); break;
266
+        #endif
267
+    }
268
+
269
+    DEBUG_ECHOLNPAIR_F("V3:", newvalue);
270
+    *(float *)var.memadr = newvalue;
271
+
272
+    skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
273
+  }
274
+#endif // HAS_PID_HEATING
275
+
276
+#if ENABLED(BABYSTEPPING)
277
+  void DGUSScreenHandler::HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr) {
278
+    DEBUG_ECHOLNPGM("HandleLiveAdjustZ");
279
+    int16_t flag  = swap16(*(uint16_t*)val_ptr),
280
+            steps = flag ? -20 : 20;
281
+    ExtUI::smartAdjustAxis_steps(steps, ExtUI::axis_t::Z, true);
282
+    ForceCompleteUpdate();
283
+  }
284
+#endif
285
+
286
+#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
287
+
288
+  void DGUSScreenHandler::HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr) {
289
+    DEBUG_ECHOLNPGM("HandleFilamentOption");
290
+
291
+    uint8_t e_temp = 0;
292
+    filament_data.heated = false;
293
+    uint16_t preheat_option = swap16(*(uint16_t*)val_ptr);
294
+    if (preheat_option <= 8) {      // Load filament type
295
+      filament_data.action = 1;
296
+    }
297
+    else if (preheat_option >= 10) { // Unload filament type
298
+      preheat_option -= 10;
299
+      filament_data.action = 2;
300
+      filament_data.purge_length = DGUS_FILAMENT_PURGE_LENGTH;
301
+    }
302
+    else {                          // Cancel filament operation
303
+      filament_data.action = 0;
304
+    }
305
+
306
+    switch (preheat_option) {
307
+      case 0: // Load PLA
308
+        #ifdef PREHEAT_1_TEMP_HOTEND
309
+          e_temp = PREHEAT_1_TEMP_HOTEND;
310
+        #endif
311
+        break;
312
+      case 1: // Load ABS
313
+        TERN_(PREHEAT_2_TEMP_HOTEND, e_temp = PREHEAT_2_TEMP_HOTEND);
314
+        break;
315
+      case 2: // Load PET
316
+        #ifdef PREHEAT_3_TEMP_HOTEND
317
+          e_temp = PREHEAT_3_TEMP_HOTEND;
318
+        #endif
319
+        break;
320
+      case 3: // Load FLEX
321
+        #ifdef PREHEAT_4_TEMP_HOTEND
322
+          e_temp = PREHEAT_4_TEMP_HOTEND;
323
+        #endif
324
+        break;
325
+      case 9: // Cool down
326
+      default:
327
+        e_temp = 0;
328
+        break;
329
+    }
330
+
331
+    if (filament_data.action == 0) { // Go back to utility screen
332
+      #if HOTENDS >= 1
333
+        thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0);
334
+      #endif
335
+      #if HOTENDS >= 2
336
+        thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1);
337
+      #endif
338
+      GotoScreen(DGUSLCD_SCREEN_UTILITY);
339
+    }
340
+    else { // Go to the preheat screen to show the heating progress
341
+      switch (var.VP) {
342
+        default: return;
343
+          #if HOTENDS >= 1
344
+            case VP_E0_FILAMENT_LOAD_UNLOAD:
345
+              filament_data.extruder = ExtUI::extruder_t::E0;
346
+              thermalManager.setTargetHotend(e_temp, filament_data.extruder);
347
+              break;
348
+          #endif
349
+          #if HOTENDS >= 2
350
+            case VP_E1_FILAMENT_LOAD_UNLOAD:
351
+              filament_data.extruder = ExtUI::extruder_t::E1;
352
+              thermalManager.setTargetHotend(e_temp, filament_data.extruder);
353
+              break;
354
+          #endif
355
+      }
356
+      GotoScreen(DGUSLCD_SCREEN_FILAMENT_HEATING);
357
+    }
358
+  }
359
+
360
+  void DGUSScreenHandler::HandleFilamentLoadUnload(DGUS_VP_Variable &var) {
361
+    DEBUG_ECHOLNPGM("HandleFilamentLoadUnload");
362
+    if (filament_data.action <= 0) return;
363
+
364
+    // If we close to the target temperature, we can start load or unload the filament
365
+    if (thermalManager.hotEnoughToExtrude(filament_data.extruder) && \
366
+        thermalManager.targetHotEnoughToExtrude(filament_data.extruder)) {
367
+      float movevalue = DGUS_FILAMENT_LOAD_LENGTH_PER_TIME;
368
+
369
+      if (filament_data.action == 1) { // load filament
370
+        if (!filament_data.heated) {
371
+          //GotoScreen(DGUSLCD_SCREEN_FILAMENT_LOADING);
372
+          filament_data.heated = true;
373
+        }
374
+        movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) + movevalue;
375
+      }
376
+      else { // unload filament
377
+        if (!filament_data.heated) {
378
+          GotoScreen(DGUSLCD_SCREEN_FILAMENT_UNLOADING);
379
+          filament_data.heated = true;
380
+        }
381
+        // Before unloading extrude to prevent jamming
382
+        if (filament_data.purge_length >= 0) {
383
+          movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) + movevalue;
384
+          filament_data.purge_length -= movevalue;
385
+        }
386
+        else {
387
+          movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) - movevalue;
388
+        }
389
+      }
390
+      ExtUI::setAxisPosition_mm(movevalue, filament_data.extruder);
391
+    }
392
+  }
393
+#endif // DGUS_FILAMENT_LOADUNLOAD
394
+
395
+bool DGUSScreenHandler::loop() {
396
+  dgusdisplay.loop();
397
+
398
+  const millis_t ms = millis();
399
+  static millis_t next_event_ms = 0;
400
+
401
+  if (!IsScreenComplete() || ELAPSED(ms, next_event_ms)) {
402
+    next_event_ms = ms + DGUS_UPDATE_INTERVAL_MS;
403
+    UpdateScreenVPData();
404
+  }
405
+
406
+  #if ENABLED(SHOW_BOOTSCREEN)
407
+    static bool booted = false;
408
+
409
+    if (!booted && TERN0(POWER_LOSS_RECOVERY, recovery.valid()))
410
+      booted = true;
411
+
412
+    if (!booted && ELAPSED(ms, TERN(USE_MKS_GREEN_UI, 1000, BOOTSCREEN_TIMEOUT)))
413
+      booted = true;
414
+  #endif
415
+  return IsScreenComplete();
416
+}
417
+
418
+#endif // DGUS_LCD_UI_ORIGIN

+ 240
- 0
Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.h Прегледај датотеку

@@ -0,0 +1,240 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "../DGUSDisplay.h"
25
+#include "../DGUSVPVariable.h"
26
+#include "../DGUSDisplayDef.h"
27
+
28
+#include "../../../../../inc/MarlinConfig.h"
29
+
30
+enum DGUSLCD_Screens : uint8_t;
31
+
32
+class DGUSScreenHandler {
33
+public:
34
+  DGUSScreenHandler() = default;
35
+
36
+  static bool loop();
37
+
38
+  // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
39
+  // The bools specifing whether the strings are in RAM or FLASH.
40
+  static void sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
41
+
42
+  static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
43
+
44
+  // "M117" Message -- msg is a RAM ptr.
45
+  static void setstatusmessage(const char* msg);
46
+  // The same for messages from Flash
47
+  static void setstatusmessagePGM(PGM_P const msg);
48
+  // Callback for VP "Display wants to change screen on idle printer"
49
+  static void ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr);
50
+  // Callback for VP "Screen has been changed"
51
+  static void ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr);
52
+
53
+  // Callback for VP "All Heaters Off"
54
+  static void HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr);
55
+  // Hook for "Change this temperature"
56
+  static void HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr);
57
+  // Hook for "Change Flowrate"
58
+  static void HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr);
59
+  #if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
60
+    // Hook for manual move option
61
+    static void HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr);
62
+  #endif
63
+
64
+  // Hook for manual move.
65
+  static void HandleManualMove(DGUS_VP_Variable &var, void *val_ptr);
66
+  // Hook for manual extrude.
67
+  static void HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr);
68
+  // Hook for motor lock and unlook
69
+  static void HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr);
70
+  #if ENABLED(POWER_LOSS_RECOVERY)
71
+    // Hook for power loss recovery.
72
+    static void HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr);
73
+  #endif
74
+  // Hook for settings
75
+  static void HandleSettings(DGUS_VP_Variable &var, void *val_ptr);
76
+  static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr);
77
+  static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr);
78
+
79
+  #if HAS_PID_HEATING
80
+    // Hook for "Change this temperature PID para"
81
+    static void HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr);
82
+    // Hook for PID autotune
83
+    static void HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr);
84
+  #endif
85
+  #if HAS_BED_PROBE
86
+    // Hook for "Change probe offset z"
87
+    static void HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr);
88
+  #endif
89
+  #if ENABLED(BABYSTEPPING)
90
+    // Hook for live z adjust action
91
+    static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr);
92
+  #endif
93
+  #if HAS_FAN
94
+    // Hook for fan control
95
+    static void HandleFanControl(DGUS_VP_Variable &var, void *val_ptr);
96
+  #endif
97
+  // Hook for heater control
98
+  static void HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr);
99
+  #if ENABLED(DGUS_PREHEAT_UI)
100
+    // Hook for preheat
101
+    static void HandlePreheat(DGUS_VP_Variable &var, void *val_ptr);
102
+  #endif
103
+  #if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
104
+    // Hook for filament load and unload filament option
105
+    static void HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr);
106
+    // Hook for filament load and unload
107
+    static void HandleFilamentLoadUnload(DGUS_VP_Variable &var);
108
+  #endif
109
+
110
+  #if ENABLED(SDSUPPORT)
111
+    // Callback for VP "Display wants to change screen when there is a SD card"
112
+    static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr);
113
+    // Scroll buttons on the file listing screen.
114
+    static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr);
115
+    // File touched.
116
+    static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr);
117
+    // start print after confirmation received.
118
+    static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr);
119
+    // User hit the pause, resume or abort button.
120
+    static void DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr);
121
+    // User confirmed the abort action
122
+    static void DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr);
123
+    // User hit the tune button
124
+    static void DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr);
125
+    // Send a single filename to the display.
126
+    static void DGUSLCD_SD_SendFilename(DGUS_VP_Variable &var);
127
+    // Marlin informed us that a new SD has been inserted.
128
+    static void SDCardInserted();
129
+    // Marlin informed us that the SD Card has been removed().
130
+    static void SDCardRemoved();
131
+    // Marlin informed us about a bad SD Card.
132
+    static void SDCardError();
133
+  #endif
134
+
135
+  // OK Button the Confirm screen.
136
+  static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr);
137
+
138
+  // Update data after went to new screen (by display or by GotoScreen)
139
+  // remember: store the last-displayed screen, so it can get returned to.
140
+  // (e.g for pop up messages)
141
+  static void UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup=false);
142
+
143
+  // Recall the remembered screen.
144
+  static void PopToOldScreen();
145
+
146
+  // Make the display show the screen and update all VPs in it.
147
+  static void GotoScreen(DGUSLCD_Screens screen, bool ispopup = false);
148
+
149
+  static void UpdateScreenVPData();
150
+
151
+  // Helpers to convert and transfer data to the display.
152
+  static void DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var);
153
+  static void DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var);
154
+  static void DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var);
155
+  static void DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var);
156
+  static void DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var);
157
+  static void DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var);
158
+  static void DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var);
159
+
160
+  #if ENABLED(PRINTCOUNTER)
161
+    static void DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var);
162
+    static void DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var);
163
+  #endif
164
+  #if HAS_FAN
165
+    static void DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var);
166
+  #endif
167
+  static void DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var);
168
+  #if ENABLED(DGUS_UI_WAITING)
169
+    static void DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var);
170
+  #endif
171
+
172
+  // Send a value from 0..100 to a variable with a range from 0..255
173
+  static void DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr);
174
+
175
+  template<typename T>
176
+  static void DGUSLCD_SetValueDirectly(DGUS_VP_Variable &var, void *val_ptr) {
177
+    if (!var.memadr) return;
178
+    union { unsigned char tmp[sizeof(T)]; T t; } x;
179
+    unsigned char *ptr = (unsigned char*)val_ptr;
180
+    LOOP_L_N(i, sizeof(T)) x.tmp[i] = ptr[sizeof(T) - i - 1];
181
+    *(T*)var.memadr = x.t;
182
+  }
183
+
184
+  // Send a float value to the display.
185
+  // Display will get a 4-byte integer scaled to the number of digits:
186
+  // Tell the display the number of digits and it cheats by displaying a dot between...
187
+  template<unsigned int decimals>
188
+  static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) {
189
+    if (var.memadr) {
190
+      float f = *(float *)var.memadr;
191
+      f *= cpow(10, decimals);
192
+      dgusdisplay.WriteVariable(var.VP, (long)f);
193
+    }
194
+  }
195
+
196
+  // Send a float value to the display.
197
+  // Display will get a 2-byte integer scaled to the number of digits:
198
+  // Tell the display the number of digits and it cheats by displaying a dot between...
199
+  template<unsigned int decimals>
200
+  static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) {
201
+    if (var.memadr) {
202
+      float f = *(float *)var.memadr;
203
+      DEBUG_ECHOLNPAIR_F(" >> ", f, 6);
204
+      f *= cpow(10, decimals);
205
+      dgusdisplay.WriteVariable(var.VP, (int16_t)f);
206
+    }
207
+  }
208
+
209
+  // Force an update of all VP on the current screen.
210
+  static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; }
211
+  // Has all VPs sent to the screen
212
+  static inline bool IsScreenComplete() { return ScreenComplete; }
213
+
214
+  static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; }
215
+
216
+  static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; }
217
+
218
+private:
219
+  static DGUSLCD_Screens current_screen;  //< currently on screen
220
+  static constexpr uint8_t NUM_PAST_SCREENS = 4;
221
+  static DGUSLCD_Screens past_screens[NUM_PAST_SCREENS]; //< LIFO with past screens for the "back" button.
222
+
223
+  static uint8_t update_ptr;      //< Last sent entry in the VPList for the actual screen.
224
+  static uint16_t skipVP;         //< When updating the screen data, skip this one, because the user is interacting with it.
225
+  static bool ScreenComplete;     //< All VPs sent to screen?
226
+
227
+  static uint16_t ConfirmVP;      //< context for confirm screen (VP that will be emulated-sent on "OK").
228
+
229
+  #if ENABLED(SDSUPPORT)
230
+    static int16_t top_file;      //< file on top of file chooser
231
+    static int16_t file_to_print; //< touched file to be confirmed
232
+  #endif
233
+
234
+  static void (*confirm_action_cb)();
235
+};
236
+
237
+#if ENABLED(POWER_LOSS_RECOVERY)
238
+  #define PLR_SCREEN_RECOVER DGUSLCD_SCREEN_SDPRINTMANIPULATION
239
+  #define PLR_SCREEN_CANCEL DGUSLCD_SCREEN_STATUS
240
+#endif

+ 2
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp Прегледај датотеку

@@ -29,6 +29,8 @@
29 29
 #include "../../../../gcode/queue.h"
30 30
 #include "../../../../inc/MarlinConfig.h"
31 31
 
32
+extern const char G28_STR[];
33
+
32 34
 extern lv_group_t *g;
33 35
 static lv_obj_t *scr;
34 36
 

+ 6
- 8
Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp Прегледај датотеку

@@ -38,8 +38,6 @@ static lv_task_t *updatePosTask;
38 38
 static char cur_label = 'Z';
39 39
 static float cur_pos = 0;
40 40
 
41
-void disp_cur_pos();
42
-
43 41
 enum {
44 42
   ID_M_X_P = 1,
45 43
   ID_M_X_N,
@@ -51,6 +49,12 @@ enum {
51 49
   ID_M_RETURN
52 50
 };
53 51
 
52
+void disp_cur_pos() {
53
+  char str_1[16];
54
+  sprintf_P(public_buf_l, PSTR("%c:%s mm"), cur_label, dtostrf(cur_pos, 1, 1, str_1));
55
+  if (labelP) lv_label_set_text(labelP, public_buf_l);
56
+}
57
+
54 58
 static void event_handler(lv_obj_t *obj, lv_event_t event) {
55 59
   char str_1[16];
56 60
   if (event != LV_EVENT_RELEASED) return;
@@ -125,12 +129,6 @@ void lv_draw_move_motor() {
125 129
   disp_cur_pos();
126 130
 }
127 131
 
128
-void disp_cur_pos() {
129
-  char str_1[16];
130
-  sprintf_P(public_buf_l, PSTR("%c:%s mm"), cur_label, dtostrf(cur_pos, 1, 1, str_1));
131
-  if (labelP) lv_label_set_text(labelP, public_buf_l);
132
-}
133
-
134 132
 void disp_move_dist() {
135 133
   if ((int)(10 * uiCfg.move_dist) == 1)
136 134
     lv_imgbtn_set_src_both(buttonV, "F:/bmp_step_move0_1.bin");

+ 6
- 6
Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp Прегледај датотеку

@@ -152,9 +152,9 @@ void lv_draw_ready_print() {
152 152
       limit_info = lv_label_create_empty(scr);
153 153
 
154 154
       lv_style_copy(&limit_style, &lv_style_scr);
155
-      limit_style.body.main_color.full = 0X0000;
156
-      limit_style.body.grad_color.full = 0X0000;
157
-      limit_style.text.color.full      = 0Xffff;
155
+      limit_style.body.main_color.full = 0x0000;
156
+      limit_style.body.grad_color.full = 0x0000;
157
+      limit_style.text.color.full      = 0xffff;
158 158
       lv_obj_set_style(limit_info, &limit_style);
159 159
 
160 160
       lv_obj_set_pos(limit_info, 20, 120);
@@ -163,9 +163,9 @@ void lv_draw_ready_print() {
163 163
       det_info = lv_label_create_empty(scr);
164 164
 
165 165
       lv_style_copy(&det_style, &lv_style_scr);
166
-      det_style.body.main_color.full = 0X0000;
167
-      det_style.body.grad_color.full = 0X0000;
168
-      det_style.text.color.full      = 0Xffff;
166
+      det_style.body.main_color.full = 0x0000;
167
+      det_style.body.grad_color.full = 0x0000;
168
+      det_style.text.color.full      = 0xffff;
169 169
       lv_obj_set_style(det_info, &det_style);
170 170
 
171 171
       lv_obj_set_pos(det_info, 20, 145);

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h Прегледај датотеку

@@ -116,7 +116,7 @@
116 116
 #endif
117 117
 
118 118
 // Flash flag
119
-#define REFLSHE_FLGA_ADD                (0X800000-32)
119
+#define REFLSHE_FLGA_ADD                (0x800000-32)
120 120
 
121 121
 // SD card information first addr
122 122
 #define VAR_INF_ADDR                    0x000000

+ 4
- 4
Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp Прегледај датотеку

@@ -1231,13 +1231,13 @@ void utf8_2_unicode(uint8_t *source, uint8_t Len) {
1231 1231
 
1232 1232
   while (1) {
1233 1233
     char_byte_num = source[i] & 0xF0;
1234
-    if (source[i] < 0X80) {
1234
+    if (source[i] < 0x80) {
1235 1235
       //ASCII --1byte
1236 1236
       FileName_unicode[char_i] = source[i];
1237 1237
       i += 1;
1238 1238
       char_i += 1;
1239 1239
     }
1240
-    else if (char_byte_num == 0XC0 || char_byte_num == 0XD0) {
1240
+    else if (char_byte_num == 0xC0 || char_byte_num == 0xD0) {
1241 1241
       //--2byte
1242 1242
       u16_h = (((uint16_t)source[i] << 8) & 0x1F00) >> 2;
1243 1243
       u16_l = ((uint16_t)source[i + 1] & 0x003F);
@@ -1247,7 +1247,7 @@ void utf8_2_unicode(uint8_t *source, uint8_t Len) {
1247 1247
       i += 2;
1248 1248
       char_i += 2;
1249 1249
     }
1250
-    else if (char_byte_num == 0XE0) {
1250
+    else if (char_byte_num == 0xE0) {
1251 1251
       //--3byte
1252 1252
       u16_h = (((uint16_t)source[i] << 8) & 0x0F00) << 4;
1253 1253
       u16_m = (((uint16_t)source[i + 1] << 8) & 0x3F00) >> 2;
@@ -1258,7 +1258,7 @@ void utf8_2_unicode(uint8_t *source, uint8_t Len) {
1258 1258
       i += 3;
1259 1259
       char_i += 2;
1260 1260
     }
1261
-    else if (char_byte_num == 0XF0) {
1261
+    else if (char_byte_num == 0xF0) {
1262 1262
       //--4byte
1263 1263
       i += 4;
1264 1264
       //char_i += 3;

+ 2
- 0
Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h Прегледај датотеку

@@ -42,6 +42,8 @@
42 42
 //#define FLASH_EEPROM_EMULATION                  // Use Flash-based EEPROM emulation
43 43
 #define I2C_EEPROM
44 44
 #define MARLIN_EEPROM_SIZE                0x1000  // 4KB
45
+#define I2C_SCL_PIN                         PB6
46
+#define I2C_SDA_PIN                         PB7
45 47
 
46 48
 //
47 49
 // Release PB4 (Z_DIR_PIN) from JTAG NRST role

+ 5
- 0
platformio.ini Прегледај датотеку

@@ -53,6 +53,7 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
53 53
   -<src/lcd/menu/menu_ubl.cpp>
54 54
   -<src/lcd/extui/lib/mks_ui>
55 55
   -<src/lcd/extui/lib/dgus> -<src/lcd/extui/dgus_lcd.cpp>
56
+  -<src/lcd/extui/lib/dgus/fysetc> -<src/lcd/extui/lib/dgus/hiprecy> -<src/lcd/extui/lib/dgus/mks> -<src/lcd/extui/lib/dgus/origin>
56 57
   -<src/lcd/extui/example.cpp>
57 58
   -<src/lcd/extui/malyan_lcd.cpp>
58 59
   -<src/lcd/extui/lib/ftdi_eve_touch_ui>
@@ -287,6 +288,10 @@ HAS_MENU_UBL            = src_filter=+<src/lcd/menu/menu_ubl.cpp>
287 288
 ANYCUBIC_LCD_CHIRON     = src_filter=+<src/lcd/extui/anycubic_chiron_lcd.cpp> +<src/lcd/extui/lib/anycubic_chiron>
288 289
 ANYCUBIC_LCD_I3MEGA     = src_filter=+<src/lcd/extui/anycubic_i3mega_lcd.cpp> +<src/lcd/extui/lib/anycubic_i3mega>
289 290
 HAS_DGUS_LCD            = src_filter=+<src/lcd/extui/lib/dgus> +<src/lcd/extui/dgus_lcd.cpp>
291
+DGUS_LCD_UI_FYSETC      = src_filter=+<src/lcd/extui/lib/dgus/fysetc>
292
+DGUS_LCD_UI_HIPRECY     = src_filter=+<src/lcd/extui/lib/dgus/hiprecy>
293
+DGUS_LCD_UI_MKS         = src_filter=+<src/lcd/extui/lib/dgus/mks>
294
+DGUS_LCD_UI_ORIGIN      = src_filter=+<src/lcd/extui/lib/dgus/origin>
290 295
 TOUCH_UI_FTDI_EVE       = src_filter=+<src/lcd/extui/lib/ftdi_eve_touch_ui>
291 296
 EXTUI_EXAMPLE           = src_filter=+<src/lcd/extui/example.cpp>
292 297
 MALYAN_LCD              = src_filter=+<src/lcd/extui/malyan_lcd.cpp>

Loading…
Откажи
Сачувај