Tool Change Migration fixes and debugging (#18448)

This commit is contained in:
InsanityAutomation 2020-06-27 22:57:01 -04:00 committed by GitHub
parent e392745c86
commit c1dcc56a0b
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 8 deletions

View file

@ -40,6 +40,7 @@ bool FilamentMonitorBase::enabled = true,
#endif #endif
#if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
//#define DEBUG_TOOLCHANGE_MIGRATION_FEATURE
#include "../module/tool_change.h" #include "../module/tool_change.h"
#endif #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 (TERN0(ADVANCED_PAUSE_FEATURE, did_pause_print)) return; // Action already in progress. Purge triggered repeated runout.
#if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
if (migration.in_progress) return; // Action already in progress. Purge triggered repeated runout. if (migration.in_progress) {
if (migration.automode) { extruder_migration(); return; } #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
if (extruder_migration()) return;
}
#endif #endif
TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getActiveTool())); TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getActiveTool()));

View file

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

View file

@ -1222,16 +1222,27 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
#if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
void extruder_migration() { bool extruder_migration() {
#if ENABLED(PREVENT_COLD_EXTRUSION) #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 #endif
// No auto-migration or specified target? // No auto-migration or specified target?
if (!migration.target && active_extruder >= migration.last) { if (!migration.target && active_extruder >= migration.last) {
#if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
SERIAL_ECHO_MSG("No Migration Target");
SERIAL_ECHO_MSG("Target: ", migration.target,
" Last: ", migration.last,
" Active: ", active_extruder);
#endif
migration.automode = false; migration.automode = false;
return; return false;
} }
// Migrate to a target or the next extruder // Migrate to a target or the next extruder
@ -1239,6 +1250,9 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
uint8_t migration_extruder = active_extruder; uint8_t migration_extruder = active_extruder;
if (migration.target) { if (migration.target) {
#if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
SERIAL_ECHOLN("Migration using fixed target");
#endif
// Specified target ok? // Specified target ok?
const int16_t t = migration.target - 1; const int16_t t = migration.target - 1;
if (t != active_extruder) migration_extruder = t; if (t != active_extruder) migration_extruder = t;
@ -1246,9 +1260,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) else if (migration.automode && migration_extruder < migration.last && migration_extruder < EXTRUDERS - 1)
migration_extruder++; 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 // Migration begins
#if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
SERIAL_ECHOLN("Beginning migration");
#endif
migration.in_progress = true; // Prevent runout script migration.in_progress = true; // Prevent runout script
planner.synchronize(); planner.synchronize();
@ -1294,6 +1316,10 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
planner.synchronize(); planner.synchronize();
planner.set_e_position_mm(current_position.e); // New extruder primed and ready 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 #endif // TOOLCHANGE_MIGRATION_FEATURE

View file

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