@ -1268,13 +1268,14 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
// Engage Z Servo endstop if enabled
// Engage Z Servo endstop if enabled
if ( servo_endstops [ Z_AXIS ] > = 0 ) {
if ( servo_endstops [ Z_AXIS ] > = 0 ) {
Servo * srv = & servo [ servo_endstops [ Z_AXIS ] ] ;
# if SERVO_LEVELING
# if SERVO_LEVELING
s ervo[ servo_endstops [ Z_AXIS ] ] . attach ( 0 ) ;
s rv- > attach ( 0 ) ;
# endif
# endif
s ervo[ servo_endstops [ Z_AXIS ] ] . write ( servo_endstop_angles [ Z_AXIS * 2 ] ) ;
s rv- > write ( servo_endstop_angles [ Z_AXIS * 2 ] ) ;
# if SERVO_LEVELING
# if SERVO_LEVELING
delay ( PROBE_SERVO_DEACTIVATION_DELAY ) ;
delay ( PROBE_SERVO_DEACTIVATION_DELAY ) ;
s ervo[ servo_endstops [ Z_AXIS ] ] . detach ( ) ;
s rv- > detach ( ) ;
# endif
# endif
}
}
@ -1320,7 +1321,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
}
}
static void stow_z_probe ( ) {
static void stow_z_probe ( bool doRaise = true ) {
# ifdef SERVO_ENDSTOPS
# ifdef SERVO_ENDSTOPS
@ -1328,19 +1329,21 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
if ( servo_endstops [ Z_AXIS ] > = 0 ) {
if ( servo_endstops [ Z_AXIS ] > = 0 ) {
# if Z_RAISE_AFTER_PROBING > 0
# if Z_RAISE_AFTER_PROBING > 0
if ( doRaise ) {
do_blocking_move_to ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , current_position [ Z_AXIS ] + Z_RAISE_AFTER_PROBING ) ; // this also updates current_position
do_blocking_move_to ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , current_position [ Z_AXIS ] + Z_RAISE_AFTER_PROBING ) ; // this also updates current_position
st_synchronize ( ) ;
st_synchronize ( ) ;
}
# endif
# endif
// Change the Z servo angle
Servo * srv = & servo [ servo_endstops [ Z_AXIS ] ] ;
# if SERVO_LEVELING
# if SERVO_LEVELING
servo [ servo_endstops [ Z_AXIS ] ] . attach ( 0 ) ;
s rv- > attach ( 0 ) ;
# endif
# endif
srv - > write ( servo_endstop_angles [ Z_AXIS * 2 + 1 ] ) ;
servo [ servo_endstops [ Z_AXIS ] ] . write ( servo_endstop_angles [ Z_AXIS * 2 + 1 ] ) ;
# if SERVO_LEVELING
# if SERVO_LEVELING
delay ( PROBE_SERVO_DEACTIVATION_DELAY ) ;
delay ( PROBE_SERVO_DEACTIVATION_DELAY ) ;
s ervo[ servo_endstops [ Z_AXIS ] ] . detach ( ) ;
s rv- > detach ( ) ;
# endif
# endif
}
}
@ -1524,19 +1527,25 @@ static void homeaxis(AxisEnum axis) {
current_position [ axis ] = 0 ;
current_position [ axis ] = 0 ;
sync_plan_position ( ) ;
sync_plan_position ( ) ;
// Engage Servo endstop if enabled
# if SERVO_LEVELING && !defined(Z_PROBE_SLED)
# if defined(SERVO_ENDSTOPS) && !defined(Z_PROBE_SLED)
// Deploy a probe if there is one, and homing towards the bed
if ( axis = = Z_AXIS ) {
if ( axis_home_dir < 0 ) deploy_z_probe ( ) ;
}
else
# if SERVO_LEVELING
if ( axis = = Z_AXIS ) deploy_z_probe ( ) ; else
# endif
# endif
# ifdef SERVO_ENDSTOPS
{
{
// Engage Servo endstop if enabled
if ( servo_endstops [ axis ] > - 1 )
if ( servo_endstops [ axis ] > - 1 )
servo [ servo_endstops [ axis ] ] . write ( servo_endstop_angles [ axis * 2 ] ) ;
servo [ servo_endstops [ axis ] ] . write ( servo_endstop_angles [ axis * 2 ] ) ;
}
}
# endif
# endif // SERVO_ENDSTOPS && !Z_PROBE_SLED
// Set a flag for Z motor locking
# ifdef Z_DUAL_ENDSTOPS
# ifdef Z_DUAL_ENDSTOPS
if ( axis = = Z_AXIS ) In_Homing_Process ( true ) ;
if ( axis = = Z_AXIS ) In_Homing_Process ( true ) ;
# endif
# endif
@ -1614,14 +1623,22 @@ static void homeaxis(AxisEnum axis) {
endstops_hit_on_purpose ( ) ; // clear endstop hit flags
endstops_hit_on_purpose ( ) ; // clear endstop hit flags
axis_known_position [ axis ] = true ;
axis_known_position [ axis ] = true ;
// Retract Servo endstop if enabled
# if SERVO_LEVELING && !defined(Z_PROBE_SLED)
# ifdef SERVO_ENDSTOPS
if ( servo_endstops [ axis ] > - 1 )
// Deploy a probe if there is one, and homing towards the bed
servo [ servo_endstops [ axis ] ] . write ( servo_endstop_angles [ axis * 2 + 1 ] ) ;
if ( axis = = Z_AXIS ) {
if ( axis_home_dir < 0 ) stow_z_probe ( ) ;
}
else
# endif
# endif
# if SERVO_LEVELING && !defined(Z_PROBE_SLED)
# ifdef SERVO_ENDSTOPS
if ( axis = = Z_AXIS ) stow_z_probe ( ) ;
{
// Retract Servo endstop if enabled
if ( servo_endstops [ axis ] > - 1 )
servo [ servo_endstops [ axis ] ] . write ( servo_endstop_angles [ axis * 2 + 1 ] ) ;
}
# endif
# endif
}
}
@ -2998,7 +3015,7 @@ inline void gcode_M42() {
current_position [ E_AXIS ] = E_current = st_get_position_mm ( E_AXIS ) ;
current_position [ E_AXIS ] = E_current = st_get_position_mm ( E_AXIS ) ;
//
//
// OK, do the init al probe to get us close to the bed.
// OK, do the init i al probe to get us close to the bed.
// Then retrace the right amount and use that in subsequent probes
// Then retrace the right amount and use that in subsequent probes
//
//
@ -3107,12 +3124,14 @@ inline void gcode_M42() {
plan_buffer_line ( X_probe_location , Y_probe_location , Z_start_location , current_position [ E_AXIS ] , homing_feedrate [ Z_AXIS ] / 60 , active_extruder ) ;
plan_buffer_line ( X_probe_location , Y_probe_location , Z_start_location , current_position [ E_AXIS ] , homing_feedrate [ Z_AXIS ] / 60 , active_extruder ) ;
st_synchronize ( ) ;
st_synchronize ( ) ;
// Stow between
if ( deploy_probe_for_each_reading ) {
if ( deploy_probe_for_each_reading ) {
stow_z_probe ( ) ;
stow_z_probe ( ) ;
delay ( 1000 ) ;
delay ( 1000 ) ;
}
}
}
}
// Stow after
if ( ! deploy_probe_for_each_reading ) {
if ( ! deploy_probe_for_each_reading ) {
stow_z_probe ( ) ;
stow_z_probe ( ) ;
delay ( 1000 ) ;
delay ( 1000 ) ;
@ -4064,13 +4083,14 @@ inline void gcode_M226() {
if ( code_seen ( ' S ' ) ) {
if ( code_seen ( ' S ' ) ) {
servo_position = code_value ( ) ;
servo_position = code_value ( ) ;
if ( ( servo_index > = 0 ) & & ( servo_index < NUM_SERVOS ) ) {
if ( ( servo_index > = 0 ) & & ( servo_index < NUM_SERVOS ) ) {
Servo * srv = & servo [ servo_index ] ;
# if SERVO_LEVELING
# if SERVO_LEVELING
s ervo[ servo_index ] . attach ( 0 ) ;
s rv- > attach ( 0 ) ;
# endif
# endif
s ervo[ servo_index ] . write ( servo_position ) ;
s rv- > write ( servo_position ) ;
# if SERVO_LEVELING
# if SERVO_LEVELING
delay ( PROBE_SERVO_DEACTIVATION_DELAY ) ;
delay ( PROBE_SERVO_DEACTIVATION_DELAY ) ;
s ervo[ servo_index ] . detach ( ) ;
s rv- > detach ( ) ;
# endif
# endif
}
}
else {
else {
@ -4374,12 +4394,12 @@ inline void gcode_M303() {
*/
*/
inline void gcode_M400 ( ) { st_synchronize ( ) ; }
inline void gcode_M400 ( ) { st_synchronize ( ) ; }
# if defined(ENABLE_AUTO_BED_LEVELING) && (defined(SERVO_ENDSTOPS) || defined(Z_PROBE_ALLEN_KEY)) && not defined(Z_PROBE_SLED )
# if defined(ENABLE_AUTO_BED_LEVELING) && !defined(Z_PROBE_SLED) && (defined(SERVO_ENDSTOPS) || defined(Z_PROBE_ALLEN_KEY))
# ifdef SERVO_ENDSTOPS
# ifdef SERVO_ENDSTOPS
void raise_z_for_servo ( ) {
void raise_z_for_servo ( ) {
float zpos = current_position [ Z_AXIS ] , z_dest = Z_RAISE_BEFORE_HOMING ;
float zpos = current_position [ Z_AXIS ] , z_dest = Z_RAISE_BEFORE_HOMING ;
if ( ! axis_known_position [ Z_AXIS ] ) z_dest + = zpos ;
z_dest + = axis_known_position [ Z_AXIS ] ? - zprobe_zoffset : zpos ;
if ( zpos < z_dest )
if ( zpos < z_dest )
do_blocking_move_to ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , z_dest ) ; // also updates current_position
do_blocking_move_to ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , z_dest ) ; // also updates current_position
}
}
@ -4402,7 +4422,7 @@ inline void gcode_M400() { st_synchronize(); }
# ifdef SERVO_ENDSTOPS
# ifdef SERVO_ENDSTOPS
raise_z_for_servo ( ) ;
raise_z_for_servo ( ) ;
# endif
# endif
stow_z_probe ( ) ;
stow_z_probe ( false ) ;
}
}
# endif
# endif