diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 67821b46a8..0c2ee24024 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1803,7 +1803,19 @@ inline void gcode_G28() { home_all_axis = !homeX && !homeY && !homeZ; // No parameters means home all axes #if Z_HOME_DIR > 0 // If homing away from BED do Z first + if (home_all_axis || homeZ) HOMEAXIS(Z); + + #elif !defined(Z_SAFE_HOMING) && defined(Z_RAISE_BEFORE_HOMING) && Z_RAISE_BEFORE_HOMING > 0 + + // Raise Z before homing any other axes + if (home_all_axis || homeZ) { + destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS); // Set destination away from bed + feedrate = max_feedrate[Z_AXIS]; + line_to_destination(); + st_synchronize(); + } + #endif #ifdef QUICK_HOME @@ -1897,16 +1909,7 @@ inline void gcode_G28() { #ifndef Z_SAFE_HOMING - if (home_all_axis || homeZ) { - // Raise Z before homing Z? Shouldn't this happen before homing X or Y? - #if defined(Z_RAISE_BEFORE_HOMING) && Z_RAISE_BEFORE_HOMING > 0 - destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS); // Set destination away from bed - feedrate = max_feedrate[Z_AXIS]; - line_to_destination(); - st_synchronize(); - #endif - HOMEAXIS(Z); - } + if (home_all_axis || homeZ) HOMEAXIS(Z); #else // Z_SAFE_HOMING