From 04a1a67b0578a3e5651ffe5e41cdc5c2fb80d164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 4 Sep 2022 12:49:34 +0000 Subject: [PATCH] PFW-1386 Address TODO We want to move the Z-axis after the XY move is done. raise_z cannot be used here because it relies on current_position[] for all axis. It is actually 10 bytes cheaper to use the previous method because syncing current_position with lastpos is surprisingly expensive --- Firmware/Marlin_main.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 053a24100..f2dbc2b1c 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3544,7 +3544,7 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float st_synchronize(); // Raise the Z axis - float delta = raise_z(z_shift); + raise_z(z_shift); // Move XY to side current_position[X_AXIS] = x_position; @@ -3611,15 +3611,14 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float plan_buffer_line_curposXYZE(FILAMENTCHANGE_EXFEED); } - // TODO: Move the Z-axis after XY, not before. Currently this does not work - // and raise_z seems to have no affect after XY move for unknown reasons. - // This needs to be looked into. - // Recover Z axis - raise_z(-delta); - // Move XY back plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_XYFEED, active_extruder); st_synchronize(); + + // Move Z back + plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_ZFEED, active_extruder); + st_synchronize(); + // Set E position to original plan_set_e_position(lastpos[E_AXIS]);