|
|
@ -846,7 +846,36 @@ static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
|
|
|
|
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
|
|
|
|
#else // not ACCURATE_BED_LEVELING
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef AUTO_BED_LEVELING_ANY_POINTS
|
|
|
|
|
|
|
|
static void set_bed_level_equation_any_pts(float z_at_pt_1, float z_at_pt_2, float z_at_pt_3) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 pt2 = vector_3(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, z_at_pt_2);
|
|
|
|
|
|
|
|
vector_3 pt3 = vector_3(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, z_at_pt_3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vector_3 from_2_to_1 = (pt1 - pt2).get_normal();
|
|
|
|
|
|
|
|
vector_3 from_2_to_3 = (pt3 - pt2).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));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vector_3 corrected_position = plan_get_position();
|
|
|
|
|
|
|
|
current_position[X_AXIS] = corrected_position.x;
|
|
|
|
|
|
|
|
current_position[Y_AXIS] = corrected_position.y;
|
|
|
|
|
|
|
|
current_position[Z_AXIS] = corrected_position.z;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// but the bed at 0 so we don't go below it.
|
|
|
|
|
|
|
|
current_position[Z_AXIS] = zprobe_zoffset;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#else // not AUTO_BED_LEVELING_ANY_POINTS
|
|
|
|
static void set_bed_level_equation(float z_at_xLeft_yFront, float z_at_xRight_yFront, float z_at_xLeft_yBack) {
|
|
|
|
static void set_bed_level_equation(float z_at_xLeft_yFront, float z_at_xRight_yFront, float z_at_xLeft_yBack) {
|
|
|
|
plan_bed_level_matrix.set_to_identity();
|
|
|
|
plan_bed_level_matrix.set_to_identity();
|
|
|
|
|
|
|
|
|
|
|
@ -881,6 +910,7 @@ static void set_bed_level_equation(float z_at_xLeft_yFront, float z_at_xRight_yF
|
|
|
|
|
|
|
|
|
|
|
|
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]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // AUTO_BED_LEVELING_ANY_POINTS
|
|
|
|
#endif // ACCURATE_BED_LEVELING
|
|
|
|
#endif // ACCURATE_BED_LEVELING
|
|
|
|
|
|
|
|
|
|
|
|
static void run_z_probe() {
|
|
|
|
static void run_z_probe() {
|
|
|
@ -1514,6 +1544,21 @@ void process_commands()
|
|
|
|
#else // ACCURATE_BED_LEVELING not defined
|
|
|
|
#else // ACCURATE_BED_LEVELING not defined
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef AUTO_BED_LEVELING_ANY_POINTS
|
|
|
|
|
|
|
|
// probe 1
|
|
|
|
|
|
|
|
float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// probe 2
|
|
|
|
|
|
|
|
float z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// probe 3
|
|
|
|
|
|
|
|
float z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clean_up_after_endstop_move();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set_bed_level_equation_any_pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
|
|
|
|
|
|
|
|
#else // not AUTO_BED_LEVELING_ANY_POINTS
|
|
|
|
|
|
|
|
|
|
|
|
// prob 1
|
|
|
|
// prob 1
|
|
|
|
float z_at_xLeft_yBack = probe_pt(LEFT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION, Z_RAISE_BEFORE_PROBING);
|
|
|
|
float z_at_xLeft_yBack = probe_pt(LEFT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION, Z_RAISE_BEFORE_PROBING);
|
|
|
|
|
|
|
|
|
|
|
@ -1526,7 +1571,7 @@ void process_commands()
|
|
|
|
clean_up_after_endstop_move();
|
|
|
|
clean_up_after_endstop_move();
|
|
|
|
|
|
|
|
|
|
|
|
set_bed_level_equation(z_at_xLeft_yFront, z_at_xRight_yFront, z_at_xLeft_yBack);
|
|
|
|
set_bed_level_equation(z_at_xLeft_yFront, z_at_xRight_yFront, z_at_xLeft_yBack);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#endif // ACCURATE_BED_LEVELING
|
|
|
|
#endif // ACCURATE_BED_LEVELING
|
|
|
|
st_synchronize();
|
|
|
|
st_synchronize();
|
|
|
|