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.
This commit is contained in:
Yuri D'Elia 2021-04-21 19:12:26 +02:00
parent 8d04316497
commit daef5428d2

View File

@ -3622,12 +3622,12 @@ static T gcode_M600_filament_change_z_shift()
#ifdef FILAMENTCHANGE_ZADD #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"); 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 // 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 ztmp = T( current_position[Z_AXIS] );
T z_shift = 0; if((ztmp + z_shift) < T(MIN_Z_FOR_SWAP)){
if(ztmp < T(25)){ z_shift = T(MIN_Z_FOR_SWAP) - ztmp; // make sure to be at least 25mm above the heat bed
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 return z_shift;
#else #else
return T(0); return T(0);
#endif #endif