瀏覽代碼

MKS H43 fix, cleanup (#21485)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
Sola 4 年之前
父節點
當前提交
4d17613050
No account linked to committer's email address

+ 5
- 1
Marlin/Configuration.h 查看文件

@@ -2373,7 +2373,11 @@
2373 2373
 //#define DGUS_LCD_UI_ORIGIN
2374 2374
 //#define DGUS_LCD_UI_FYSETC
2375 2375
 //#define DGUS_LCD_UI_HIPRECY
2376
-//#define DGUS_LCD_UI_MKS
2376
+
2377
+// #define DGUS_LCD_UI_MKS
2378
+#if ENABLED(DGUS_LCD_UI_MKS)
2379
+  #define USE_MKS_GREEN_UI
2380
+#endif
2377 2381
 
2378 2382
 //
2379 2383
 // Touch-screen LCD for Malyan M200/M300 printers

+ 3
- 0
Marlin/src/HAL/LPC1768/HAL.h 查看文件

@@ -102,6 +102,9 @@ extern DefaultSerial1 USBSerial;
102 102
   #else
103 103
     #error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
104 104
   #endif
105
+  #if HAS_DGUS_LCD
106
+    #define SERIAL_GET_TX_BUFFER_FREE() MSerial0.available()
107
+  #endif
105 108
 #endif
106 109
 
107 110
 //

+ 5
- 3
Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp 查看文件

@@ -62,9 +62,11 @@ void DGUSDisplay::InitDisplay() {
62 62
     #define LCD_BAUDRATE 115200
63 63
   #endif
64 64
   LCD_SERIAL.begin(LCD_BAUDRATE);
65
-  #if BOTH(DGUS_LCD_UI_MKS, POWER_LOSS_RECOVERY)
66
-    if (!recovery.valid()) delay(LOGO_TIME_DELAY);
67
-  #endif
65
+
66
+  if (TERN1(POWER_LOSS_RECOVERY, !recovery.valid())) {  // If no Power-Loss Recovery is needed...
67
+    TERN_(DGUS_LCD_UI_MKS, delay(LOGO_TIME_DELAY));     // Show the logo for a little while
68
+  }
69
+
68 70
   RequestScreen(TERN(SHOW_BOOTSCREEN, DGUSLCD_SCREEN_BOOT, DGUSLCD_SCREEN_MAIN));
69 71
 }
70 72
 

+ 42
- 55
Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp 查看文件

@@ -43,58 +43,45 @@
43 43
   uint16_t distanceToMove = 10;
44 44
 #endif
45 45
 
46
-uint16_t distanceMove = 1;
46
+uint16_t manualMoveStep = 1;
47 47
 float distanceFilament = 10;
48 48
 uint16_t FilamentSpeed = 25;
49 49
 float ZOffset_distance = 0.1;
50
-float mesh_adj_distance = 0.1;
50
+float mesh_adj_distance = 0.01;
51 51
 float Z_distance = 0.1;
52 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;
53
+//struct { uint16_t h, m, s; } dgus_time;
54
+
55
+//
56
+// Persistent settings
57
+//
58
+xy_int_t mks_corner_offsets[5];   // Initialized by settings.load()
59
+xyz_int_t mks_park_pos;           // Initialized by settings.load()
60
+celsius_t mks_min_extrusion_temp; // Initialized by settings.load()
61
+
62
+void MKS_reset_settings() {
63
+  constexpr xy_int_t init_dgus_level_offsets[5] = {
64
+    { 20, 20 }, { 20, 20 },
65
+    { 20, 20 }, { 20, 20 },
66
+    { X_CENTER, Y_CENTER }
67
+  };
68
+  mks_language_index = 0;
69
+  COPY(mks_corner_offsets, init_dgus_level_offsets);
70
+  mks_park_pos.set(20, 20, 10);
71
+  mks_min_extrusion_temp = 0;
72
+}
74 73
 
75 74
 xyz_pos_t position_before_pause;
76
-
77 75
 void MKS_pause_print_move() {
78 76
   queue.exhaust();
79 77
   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);
78
+  do_blocking_move_to(X_MIN_POS + mks_park_pos.x, Y_MIN_POS + mks_park_pos.y, current_position.z + mks_park_pos.z);
81 79
 }
82
-
83 80
 void MKS_resume_print_move() { do_blocking_move_to(position_before_pause); }
84 81
 
85
-uint16_t min_ex_temp = 0;
86
-
87 82
 float z_offset_add = 0;
88 83
 
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
84
+xyz_int_t tmc_step; // = { 0, 0, 0 }
98 85
 
99 86
 uint16_t lcd_default_light = 50;
100 87
 
@@ -525,7 +512,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
525 512
   VPHELPER(VP_Y_HOME, nullptr, &ScreenHandler.HandleManualMove, nullptr),
526 513
   VPHELPER(VP_Z_HOME, nullptr, &ScreenHandler.HandleManualMove, nullptr),
527 514
 
528
-  VPHELPER(VP_MOVE_DISTANCE, &distanceMove, &ScreenHandler.GetManualMovestep, nullptr),
515
+  VPHELPER(VP_MOVE_DISTANCE, &manualMoveStep, &ScreenHandler.GetManualMovestep, nullptr),
529 516
 
530 517
   VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, &ScreenHandler.HandleManualMove, nullptr),
531 518
   VPHELPER(VP_LEVEL_POINT, nullptr, &ScreenHandler.ManualAssistLeveling, nullptr),
@@ -567,7 +554,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
567 554
     #if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
568 555
       VPHELPER(VP_LOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentLoad, nullptr),
569 556
       VPHELPER(VP_UNLOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentUnLoad, nullptr),
