@ -29,12 +29,12 @@
# include "Marlin.h"
# include "Marlin.h"
# ifdef ENABLE_AUTO_BED_ COMPENSATION
# ifdef ENABLE_AUTO_BED_ LEVELING
# include "vector_3.h"
# include "vector_3.h"
# ifdef AUTO_BED_ COMPENSATION _GRID
# ifdef AUTO_BED_ LEVELING _GRID
# include "qr_solve.h"
# include "qr_solve.h"
# endif
# endif
# endif // ENABLE_AUTO_BED_ COMPENSATION
# endif // ENABLE_AUTO_BED_ LEVELING
# include "ultralcd.h"
# include "ultralcd.h"
# include "planner.h"
# include "planner.h"
@ -525,7 +525,7 @@ void servo_init()
}
}
# endif
# endif
# if defined (ENABLE_AUTO_BED_ COMPENSATION ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
# if defined (ENABLE_AUTO_BED_ LEVELING ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
delay ( PROBE_SERVO_DEACTIVATION_DELAY ) ;
delay ( PROBE_SERVO_DEACTIVATION_DELAY ) ;
servos [ servo_endstops [ Z_AXIS ] ] . detach ( ) ;
servos [ servo_endstops [ Z_AXIS ] ] . detach ( ) ;
# endif
# endif
@ -967,16 +967,16 @@ static void axis_is_at_home(int axis) {
# endif
# endif
}
}
# ifdef ENABLE_AUTO_BED_ COMPENSATION
# ifdef ENABLE_AUTO_BED_ LEVELING
# ifdef AUTO_BED_ COMPENSATION _GRID
# ifdef AUTO_BED_ LEVELING _GRID
static void set_bed_ compensation _equation_lsq( double * plane_equation_coefficients )
static void set_bed_ level _equation_lsq( double * plane_equation_coefficients )
{
{
vector_3 planeNormal = vector_3 ( - plane_equation_coefficients [ 0 ] , - plane_equation_coefficients [ 1 ] , 1 ) ;
vector_3 planeNormal = vector_3 ( - plane_equation_coefficients [ 0 ] , - plane_equation_coefficients [ 1 ] , 1 ) ;
planeNormal . debug ( " planeNormal " ) ;
planeNormal . debug ( " planeNormal " ) ;
plan_bed_ compensation _matrix = matrix_3x3 : : create_look_at ( planeNormal ) ;
plan_bed_ level _matrix = matrix_3x3 : : create_look_at ( planeNormal ) ;
//bed Compensation.debug("bedCompensation ");
//bed Level.debug("bedLevel ");
//plan_bed_ compensation_matrix.debug("bed compensation before");
//plan_bed_ level_matrix.debug("bed level before");
//vector_3 uncorrected_position = plan_get_position_mm();
//vector_3 uncorrected_position = plan_get_position_mm();
//uncorrected_position.debug("position before");
//uncorrected_position.debug("position before");
@ -992,11 +992,11 @@ static void set_bed_compensation_equation_lsq(double *plane_equation_coefficient
plan_set_position ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , current_position [ Z_AXIS ] , current_position [ E_AXIS ] ) ;
plan_set_position ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , current_position [ Z_AXIS ] , current_position [ E_AXIS ] ) ;
}
}
# else // not AUTO_BED_ COMPENSATION _GRID
# else // not AUTO_BED_ LEVELING _GRID
static void set_bed_ compensation _equation_3pts( float z_at_pt_1 , float z_at_pt_2 , float z_at_pt_3 ) {
static void set_bed_ level _equation_3pts( float z_at_pt_1 , float z_at_pt_2 , float z_at_pt_3 ) {
plan_bed_ compensation _matrix. set_to_identity ( ) ;
plan_bed_ level _matrix. set_to_identity ( ) ;
vector_3 pt1 = vector_3 ( ABL_PROBE_PT_1_X , ABL_PROBE_PT_1_Y , z_at_pt_1 ) ;
vector_3 pt1 = vector_3 ( ABL_PROBE_PT_1_X , ABL_PROBE_PT_1_Y , z_at_pt_1 ) ;
vector_3 pt2 = vector_3 ( ABL_PROBE_PT_2_X , ABL_PROBE_PT_2_Y , z_at_pt_2 ) ;
vector_3 pt2 = vector_3 ( ABL_PROBE_PT_2_X , ABL_PROBE_PT_2_Y , z_at_pt_2 ) ;
@ -1007,7 +1007,7 @@ static void set_bed_compensation_equation_3pts(float z_at_pt_1, float z_at_pt_2,
vector_3 planeNormal = vector_3 : : cross ( from_2_to_1 , from_2_to_3 ) . get_normal ( ) ;
vector_3 planeNormal = vector_3 : : cross ( from_2_to_1 , from_2_to_3 ) . get_normal ( ) ;
planeNormal = vector_3 ( planeNormal . x , planeNormal . y , abs ( planeNormal . z ) ) ;
planeNormal = vector_3 ( planeNormal . x , planeNormal . y , abs ( planeNormal . z ) ) ;
plan_bed_ compensation _matrix = matrix_3x3 : : create_look_at ( planeNormal ) ;
plan_bed_ level _matrix = matrix_3x3 : : create_look_at ( planeNormal ) ;
vector_3 corrected_position = plan_get_position ( ) ;
vector_3 corrected_position = plan_get_position ( ) ;
current_position [ X_AXIS ] = corrected_position . x ;
current_position [ X_AXIS ] = corrected_position . x ;
@ -1021,10 +1021,10 @@ static void set_bed_compensation_equation_3pts(float z_at_pt_1, float z_at_pt_2,
}
}
# endif // AUTO_BED_ COMPENSATION _GRID
# endif // AUTO_BED_ LEVELING _GRID
static void run_z_probe ( ) {
static void run_z_probe ( ) {
plan_bed_ compensation _matrix. set_to_identity ( ) ;
plan_bed_ level _matrix. set_to_identity ( ) ;
feedrate = homing_feedrate [ Z_AXIS ] ;
feedrate = homing_feedrate [ Z_AXIS ] ;
// move down until you find the bed
// move down until you find the bed
@ -1098,11 +1098,11 @@ static void engage_z_probe() {
// Engage Z Servo endstop if enabled
// Engage Z Servo endstop if enabled
# ifdef SERVO_ENDSTOPS
# ifdef SERVO_ENDSTOPS
if ( servo_endstops [ Z_AXIS ] > - 1 ) {
if ( servo_endstops [ Z_AXIS ] > - 1 ) {
# if defined (ENABLE_AUTO_BED_ COMPENSATION ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
# if defined (ENABLE_AUTO_BED_ LEVELING ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
servos [ servo_endstops [ Z_AXIS ] ] . attach ( 0 ) ;
servos [ servo_endstops [ Z_AXIS ] ] . attach ( 0 ) ;
# endif
# endif
servos [ servo_endstops [ Z_AXIS ] ] . write ( servo_endstop_angles [ Z_AXIS * 2 ] ) ;
servos [ servo_endstops [ Z_AXIS ] ] . write ( servo_endstop_angles [ Z_AXIS * 2 ] ) ;
# if defined (ENABLE_AUTO_BED_ COMPENSATION ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
# if defined (ENABLE_AUTO_BED_ LEVELING ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
delay ( PROBE_SERVO_DEACTIVATION_DELAY ) ;
delay ( PROBE_SERVO_DEACTIVATION_DELAY ) ;
servos [ servo_endstops [ Z_AXIS ] ] . detach ( ) ;
servos [ servo_endstops [ Z_AXIS ] ] . detach ( ) ;
# endif
# endif
@ -1114,11 +1114,11 @@ static void retract_z_probe() {
// Retract Z Servo endstop if enabled
// Retract Z Servo endstop if enabled
# ifdef SERVO_ENDSTOPS
# ifdef SERVO_ENDSTOPS
if ( servo_endstops [ Z_AXIS ] > - 1 ) {
if ( servo_endstops [ Z_AXIS ] > - 1 ) {
# if defined (ENABLE_AUTO_BED_ COMPENSATION ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
# if defined (ENABLE_AUTO_BED_ LEVELING ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
servos [ servo_endstops [ Z_AXIS ] ] . attach ( 0 ) ;
servos [ servo_endstops [ Z_AXIS ] ] . attach ( 0 ) ;
# endif
# endif
servos [ servo_endstops [ Z_AXIS ] ] . write ( servo_endstop_angles [ Z_AXIS * 2 + 1 ] ) ;
servos [ servo_endstops [ Z_AXIS ] ] . write ( servo_endstop_angles [ Z_AXIS * 2 + 1 ] ) ;
# if defined (ENABLE_AUTO_BED_ COMPENSATION ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
# if defined (ENABLE_AUTO_BED_ LEVELING ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
delay ( PROBE_SERVO_DEACTIVATION_DELAY ) ;
delay ( PROBE_SERVO_DEACTIVATION_DELAY ) ;
servos [ servo_endstops [ Z_AXIS ] ] . detach ( ) ;
servos [ servo_endstops [ Z_AXIS ] ] . detach ( ) ;
# endif
# endif
@ -1152,7 +1152,7 @@ static float probe_pt(float x, float y, float z_before) {
return measured_z ;
return measured_z ;
}
}
# endif // #ifdef ENABLE_AUTO_BED_ COMPENSATION
# endif // #ifdef ENABLE_AUTO_BED_ LEVELING
static void homeaxis ( int axis ) {
static void homeaxis ( int axis ) {
# define HOMEAXIS_DO(LETTER) \
# define HOMEAXIS_DO(LETTER) \
@ -1175,7 +1175,7 @@ static void homeaxis(int axis) {
# ifndef Z_PROBE_SLED
# ifndef Z_PROBE_SLED
// Engage Servo endstop if enabled
// Engage Servo endstop if enabled
# ifdef SERVO_ENDSTOPS
# ifdef SERVO_ENDSTOPS
# if defined (ENABLE_AUTO_BED_ COMPENSATION ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
# if defined (ENABLE_AUTO_BED_ LEVELING ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
if ( axis = = Z_AXIS ) {
if ( axis = = Z_AXIS ) {
engage_z_probe ( ) ;
engage_z_probe ( ) ;
}
}
@ -1226,7 +1226,7 @@ static void homeaxis(int axis) {
servos [ servo_endstops [ axis ] ] . write ( servo_endstop_angles [ axis * 2 + 1 ] ) ;
servos [ servo_endstops [ axis ] ] . write ( servo_endstop_angles [ axis * 2 + 1 ] ) ;
}
}
# endif
# endif
# if defined (ENABLE_AUTO_BED_ COMPENSATION ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
# if defined (ENABLE_AUTO_BED_ LEVELING ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
# ifndef Z_PROBE_SLED
# ifndef Z_PROBE_SLED
if ( axis = = Z_AXIS ) retract_z_probe ( ) ;
if ( axis = = Z_AXIS ) retract_z_probe ( ) ;
# endif
# endif
@ -1335,7 +1335,7 @@ void process_commands()
{
{
unsigned long codenum ; //throw away variable
unsigned long codenum ; //throw away variable
char * starpos = NULL ;
char * starpos = NULL ;
# ifdef ENABLE_AUTO_BED_ COMPENSATION
# ifdef ENABLE_AUTO_BED_ LEVELING
float x_tmp , y_tmp , z_tmp , real_z ;
float x_tmp , y_tmp , z_tmp , real_z ;
# endif
# endif
if ( code_seen ( ' G ' ) )
if ( code_seen ( ' G ' ) )
@ -1409,9 +1409,9 @@ void process_commands()
break ;
break ;
# endif //FWRETRACT
# endif //FWRETRACT
case 28 : //G28 Home all Axis one at a time
case 28 : //G28 Home all Axis one at a time
# ifdef ENABLE_AUTO_BED_ COMPENSATION
# ifdef ENABLE_AUTO_BED_ LEVELING
plan_bed_ compensation _matrix. set_to_identity ( ) ; //Reset the plane ("erase" all compensation data)
plan_bed_ level _matrix. set_to_identity ( ) ; //Reset the plane ("erase" all leveling data)
# endif //ENABLE_AUTO_BED_ COMPENSATION
# endif //ENABLE_AUTO_BED_ LEVELING
saved_feedrate = feedrate ;
saved_feedrate = feedrate ;
saved_feedmultiply = feedmultiply ;
saved_feedmultiply = feedmultiply ;
@ -1615,7 +1615,7 @@ void process_commands()
current_position [ Z_AXIS ] = code_value ( ) + add_homing [ Z_AXIS ] ;
current_position [ Z_AXIS ] = code_value ( ) + add_homing [ Z_AXIS ] ;
}
}
}
}
# ifdef ENABLE_AUTO_BED_ COMPENSATION
# ifdef ENABLE_AUTO_BED_ LEVELING
if ( ( home_all_axis ) | | ( code_seen ( axis_codes [ Z_AXIS ] ) ) ) {
if ( ( home_all_axis ) | | ( code_seen ( axis_codes [ Z_AXIS ] ) ) ) {
current_position [ Z_AXIS ] + = zprobe_zoffset ; //Add Z_Probe offset (the distance is negative)
current_position [ Z_AXIS ] + = zprobe_zoffset ; //Add Z_Probe offset (the distance is negative)
}
}
@ -1638,11 +1638,11 @@ void process_commands()
endstops_hit_on_purpose ( ) ;
endstops_hit_on_purpose ( ) ;
break ;
break ;
# ifdef ENABLE_AUTO_BED_ COMPENSATION
# ifdef ENABLE_AUTO_BED_ LEVELING
case 29 : // G29 Detailed Z-Probe, probes the bed at 3 or more points.
case 29 : // G29 Detailed Z-Probe, probes the bed at 3 or more points.
{
{
# if Z_MIN_PIN == -1
# if Z_MIN_PIN == -1
# error "You must have a Z_MIN endstop in order to enable Auto Bed Compensation feature!!! Z_MIN_PIN must point to a valid hardware pin."
# error "You must have a Z_MIN endstop in order to enable Auto Bed Leveling feature!!! Z_MIN_PIN must point to a valid hardware pin."
# endif
# endif
// Prevent user from running a G29 without first homing in X and Y
// Prevent user from running a G29 without first homing in X and Y
@ -1658,10 +1658,10 @@ void process_commands()
dock_sled ( false ) ;
dock_sled ( false ) ;
# endif // Z_PROBE_SLED
# endif // Z_PROBE_SLED
st_synchronize ( ) ;
st_synchronize ( ) ;
// make sure the bed_ compensation _rotation_matrix is identity or the planner will get it incorectly
// make sure the bed_ level _rotation_matrix is identity or the planner will get it incorectly
//vector_3 corrected_position = plan_get_position_mm();
//vector_3 corrected_position = plan_get_position_mm();
//corrected_position.debug("position before G29");
//corrected_position.debug("position before G29");
plan_bed_ compensation _matrix. set_to_identity ( ) ;
plan_bed_ level _matrix. set_to_identity ( ) ;
vector_3 uncorrected_position = plan_get_position ( ) ;
vector_3 uncorrected_position = plan_get_position ( ) ;
//uncorrected_position.debug("position durring G29");
//uncorrected_position.debug("position durring G29");
current_position [ X_AXIS ] = uncorrected_position . x ;
current_position [ X_AXIS ] = uncorrected_position . x ;
@ -1671,11 +1671,11 @@ void process_commands()
setup_for_endstop_move ( ) ;
setup_for_endstop_move ( ) ;
feedrate = homing_feedrate [ Z_AXIS ] ;
feedrate = homing_feedrate [ Z_AXIS ] ;
# ifdef AUTO_BED_ COMPENSATION _GRID
# ifdef AUTO_BED_ LEVELING _GRID
// probe at the points of a lattice grid
// probe at the points of a lattice grid
int xGridSpacing = ( RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION ) / ( AUTO_BED_ COMPENSATION _GRID_POINTS- 1 ) ;
int xGridSpacing = ( RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION ) / ( AUTO_BED_ LEVELING _GRID_POINTS- 1 ) ;
int yGridSpacing = ( BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION ) / ( AUTO_BED_ COMPENSATION _GRID_POINTS- 1 ) ;
int yGridSpacing = ( BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION ) / ( AUTO_BED_ LEVELING _GRID_POINTS- 1 ) ;
// solve the plane equation ax + by + d = z
// solve the plane equation ax + by + d = z
@ -1685,9 +1685,9 @@ void process_commands()
// so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
// so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
// "A" matrix of the linear system of equations
// "A" matrix of the linear system of equations
double eqnAMatrix [ AUTO_BED_ COMPENSATION_GRID_POINTS* AUTO_BED_COMPENSATION _GRID_POINTS* 3 ] ;
double eqnAMatrix [ AUTO_BED_ LEVELING_GRID_POINTS* AUTO_BED_LEVELING _GRID_POINTS* 3 ] ;
// "B" vector of Z points
// "B" vector of Z points
double eqnBVector [ AUTO_BED_ COMPENSATION_GRID_POINTS* AUTO_BED_COMPENSATION _GRID_POINTS] ;
double eqnBVector [ AUTO_BED_ LEVELING_GRID_POINTS* AUTO_BED_LEVELING _GRID_POINTS] ;
int probePointCounter = 0 ;
int probePointCounter = 0 ;
@ -1710,7 +1710,7 @@ void process_commands()
zig = true ;
zig = true ;
}
}
for ( int xCount = 0 ; xCount < AUTO_BED_ COMPENSATION _GRID_POINTS; xCount + + )
for ( int xCount = 0 ; xCount < AUTO_BED_ LEVELING _GRID_POINTS; xCount + + )
{
{
float z_before ;
float z_before ;
if ( probePointCounter = = 0 )
if ( probePointCounter = = 0 )
@ -1727,9 +1727,9 @@ void process_commands()
eqnBVector [ probePointCounter ] = measured_z ;
eqnBVector [ probePointCounter ] = measured_z ;
eqnAMatrix [ probePointCounter + 0 * AUTO_BED_ COMPENSATION_GRID_POINTS* AUTO_BED_COMPENSATION _GRID_POINTS] = xProbe ;
eqnAMatrix [ probePointCounter + 0 * AUTO_BED_ LEVELING_GRID_POINTS* AUTO_BED_LEVELING _GRID_POINTS] = xProbe ;
eqnAMatrix [ probePointCounter + 1 * AUTO_BED_ COMPENSATION_GRID_POINTS* AUTO_BED_COMPENSATION _GRID_POINTS] = yProbe ;
eqnAMatrix [ probePointCounter + 1 * AUTO_BED_ LEVELING_GRID_POINTS* AUTO_BED_LEVELING _GRID_POINTS] = yProbe ;
eqnAMatrix [ probePointCounter + 2 * AUTO_BED_ COMPENSATION_GRID_POINTS* AUTO_BED_COMPENSATION _GRID_POINTS] = 1 ;
eqnAMatrix [ probePointCounter + 2 * AUTO_BED_ LEVELING_GRID_POINTS* AUTO_BED_LEVELING _GRID_POINTS] = 1 ;
probePointCounter + + ;
probePointCounter + + ;
xProbe + = xInc ;
xProbe + = xInc ;
}
}
@ -1737,7 +1737,7 @@ void process_commands()
clean_up_after_endstop_move ( ) ;
clean_up_after_endstop_move ( ) ;
// solve lsq problem
// solve lsq problem
double * plane_equation_coefficients = qr_solve ( AUTO_BED_ COMPENSATION_GRID_POINTS* AUTO_BED_COMPENSATION _GRID_POINTS, 3 , eqnAMatrix , eqnBVector ) ;
double * plane_equation_coefficients = qr_solve ( AUTO_BED_ LEVELING_GRID_POINTS* AUTO_BED_LEVELING _GRID_POINTS, 3 , eqnAMatrix , eqnBVector ) ;
SERIAL_PROTOCOLPGM ( " Eqn coefficients: a: " ) ;
SERIAL_PROTOCOLPGM ( " Eqn coefficients: a: " ) ;
SERIAL_PROTOCOL ( plane_equation_coefficients [ 0 ] ) ;
SERIAL_PROTOCOL ( plane_equation_coefficients [ 0 ] ) ;
@ -1747,11 +1747,11 @@ void process_commands()
SERIAL_PROTOCOLLN ( plane_equation_coefficients [ 2 ] ) ;
SERIAL_PROTOCOLLN ( plane_equation_coefficients [ 2 ] ) ;
set_bed_ compensation _equation_lsq( plane_equation_coefficients ) ;
set_bed_ level _equation_lsq( plane_equation_coefficients ) ;
free ( plane_equation_coefficients ) ;
free ( plane_equation_coefficients ) ;
# else // AUTO_BED_ COMPENSATION _GRID not defined
# else // AUTO_BED_ LEVELING _GRID not defined
// Probe at 3 arbitrary points
// Probe at 3 arbitrary points
// probe 1
// probe 1
@ -1765,21 +1765,21 @@ void process_commands()
clean_up_after_endstop_move ( ) ;
clean_up_after_endstop_move ( ) ;
set_bed_ compensation _equation_3pts( z_at_pt_1 , z_at_pt_2 , z_at_pt_3 ) ;
set_bed_ level _equation_3pts( z_at_pt_1 , z_at_pt_2 , z_at_pt_3 ) ;
# endif // AUTO_BED_ COMPENSATION _GRID
# endif // AUTO_BED_ LEVELING _GRID
st_synchronize ( ) ;
st_synchronize ( ) ;
// The following code correct the Z height difference from z-probe position and hotend tip position.
// The following code correct the Z height difference from z-probe position and hotend tip position.
// The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
// The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
// When the bed is uneven, this height must be corrected.
// When the bed is uneven, this height must be corrected.
real_z = float ( st_get_position ( Z_AXIS ) ) / axis_steps_per_unit [ Z_AXIS ] ; //get the real Z (since the auto bed compensation is already correcting the plane)
real_z = float ( st_get_position ( Z_AXIS ) ) / axis_steps_per_unit [ Z_AXIS ] ; //get the real Z (since the auto bed leveling is already correcting the plane)
x_tmp = current_position [ X_AXIS ] + X_PROBE_OFFSET_FROM_EXTRUDER ;
x_tmp = current_position [ X_AXIS ] + X_PROBE_OFFSET_FROM_EXTRUDER ;
y_tmp = current_position [ Y_AXIS ] + Y_PROBE_OFFSET_FROM_EXTRUDER ;
y_tmp = current_position [ Y_AXIS ] + Y_PROBE_OFFSET_FROM_EXTRUDER ;
z_tmp = current_position [ Z_AXIS ] ;
z_tmp = current_position [ Z_AXIS ] ;
apply_rotation_xyz ( plan_bed_ compensation _matrix, x_tmp , y_tmp , z_tmp ) ; //Apply the correction sending the probe offset
apply_rotation_xyz ( plan_bed_ level _matrix, x_tmp , y_tmp , z_tmp ) ; //Apply the correction sending the probe offset
current_position [ Z_AXIS ] = z_tmp - real_z + current_position [ Z_AXIS ] ; //The difference is added to current position and sent to planner.
current_position [ Z_AXIS ] = z_tmp - real_z + current_position [ Z_AXIS ] ; //The difference is added to current position and sent to planner.
plan_set_position ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , current_position [ Z_AXIS ] , current_position [ E_AXIS ] ) ;
plan_set_position ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , current_position [ Z_AXIS ] , current_position [ E_AXIS ] ) ;
# ifdef Z_PROBE_SLED
# ifdef Z_PROBE_SLED
@ -1792,7 +1792,7 @@ void process_commands()
{
{
engage_z_probe ( ) ; // Engage Z Servo endstop if available
engage_z_probe ( ) ; // Engage Z Servo endstop if available
st_synchronize ( ) ;
st_synchronize ( ) ;
// TODO: make sure the bed_ compensation _rotation_matrix is identity or the planner will get set incorectly
// TODO: make sure the bed_ level _rotation_matrix is identity or the planner will get set incorectly
setup_for_endstop_move ( ) ;
setup_for_endstop_move ( ) ;
feedrate = homing_feedrate [ Z_AXIS ] ;
feedrate = homing_feedrate [ Z_AXIS ] ;
@ -1819,7 +1819,7 @@ void process_commands()
dock_sled ( false ) ;
dock_sled ( false ) ;
break ;
break ;
# endif // Z_PROBE_SLED
# endif // Z_PROBE_SLED
# endif // ENABLE_AUTO_BED_ COMPENSATION
# endif // ENABLE_AUTO_BED_ LEVELING
case 90 : // G90
case 90 : // G90
relative_mode = false ;
relative_mode = false ;
break ;
break ;
@ -2078,7 +2078,7 @@ void process_commands()
//
//
// This function assumes the bed has been homed. Specificaly, that a G28 command
// This function assumes the bed has been homed. Specificaly, that a G28 command
// as been issued prior to invoking the M48 Z-Probe repeatability measurement function.
// as been issued prior to invoking the M48 Z-Probe repeatability measurement function.
// Any information generated by a prior G29 Bed compensation command will be lost and need to be
// Any information generated by a prior G29 Bed leveling command will be lost and need to be
// regenerated.
// regenerated.
//
//
// The number of samples will default to 10 if not specified. You can use upper or lower case
// The number of samples will default to 10 if not specified. You can use upper or lower case
@ -2086,7 +2086,7 @@ void process_commands()
// N for its communication protocol and will get horribly confused if you send it a capital N.
// N for its communication protocol and will get horribly confused if you send it a capital N.
//
//
# ifdef ENABLE_AUTO_BED_ COMPENSATION
# ifdef ENABLE_AUTO_BED_ LEVELING
# ifdef Z_PROBE_REPEATABILITY_TEST
# ifdef Z_PROBE_REPEATABILITY_TEST
case 48 : // M48 Z-Probe repeatability
case 48 : // M48 Z-Probe repeatability
@ -2164,7 +2164,7 @@ void process_commands()
//
//
st_synchronize ( ) ;
st_synchronize ( ) ;
plan_bed_ compensation _matrix. set_to_identity ( ) ;
plan_bed_ level _matrix. set_to_identity ( ) ;
plan_buffer_line ( X_current , Y_current , Z_start_location ,
plan_buffer_line ( X_current , Y_current , Z_start_location ,
ext_position ,
ext_position ,
homing_feedrate [ Z_AXIS ] / 60 ,
homing_feedrate [ Z_AXIS ] / 60 ,
@ -2343,7 +2343,7 @@ Sigma_Exit:
break ;
break ;
}
}
# endif // Z_PROBE_REPEATABILITY_TEST
# endif // Z_PROBE_REPEATABILITY_TEST
# endif // ENABLE_AUTO_BED_ COMPENSATION
# endif // ENABLE_AUTO_BED_ LEVELING
case 104 : // M104
case 104 : // M104
if ( setTargetedHotend ( 104 ) ) {
if ( setTargetedHotend ( 104 ) ) {
@ -3104,11 +3104,11 @@ Sigma_Exit:
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 ) ) {
# if defined (ENABLE_AUTO_BED_ COMPENSATION ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
# if defined (ENABLE_AUTO_BED_ LEVELING ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
servos [ servo_index ] . attach ( 0 ) ;
servos [ servo_index ] . attach ( 0 ) ;
# endif
# endif
servos [ servo_index ] . write ( servo_position ) ;
servos [ servo_index ] . write ( servo_position ) ;
# if defined (ENABLE_AUTO_BED_ COMPENSATION ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
# if defined (ENABLE_AUTO_BED_ LEVELING ) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
delay ( PROBE_SERVO_DEACTIVATION_DELAY ) ;
delay ( PROBE_SERVO_DEACTIVATION_DELAY ) ;
servos [ servo_index ] . detach ( ) ;
servos [ servo_index ] . detach ( ) ;
# endif
# endif
@ -3373,7 +3373,7 @@ Sigma_Exit:
st_synchronize ( ) ;
st_synchronize ( ) ;
}
}
break ;
break ;
# if defined(ENABLE_AUTO_BED_ COMPENSATION ) && defined(SERVO_ENDSTOPS) && not defined(Z_PROBE_SLED)
# if defined(ENABLE_AUTO_BED_ LEVELING ) && defined(SERVO_ENDSTOPS) && not defined(Z_PROBE_SLED)
case 401 :
case 401 :
{
{
engage_z_probe ( ) ; // Engage Z Servo endstop if available
engage_z_probe ( ) ; // Engage Z Servo endstop if available