Просмотр исходного кода

Tool Change Migration fixes and debugging (#18448)

InsanityAutomation 4 лет назад
Родитель
Сommit
c1dcc56a0b
Аккаунт пользователя с таким Email не найден

+ 13
- 2
Marlin/src/feature/runout.cpp Просмотреть файл

@@ -40,6 +40,7 @@ bool FilamentMonitorBase::enabled = true,
40 40
 #endif
41 41
 
42 42
 #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
43
+  //#define DEBUG_TOOLCHANGE_MIGRATION_FEATURE
43 44
   #include "../module/tool_change.h"
44 45
 #endif
45 46
 
@@ -80,8 +81,18 @@ void event_filament_runout() {
80 81
   if (TERN0(ADVANCED_PAUSE_FEATURE, did_pause_print)) return;  // Action already in progress. Purge triggered repeated runout.
81 82
 
82 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 96
   #endif
86 97
 
87 98
   TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getActiveTool()));

+ 1
- 1
Marlin/src/gcode/config/M217.cpp Просмотреть файл

@@ -49,7 +49,7 @@ void M217_report(const bool eeprom=false) {
49 49
                     " G", toolchange_settings.fan_time);
50 50
 
51 51
     #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
52
-      SERIAL_ECHOPAIR(" N", int(migration.automode));
52
+      SERIAL_ECHOPAIR(" A", int(migration.automode));
53 53
       SERIAL_ECHOPAIR(" L", LINEAR_UNIT(migration.last));
54 54
     #endif
55 55
 

+ 30
- 4
Marlin/src/module/tool_change.cpp Просмотреть файл

@@ -1222,16 +1222,27 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
1222 1222
 
1223 1223
 #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
1224 1224
 
1225
-  void extruder_migration() {
1225
+  bool extruder_migration() {
1226 1226
 
1227 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 1234
     #endif
1230 1235
 
1231 1236
     // No auto-migration or specified target?
1232 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 1244
       migration.automode = false;
1234
-      return;
1245
+      return false;
1235 1246
     }
1236 1247
 
1237 1248
     // Migrate to a target or the next extruder
@@ -1239,6 +1250,9 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
1239 1250
     uint8_t migration_extruder = active_extruder;
1240 1251
 
1241 1252
     if (migration.target) {
1253
+      #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
1254
+        SERIAL_ECHOLN("Migration using fixed target");
1255
+      #endif
1242 1256
       // Specified target ok?
1243 1257
       const int16_t t = migration.target - 1;
1244 1258
       if (t != active_extruder) migration_extruder = t;
@@ -1246,9 +1260,17 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
1246 1260
     else if (migration.automode && migration_extruder < migration.last && migration_extruder < EXTRUDERS - 1)
1247 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 1270
     // Migration begins
1271
+    #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
1272
+      SERIAL_ECHOLN("Beginning migration");
1273
+    #endif
1252 1274
 
1253 1275
     migration.in_progress = true; // Prevent runout script
1254 1276
     planner.synchronize();
@@ -1294,6 +1316,10 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
1294 1316
 
1295 1317
     planner.synchronize();
1296 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 1325
 #endif // TOOLCHANGE_MIGRATION_FEATURE

+ 1
- 1
Marlin/src/module/tool_change.h Просмотреть файл

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

Загрузка…
Отмена
Сохранить