Save 7714 bytes of program memory when doing AUTO_BED_LEVELING_LINEAR (#7276)
We can save more and a pile of RAM by eleminating the eqnBVector and EqnAMatrix arrays next.
This commit is contained in:
parent
e5904c4df8
commit
9af67e2446
5 changed files with 28 additions and 1653 deletions
|
|
@ -261,7 +261,7 @@
|
|||
#if HAS_ABL
|
||||
#include "vector_3.h"
|
||||
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
||||
#include "qr_solve.h"
|
||||
#include "least_squares_fit.h"
|
||||
#endif
|
||||
#elif ENABLED(MESH_BED_LEVELING)
|
||||
#include "mesh_bed_leveling.h"
|
||||
|
|
@ -4336,8 +4336,8 @@ void home_all_axes() { gcode_G28(true); }
|
|||
ABL_VAR int indexIntoAB[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
|
||||
|
||||
ABL_VAR float eqnAMatrix[GRID_MAX_POINTS * 3], // "A" matrix of the linear system of equations
|
||||
eqnBVector[GRID_MAX_POINTS], // "B" vector of Z points
|
||||
mean;
|
||||
eqnBVector[GRID_MAX_POINTS], // "B" vector of Z points
|
||||
mean;
|
||||
#endif
|
||||
|
||||
#elif ENABLED(AUTO_BED_LEVELING_3POINT)
|
||||
|
|
@ -4353,6 +4353,11 @@ void home_all_axes() { gcode_G28(true); }
|
|||
|
||||
#endif // AUTO_BED_LEVELING_3POINT
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
||||
struct linear_fit_data lsf_results;
|
||||
incremental_LSF_reset(&lsf_results);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* On the initial G29 fetch command parameters.
|
||||
*/
|
||||
|
|
@ -4549,11 +4554,7 @@ void home_all_axes() { gcode_G28(true); }
|
|||
abl_should_enable = false;
|
||||
}
|
||||
|
||||
#elif ENABLED(AUTO_BED_LEVELING_LINEAR)
|
||||
|
||||
mean = 0.0;
|
||||
|
||||
#endif // AUTO_BED_LEVELING_LINEAR
|
||||
#endif // AUTO_BED_LEVELING_BILINEAR
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_3POINT)
|
||||
|
||||
|
|
@ -4616,11 +4617,11 @@ void home_all_axes() { gcode_G28(true); }
|
|||
|
||||
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
||||
|
||||
mean += measured_z;
|
||||
eqnBVector[abl_probe_index] = measured_z;
|
||||
eqnAMatrix[abl_probe_index + 0 * abl2] = xProbe;
|
||||
eqnAMatrix[abl_probe_index + 1 * abl2] = yProbe;
|
||||
eqnAMatrix[abl_probe_index + 2 * abl2] = 1;
|
||||
// mean += measured_z; // I believe this is unused code?
|
||||
// eqnBVector[abl_probe_index] = measured_z; // I believe this is unused code?
|
||||
// eqnAMatrix[abl_probe_index + 0 * abl2] = xProbe; // I believe this is unused code?
|
||||
// eqnAMatrix[abl_probe_index + 1 * abl2] = yProbe; // I believe this is unused code?
|
||||
// eqnAMatrix[abl_probe_index + 2 * abl2] = 1; // I believe this is unused code?
|
||||
|
||||
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
|
||||
|
|
@ -4794,6 +4795,11 @@ void home_all_axes() { gcode_G28(true); }
|
|||
eqnAMatrix[abl_probe_index + 1 * abl2] = yProbe;
|
||||
eqnAMatrix[abl_probe_index + 2 * abl2] = 1;
|
||||
|
||||
incremental_LSF(&lsf_results, xProbe, yProbe, measured_z);
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
||||
indexIntoAB[xCount][yCount] = abl_probe_index;
|
||||
#endif
|
||||
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
|
||||
z_values[xCount][yCount] = measured_z + zoffset;
|
||||
|
|
@ -4894,7 +4900,11 @@ void home_all_axes() { gcode_G28(true); }
|
|||
* so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
|
||||
*/
|
||||
float plane_equation_coefficients[3];
|
||||
qr_solve(plane_equation_coefficients, abl2, 3, eqnAMatrix, eqnBVector);
|
||||
|
||||
finish_incremental_LSF(&lsf_results);
|
||||
plane_equation_coefficients[0] = -lsf_results.A; // We should be able to eliminate the '-' on these three lines and down below
|
||||
plane_equation_coefficients[1] = -lsf_results.B; // but that is not yet tested.
|
||||
plane_equation_coefficients[2] = -lsf_results.D;
|
||||
|
||||
mean /= abl2;
|
||||
|
||||
|
|
@ -4916,7 +4926,7 @@ void home_all_axes() { gcode_G28(true); }
|
|||
// Create the matrix but don't correct the position yet
|
||||
if (!dryrun) {
|
||||
planner.bed_level_matrix = matrix_3x3::create_look_at(
|
||||
vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1)
|
||||
vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1) // We can eleminate the '-' here and up above
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue