@ -2344,135 +2344,134 @@ static void clean_up_after_endstop_or_probe_move() {
# define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
# define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
static void homeaxis ( AxisEnum axis ) {
static void homeaxis ( AxisEnum axis ) {
# define HOMEAXIS_DO(LETTER) \
( ( LETTER # # _MIN_PIN > - 1 & & LETTER # # _HOME_DIR = = - 1 ) | | ( LETTER # # _MAX_PIN > - 1 & & LETTER # # _HOME_DIR = = 1 ) )
if ( ! ( axis = = X_AXIS ? HOMEAXIS_DO ( X ) : axis = = Y_AXIS ? HOMEAXIS_DO ( Y ) : axis = = Z_AXIS ? HOMEAXIS_DO ( Z ) : 0 ) ) return ;
# if ENABLED(DEBUG_LEVELING_FEATURE)
# if ENABLED(DEBUG_LEVELING_FEATURE)
if ( DEBUGGING ( LEVELING ) ) {
if ( DEBUGGING ( LEVELING ) ) {
SERIAL_ECHOPAIR ( " >>> homeaxis( " , axis ) ;
SERIAL_ECHOPAIR ( " >>> homeaxis( " , axis ) ;
SERIAL_ECHOLNPGM ( " ) " ) ;
SERIAL_ECHOLNPGM ( " ) " ) ;
}
}
# endif
# endif
# define HOMEAXIS_DO(LETTER) \
( ( LETTER # # _MIN_PIN > - 1 & & LETTER # # _HOME_DIR = = - 1 ) | | ( LETTER # # _MAX_PIN > - 1 & & LETTER # # _HOME_DIR = = 1 ) )
if ( axis = = X_AXIS ? HOMEAXIS_DO ( X ) : axis = = Y_AXIS ? HOMEAXIS_DO ( Y ) : axis = = Z_AXIS ? HOMEAXIS_DO ( Z ) : 0 ) {
int axis_home_dir =
# if ENABLED(DUAL_X_CARRIAGE)
( axis = = X_AXIS ) ? x_home_dir ( active_extruder ) :
# endif
home_dir ( axis ) ;
int axis_home_dir =
// Homing Z towards the bed? Deploy the Z probe or endstop.
# if ENABLED(DUAL_X_CARRIAGE)
# if HAS_BED_PROBE
( axis = = X_AXIS ) ? x_home_dir ( active_extruder ) :
if ( axis = = Z_AXIS & & axis_home_dir < 0 ) {
# if ENABLED(DEBUG_LEVELING_FEATURE)
if ( DEBUGGING ( LEVELING ) ) SERIAL_ECHOPGM ( " > " ) ;
# endif
# endif
home_dir ( axis ) ;
if ( DEPLOY_PROBE ( ) ) return ;
}
// Homing Z towards the bed? Deploy the Z probe or endstop.
# endif
# if HAS_BED_PROBE
if ( axis = = Z_AXIS & & axis_home_dir < 0 ) {
# if ENABLED(DEBUG_LEVELING_FEATURE)
if ( DEBUGGING ( LEVELING ) ) SERIAL_ECHOPGM ( " > " ) ;
# endif
if ( DEPLOY_PROBE ( ) ) return ;
}
# endif
// Set the axis position as setup for the move
// Set the axis position as setup for the move
current_position [ axis ] = 0 ;
current_position [ axis ] = 0 ;
sync_plan_position ( ) ;
sync_plan_position ( ) ;
// Set a flag for Z motor locking
// Set a flag for Z motor locking
# if ENABLED(Z_DUAL_ENDSTOPS)
# if ENABLED(Z_DUAL_ENDSTOPS)
if ( axis = = Z_AXIS ) stepper . set_homing_flag ( true ) ;
if ( axis = = Z_AXIS ) stepper . set_homing_flag ( true ) ;
# endif
# endif
// Move towards the endstop until an endstop is triggered
// Move towards the endstop until an endstop is triggered
destination [ axis ] = 1.5 * max_length ( axis ) * axis_home_dir ;
destination [ axis ] = 1.5 * max_length ( axis ) * axis_home_dir ;
feedrate = homing_feedrate [ axis ] ;
feedrate = homing_feedrate [ axis ] ;
line_to_destination ( ) ;
line_to_destination ( ) ;
stepper . synchronize ( ) ;
stepper . synchronize ( ) ;
// Set the axis position as setup for the move
// Set the axis position as setup for the move
current_position [ axis ] = 0 ;
current_position [ axis ] = 0 ;
sync_plan_position ( ) ;
sync_plan_position ( ) ;
// Move away from the endstop by the axis HOME_BUMP_MM
// Move away from the endstop by the axis HOME_BUMP_MM
destination [ axis ] = - home_bump_mm ( axis ) * axis_home_dir ;
destination [ axis ] = - home_bump_mm ( axis ) * axis_home_dir ;
line_to_destination ( ) ;
line_to_destination ( ) ;
stepper . synchronize ( ) ;
stepper . synchronize ( ) ;
// Slow down the feedrate for the next move
// Slow down the feedrate for the next move
set_homing_bump_feedrate ( axis ) ;
set_homing_bump_feedrate ( axis ) ;
// Move slowly towards the endstop until triggered
// Move slowly towards the endstop until triggered
destination [ axis ] = 2 * home_bump_mm ( axis ) * axis_home_dir ;
destination [ axis ] = 2 * home_bump_mm ( axis ) * axis_home_dir ;
line_to_destination ( ) ;
line_to_destination ( ) ;
stepper . synchronize ( ) ;
stepper . synchronize ( ) ;
# if ENABLED(DEBUG_LEVELING_FEATURE)
# if ENABLED(DEBUG_LEVELING_FEATURE)
if ( DEBUGGING ( LEVELING ) ) DEBUG_POS ( " > TRIGGER ENDSTOP " , current_position ) ;
if ( DEBUGGING ( LEVELING ) ) DEBUG_POS ( " > TRIGGER ENDSTOP " , current_position ) ;
# endif
# endif
# if ENABLED(Z_DUAL_ENDSTOPS)
# if ENABLED(Z_DUAL_ENDSTOPS)
if ( axis = = Z_AXIS ) {
if ( axis = = Z_AXIS ) {
float adj = fabs ( z_endstop_adj ) ;
float adj = fabs ( z_endstop_adj ) ;
bool lockZ1 ;
bool lockZ1 ;
if ( axis_home_dir > 0 ) {
if ( axis_home_dir > 0 ) {
adj = - adj ;
adj = - adj ;
lockZ1 = ( z_endstop_adj > 0 ) ;
lockZ1 = ( z_endstop_adj > 0 ) ;
}
}
else
else
lockZ1 = ( z_endstop_adj < 0 ) ;
lockZ1 = ( z_endstop_adj < 0 ) ;
if ( lockZ1 ) stepper . set_z_lock ( true ) ; else stepper . set_z2_lock ( true ) ;
if ( lockZ1 ) stepper . set_z_lock ( true ) ; else stepper . set_z2_lock ( true ) ;
sync_plan_position ( ) ;
sync_plan_position ( ) ;
// Move to the adjusted endstop height
// Move to the adjusted endstop height
feedrate = homing_feedrate [ axis ] ;
feedrate = homing_feedrate [ axis ] ;
destination [ Z_AXIS ] = adj ;
destination [ Z_AXIS ] = adj ;
line_to_destination ( ) ;
line_to_destination ( ) ;
stepper . synchronize ( ) ;
stepper . synchronize ( ) ;
if ( lockZ1 ) stepper . set_z_lock ( false ) ; else stepper . set_z2_lock ( false ) ;
stepper . set_homing_flag ( false ) ;
} // Z_AXIS
# endif
# if ENABLED(DELTA)
if ( lockZ1 ) stepper . set_z_lock ( false ) ; else stepper . set_z2_lock ( false ) ;
// retrace by the amount specified in endstop_adj
stepper . set_homing_flag ( false ) ;
if ( endstop_adj [ axis ] * axis_home_dir < 0 ) {
} // Z_AXIS
sync_plan_position ( ) ;
# endif
destination [ axis ] = endstop_adj [ axis ] ;
# if ENABLED(DEBUG_LEVELING_FEATURE)
if ( DEBUGGING ( LEVELING ) ) {
SERIAL_ECHOPAIR ( " > endstop_adj = " , endstop_adj [ axis ] ) ;
DEBUG_POS ( " " , destination ) ;
}
# endif
line_to_destination ( ) ;
stepper . synchronize ( ) ;
}
# endif
// Set the axis position to its home position (plus home offsets)
# if ENABLED(DELTA)
set_axis_is_at_home ( axis ) ;
// retrace by the amount specified in endstop_adj
if ( endstop_adj [ axis ] * axis_home_dir < 0 ) {
sync_plan_position ( ) ;
destination [ axis ] = endstop_adj [ axis ] ;
# if ENABLED(DEBUG_LEVELING_FEATURE)
if ( DEBUGGING ( LEVELING ) ) {
SERIAL_ECHOPAIR ( " > endstop_adj = " , endstop_adj [ axis ] ) ;
DEBUG_POS ( " " , destination ) ;
}
# endif
line_to_destination ( ) ;
stepper . synchronize ( ) ;
}
# endif
SYNC_PLAN_POSITION_KINEMATIC ( ) ;
// Set the axis position to its home position (plus home offsets)
set_axis_is_at_home ( axis ) ;
# if ENABLED(DEBUG_LEVELING_FEATURE)
SYNC_PLAN_POSITION_KINEMATIC ( ) ;
if ( DEBUGGING ( LEVELING ) ) DEBUG_POS ( " > AFTER set_axis_is_at_home " , current_position ) ;
# endif
destination [ axis ] = current_position [ axis ] ;
# if ENABLED(DEBUG_LEVELING_FEATURE)
endstops . hit_on_purpose ( ) ; // clear endstop hit flags
if ( DEBUGGING ( LEVELING ) ) DEBUG_POS ( " > AFTER set_axis_is_at_home " , current_position ) ;
axis_known_position [ axis ] = true ;
# endif
axis_homed [ axis ] = true ;
// Put away the Z probe
destination [ axis ] = current_position [ axis ] ;
# if HAS_BED_PROBE
endstops . hit_on_purpose ( ) ; // clear endstop hit flags
if ( axis = = Z_AXIS & & axis_home_dir < 0 ) {
axis_known_position [ axis ] = true ;
# if ENABLED(DEBUG_LEVELING_FEATURE)
axis_homed [ axis ] = true ;
if ( DEBUGGING ( LEVELING ) ) SERIAL_ECHOPGM ( " > " ) ;
# endif
if ( STOW_PROBE ( ) ) return ;
}
# endif
}
// Put away the Z probe
# if HAS_BED_PROBE
if ( axis = = Z_AXIS & & axis_home_dir < 0 ) {
# if ENABLED(DEBUG_LEVELING_FEATURE)
if ( DEBUGGING ( LEVELING ) ) SERIAL_ECHOPGM ( " > " ) ;
# endif
if ( STOW_PROBE ( ) ) return ;
}
# endif
# if ENABLED(DEBUG_LEVELING_FEATURE)
# if ENABLED(DEBUG_LEVELING_FEATURE)
if ( DEBUGGING ( LEVELING ) ) {
if ( DEBUGGING ( LEVELING ) ) {