From 72349a465f2eb1c5cb49d04fe8774d82bee0b931 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 27 Jun 2020 10:15:47 -0400 Subject: [PATCH 1/6] FixToolMigrationReportArg --- Marlin/src/gcode/config/M217.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/config/M217.cpp b/Marlin/src/gcode/config/M217.cpp index a1e53e5ecb43..a3a9d7b0aaa5 100644 --- a/Marlin/src/gcode/config/M217.cpp +++ b/Marlin/src/gcode/config/M217.cpp @@ -49,7 +49,7 @@ void M217_report(const bool eeprom=false) { " G", toolchange_settings.fan_time); #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) - SERIAL_ECHOPAIR(" N", int(migration.automode)); + SERIAL_ECHOPAIR(" A", int(migration.automode)); SERIAL_ECHOPAIR(" L", LINEAR_UNIT(migration.last)); #endif From c41cf410a20c6a574d50db2e9c8c5d673dddc951 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 27 Jun 2020 11:50:16 -0400 Subject: [PATCH 2/6] Add debug options and migration status allowing return to pause script on migration error --- Marlin/src/feature/runout.cpp | 15 ++++++++++++-- Marlin/src/module/tool_change.cpp | 33 ++++++++++++++++++++++++++++--- Marlin/src/module/tool_change.h | 2 +- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 452781b7f29b..7de49ead38fb 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -40,6 +40,7 @@ bool FilamentMonitorBase::enabled = true, #endif #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) + //#define DEBUG_TOOLCHANGE_MIGRATION_FEATURE #include "../module/tool_change.h" #endif @@ -80,8 +81,18 @@ void event_filament_runout() { if (TERN0(ADVANCED_PAUSE_FEATURE, did_pause_print)) return; // Action already in progress. Purge triggered repeated runout. #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) - if (migration.in_progress) return; // Action already in progress. Purge triggered repeated runout. - if (migration.automode) { extruder_migration(); return; } + if (migration.in_progress) { + #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE) + SERIAL_ECHOLN("Migration Already In Progress"); + #endif + return; // Action already in progress. Purge triggered repeated runout. + } + if (migration.automode) { + #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE) + SERIAL_ECHOLN("Migration Starting"); + #endif + extruder_migration(); return; + } #endif TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getActiveTool())); diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 8aa367555dc3..f7f564457c41 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1225,13 +1225,25 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { void extruder_migration() { #if ENABLED(PREVENT_COLD_EXTRUSION) - if (thermalManager.targetTooColdToExtrude(active_extruder)) return; + if (thermalManager.targetTooColdToExtrude(active_extruder)) { + + #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE) + SERIAL_ECHOLN("Migration Source Too Cold"); + #endif + return false; + } #endif // No auto-migration or specified target? if (!migration.target && active_extruder >= migration.last) { + #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE) + SERIAL_ECHOLN("No Migration Target"); + SERIAL_ECHOLNPAIR("Target : ", migration.target); + SERIAL_ECHOLNPAIR("Last : ", migration.last); + SERIAL_ECHOLNPAIR("Active : ", active_extruder); + #endif migration.automode = false; - return; + return false; } // Migrate to a target or the next extruder @@ -1239,6 +1251,9 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { uint8_t migration_extruder = active_extruder; if (migration.target) { + #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE) + SERIAL_ECHOLN("Migration using fixed target"); + #endif // Specified target ok? const int16_t t = migration.target - 1; if (t != active_extruder) migration_extruder = t; @@ -1246,9 +1261,17 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { else if (migration.automode && migration_extruder < migration.last && migration_extruder < EXTRUDERS - 1) migration_extruder++; - if (migration_extruder == active_extruder) return; + if (migration_extruder == active_extruder) { + #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE) + SERIAL_ECHOLN("Migration source matches active"); + #endif + return false; + } // Migration begins + #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE) + SERIAL_ECHOLN("Beginning migration"); + #endif migration.in_progress = true; // Prevent runout script planner.synchronize(); @@ -1294,6 +1317,10 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { planner.synchronize(); planner.set_e_position_mm(current_position.e); // New extruder primed and ready + #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE) + SERIAL_ECHOLN("Migration Complete"); + #endif + return true; } #endif // TOOLCHANGE_MIGRATION_FEATURE diff --git a/Marlin/src/module/tool_change.h b/Marlin/src/module/tool_change.h index 4b004950ab75..d39d7bc7833f 100644 --- a/Marlin/src/module/tool_change.h +++ b/Marlin/src/module/tool_change.h @@ -59,7 +59,7 @@ } migration_settings_t; constexpr migration_settings_t migration_defaults = { 0, 0, false, false }; extern migration_settings_t migration; - void extruder_migration(); + bool extruder_migration(); #endif #endif From ac6b9e1600b70ef2729a4ed7137d26b87b18397e Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 27 Jun 2020 11:53:18 -0400 Subject: [PATCH 3/6] Update runout.cpp --- Marlin/src/feature/runout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 7de49ead38fb..2a439dbe88f8 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -91,7 +91,7 @@ void event_filament_runout() { #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE) SERIAL_ECHOLN("Migration Starting"); #endif - extruder_migration(); return; + if(extruder_migration()) return; } #endif From d53cfe46e85462e8b2e14ca29ff1a7ab59ee6c08 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 27 Jun 2020 12:28:29 -0400 Subject: [PATCH 4/6] Update tool_change.cpp --- Marlin/src/module/tool_change.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index f7f564457c41..3ab591cb214b 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1222,7 +1222,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) - void extruder_migration() { + bool extruder_migration() { #if ENABLED(PREVENT_COLD_EXTRUSION) if (thermalManager.targetTooColdToExtrude(active_extruder)) { From 06ec8d3e630aeaf495c176828781b727ce5997aa Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 27 Jun 2020 21:55:37 -0500 Subject: [PATCH 5/6] Tweak formatting --- Marlin/src/module/tool_change.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 3ab591cb214b..3a283f8357da 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1226,21 +1226,20 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #if ENABLED(PREVENT_COLD_EXTRUSION) if (thermalManager.targetTooColdToExtrude(active_extruder)) { - - #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE) - SERIAL_ECHOLN("Migration Source Too Cold"); - #endif - return false; + #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE) + SERIAL_ECHOLN("Migration Source Too Cold"); + #endif + return false; } #endif // No auto-migration or specified target? if (!migration.target && active_extruder >= migration.last) { #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE) - SERIAL_ECHOLN("No Migration Target"); - SERIAL_ECHOLNPAIR("Target : ", migration.target); - SERIAL_ECHOLNPAIR("Last : ", migration.last); - SERIAL_ECHOLNPAIR("Active : ", active_extruder); + SERIAL_ECHO_MSG("No Migration Target"); + SERIAL_ECHO_MSG("Target: ", migration.target, + " Last: ", migration.last, + " Active: ", active_extruder); #endif migration.automode = false; return false; From a097bbb52234c4b3aca6a4c6b1727987930c20b0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 27 Jun 2020 21:56:17 -0500 Subject: [PATCH 6/6] Update runout.cpp --- Marlin/src/feature/runout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 2a439dbe88f8..80bce6d75844 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -91,7 +91,7 @@ void event_filament_runout() { #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE) SERIAL_ECHOLN("Migration Starting"); #endif - if(extruder_migration()) return; + if (extruder_migration()) return; } #endif