570
-      VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
557
+      VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
571 558
       VPHELPER(VP_Filament_speed, &FilamentSpeed, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
572 559
     #endif
573 560
   #endif
@@ -623,16 +610,16 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
623 610
   VPHELPER(VP_ZPos, &current_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
624 611
 
625 612
   // 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),
613
+  VPHELPER(VP_Level_Point_One_X, &mks_corner_offsets[0].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
614
+  VPHELPER(VP_Level_Point_One_Y, &mks_corner_offsets[0].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
615
+  VPHELPER(VP_Level_Point_Two_X, &mks_corner_offsets[1].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
616
+  VPHELPER(VP_Level_Point_Two_Y, &mks_corner_offsets[1].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
617
+  VPHELPER(VP_Level_Point_Three_X, &mks_corner_offsets[2].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
618
+  VPHELPER(VP_Level_Point_Three_Y, &mks_corner_offsets[2].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
619
+  VPHELPER(VP_Level_Point_Four_X, &mks_corner_offsets[3].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
620
+  VPHELPER(VP_Level_Point_Four_Y, &mks_corner_offsets[3].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
621
+  VPHELPER(VP_Level_Point_Five_X, &mks_corner_offsets[4].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
622
+  VPHELPER(VP_Level_Point_Five_Y, &mks_corner_offsets[4].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
636 623
 
637 624
   // Print Progress
638 625
   VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay),
@@ -679,20 +666,20 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
679 666
   VPHELPER(VP_T_F_SPEED, (uint16_t *)&planner.settings.min_travel_feedrate_mm_s, ScreenHandler.HandleMin_T_F_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
680 667
   VPHELPER(VP_ACC_SPEED, (uint16_t *)&planner.settings.acceleration, ScreenHandler.HandleAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
681 668
 
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),
669
+  VPHELPER(VP_X_PARK_POS, &mks_park_pos.x, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
670
+  VPHELPER(VP_Y_PARK_POS, &mks_park_pos.y, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
671
+  VPHELPER(VP_Z_PARK_POS, &mks_park_pos.z, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
685 672
   VPHELPER(VP_MIN_EX_T, &thermalManager.extrude_min_temp, ScreenHandler.HandleGetExMinTemp_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
686 673
 
687 674
   #if ENABLED(SENSORLESS_HOMING)  // TMC SENSORLESS Setting
688 675
     #if AXIS_HAS_STEALTHCHOP(X)
689
-      VPHELPER(VP_TMC_X_STEP, &tmc_x_step, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
676
+      VPHELPER(VP_TMC_X_STEP, &tmc_step.x, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
690 677
     #endif
691 678
     #if AXIS_HAS_STEALTHCHOP(Y)
692
-      VPHELPER(VP_TMC_Y_STEP, &tmc_y_step, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
679
+      VPHELPER(VP_TMC_Y_STEP, &tmc_step.y, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
693 680
     #endif
694 681
     #if AXIS_HAS_STEALTHCHOP(Z)
695
-      VPHELPER(VP_TMC_Z_STEP, &tmc_z_step, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
682
+      VPHELPER(VP_TMC_Z_STEP, &tmc_step.z, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
696 683
     #endif
697 684
   #endif
698 685
 

+ 10
- 27
Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h 查看文件

@@ -23,7 +23,6 @@
23 23
 
24 24
 #include "../DGUSDisplayDef.h"
25 25
 
26
-#define USE_MKS_GREEN_UI
27 26
 //#define DGUS_MKS_RUNOUT_SENSOR
28 27
 
29 28
 #define LOGO_TIME_DELAY TERN(USE_MKS_GREEN_UI, 8000, 1500)
@@ -36,43 +35,27 @@
36 35
 
37 36
 #define MKS_FINSH
38 37
 
39
-extern uint16_t distanceMove;
38
+extern uint16_t manualMoveStep;
40 39
 extern float    distanceFilament;
41 40
 extern uint16_t FilamentSpeed;
42 41
 extern float    ZOffset_distance;
43 42
 extern float    mesh_adj_distance;
44 43
 extern float    Z_distance;
45 44
 
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;
45
+//extern struct { uint16_t h, m, s; } dgus_time;
46
+
47
+extern xy_int_t mks_corner_offsets[5];
48
+extern xyz_int_t mks_park_pos;
49
+extern celsius_t mks_min_extrusion_temp;
50
+
51
+void MKS_reset_settings(); // Restore persistent settings to defaults
52
+
66 53
 void MKS_pause_print_move();
67 54
 void MKS_resume_print_move();
68 55
 
69
-extern uint16_t min_ex_temp;
70
-
71 56
 extern float z_offset_add;
72 57
 
73
-extern uint16_t tmc_x_step;
74
-extern uint16_t tmc_y_step;
75
-extern uint16_t tmc_z_step;
58
+xyz_int_t tmc_step;
76 59
 
77 60
 extern uint16_t lcd_default_light;
78 61
 

+ 98
- 121
Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp 查看文件

@@ -55,7 +55,7 @@
55 55
 #endif
56 56
 
57 57
 bool DGUSAutoTurnOff = false;
58
-uint8_t DGUSLanguageSwitch = 0; // Switch language for MKS DGUS
58
+uint8_t mks_language_index; // Initialized by settings.load()
59 59
 
60 60
 // endianness swap
61 61
 uint32_t swap32(const uint32_t value) { return (value & 0x000000FFU) << 24U | (value & 0x0000FF00U) << 8U | (value & 0x00FF0000U) >> 8U | (value & 0xFF000000U) >> 24U; }
@@ -125,11 +125,11 @@ void DGUSScreenHandler::DGUSLCD_SendGbkToDisplay(DGUS_VP_Variable &var) {
125 125
 }
126 126
 
127 127
 void DGUSScreenHandler::DGUSLCD_SendStringToDisplay_Language_MKS(DGUS_VP_Variable &var) {
128
-  if (DGUSLanguageSwitch == MKS_English) {
128
+  if (mks_language_index == MKS_English) {
129 129
     char *tmp = (char*) var.memadr;
130 130
     dgusdisplay.WriteVariable(var.VP, tmp, var.size, true);
131 131
   }
132
-  else if (DGUSLanguageSwitch == MKS_SimpleChinese) {
132
+  else if (mks_language_index == MKS_SimpleChinese) {
133 133
     uint16_t *tmp = (uint16_t *)var.memadr;
134 134
     dgusdisplay.WriteVariable(var.VP, tmp, var.size, true);
135 135
   }
@@ -138,15 +138,15 @@ void DGUSScreenHandler::DGUSLCD_SendStringToDisplay_Language_MKS(DGUS_VP_Variabl
138 138
 void DGUSScreenHandler::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) {
139 139
   #if ENABLED(SENSORLESS_HOMING)
140 140
     #if AXIS_HAS_STEALTHCHOP(X)
141
-      tmc_x_step = stepperX.homing_threshold();
141
+      tmc_step.x = stepperX.homing_threshold();
142 142
       dgusdisplay.WriteVariable(var.VP, *(int16_t*)var.memadr);
143 143
     #endif
144 144
     #if AXIS_HAS_STEALTHCHOP(Y)
145
-      tmc_y_step = stepperY.homing_threshold();
145
+      tmc_step.y = stepperY.homing_threshold();
146 146
       dgusdisplay.WriteVariable(var.VP, *(int16_t*)var.memadr);
147 147
     #endif
148 148
     #if AXIS_HAS_STEALTHCHOP(Z)
149
-      tmc_z_step = stepperZ.homing_threshold();
149
+      tmc_step.z = stepperZ.homing_threshold();
150 150
       dgusdisplay.WriteVariable(var.VP, *(int16_t*)var.memadr);
151 151
     #endif
152 152
   #endif
@@ -329,7 +329,7 @@ void DGUSScreenHandler::ZoffsetConfirm(DGUS_VP_Variable &var, void *val_ptr) {
329 329
 }
330 330
 
331 331
 void DGUSScreenHandler::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) {
332
-  DEBUG_ECHOLNPGM("ctrl turn off\n");
332
+  DEBUG_ECHOLNPGM("GetTurnOffCtrl\n");
333 333
   const uint16_t value = swap16(*(uint16_t *)val_ptr);
334 334
   switch (value) {
335 335
     case 0 ... 1: DGUSAutoTurnOff = (bool)value; break;
@@ -338,15 +338,15 @@ void DGUSScreenHandler::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) {
338 338
 }
339 339
 
340 340
 void DGUSScreenHandler::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr) {
341
-  DEBUG_ECHOLNPGM("MinExtrudeTempChange DistanceChange");
341
+  DEBUG_ECHOLNPGM("GetMinExtrudeTemp");
342 342
   const uint16_t value = swap16(*(uint16_t *)val_ptr);
343 343
   thermalManager.extrude_min_temp = value;
344
-  min_ex_temp = value;
344
+  mks_min_extrusion_temp = value;
345 345
   settings.save();
346 346
 }
347 347
 
348 348
 void DGUSScreenHandler::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr) {
349
-  DEBUG_ECHOLNPGM("Zoffset DistanceChange");
349
+  DEBUG_ECHOLNPGM("GetZoffsetDistance");
350 350
   const uint16_t value = swap16(*(uint16_t *)val_ptr);
351 351
   float val_distance = 0;
352 352
   switch (value) {
@@ -360,7 +360,7 @@ void DGUSScreenHandler::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr)
360 360
 }
361 361
 
362 362
 void DGUSScreenHandler::GetManualMovestep(DGUS_VP_Variable &var, void *val_ptr) {
363
-  DEBUG_ECHOLNPGM("\nMove DistanceChange");
363
+  DEBUG_ECHOLNPGM("\nGetManualMovestep");
364 364
   *(uint16_t *)var.memadr = swap16(*(uint16_t *)val_ptr);
365 365
 }
366 366
 
@@ -414,14 +414,14 @@ void DGUSScreenHandler::LanguageChange_MKS(DGUS_VP_Variable &var, void *val_ptr)
414 414
   switch (lag_flag) {
415 415
     case MKS_SimpleChinese:
416 416
       DGUS_LanguageDisplay(MKS_SimpleChinese);
417
-      DGUSLanguageSwitch = MKS_SimpleChinese;
417
+      mks_language_index = MKS_SimpleChinese;
418 418
       dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_Choose);
419 419
       dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_NoChoose);
420 420
       settings.save();
421 421
       break;
422 422
     case MKS_English:
423 423
       DGUS_LanguageDisplay(MKS_English);
424
-      DGUSLanguageSwitch = MKS_English;
424
+      mks_language_index = MKS_English;
425 425
       dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_NoChoose);
426 426
       dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_Choose);
427 427
       settings.save();
@@ -454,11 +454,11 @@ void DGUSScreenHandler::Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr) {
454 454
 
455 455
         mesh_point_count = GRID_MAX_POINTS;
456 456
 
457
-        if (DGUSLanguageSwitch == MKS_English) {
457
+        if (mks_language_index == MKS_English) {
458 458
           const char level_buf_en[] = "Start Level";
459 459
           dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_en, 32, true);
460 460
         }
461
-        else if (DGUSLanguageSwitch == MKS_SimpleChinese) {
461
+        else if (mks_language_index == MKS_SimpleChinese) {
462 462
           const uint16_t level_buf_ch[] = {0xAABF, 0xBCCA, 0xF7B5, 0xBDC6, 0x2000};
463 463
           dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_ch, 32, true);
464 464
         }
@@ -532,15 +532,17 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) {
532 532
         break;
533 533
 
534 534
       case 2:
535
-        if (mesh_point_count == GRID_MAX_POINTS) { // 第1个点
535
+        if (mesh_point_count == GRID_MAX_POINTS) { // The first point
536
+
537
+          queue.enqueue_now_P(PSTR("G28"));
536 538
           queue.enqueue_now_P(PSTR("G29S1"));
537 539
           mesh_point_count--;
538 540
 
539
-          if (DGUSLanguageSwitch == MKS_English) {
541
+          if (mks_language_index == MKS_English) {
540 542
             const char level_buf_en1[] = "Next Point";
541 543
             dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_en1, 32, true);
542 544
           }
543
-          else if (DGUSLanguageSwitch == MKS_SimpleChinese) {
545
+          else if (mks_language_index == MKS_SimpleChinese) {
544 546
             const uint16_t level_buf_ch1[] = {0xC2CF, 0xBBD2, 0xE3B5, 0x2000};
545 547
             dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_ch1, 32, true);
546 548
           }
@@ -548,11 +550,11 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) {
548 550
         else if (mesh_point_count > 1) {                              // 倒数第二个点
549 551
           queue.enqueue_now_P(PSTR("G29S2"));
550 552
           mesh_point_count--;
551
-          if (DGUSLanguageSwitch == MKS_English) {
553
+          if (mks_language_index == MKS_English) {
552 554
             const char level_buf_en2[] = "Next Point";
553 555
             dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_en2, 32, true);
554 556
           }
555
-          else if (DGUSLanguageSwitch == MKS_SimpleChinese) {
557
+          else if (mks_language_index == MKS_SimpleChinese) {
556 558
             const uint16_t level_buf_ch2[] = {0xC2CF, 0xBBD2, 0xE3B5, 0x2000};
557 559
             dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_ch2, 32, true);
558 560
           }
@@ -560,11 +562,11 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) {
560 562
         else if (mesh_point_count == 1) {
561 563
           queue.enqueue_now_P(PSTR("G29S2"));
562 564
           mesh_point_count--;
563
-          if (DGUSLanguageSwitch == MKS_English) {
565
+          if (mks_language_index == MKS_English) {
564 566
             const char level_buf_en2[] = "Level Finsh";
565 567
             dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_en2, 32, true);
566 568
           }
567
-          else if (DGUSLanguageSwitch == MKS_SimpleChinese) {
569
+          else if (mks_language_index == MKS_SimpleChinese) {
568 570
             const uint16_t level_buf_ch2[] = {0xF7B5, 0xBDC6, 0xEACD, 0xC9B3, 0x2000};
569 571
             dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_ch2, 32, true);
570 572
           }
@@ -597,85 +599,52 @@ void DGUSScreenHandler::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) {
597 599
 void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_ptr) {
598 600
   const int16_t point_value = swap16(*(uint16_t *)val_ptr);
599 601
 
600
-  int16_t level_x_pos, level_y_pos;
601
-  char buf_level[32] = {0};
602
-  unsigned int level_speed = 1500;
602
+  // Insist on leveling first time at this screen
603 603
   static bool first_level_flag = false;
604
-
605
-  if (!first_level_flag)
604
+  if (!first_level_flag || point_value == 0x0001) {
606 605
     queue.enqueue_now_P(G28_STR);
606
+    first_level_flag = true;
607
+  }
608
+
609
+  constexpr uint16_t level_speed = 1500;
610
+
611
+  auto enqueue_corner_move = [](int16_t lx, int16_t ly, uint16_t fr) {
612
+    char buf_level[32];
613
+    sprintf_P(buf_level, "G0X%dY%dF%d", lx, ly, fr);
614
+    queue.enqueue_one_now(buf_level);
615
+  };
616
+
617
+  if (WITHIN(point_value, 0x0001, 0x0005))
618
+    queue.enqueue_now_P(PSTR("G1Z10"));
607 619
 
608 620
   switch (point_value) {
609 621
     case 0x0001:
610
-      if (first_level_flag)
611
-        queue.enqueue_now_P(G28_STR);
612
-      queue.enqueue_now_P(PSTR("G1 Z10"));
613
-      //level_x_pos = X_MIN_POS + 20;
614
-      //level_y_pos = Y_MIN_POS + 20;
615
-      level_x_pos = X_MIN_POS + abs(level_1_x_point);
616
-      level_y_pos = Y_MIN_POS + abs(level_1_y_point);
617
-
618
-      memset(buf_level, 0, sizeof(buf_level));
619
-      sprintf_P(buf_level, "G0 X%d Y%d F%d", level_x_pos, level_y_pos, level_speed);
620
-      queue.enqueue_one_now(buf_level);
621
-      queue.enqueue_now_P(PSTR("G28 Z"));
622
+      enqueue_corner_move(X_MIN_POS + abs(mks_corner_offsets[0].x),
623
+                          Y_MIN_POS + abs(mks_corner_offsets[0].y), level_speed);
624
+      queue.enqueue_now_P(PSTR("G28Z"));
622 625
       break;
623 626
     case 0x0002:
624
-      queue.enqueue_now_P(PSTR("G1 Z10"));
625
-
626
-      //level_x_pos = X_MAX_POS - 20;
627
-      //level_y_pos = Y_MIN_POS + 20;
628
-
629
-      level_x_pos = X_MAX_POS - abs(level_2_x_point);
630
-      level_y_pos = Y_MIN_POS + abs(level_2_y_point);
631
-
632
-      sprintf_P(buf_level, "G0 X%d Y%d F%d", level_x_pos, level_y_pos, level_speed);
633
-      queue.enqueue_one_now(buf_level);
634
-      //queue.enqueue_now_P(PSTR("G28Z"));
635
-      queue.enqueue_now_P(PSTR("G1 Z-10"));
627
+      enqueue_corner_move(X_MAX_POS - abs(mks_corner_offsets[1].x),
628
+                          Y_MIN_POS + abs(mks_corner_offsets[1].y), level_speed);
636 629
       break;
637 630
     case 0x0003:
638
-      queue.enqueue_now_P(PSTR("G1 Z10"));
639
-
640
-      //level_x_pos = X_MAX_POS - 20;
641
-      //level_y_pos = Y_MAX_POS - 20;
642
-
643
-      level_x_pos = X_MAX_POS - abs(level_3_x_point);
644
-      level_y_pos = Y_MAX_POS - abs(level_3_y_point);
645
-
646
-      sprintf_P(buf_level, "G0 X%d Y%d F%d", level_x_pos, level_y_pos, level_speed);
647
-      queue.enqueue_one_now(buf_level);
648
-      //sprintf_P(buf_level, PSTR("G28 Z"));
649
-      queue.enqueue_now_P(PSTR("G1 Z-10"));
631
+      enqueue_corner_move(X_MAX_POS - abs(mks_corner_offsets[2].x),
632
+                          Y_MAX_POS - abs(mks_corner_offsets[2].y), level_speed);
650 633
       break;
651 634
     case 0x0004:
652
-      queue.enqueue_now_P(PSTR("G1 Z10"));
653
-
654
-      //level_x_pos = X_MIN_POS + 20;
655
-      //level_y_pos = Y_MAX_POS - 20;
656
-      level_x_pos = X_MIN_POS + abs(level_4_x_point);
657
-      level_y_pos = Y_MAX_POS - abs(level_4_y_point);
658
-
659
-      sprintf_P(buf_level, "G0 X%d Y%d F%d", level_x_pos, level_y_pos, level_speed);
660
-      queue.enqueue_one_now(buf_level);
661
-      //sprintf_P(buf_level, PSTR("G28 Z"));
662
-      queue.enqueue_now_P(PSTR("G1 Z-10"));
635
+      enqueue_corner_move(X_MIN_POS + abs(mks_corner_offsets[3].x),
636
+                          Y_MAX_POS - abs(mks_corner_offsets[3].y), level_speed);
663 637
       break;
664 638
     case 0x0005:
665
-      queue.enqueue_now_P(PSTR("G1 Z10"));
666
-      //level_x_pos = (uint16_t)(X_MAX_POS / 2);
667
-      //level_y_pos = (uint16_t)(Y_MAX_POS / 2);
668
-      level_x_pos = abs(level_5_x_point);
669
-      level_y_pos = abs(level_5_y_point);
670
-
671
-      sprintf_P(buf_level, "G0 X%d Y%d F%d", level_x_pos, level_y_pos, level_speed);
672
-      queue.enqueue_one_now(buf_level);
673
-      queue.enqueue_now_P(PSTR("G1 Z-10"));
639
+      enqueue_corner_move(abs(mks_corner_offsets[4].x),
640
+                          abs(mks_corner_offsets[4].y), level_speed);
674 641
       break;
675 642
   }
676 643
 
677
-  // Only once
678
-  first_level_flag = true;
644
+  if (WITHIN(point_value, 0x0002, 0x0005)) {
645
+    //queue.enqueue_now_P(PSTR("G28Z"));
646
+    queue.enqueue_now_P(PSTR("G1Z-10"));
647
+  }
679 648
 }
680 649
 
681 650
 #define mks_min(a, b) ((a) < (b)) ? (a) : (b)
@@ -691,7 +660,7 @@ void DGUSScreenHandler::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) {
691 660
         #if AXIS_HAS_STEALTHCHOP(X)
692 661
           stepperX.homing_threshold(mks_min(tmc_value, 255));
693 662
           settings.save();
694
-          //tmc_x_step = stepperX.homing_threshold();
663
+          //tmc_step.x = stepperX.homing_threshold();
695 664
         #endif
696 665
       #endif
697 666
       break;
@@ -700,7 +669,7 @@ void DGUSScreenHandler::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) {
700 669
         #if AXIS_HAS_STEALTHCHOP(Y)
701 670
           stepperY.homing_threshold(mks_min(tmc_value, 255));
702 671
           settings.save();
703
-          //tmc_y_step = stepperY.homing_threshold();
672
+          //tmc_step.y = stepperY.homing_threshold();
704 673
         #endif
705 674
       #endif
706 675
       break;
@@ -709,7 +678,7 @@ void DGUSScreenHandler::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) {
709 678
         #if AXIS_HAS_STEALTHCHOP(Z)
710 679
           stepperZ.homing_threshold(mks_min(tmc_value, 255));
711 680
           settings.save();
712
-          //tmc_z_step = stepperZ.homing_threshold();
681
+          //tmc_step.z = stepperZ.homing_threshold();
713 682
         #endif
714 683
       #endif
715 684
       break;
@@ -767,13 +736,13 @@ void DGUSScreenHandler::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) {
767 736
   }
768 737
   #if USE_SENSORLESS
769 738
     #if AXIS_HAS_STEALTHCHOP(X)
770
-      tmc_x_step = stepperX.homing_threshold();
739
+      tmc_step.x = stepperX.homing_threshold();
771 740
     #endif
772 741
     #if AXIS_HAS_STEALTHCHOP(Y)
773
-      tmc_y_step = stepperY.homing_threshold();
742
+      tmc_step.y = stepperY.homing_threshold();
774 743
     #endif
775 744
     #if AXIS_HAS_STEALTHCHOP(Z)
776
-      tmc_z_step = stepperZ.homing_threshold();
745
+      tmc_step.z = stepperZ.homing_threshold();
777 746
     #endif
778 747
   #endif
779 748
 }
@@ -784,9 +753,9 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
784 753
   int16_t movevalue = swap16(*(uint16_t*)val_ptr);
785 754
 
786 755
   // Choose Move distance
787
-       if (distanceMove == 0x01) distanceMove =   10;
788
-  else if (distanceMove == 0x02) distanceMove =  100;
789
-  else if (distanceMove == 0x03) distanceMove = 1000;
756
+       if (manualMoveStep == 0x01) manualMoveStep =   10;
757
+  else if (manualMoveStep == 0x02) manualMoveStep =  100;
758
+  else if (manualMoveStep == 0x03) manualMoveStep = 1000;
790 759
 
791 760
   DEBUG_ECHOLNPAIR("QUEUE LEN:", queue.length);
792 761
 
@@ -853,8 +822,8 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
853 822
   DEBUG_ECHOPAIR("movevalue = ", movevalue);
854 823
   if (movevalue != 0 && movevalue != 5) { // get move distance
855 824
     switch (movevalue) {
856
-      case 0x0001: movevalue =  distanceMove; break;
857
-      case 0x0002: movevalue = -distanceMove; break;
825
+      case 0x0001: movevalue =  manualMoveStep; break;
826
+      case 0x0002: movevalue = -manualMoveStep; break;
858 827
       default:     movevalue = 0; break;
859 828
     }
860 829
   }
@@ -929,16 +898,16 @@ void DGUSScreenHandler::GetParkPos_MKS(DGUS_VP_Variable &var, void *val_ptr) {
929 898
   const int16_t value_pos = swap16(*(int16_t*)val_ptr);
930 899
 
931 900
   switch (var.VP) {
932
-    case VP_X_PARK_POS: x_park_pos = value_pos; break;
933
-    case VP_Y_PARK_POS: y_park_pos = value_pos; break;
934
-    case VP_Z_PARK_POS: z_park_pos = value_pos; break;
901
+    case VP_X_PARK_POS: mks_park_pos.x = value_pos; break;
902
+    case VP_Y_PARK_POS: mks_park_pos.y = value_pos; break;
903
+    case VP_Z_PARK_POS: mks_park_pos.z = value_pos; break;
935 904
     default: break;
936 905
   }
937 906
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
938 907
 }
939 908
 
940 909
 void DGUSScreenHandler::HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void *val_ptr) {
941
-  DEBUG_ECHOLNPGM("HandleStepPerMMChanged");
910
+  DEBUG_ECHOLNPGM("HandleChangeLevelPoint_MKS");
942 911
 
943 912
   const int16_t value_raw = swap16(*(int16_t*)val_ptr);
944 913
   DEBUG_ECHOLNPAIR_F("value_raw:", value_raw);
@@ -950,7 +919,7 @@ void DGUSScreenHandler::HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void *
950 919
 }
951 920
 
952 921
 void DGUSScreenHandler::HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) {
953
-  DEBUG_ECHOLNPGM("HandleStepPerMMChanged");
922
+  DEBUG_ECHOLNPGM("HandleStepPerMMChanged_MKS");
954 923
 
955 924
   const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
956 925
   const float value = (float)value_raw;
@@ -972,7 +941,7 @@ void DGUSScreenHandler::HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void *
972 941
 }
973 942
 
974 943
 void DGUSScreenHandler::HandleStepPerMMExtruderChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) {
975
-  DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged");
944
+  DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged_MKS");
976 945
 
977 946
   const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
978 947
   const float value = (float)value_raw;
@@ -1019,7 +988,7 @@ void DGUSScreenHandler::HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *va
1019 988
 }
1020 989
 
1021 990
 void DGUSScreenHandler::HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1022
-  DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS");
991
+  DEBUG_ECHOLNPGM("HandleExtruderMaxSpeedChange_MKS");
1023 992
 
1024 993
   const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
1025 994
   const float value = (float)value_raw;
@@ -1044,7 +1013,7 @@ void DGUSScreenHandler::HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var,
1044 1013
 }
1045 1014
 
1046 1015
 void DGUSScreenHandler::HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1047
-  DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS");
1016
+  DEBUG_ECHOLNPGM("HandleMaxAccChange_MKS");
1048 1017
 
1049 1018
   const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
1050 1019
   const float value = (float)value_raw;
@@ -1066,7 +1035,7 @@ void DGUSScreenHandler::HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_
1066 1035
 }
1067 1036
 
1068 1037
 void DGUSScreenHandler::HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1069
-  DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS");
1038
+  DEBUG_ECHOLNPGM("HandleExtruderAccChange_MKS");
1070 1039
 
1071 1040
   uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
1072 1041
   DEBUG_ECHOLNPAIR("value_raw:", value_raw);
@@ -1199,7 +1168,7 @@ void DGUSScreenHandler::HandleGetExMinTemp_MKS(DGUS_VP_Variable &var, void *val_
1199 1168
 #endif // BABYSTEPPING
1200 1169
 
1201 1170
 void DGUSScreenHandler::GetManualFilament(DGUS_VP_Variable &var, void *val_ptr) {
1202
-  DEBUG_ECHOLNPGM("HandleGetFilament");
1171
+  DEBUG_ECHOLNPGM("GetManualFilament");
1203 1172
 
1204 1173
   uint16_t value_len = swap16(*(uint16_t*)val_ptr);
1205 1174
 
@@ -1212,7 +1181,7 @@ void DGUSScreenHandler::GetManualFilament(DGUS_VP_Variable &var, void *val_ptr)
1212 1181
 }
1213 1182
 
1214 1183
 void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr) {
1215
-  DEBUG_ECHOLNPGM("HandleGetFilamentSpeed");
1184
+  DEBUG_ECHOLNPGM("GetManualFilamentSpeed");
1216 1185
 
1217 1186
   uint16_t value_len = swap16(*(uint16_t*)val_ptr);
1218 1187
 
@@ -1225,8 +1194,10 @@ void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_
1225 1194
 
1226 1195
 void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir) {
1227 1196
   #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE)
1197
+    char buf[40];
1228 1198
     uint8_t swap_tool = 0;
1229 1199
   #endif
1200
+
1230 1201
   #if HAS_HOTEND
1231 1202
     uint8_t hotend_too_cold = 0;
1232 1203
   #endif
@@ -1234,13 +1205,19 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_
1234 1205
   if (!print_job_timer.isPaused() && !queue.ring_buffer.empty())
1235 1206
     return;
1236 1207
 
1237
-  char buf[40];
1238 1208
   const uint16_t val_t = swap16(*(uint16_t*)val_ptr);
1239 1209
   switch (val_t) {
1240 1210
     default: break;
1241 1211
     case 0:
1242 1212
       #if HAS_HOTEND
1243
-        if (thermalManager.tooColdToExtrude(0)) hotend_too_cold = 1; else swap_tool = 1;
1213
+        if (thermalManager.tooColdToExtrude(0)) {
1214
+          hotend_too_cold = 1;
1215
+        }
1216
+        else {
1217
+          #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE)
1218
+            swap_tool = 2;
1219
+          #endif
1220
+        }
1244 1221
       #endif
1245 1222
       break;
1246 1223
     case 1:
@@ -1273,12 +1250,12 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_
1273 1250
 }
1274 1251
 
1275 1252
 void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) {
1276
-  DEBUG_ECHOLNPGM("Load Filament");
1253
+  DEBUG_ECHOLNPGM("MKS_FilamentLoad");
1277 1254
    MKS_FilamentLoadUnload(var, val_ptr, 1);
1278 1255
 }
1279 1256
 
1280 1257
 void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) {
1281
-  DEBUG_ECHOLNPGM("UnLoad Filament");
1258
+  DEBUG_ECHOLNPGM("MKS_FilamentUnLoad");
1282 1259
   MKS_FilamentLoadUnload(var, val_ptr, -1);
1283 1260
 }
1284 1261
 
@@ -1403,7 +1380,7 @@ bool DGUSScreenHandler::loop() {
1403 1380
 
1404 1381
   if (language_times != 0) {
1405 1382
     LanguagePInit();
1406
-    DGUS_LanguageDisplay(DGUSLanguageSwitch);
1383
+    DGUS_LanguageDisplay(mks_language_index);
1407 1384
     language_times--;
1408 1385
   }
1409 1386
 
@@ -1413,18 +1390,18 @@ bool DGUSScreenHandler::loop() {
1413 1390
       booted = true;
1414 1391
       #if USE_SENSORLESS
1415 1392
         #if AXIS_HAS_STEALTHCHOP(X)
1416
-          tmc_x_step = stepperX.homing_threshold();
1393
+          tmc_step.x = stepperX.homing_threshold();
1417 1394
         #endif
1418 1395
         #if AXIS_HAS_STEALTHCHOP(Y)
1419
-          tmc_y_step = stepperY.homing_threshold();
1396
+          tmc_step.y = stepperY.homing_threshold();
1420 1397
         #endif
1421 1398
         #if AXIS_HAS_STEALTHCHOP(Z)
1422
-          tmc_z_step = stepperZ.homing_threshold();
1399
+          tmc_step.z = stepperZ.homing_threshold();
1423 1400
         #endif
1424 1401
       #endif
1425 1402
 
1426
-      if (min_ex_temp != 0)
1427
-        thermalManager.extrude_min_temp = min_ex_temp;
1403
+      if (mks_min_extrusion_temp != 0)
1404
+        thermalManager.extrude_min_temp = mks_min_extrusion_temp;
1428 1405
 
1429 1406
       DGUS_ExtrudeLoadInit();
1430 1407
 
@@ -1446,7 +1423,7 @@ bool DGUSScreenHandler::loop() {
1446 1423
 }
1447 1424
 
1448 1425
 void DGUSScreenHandler::LanguagePInit() {
1449
-  switch (DGUSLanguageSwitch) {
1426
+  switch (mks_language_index) {
1450 1427
     case MKS_SimpleChinese:
1451 1428
       dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_Choose);
1452 1429
       dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_NoChoose);
@@ -1705,10 +1682,10 @@ void DGUSScreenHandler::DGUS_LanguageDisplay(uint8_t var) {
1705 1682
     const char Printing_buf_en[] = "Printing";
1706 1683
     dgusdisplay.WriteVariable(VP_Printing_Dis, Printing_buf_en, 32, true);
1707 1684
 
1708
-    const char Info_EEPROM_1_buf_en[] = "Store setting";
1685
+    const char Info_EEPROM_1_buf_en[] = "Store setting?";
1709 1686
     dgusdisplay.WriteVariable(VP_Info_EEPROM_1_Dis, Info_EEPROM_1_buf_en, 32, true);
1710 1687
 
1711
-    const char Info_EEPROM_2_buf_en[] = "Revert setting";
1688
+    const char Info_EEPROM_2_buf_en[] = "Revert setting?";
1712 1689
     dgusdisplay.WriteVariable(VP_Info_EEPROM_2_Dis, Info_EEPROM_2_buf_en, 32, true);
1713 1690
 
1714 1691
     const char Info_PrinfFinsh_1_buf_en[] = "Print Done";
@@ -1963,7 +1940,7 @@ void DGUSScreenHandler::DGUS_LanguageDisplay(uint8_t var) {
1963 1940
     const uint16_t Info_EEPROM_1_buf_ch[] = { 0xC7CA, 0xF1B7, 0xA3B1, 0xE6B4, 0xE8C9, 0xC3D6, 0xBFA3, 0x2000 };
1964 1941
     dgusdisplay.WriteVariable(VP_Info_EEPROM_1_Dis, Info_EEPROM_1_buf_ch, 32, true);
1965 1942
 
1966
-    const uint16_t Info_EEPROM_2_buf_ch[] = { 0xC7CA, 0xF1B7, 0xD6BB, 0xB4B8, 0xF6B3, 0xA7B3, 0xE8C9, 0xC3D6, 0x2000 };
1943
+    const uint16_t Info_EEPROM_2_buf_ch[] = { 0xC7CA, 0xF1B7, 0xD6BB, 0xB4B8, 0xF6B3, 0xA7B3, 0xE8C9, 0xC3D6, 0xBFA3, 0x2000 };
1967 1944
     dgusdisplay.WriteVariable(VP_Info_EEPROM_2_Dis, Info_EEPROM_2_buf_ch, 32, true);
1968 1945
 
1969 1946
     const uint16_t TMC_X_Step_buf_ch[] = { 0x2058, 0xE9C1, 0xF4C3, 0xC8B6, 0x2000 };

+ 3
- 3
Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h 查看文件

@@ -158,13 +158,13 @@ public:
158 158
     static void GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr);
159 159
   #endif
160 160
 
161
+  // File touched.
162
+  static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr);
161 163
   #if ENABLED(SDSUPPORT)
162 164
     // Callback for VP "Display wants to change screen when there is a SD card"
163 165
     static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr);
164 166
     // Scroll buttons on the file listing screen.
165 167
     static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr);
166
-    // File touched.
167
-    static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr);
168 168
     // start print after confirmation received.
169 169
     static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr);
170 170
     // User hit the pause, resume or abort button.
@@ -301,7 +301,7 @@ private:
301 301
 
302 302
 #define MKS_SimpleChinese     0
303 303
 #define MKS_English           1
304
-extern uint8_t DGUSLanguageSwitch;
304
+extern uint8_t mks_language_index;
305 305
 extern bool DGUSAutoTurnOff;
306 306
 
307 307
 #if ENABLED(POWER_LOSS_RECOVERY)

+ 41
- 0
Marlin/src/module/settings.cpp 查看文件

@@ -153,6 +153,11 @@
153 153
   #include "../libs/buzzer.h"
154 154
 #endif
155 155
 
156
+#if ENABLED(DGUS_LCD_UI_MKS)
157
+  #include "../lcd/extui/lib/dgus/DGUSScreenHandler.h"
158
+  #include "../lcd/extui/lib/dgus/DGUSDisplayDef.h"
159
+#endif
160
+
156 161
 #pragma pack(push, 1) // No padding between variables
157 162
 
158 163
 #if HAS_ETHERNET
@@ -461,6 +466,16 @@ typedef struct SettingsDataStruct {
461 466
     bool buzzer_enabled;
462 467
   #endif
463 468
 
469
+  //
470
+  // MKS UI controller
471
+  //
472
+  #if ENABLED(DGUS_LCD_UI_MKS)
473
+    uint8_t mks_language_index;                         // Display Language
474
+    xy_int_t mks_corner_offsets[5];                     // Bed Tramming
475
+    xyz_int_t mks_park_pos;                             // Custom Parking (without NOZZLE_PARK)
476
+    celsius_t mks_min_extrusion_temp;                   // Min E Temp (shadow M302 value)
477
+  #endif
478
+
464 479
   #if HAS_MULTI_LANGUAGE
465 480
     uint8_t ui_language;                                // M414 S
466 481
   #endif
@@ -1403,6 +1418,16 @@ void MarlinSettings::postprocess() {
1403 1418
     #endif
1404 1419
 
1405 1420
     //
1421
+    // MKS UI controller
1422
+    //
1423
+    #if ENABLED(DGUS_LCD_UI_MKS)
1424
+      EEPROM_WRITE(mks_language_index);
1425
+      EEPROM_WRITE(mks_corner_offsets);
1426
+      EEPROM_WRITE(mks_park_pos);
1427
+      EEPROM_WRITE(mks_min_extrusion_temp);
1428
+    #endif
1429
+
1430
+    //
1406 1431
     // Selected LCD language
1407 1432
     //
1408 1433
     #if HAS_MULTI_LANGUAGE
@@ -2303,6 +2328,17 @@ void MarlinSettings::postprocess() {
2303 2328
       #endif
2304 2329
 
2305 2330
       //
2331
+      // MKS UI controller
2332
+      //
2333
+      #if ENABLED(DGUS_LCD_UI_MKS)
2334
+        _FIELD_TEST(mks_language_index);
2335
+        EEPROM_READ(mks_language_index);
2336
+        EEPROM_READ(mks_corner_offsets);
2337
+        EEPROM_READ(mks_park_pos);
2338
+        EEPROM_READ(mks_min_extrusion_temp);
2339
+      #endif
2340
+
2341
+      //
2306 2342
       // Selected LCD language
2307 2343
       //
2308 2344
       #if HAS_MULTI_LANGUAGE
@@ -2967,6 +3003,11 @@ void MarlinSettings::reset() {
2967 3003
     #endif
2968 3004
   #endif
2969 3005
 
3006
+  //
3007
+  // MKS UI controller
3008
+  //
3009
+  TERN_(DGUS_LCD_UI_MKS, MKS_reset_settings());
3010
+
2970 3011
   postprocess();
2971 3012
 
2972 3013
   DEBUG_ECHO_START();

Loading…
取消
儲存