Browse Source

Tool Change Migration fixes and debugging (#18448)

InsanityAutomation 4 years ago
parent
commit
c1dcc56a0b
No account linked to committer's email address

+ 13
- 2
Marlin/src/feature/runout.cpp View File

40
 #endif
40
 #endif
41
 
41
 
42
 #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
42
 #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
43
+  //#define DEBUG_TOOLCHANGE_MIGRATION_FEATURE
43
   #include "../module/tool_change.h"
44
   #include "../module/tool_change.h"
44
 #endif
45
 #endif
45
 
46
 
80
   if (TERN0(ADVANCED_PAUSE_FEATURE, did_pause_print)) return;  // Action already in progress. Purge triggered repeated runout.
81
   if (TERN0(ADVANCED_PAUSE_FEATURE, did_pause_print)) return;  // Action already in progress. Purge triggered repeated runout.
81
 
82
 
82
   #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
83
   #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
83
-    if (migration.in_progress) return;  // Action already in progress. Purge triggered repeated runout.
84
-    if (migration.automode) { extruder_migration(); return; }
84
+    if (migration.in_progress) {
85
+      #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
86
+        SERIAL_ECHOLN("Migration Already In Progress");
87
+      #endif
88
+      return;  // Action already in progress. Purge triggered repeated runout.
89
+    }
90
+    if (migration.automode) {
91
+      #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
92
+        SERIAL_ECHOLN("Migration Starting");
93
+      #endif
94
+      if (extruder_migration()) return;
95
+    }
85
   #endif
96
   #endif
86
 
97
 
87
   TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getActiveTool()));
98
   TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getActiveTool()));

+ 1
- 1
Marlin/src/gcode/config/M217.cpp View File

49
                     " G", toolchange_settings.fan_time);
49
                     " G", toolchange_settings.fan_time);
50
 
50
 
51
     #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
51
     #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
52
-      SERIAL_ECHOPAIR(" N", int(migration.automode));
52
+      SERIAL_ECHOPAIR(" A", int(migration.automode));
53
       SERIAL_ECHOPAIR(" L", LINEAR_UNIT(migration.last));
53
       SERIAL_ECHOPAIR(" L", LINEAR_UNIT(migration.last));
54
     #endif
54
     #endif
55
 
55
 

+ 30
- 4
Marlin/src/module/tool_change.cpp View File

1222
 
1222
 
1223
 #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
1223
 #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
1224
 
1224
 
1225
-  void extruder_migration() {
1225
+  bool extruder_migration() {
1226
 
1226
 
1227
     #if ENABLED(PREVENT_COLD_EXTRUSION)
1227
     #if ENABLED(PREVENT_COLD_EXTRUSION)
1228
-      if (thermalManager.targetTooColdToExtrude(active_extruder)) return;
1228
+      if (thermalManager.targetTooColdToExtrude(active_extruder)) {
1229
+        #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
1230
+          SERIAL_ECHOLN("Migration Source Too Cold");
1231
+        #endif
1232
+        return false;
1233
+      }
1229
     #endif
1234
     #endif
1230
 
1235
 
1231
     // No auto-migration or specified target?
1236
     // No auto-migration or specified target?
1232
     if (!migration.target && active_extruder >= migration.last) {
1237
     if (!migration.target && active_extruder >= migration.last) {
1238
+      #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
1239
+        SERIAL_ECHO_MSG("No Migration Target");
1240
+        SERIAL_ECHO_MSG("Target: ", migration.target,
1241
+                        " Last: ", migration.last,
1242
+                        " Active: ", active_extruder);
1243
+      #endif
1233
       migration.automode = false;
1244
       migration.automode = false;
1234
-      return;
1245
+      return false;
1235
     }
1246
     }
1236
 
1247
 
1237
     // Migrate to a target or the next extruder
1248
     // Migrate to a target or the next extruder
1239
     uint8_t migration_extruder = active_extruder;
1250
     uint8_t migration_extruder = active_extruder;
1240
 
1251
 
1241
     if (migration.target) {
1252
     if (migration.target) {
1253
+      #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
1254
+        SERIAL_ECHOLN("Migration using fixed target");
1255
+      #endif
1242
       // Specified target ok?
1256
       // Specified target ok?
1243
       const int16_t t = migration.target - 1;
1257
       const int16_t t = migration.target - 1;
1244
       if (t != active_extruder) migration_extruder = t;
1258
       if (t != active_extruder) migration_extruder = t;
1246
     else if (migration.automode && migration_extruder < migration.last && migration_extruder < EXTRUDERS - 1)
1260
     else if (migration.automode && migration_extruder < migration.last && migration_extruder < EXTRUDERS - 1)
1247
       migration_extruder++;
1261
       migration_extruder++;
1248
 
1262
 
1249
-    if (migration_extruder == active_extruder) return;
1263
+    if (migration_extruder == active_extruder) {
1264
+      #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
1265
+        SERIAL_ECHOLN("Migration source matches active");
1266
+      #endif
1267
+      return false;
1268
+    }
1250
 
1269
 
1251
     // Migration begins
1270
     // Migration begins
1271
+    #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
1272
+      SERIAL_ECHOLN("Beginning migration");
1273
+    #endif
1252
 
1274
 
1253
     migration.in_progress = true; // Prevent runout script
1275
     migration.in_progress = true; // Prevent runout script
1254
     planner.synchronize();
1276
     planner.synchronize();
1294
 
1316
 
1295
     planner.synchronize();
1317
     planner.synchronize();
1296
     planner.set_e_position_mm(current_position.e); // New extruder primed and ready
1318
     planner.set_e_position_mm(current_position.e); // New extruder primed and ready
1319
+    #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
1320
+      SERIAL_ECHOLN("Migration Complete");
1321
+    #endif
1322
+    return true;
1297
   }
1323
   }
1298
 
1324
 
1299
 #endif // TOOLCHANGE_MIGRATION_FEATURE
1325
 #endif // TOOLCHANGE_MIGRATION_FEATURE

+ 1
- 1
Marlin/src/module/tool_change.h View File

59
     } migration_settings_t;
59
     } migration_settings_t;
60
     constexpr migration_settings_t migration_defaults = { 0, 0, false, false };
60
     constexpr migration_settings_t migration_defaults = { 0, 0, false, false };
61
     extern migration_settings_t migration;
61
     extern migration_settings_t migration;
62
-    void extruder_migration();
62
+    bool extruder_migration();
63
   #endif
63
   #endif
64
 #endif
64
 #endif
65
 
65
 

Loading…
Cancel
Save