From daef5428d273d36fe3a584a2db4ef9757b5d93c2 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Wed, 21 Apr 2021 19:12:26 +0200 Subject: [PATCH] Rework gcode_M600_filament_change_z_shift to make it consistent gcode_M600_filament_change_z_shift is almost useless, since it performs what is already been done internally by filament_unload(). However it *does* cause the carriage to raise earlier during unload compared to making the user wait after "press for unload". Change it so the calculated Z height matches MIN_Z_FOR_SWAP. --- Firmware/Marlin_main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f7e8a43d..d0235b8b 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3622,12 +3622,12 @@ static T gcode_M600_filament_change_z_shift() #ifdef FILAMENTCHANGE_ZADD static_assert(Z_MAX_POS < (255 - FILAMENTCHANGE_ZADD), "Z-range too high, change the T type from uint8_t to uint16_t"); // avoid floating point arithmetics when not necessary - results in shorter code + T z_shift = T(FILAMENTCHANGE_ZADD); // always move above printout T ztmp = T( current_position[Z_AXIS] ); - T z_shift = 0; - if(ztmp < T(25)){ - z_shift = T(25) - ztmp; // make sure to be at least 25mm above the heat bed - } - return z_shift + T(FILAMENTCHANGE_ZADD); // always move above printout + if((ztmp + z_shift) < T(MIN_Z_FOR_SWAP)){ + z_shift = T(MIN_Z_FOR_SWAP) - ztmp; // make sure to be at least 25mm above the heat bed + } + return z_shift; #else return T(0); #endif