Skip to content

Commit c1dcc56

Browse files
Tool Change Migration fixes and debugging (#18448)
1 parent e392745 commit c1dcc56

File tree

4 files changed

+45
-8
lines changed

4 files changed

+45
-8
lines changed

Marlin/src/feature/runout.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ bool FilamentMonitorBase::enabled = true,
4040
#endif
4141

4242
#if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
43+
//#define DEBUG_TOOLCHANGE_MIGRATION_FEATURE
4344
#include "../module/tool_change.h"
4445
#endif
4546

@@ -80,8 +81,18 @@ void event_filament_runout() {
8081
if (TERN0(ADVANCED_PAUSE_FEATURE, did_pause_print)) return; // Action already in progress. Purge triggered repeated runout.
8182

8283
#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+
}
8596
#endif
8697

8798
TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getActiveTool()));

Marlin/src/gcode/config/M217.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void M217_report(const bool eeprom=false) {
4949
" G", toolchange_settings.fan_time);
5050

5151
#if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
52-
SERIAL_ECHOPAIR(" N", int(migration.automode));
52+
SERIAL_ECHOPAIR(" A", int(migration.automode));
5353
SERIAL_ECHOPAIR(" L", LINEAR_UNIT(migration.last));
5454
#endif
5555

Marlin/src/module/tool_change.cpp

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,33 +1222,55 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
12221222

12231223
#if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
12241224

1225-
void extruder_migration() {
1225+
bool extruder_migration() {
12261226

12271227
#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+
}
12291234
#endif
12301235

12311236
// No auto-migration or specified target?
12321237
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
12331244
migration.automode = false;
1234-
return;
1245+
return false;
12351246
}
12361247

12371248
// Migrate to a target or the next extruder
12381249

12391250
uint8_t migration_extruder = active_extruder;
12401251

12411252
if (migration.target) {
1253+
#if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
1254+
SERIAL_ECHOLN("Migration using fixed target");
1255+
#endif
12421256
// Specified target ok?
12431257
const int16_t t = migration.target - 1;
12441258
if (t != active_extruder) migration_extruder = t;
12451259
}
12461260
else if (migration.automode && migration_extruder < migration.last && migration_extruder < EXTRUDERS - 1)
12471261
migration_extruder++;
12481262

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+
}
12501269

12511270
// Migration begins
1271+
#if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
1272+
SERIAL_ECHOLN("Beginning migration");
1273+
#endif
12521274

12531275
migration.in_progress = true; // Prevent runout script
12541276
planner.synchronize();
@@ -1294,6 +1316,10 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
12941316

12951317
planner.synchronize();
12961318
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;
12971323
}
12981324

12991325
#endif // TOOLCHANGE_MIGRATION_FEATURE

Marlin/src/module/tool_change.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
} migration_settings_t;
6060
constexpr migration_settings_t migration_defaults = { 0, 0, false, false };
6161
extern migration_settings_t migration;
62-
void extruder_migration();
62+
bool extruder_migration();
6363
#endif
6464
#endif
6565

0 commit comments

Comments
 (0)