@ -182,7 +182,6 @@
*
*
*/
*/
void GcodeSuite : : G28 ( const bool always_home_all ) {
void GcodeSuite : : G28 ( const bool always_home_all ) {
if ( DEBUGGING ( LEVELING ) ) {
if ( DEBUGGING ( LEVELING ) ) {
DEBUG_ECHOLNPGM ( " >>> G28 " ) ;
DEBUG_ECHOLNPGM ( " >>> G28 " ) ;
log_machine_info ( ) ;
log_machine_info ( ) ;
@ -268,13 +267,16 @@ void GcodeSuite::G28(const bool always_home_all) {
const bool homeX = always_home_all | | parser . seen ( ' X ' ) ,
const bool homeX = always_home_all | | parser . seen ( ' X ' ) ,
homeY = always_home_all | | parser . seen ( ' Y ' ) ,
homeY = always_home_all | | parser . seen ( ' Y ' ) ,
homeZ = always_home_all | | parser . seen ( ' Z ' ) ,
homeZ = always_home_all | | parser . seen ( ' Z ' ) ,
home_all = ( ! homeX & & ! homeY & & ! homeZ ) | | ( homeX & & homeY & & homeZ ) ;
home_all = ( ! homeX & & ! homeY & & ! homeZ ) | | ( homeX & & homeY & & homeZ ) ,
doX = home_all | | homeX ,
doY = home_all | | homeY ,
doZ = home_all | | homeZ ;
set_destination_from_current ( ) ;
set_destination_from_current ( ) ;
# if Z_HOME_DIR > 0 // If homing away from BED do Z first
# if Z_HOME_DIR > 0 // If homing away from BED do Z first
if ( home_all | | home Z) homeaxis ( Z_AXIS ) ;
if ( do Z) homeaxis ( Z_AXIS ) ;
# endif
# endif
@ -285,7 +287,7 @@ void GcodeSuite::G28(const bool always_home_all) {
( parser . seenval ( ' R ' ) ? parser . value_linear_units ( ) : Z_HOMING_HEIGHT )
( parser . seenval ( ' R ' ) ? parser . value_linear_units ( ) : Z_HOMING_HEIGHT )
) ;
) ;
if ( z_homing_height & & ( home_all | | homeX | | home Y) ) {
if ( z_homing_height & & ( doX | | do Y) ) {
// Raise Z before homing any other axes and z is not already high enough (never lower z)
// Raise Z before homing any other axes and z is not already high enough (never lower z)
destination [ Z_AXIS ] = z_homing_height ;
destination [ Z_AXIS ] = z_homing_height ;
if ( destination [ Z_AXIS ] > current_position [ Z_AXIS ] ) {
if ( destination [ Z_AXIS ] > current_position [ Z_AXIS ] ) {
@ -296,25 +298,25 @@ void GcodeSuite::G28(const bool always_home_all) {
# if ENABLED(QUICK_HOME)
# if ENABLED(QUICK_HOME)
if ( home_all | | ( homeX & & homeY ) ) quick_home_xy ( ) ;
if ( doX & & doY ) quick_home_xy ( ) ;
# endif
# endif
// Home Y (before X)
// Home Y (before X)
# if ENABLED(HOME_Y_BEFORE_X)
# if ENABLED(HOME_Y_BEFORE_X)
if ( home_all | | home Y
if ( do Y
# if ENABLED(CODEPENDENT_XY_HOMING)
# if ENABLED(CODEPENDENT_XY_HOMING)
| | home X
| | do X
# endif
# endif
) homeaxis ( Y_AXIS ) ;
) homeaxis ( Y_AXIS ) ;
# endif
# endif
// Home X
// Home X
if ( home_all | | home X
if ( do X
# if ENABLED(CODEPENDENT_XY_HOMING) && DISABLED(HOME_Y_BEFORE_X)
# if ENABLED(CODEPENDENT_XY_HOMING) && DISABLED(HOME_Y_BEFORE_X)
| | home Y
| | do Y
# endif
# endif
) {
) {
@ -345,12 +347,12 @@ void GcodeSuite::G28(const bool always_home_all) {
// Home Y (after X)
// Home Y (after X)
# if DISABLED(HOME_Y_BEFORE_X)
# if DISABLED(HOME_Y_BEFORE_X)
if ( home_all | | home Y) homeaxis ( Y_AXIS ) ;
if ( do Y) homeaxis ( Y_AXIS ) ;
# endif
# endif
// Home Z last if homing towards the bed
// Home Z last if homing towards the bed
# if Z_HOME_DIR < 0
# if Z_HOME_DIR < 0
if ( home_all | | home Z) {
if ( do Z) {
# if ENABLED(Z_SAFE_HOMING)
# if ENABLED(Z_SAFE_HOMING)
home_z_safely ( ) ;
home_z_safely ( ) ;
# else
# else
@ -361,7 +363,7 @@ void GcodeSuite::G28(const bool always_home_all) {
move_z_after_probing ( ) ;
move_z_after_probing ( ) ;
# endif
# endif
} // home_all || home Z
} // do Z
# endif // Z_HOME_DIR < 0
# endif // Z_HOME_DIR < 0
sync_plan_position ( ) ;
sync_plan_position ( ) ;
@ -402,6 +404,16 @@ void GcodeSuite::G28(const bool always_home_all) {
# endif // DUAL_X_CARRIAGE
# endif // DUAL_X_CARRIAGE
# ifdef HOMING_BACKOFF_MM
endstops . enable ( false ) ;
constexpr float backoff [ XYZ ] = HOMING_BACKOFF_MM ;
const float backoff_x = doX ? ABS ( endstop_backoff [ X_AXIS ] ) * ( X_HOME_DIR ) : 0 ,
backoff_y = doY ? ABS ( endstop_backoff [ Y_AXIS ] ) * ( Y_HOME_DIR ) : 0 ,
backoff_z = doZ ? ABS ( endstop_backoff [ Z_AXIS ] ) * ( Z_HOME_DIR ) : 0 ;
if ( backoff_z ) do_blocking_move_to_z ( current_position [ Z_AXIS ] - backoff_z ) ;
if ( backoff_x | | backoff_y ) do_blocking_move_to_xy ( current_position [ X_AXIS ] - backoff_x , current_position [ Y_AXIS ] - backoff_y ) ;
# endif
endstops . not_homing ( ) ;
endstops . not_homing ( ) ;
# if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE)
# if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE)
@ -430,9 +442,9 @@ void GcodeSuite::G28(const bool always_home_all) {
report_current_position ( ) ;
report_current_position ( ) ;
# if ENABLED(NANODLP_Z_SYNC)
# if ENABLED(NANODLP_Z_SYNC)
# if ENABLED(NANODLP_ALL_AXIS)
# if ENABLED(NANODLP_ALL_AXIS)
# define _HOME_SYNC true // For any axis, output sync text.
# define _HOME_SYNC true // For any axis, output sync text.
# else
# else
# define _HOME_SYNC (home_all || homeZ) // Only for Z-axis
# define _HOME_SYNC doZ // Only for Z-axis
# endif
# endif
if ( _HOME_SYNC )
if ( _HOME_SYNC )
SERIAL_ECHOLNPGM ( MSG_Z_MOVE_COMP ) ;
SERIAL_ECHOLNPGM ( MSG_Z_MOVE_COMP ) ;