Browse Source

Multi extruder support for M600 and LCD

Scott Lahteine 7 years ago
parent
commit
9ecdd1f4c7
2 changed files with 113 additions and 21 deletions
  1. 28
    12
      Marlin/src/gcode/feature/pause/M600.cpp
  2. 85
    9
      Marlin/src/lcd/ultralcd.cpp

+ 28
- 12
Marlin/src/gcode/feature/pause/M600.cpp View File

@@ -24,14 +24,15 @@
24 24
 
25 25
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
26 26
 
27
-#include "../../../feature/pause.h"
28
-
29 27
 #include "../../gcode.h"
28
+#include "../../../feature/pause.h"
30 29
 #include "../../../module/motion.h"
31
-#include "../../parser.h"
32
-
33 30
 #include "../../../module/printcounter.h"
34 31
 
32
+#if EXTRUDERS > 1
33
+  #include "../../../module/tool_change.h"
34
+#endif
35
+
35 36
 /**
36 37
  * M600: Pause for filament change
37 38
  *
@@ -42,6 +43,7 @@
42 43
  *  U[distance] - Retract distance for removal (negative value) (manual reload)
43 44
  *  L[distance] - Extrude distance for insertion (positive value) (manual reload)
44 45
  *  B[count]    - Number of times to beep, -1 for indefinite (if equipped with a buzzer)
46
+ *  T[toolhead] - Select extruder for filament change
45 47
  *
46 48
  *  Default values are used for omitted arguments.
47 49
  *
@@ -54,6 +56,18 @@ void GcodeSuite::M600() {
54 56
     if (axis_unhomed_error()) home_all_axes();
55 57
   #endif
56 58
 
59
+  #if EXTRUDERS > 1
60
+    // Change toolhead if specified
61
+    uint8_t active_extruder_before_filament_change = -1;
62
+    if (parser.seen('T')) {
63
+      const uint8_t extruder = parser.value_byte();
64
+      if (active_extruder != extruder) {
65
+        active_extruder_before_filament_change = active_extruder;
66
+        tool_change(extruder, 0, true);
67
+      }
68
+    }
69
+  #endif
70
+
57 71
   // Initial retract before move to filament change position
58 72
   const float retract = parser.seen('E') ? parser.value_axis_units(E_AXIS) : 0
59 73
     #ifdef PAUSE_PARK_RETRACT_LENGTH
@@ -61,16 +75,12 @@ void GcodeSuite::M600() {
61 75
     #endif
62 76
   ;
63 77
 
64
-  // Lift Z axis
65
-  if (parser.seenval('Z'))
66
-    park_point.z = parser.linearval('Z');
67
-
68 78
   // Move XY axes to filament change position or given position
69
-  if (parser.seenval('X'))
70
-    park_point.x = parser.linearval('X');
79
+  if (parser.seenval('X')) park_point.x = parser.linearval('X');
80
+  if (parser.seenval('Y')) park_point.y = parser.linearval('Y');
71 81
 
72
-  if (parser.seenval('Y'))
73
-    park_point.y = parser.linearval('Y');
82
+  // Lift Z axis
83
+  if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
74 84
 
75 85
   #if HOTENDS > 1 && DISABLED(DUAL_X_CARRIAGE)
76 86
     park_point.x += (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0);
@@ -106,6 +116,12 @@ void GcodeSuite::M600() {
106 116
     resume_print(load_length, ADVANCED_PAUSE_EXTRUDE_LENGTH, beep_count);
107 117
   }
108 118
 
119
+  #if EXTRUDERS > 1
120
+    // Restore toolhead if it was changed
121
+    if (active_extruder_before_filament_change >= 0)
122
+      tool_change(active_extruder_before_filament_change, 0, true);
123
+  #endif
124
+
109 125
   // Resume the print job timer if it was running
110 126
   if (job_running) print_job_timer.start();
111 127
 }

+ 85
- 9
Marlin/src/lcd/ultralcd.cpp View File

@@ -1246,11 +1246,14 @@ void kill_screen(const char* lcd_msg) {
1246 1246
 
1247 1247
   #if ENABLED(ADVANCED_PAUSE_FEATURE)
1248 1248
 
1249
-    void lcd_enqueue_filament_change() {
1249
+    void lcd_enqueue_filament_change(
1250
+      #if EXTRUDERS > 1
1251
+        const uint8_t extruder
1252
+      #endif
1253
+    ) {
1250 1254
 
1251 1255
       #if ENABLED(PREVENT_COLD_EXTRUSION)
1252
-        if (!DEBUGGING(DRYRUN) && !thermalManager.allow_cold_extrude &&
1253
-            thermalManager.degTargetHotend(active_extruder) < thermalManager.extrude_min_temp) {
1256
+        if (!DEBUGGING(DRYRUN) && thermalManager.tooColdToExtrude(active_extruder)) {
1254 1257
           lcd_save_previous_screen();
1255 1258
           lcd_goto_screen(lcd_advanced_pause_toocold_menu);
1256 1259
           return;
@@ -1258,9 +1261,42 @@ void kill_screen(const char* lcd_msg) {
1258 1261
       #endif
1259 1262
 
1260 1263
       lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT);
1261
-      enqueue_and_echo_commands_P(PSTR("M600 B0"));
1264
+
1265
+      #if EXTRUDERS <= 1
1266
+        enqueue_and_echo_commands_P(PSTR("M600 B0"));
1267
+      #else
1268
+        char *command_M600;
1269
+        switch (extruder) {
1270
+          case 0: command_M600 = PSTR("M600 B0 T0"); break;
1271
+          case 1: command_M600 = PSTR("M600 B0 T1"); break;
1272
+          #if EXTRUDERS > 2
1273
+            case 2: command_M600 = PSTR("M600 B0 T2"); break;
1274
+            #if EXTRUDERS > 3
1275
+              case 3: command_M600 = PSTR("M600 B0 T3"); break;
1276
+              #if EXTRUDERS > 4
1277
+                case 4: command_M600 = PSTR("M600 B0 T4"); break;
1278
+              #endif // EXTRUDERS > 4
1279
+            #endif // EXTRUDERS > 3
1280
+          #endif // EXTRUDERS > 2
1281
+        }
1282
+        enqueue_and_echo_commands_P(command_M600);
1283
+      #endif // EXTRUDERS > 1
1262 1284
     }
1263 1285
 
1286
+    #if EXTRUDERS > 1
1287
+      void lcd_enqueue_filament_change_e0() { lcd_enqueue_filament_change(0); }
1288
+      void lcd_enqueue_filament_change_e1() { lcd_enqueue_filament_change(1); }
1289
+      #if EXTRUDERS > 2
1290
+        void lcd_enqueue_filament_change_e2() { lcd_enqueue_filament_change(2); }
1291
+        #if EXTRUDERS > 3
1292
+          void lcd_enqueue_filament_change_e3() { lcd_enqueue_filament_change(3); }
1293
+          #if EXTRUDERS > 4
1294
+            void lcd_enqueue_filament_change_e4() { lcd_enqueue_filament_change(4); }
1295
+          #endif // EXTRUDERS > 4
1296
+        #endif // EXTRUDERS > 3
1297
+      #endif // EXTRUDERS > 2
1298
+    #endif // EXTRUDERS > 1
1299
+
1264 1300
   #endif // ADVANCED_PAUSE_FEATURE
1265 1301
 
1266 1302
   // First Fan Speed title in "Tune" and "Control>Temperature" menus
@@ -1404,8 +1440,27 @@ void kill_screen(const char* lcd_msg) {
1404 1440
     // Change filament
1405 1441
     //
1406 1442
     #if ENABLED(ADVANCED_PAUSE_FEATURE)
1407
-      if (!thermalManager.tooColdToExtrude(active_extruder))
1408
-        MENU_ITEM(function, MSG_FILAMENTCHANGE, lcd_enqueue_filament_change);
1443
+      #if EXTRUDERS > 1
1444
+        if (!thermalManager.tooColdToExtrude(0))
1445
+          MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E1, lcd_enqueue_filament_change_e0);
1446
+        if (!thermalManager.tooColdToExtrude(1))
1447
+          MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E2, lcd_enqueue_filament_change_e1);
1448
+        #if EXTRUDERS > 2
1449
+          if (!thermalManager.tooColdToExtrude(2))
1450
+            MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E3, lcd_enqueue_filament_change_e2);
1451
+          #if EXTRUDERS > 3
1452
+            if (!thermalManager.tooColdToExtrude(3))
1453
+              MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E4, lcd_enqueue_filament_change_e3);
1454
+            #if EXTRUDERS > 4
1455
+              if (!thermalManager.tooColdToExtrude(4))
1456
+                MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E5, lcd_enqueue_filament_change_e4);
1457
+            #endif // EXTRUDERS > 4
1458
+          #endif // EXTRUDERS > 3
1459
+        #endif // EXTRUDERS > 2
1460
+      #else
1461
+        if (!thermalManager.tooColdToExtrude(active_extruder))
1462
+          MENU_ITEM(function, MSG_FILAMENTCHANGE, lcd_enqueue_filament_change);
1463
+      #endif
1409 1464
     #endif
1410 1465
 
1411 1466
     END_MENU();
@@ -2595,9 +2650,30 @@ void kill_screen(const char* lcd_msg) {
2595 2650
     // Change filament
2596 2651
     //
2597 2652
     #if ENABLED(ADVANCED_PAUSE_FEATURE)
2598
-      if (!thermalManager.tooColdToExtrude(active_extruder) && !IS_SD_FILE_OPEN)
2599
-        MENU_ITEM(function, MSG_FILAMENTCHANGE, lcd_enqueue_filament_change);
2600
-    #endif
2653
+      if (!IS_SD_FILE_OPEN) {
2654
+        #if EXTRUDERS > 1
2655
+          if (!thermalManager.tooColdToExtrude(0))
2656
+            MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E1, lcd_enqueue_filament_change_e0);
2657
+          if (!thermalManager.tooColdToExtrude(1))
2658
+            MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E2, lcd_enqueue_filament_change_e1);
2659
+          #if EXTRUDERS > 2
2660
+            if (!thermalManager.tooColdToExtrude(2))
2661
+              MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E3, lcd_enqueue_filament_change_e2);
2662
+            #if EXTRUDERS > 3
2663
+              if (!thermalManager.tooColdToExtrude(3))
2664
+                MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E4, lcd_enqueue_filament_change_e3);
2665
+              #if EXTRUDERS > 4
2666
+                if (!thermalManager.tooColdToExtrude(4))
2667
+                  MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E5, lcd_enqueue_filament_change_e4);
2668
+              #endif // EXTRUDERS > 4
2669
+            #endif // EXTRUDERS > 3
2670
+          #endif // EXTRUDERS > 2
2671
+        #else
2672
+          if (!thermalManager.tooColdToExtrude(active_extruder))
2673
+            MENU_ITEM(function, MSG_FILAMENTCHANGE, lcd_enqueue_filament_change);
2674
+        #endif
2675
+      }
2676
+    #endif // ADVANCED_PAUSE_FEATURE
2601 2677
 
2602 2678
     #if TEMP_SENSOR_0 != 0
2603 2679
 

Loading…
Cancel
Save