|
@@ -846,7 +846,36 @@ static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
|
846
|
846
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
847
|
847
|
}
|
848
|
848
|
|
849
|
|
-#else
|
|
849
|
+#else // not ACCURATE_BED_LEVELING
|
|
850
|
+
|
|
851
|
+ #ifdef AUTO_BED_LEVELING_ANY_POINTS
|
|
852
|
+static void set_bed_level_equation_any_pts(float z_at_pt_1, float z_at_pt_2, float z_at_pt_3) {
|
|
853
|
+
|
|
854
|
+ plan_bed_level_matrix.set_to_identity();
|
|
855
|
+
|
|
856
|
+ vector_3 pt1 = vector_3(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, z_at_pt_1);
|
|
857
|
+ vector_3 pt2 = vector_3(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, z_at_pt_2);
|
|
858
|
+ vector_3 pt3 = vector_3(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, z_at_pt_3);
|
|
859
|
+
|
|
860
|
+ vector_3 from_2_to_1 = (pt1 - pt2).get_normal();
|
|
861
|
+ vector_3 from_2_to_3 = (pt3 - pt2).get_normal();
|
|
862
|
+ vector_3 planeNormal = vector_3::cross(from_2_to_1, from_2_to_3).get_normal();
|
|
863
|
+ planeNormal = vector_3(planeNormal.x, planeNormal.y, abs(planeNormal.z));
|
|
864
|
+
|
|
865
|
+ plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
|
|
866
|
+
|
|
867
|
+ vector_3 corrected_position = plan_get_position();
|
|
868
|
+ current_position[X_AXIS] = corrected_position.x;
|
|
869
|
+ current_position[Y_AXIS] = corrected_position.y;
|
|
870
|
+ current_position[Z_AXIS] = corrected_position.z;
|
|
871
|
+
|
|
872
|
+ // but the bed at 0 so we don't go below it.
|
|
873
|
+ current_position[Z_AXIS] = zprobe_zoffset;
|
|
874
|
+
|
|
875
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
876
|
+
|
|
877
|
+}
|
|
878
|
+ #else // not AUTO_BED_LEVELING_ANY_POINTS
|
850
|
879
|
static void set_bed_level_equation(float z_at_xLeft_yFront, float z_at_xRight_yFront, float z_at_xLeft_yBack) {
|
851
|
880
|
plan_bed_level_matrix.set_to_identity();
|
852
|
881
|
|
|
@@ -881,6 +910,7 @@ static void set_bed_level_equation(float z_at_xLeft_yFront, float z_at_xRight_yF
|
881
|
910
|
|
882
|
911
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
883
|
912
|
}
|
|
913
|
+ #endif // AUTO_BED_LEVELING_ANY_POINTS
|
884
|
914
|
#endif // ACCURATE_BED_LEVELING
|
885
|
915
|
|
886
|
916
|
static void run_z_probe() {
|
|
@@ -1514,6 +1544,21 @@ void process_commands()
|
1514
|
1544
|
#else // ACCURATE_BED_LEVELING not defined
|
1515
|
1545
|
|
1516
|
1546
|
|
|
1547
|
+ #ifdef AUTO_BED_LEVELING_ANY_POINTS
|
|
1548
|
+ // probe 1
|
|
1549
|
+ float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING);
|
|
1550
|
+
|
|
1551
|
+ // probe 2
|
|
1552
|
+ 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);
|
|
1553
|
+
|
|
1554
|
+ // probe 3
|
|
1555
|
+ 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);
|
|
1556
|
+
|
|
1557
|
+ clean_up_after_endstop_move();
|
|
1558
|
+
|
|
1559
|
+ set_bed_level_equation_any_pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
|
|
1560
|
+ #else // not AUTO_BED_LEVELING_ANY_POINTS
|
|
1561
|
+
|
1517
|
1562
|
// prob 1
|
1518
|
1563
|
float z_at_xLeft_yBack = probe_pt(LEFT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION, Z_RAISE_BEFORE_PROBING);
|
1519
|
1564
|
|
|
@@ -1526,7 +1571,7 @@ void process_commands()
|
1526
|
1571
|
clean_up_after_endstop_move();
|
1527
|
1572
|
|
1528
|
1573
|
set_bed_level_equation(z_at_xLeft_yFront, z_at_xRight_yFront, z_at_xLeft_yBack);
|
1529
|
|
-
|
|
1574
|
+ #endif
|
1530
|
1575
|
|
1531
|
1576
|
#endif // ACCURATE_BED_LEVELING
|
1532
|
1577
|
st_synchronize();
|