|
@@ -261,7 +261,7 @@
|
261
|
261
|
#if HAS_ABL
|
262
|
262
|
#include "vector_3.h"
|
263
|
263
|
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
264
|
|
- #include "qr_solve.h"
|
|
264
|
+ #include "least_squares_fit.h"
|
265
|
265
|
#endif
|
266
|
266
|
#elif ENABLED(MESH_BED_LEVELING)
|
267
|
267
|
#include "mesh_bed_leveling.h"
|
|
@@ -4336,8 +4336,8 @@ void home_all_axes() { gcode_G28(true); }
|
4336
|
4336
|
ABL_VAR int indexIntoAB[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
|
4337
|
4337
|
|
4338
|
4338
|
ABL_VAR float eqnAMatrix[GRID_MAX_POINTS * 3], // "A" matrix of the linear system of equations
|
4339
|
|
- eqnBVector[GRID_MAX_POINTS], // "B" vector of Z points
|
4340
|
|
- mean;
|
|
4339
|
+ eqnBVector[GRID_MAX_POINTS], // "B" vector of Z points
|
|
4340
|
+ mean;
|
4341
|
4341
|
#endif
|
4342
|
4342
|
|
4343
|
4343
|
#elif ENABLED(AUTO_BED_LEVELING_3POINT)
|
|
@@ -4353,6 +4353,11 @@ void home_all_axes() { gcode_G28(true); }
|
4353
|
4353
|
|
4354
|
4354
|
#endif // AUTO_BED_LEVELING_3POINT
|
4355
|
4355
|
|
|
4356
|
+ #if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
|
4357
|
+ struct linear_fit_data lsf_results;
|
|
4358
|
+ incremental_LSF_reset(&lsf_results);
|
|
4359
|
+ #endif
|
|
4360
|
+
|
4356
|
4361
|
/**
|
4357
|
4362
|
* On the initial G29 fetch command parameters.
|
4358
|
4363
|
*/
|
|
@@ -4549,11 +4554,7 @@ void home_all_axes() { gcode_G28(true); }
|
4549
|
4554
|
abl_should_enable = false;
|
4550
|
4555
|
}
|
4551
|
4556
|
|
4552
|
|
- #elif ENABLED(AUTO_BED_LEVELING_LINEAR)
|
4553
|
|
-
|
4554
|
|
- mean = 0.0;
|
4555
|
|
-
|
4556
|
|
- #endif // AUTO_BED_LEVELING_LINEAR
|
|
4557
|
+ #endif // AUTO_BED_LEVELING_BILINEAR
|
4557
|
4558
|
|
4558
|
4559
|
#if ENABLED(AUTO_BED_LEVELING_3POINT)
|
4559
|
4560
|
|
|
@@ -4616,11 +4617,11 @@ void home_all_axes() { gcode_G28(true); }
|
4616
|
4617
|
|
4617
|
4618
|
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
4618
|
4619
|
|
4619
|
|
- mean += measured_z;
|
4620
|
|
- eqnBVector[abl_probe_index] = measured_z;
|
4621
|
|
- eqnAMatrix[abl_probe_index + 0 * abl2] = xProbe;
|
4622
|
|
- eqnAMatrix[abl_probe_index + 1 * abl2] = yProbe;
|
4623
|
|
- eqnAMatrix[abl_probe_index + 2 * abl2] = 1;
|
|
4620
|
+// mean += measured_z; // I believe this is unused code?
|
|
4621
|
+// eqnBVector[abl_probe_index] = measured_z; // I believe this is unused code?
|
|
4622
|
+// eqnAMatrix[abl_probe_index + 0 * abl2] = xProbe; // I believe this is unused code?
|
|
4623
|
+// eqnAMatrix[abl_probe_index + 1 * abl2] = yProbe; // I believe this is unused code?
|
|
4624
|
+// eqnAMatrix[abl_probe_index + 2 * abl2] = 1; // I believe this is unused code?
|
4624
|
4625
|
|
4625
|
4626
|
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
4626
|
4627
|
|
|
@@ -4794,6 +4795,11 @@ void home_all_axes() { gcode_G28(true); }
|
4794
|
4795
|
eqnAMatrix[abl_probe_index + 1 * abl2] = yProbe;
|
4795
|
4796
|
eqnAMatrix[abl_probe_index + 2 * abl2] = 1;
|
4796
|
4797
|
|
|
4798
|
+ incremental_LSF(&lsf_results, xProbe, yProbe, measured_z);
|
|
4799
|
+
|
|
4800
|
+ #if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
|
4801
|
+ indexIntoAB[xCount][yCount] = abl_probe_index;
|
|
4802
|
+ #endif
|
4797
|
4803
|
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
4798
|
4804
|
|
4799
|
4805
|
z_values[xCount][yCount] = measured_z + zoffset;
|
|
@@ -4894,7 +4900,11 @@ void home_all_axes() { gcode_G28(true); }
|
4894
|
4900
|
* so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
|
4895
|
4901
|
*/
|
4896
|
4902
|
float plane_equation_coefficients[3];
|
4897
|
|
- qr_solve(plane_equation_coefficients, abl2, 3, eqnAMatrix, eqnBVector);
|
|
4903
|
+
|
|
4904
|
+ finish_incremental_LSF(&lsf_results);
|
|
4905
|
+ plane_equation_coefficients[0] = -lsf_results.A; // We should be able to eliminate the '-' on these three lines and down below
|
|
4906
|
+ plane_equation_coefficients[1] = -lsf_results.B; // but that is not yet tested.
|
|
4907
|
+ plane_equation_coefficients[2] = -lsf_results.D;
|
4898
|
4908
|
|
4899
|
4909
|
mean /= abl2;
|
4900
|
4910
|
|
|
@@ -4916,7 +4926,7 @@ void home_all_axes() { gcode_G28(true); }
|
4916
|
4926
|
// Create the matrix but don't correct the position yet
|
4917
|
4927
|
if (!dryrun) {
|
4918
|
4928
|
planner.bed_level_matrix = matrix_3x3::create_look_at(
|
4919
|
|
- vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1)
|
|
4929
|
+ vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1) // We can eleminate the '-' here and up above
|
4920
|
4930
|
);
|
4921
|
4931
|
}
|
4922
|
4932
|
|