From 61591fd23369a03063a42f57a174c51f995c7efb Mon Sep 17 00:00:00 2001 From: studiodyne <42887851+studiodyne@users.noreply.github.com> Date: Tue, 10 Oct 2023 00:50:09 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20tool-change=20E=20prime=20?= =?UTF-8?q?(#26237)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/module/tool_change.cpp | 35 +++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 622877667d..b33b642966 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -940,19 +940,20 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. * sync_plan_position_e(); */ void extruder_cutting_recover(const_float_t e) { - if (!too_cold(active_extruder)) { - const float dist = toolchange_settings.extra_resume + toolchange_settings.wipe_retract; - FS_DEBUG("Performing Cutting Recover | Distance: ", dist, " | Speed: ", MMM_TO_MMS(toolchange_settings.unretract_speed), "mm/s"); - unscaled_e_move(dist, MMM_TO_MMS(toolchange_settings.unretract_speed)); - planner.synchronize(); - FS_DEBUG("Set position to: ", e); - current_position.e = e; - sync_plan_position_e(); // Resume new E Position - } + if (too_cold(active_extruder)) return; + + const float dist = toolchange_settings.extra_resume + toolchange_settings.wipe_retract; + FS_DEBUG("Performing Cutting Recover | Distance: ", dist, " | Speed: ", MMM_TO_MMS(toolchange_settings.unretract_speed), "mm/s"); + unscaled_e_move(dist, MMM_TO_MMS(toolchange_settings.unretract_speed)); + + FS_DEBUG("Set E position: ", e); + current_position.e = e; + sync_plan_position_e(); // Resume new E Position } /** * Prime the currently selected extruder (Filament loading only) + * Leave the E position unchanged so subsequent extrusion works properly. * * If too_cold(toolID) returns TRUE -> returns without moving extruder. * Extruders filament = swap_length + extra prime, then performs cutting retraction if enabled. @@ -966,6 +967,8 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. feedRate_t fr_mm_s = MMM_TO_MMS(toolchange_settings.unretract_speed); // Set default speed for unretract + const float resume_current_e = current_position.e; + #if ENABLED(TOOLCHANGE_FS_SLOW_FIRST_PRIME) /** * Perform first unretract movement at the slower Prime_Speed to avoid breakage on first prime @@ -1010,6 +1013,10 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. unscaled_e_move(-toolchange_settings.wipe_retract, MMM_TO_MMS(toolchange_settings.retract_speed)); #endif + // Leave E unchanged when priming + current_position.e = resume_current_e; + sync_plan_position_e(); + // Cool down with fan filament_swap_cooling(); } @@ -1061,17 +1068,19 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. } #endif + // Prime without changing E extruder_prime(); // Move back #if ENABLED(TOOLCHANGE_PARK) if (ok) { #if ENABLED(TOOLCHANGE_NO_RETURN) - const float temp = destination.z; - destination = current_position; - destination.z = temp; + destination.x = current_position.x; + destination.y = current_position.y; #endif - prepare_internal_move_to_destination(TERN(TOOLCHANGE_NO_RETURN, planner.settings.max_feedrate_mm_s[Z_AXIS], MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE))); + do_blocking_move_to_xy(destination, MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE)); + do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]); + planner.synchronize(); } #endif