Browse Source

Fix manual move with MKS H43 (#21511)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
Sola 4 years ago
parent
commit
4cba40f9fd
No account linked to committer's email address

+ 4
- 0
Marlin/src/gcode/gcode.cpp View File

@@ -977,6 +977,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
977 977
         case 1001: M1001(); break;                                // M1001: [INTERNAL] Handle SD completion
978 978
       #endif
979 979
 
980
+      #if ENABLED(DGUS_LCD_UI_MKS)
981
+        case 1002: M1002(); break;                                // M1002: [INTERNAL] Tool-change and Relative E Move
982
+      #endif
983
+
980 984
       #if ENABLED(MAX7219_GCODE)
981 985
         case 7219: M7219(); break;                                // M7219: Set LEDs, columns, and rows
982 986
       #endif

+ 4
- 0
Marlin/src/gcode/gcode.h View File

@@ -1069,6 +1069,10 @@ private:
1069 1069
     static void M1001();
1070 1070
   #endif
1071 1071
 
1072
+  #if ENABLED(DGUS_LCD_UI_MKS)
1073
+    static void M1002();
1074
+  #endif
1075
+
1072 1076
   #if ENABLED(MAX7219_GCODE)
1073 1077
     static void M7219();
1074 1078
   #endif

+ 3
- 3
Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp View File

@@ -45,7 +45,7 @@
45 45
 
46 46
 uint16_t manualMoveStep = 1;
47 47
 uint16_t distanceFilament = 10;
48
-uint16_t FilamentSpeed = 25;
48
+uint16_t filamentSpeed_mm_s = 25;
49 49
 float ZOffset_distance = 0.1;
50 50
 float mesh_adj_distance = 0.01;
51 51
 float Z_distance = 0.1;
@@ -555,7 +555,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
555 555
       VPHELPER(VP_LOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentLoad, nullptr),
556 556
       VPHELPER(VP_UNLOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentUnLoad, nullptr),
557 557
       VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
558
-      VPHELPER(VP_Filament_speed, &FilamentSpeed, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
558
+      VPHELPER(VP_Filament_speed, &filamentSpeed_mm_s, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
559 559
     #endif
560 560
   #endif
561 561
 
@@ -569,7 +569,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
569 569
 
570 570
     #if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
571 571
       VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
572
-      VPHELPER(VP_Filament_speed, &FilamentSpeed, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
572
+      VPHELPER(VP_Filament_speed, &filamentSpeed_mm_s, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
573 573
     #endif
574 574
 
575 575
     #if ENABLED(PIDTEMP)

+ 1
- 1
Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h View File

@@ -37,7 +37,7 @@
37 37
 
38 38
 extern uint16_t manualMoveStep;
39 39
 extern uint16_t distanceFilament;
40
-extern uint16_t FilamentSpeed;
40
+extern uint16_t filamentSpeed_mm_s;
41 41
 extern float    ZOffset_distance;
42 42
 extern float    mesh_adj_distance;
43 43
 extern float    Z_distance;

+ 40
- 14
Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp View File

@@ -840,7 +840,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
840 840
     // buf[4] = axiscode;
841 841
 
842 842
     char buf[6];
843
-    sprintf(buf,"G28 %c",axiscode);
843
+    sprintf(buf, "G28 %c", axiscode);
844 844
     //DEBUG_ECHOPAIR(" ", buf);
845 845
     queue.enqueue_one_now(buf);
846 846
     //DEBUG_ECHOLNPGM(" ✓");
@@ -1190,17 +1190,18 @@ void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_
1190 1190
 
1191 1191
   uint16_t value_len = swap16(*(uint16_t*)val_ptr);
1192 1192
 
1193
-  DEBUG_ECHOLNPAIR_F("FilamentSpeed value:", value_len);
1193
+  DEBUG_ECHOLNPAIR_F("filamentSpeed_mm_s value:", value_len);
1194 1194
 
1195
-  FilamentSpeed = value_len;
1195
+  filamentSpeed_mm_s = value_len;
1196 1196
 
1197 1197
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1198 1198
 }
1199 1199
 
1200 1200
 void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir) {
1201 1201
   #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE)
1202
-    char buf[40];
1203 1202
     uint8_t swap_tool = 0;
1203
+  #else
1204
+    constexpr uint8_t swap_tool = 1; // T0 (or none at all)
1204 1205
   #endif
1205 1206
 
1206 1207
   #if HAS_HOTEND
@@ -1215,9 +1216,8 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_
1215 1216
     default: break;
1216 1217
     case 0:
1217 1218
       #if HAS_HOTEND
1218
-        if (thermalManager.tooColdToExtrude(0)) {
1219
+        if (thermalManager.tooColdToExtrude(0))
1219 1220
           hotend_too_cold = 1;
1220
-        }
1221 1221
         else {
1222 1222
           #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE)
1223 1223
             swap_tool = 1;
@@ -1243,15 +1243,41 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_
1243 1243
     }
1244 1244
   #endif
1245 1245
 
1246
+  if (swap_tool) {
1247
+    char buf[30];
1248
+    snprintf_P(buf, 30
1249
+      #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE)
1250
+        , PSTR("M1002T%cE%dF%d"), char('0' + swap_tool - 1)
1251
+      #else
1252
+        , PSTR("M1002E%dF%d")
1253
+      #endif
1254
+      , (int)distanceFilament * filamentDir, filamentSpeed_mm_s * 60
1255
+    );
1256
+    queue.inject(buf);
1257
+  }
1258
+}
1259
+
1260
+/**
1261
+ * M1002: Do a tool-change and relative move for MKS_FilamentLoadUnload
1262
+ *        within the G-code execution window for best concurrency.
1263
+ */
1264
+void GcodeSuite::M1002() {
1246 1265
   #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE)
1247
-    if (swap_tool) {
1248
-      queue.enqueue_now_P(swap_tool == 2 ? PSTR("T1") : PSTR("T0"));
1249
-      queue.enqueue_now_P(PSTR("G91"));
1250
-      snprintf_P(buf, 40, PSTR("G1 E%d F%d"), (int)distanceFilament * filamentDir, FilamentSpeed * 60);
1251
-      queue.enqueue_one_now(buf);
1252
-      queue.enqueue_now_P(PSTR("G90"));
1253
-    }
1266
+  {
1267
+    char buf[3];
1268
+    sprintf_P(buf, PSTR("T%c"), char('0' + parser.intval('T')));
1269
+    process_subcommands_now(buf);
1270
+  }
1254 1271
   #endif
1272
+
1273
+  const uint8_t old_axis_relative = axis_relative;
1274
+  set_e_relative(true); // M83
1275
+  {
1276
+    char buf[20];
1277
+    snprintf_P(buf, 20, PSTR("G1E%dF%d"), parser.intval('E'), parser.intval('F'));
1278
+    process_subcommands_now(buf);
1279
+  }
1280
+  axis_relative = old_axis_relative;
1255 1281
 }
1256 1282
 
1257 1283
 void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) {
@@ -1445,7 +1471,7 @@ void DGUSScreenHandler::LanguagePInit() {
1445 1471
 void DGUSScreenHandler::DGUS_ExtrudeLoadInit(void) {
1446 1472
   ex_filament.ex_length           = distanceFilament;
1447 1473
   ex_filament.ex_load_unload_flag = 0;
1448
-  ex_filament.ex_need_time        = FilamentSpeed;
1474
+  ex_filament.ex_need_time        = filamentSpeed_mm_s;
1449 1475
   ex_filament.ex_speed            = 0;
1450 1476
   ex_filament.ex_status           = EX_NONE;
1451 1477
   ex_filament.ex_tick_end         = 0;

Loading…
Cancel
Save