parent
cbdc78ec0f
commit
aa20b3ef7c
|
@ -209,9 +209,9 @@ void GcodeSuite::G29() {
|
|||
#endif
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
||||
ABL_VAR int abl2;
|
||||
ABL_VAR int abl_points;
|
||||
#elif ENABLED(PROBE_MANUALLY) // Bilinear
|
||||
int constexpr abl2 = GRID_MAX_POINTS;
|
||||
int constexpr abl_points = GRID_MAX_POINTS;
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
|
@ -230,7 +230,7 @@ void GcodeSuite::G29() {
|
|||
#elif ENABLED(AUTO_BED_LEVELING_3POINT)
|
||||
|
||||
#if ENABLED(PROBE_MANUALLY)
|
||||
int constexpr abl2 = 3; // used to show total points
|
||||
int constexpr abl_points = 3; // used to show total points
|
||||
#endif
|
||||
|
||||
// Probe at 3 arbitrary points
|
||||
|
@ -342,7 +342,7 @@ void GcodeSuite::G29() {
|
|||
return;
|
||||
}
|
||||
|
||||
abl2 = abl_grid_points_x * abl_grid_points_y;
|
||||
abl_points = abl_grid_points_x * abl_grid_points_y;
|
||||
mean = 0;
|
||||
|
||||
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
|
@ -458,8 +458,8 @@ void GcodeSuite::G29() {
|
|||
if (verbose_level || seenQ) {
|
||||
SERIAL_PROTOCOLPGM("Manual G29 ");
|
||||
if (g29_in_progress) {
|
||||
SERIAL_PROTOCOLPAIR("point ", min(abl_probe_index + 1, abl2));
|
||||
SERIAL_PROTOCOLLNPAIR(" of ", abl2);
|
||||
SERIAL_PROTOCOLPAIR("point ", min(abl_probe_index + 1, abl_points));
|
||||
SERIAL_PROTOCOLLNPAIR(" of ", abl_points);
|
||||
}
|
||||
else
|
||||
SERIAL_PROTOCOLLNPGM("idle");
|
||||
|
@ -474,6 +474,11 @@ void GcodeSuite::G29() {
|
|||
#endif
|
||||
}
|
||||
else {
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_3POINT)
|
||||
const uint16_t index = abl_probe_index - 1;
|
||||
#endif
|
||||
|
||||
// For G29 after adjusting Z.
|
||||
// Save the previous Z before going to the next point
|
||||
measured_z = current_position[Z_AXIS];
|
||||
|
@ -481,13 +486,17 @@ void GcodeSuite::G29() {
|
|||
#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;
|
||||
eqnBVector[index] = measured_z;
|
||||
eqnAMatrix[index + 0 * abl_points] = xProbe;
|
||||
eqnAMatrix[index + 1 * abl_points] = yProbe;
|
||||
eqnAMatrix[index + 2 * abl_points] = 1;
|
||||
|
||||
incremental_LSF(&lsf_results, xProbe, yProbe, measured_z);
|
||||
|
||||
#elif ENABLED(AUTO_BED_LEVELING_3POINT)
|
||||
|
||||
points[index].z = measured_z;
|
||||
|
||||
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
|
||||
z_values[xCount][yCount] = measured_z + zoffset;
|
||||
|
@ -500,10 +509,6 @@ void GcodeSuite::G29() {
|
|||
}
|
||||
#endif
|
||||
|
||||
#elif ENABLED(AUTO_BED_LEVELING_3POINT)
|
||||
|
||||
points[abl_probe_index].z = measured_z;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -514,7 +519,7 @@ void GcodeSuite::G29() {
|
|||
#if ABL_GRID
|
||||
|
||||
// Skip any unreachable points
|
||||
while (abl_probe_index < abl2) {
|
||||
while (abl_probe_index < abl_points) {
|
||||
|
||||
// Set xCount, yCount based on abl_probe_index, with zig-zag
|
||||
PR_OUTER_VAR = abl_probe_index / PR_INNER_END;
|
||||
|
@ -541,7 +546,7 @@ void GcodeSuite::G29() {
|
|||
}
|
||||
|
||||
// Is there a next point to move to?
|
||||
if (abl_probe_index < abl2) {
|
||||
if (abl_probe_index < abl_points) {
|
||||
_manual_goto_xy(xProbe, yProbe); // Can be used here too!
|
||||
#if HAS_SOFTWARE_ENDSTOPS
|
||||
// Disable software endstops to allow manual adjustment
|
||||
|
@ -565,7 +570,7 @@ void GcodeSuite::G29() {
|
|||
#elif ENABLED(AUTO_BED_LEVELING_3POINT)
|
||||
|
||||
// Probe at 3 arbitrary points
|
||||
if (abl_probe_index < abl2) {
|
||||
if (abl_probe_index < abl_points) {
|
||||
xProbe = points[abl_probe_index].x;
|
||||
yProbe = points[abl_probe_index].y;
|
||||
_manual_goto_xy(xProbe, yProbe);
|
||||
|
@ -661,9 +666,9 @@ void GcodeSuite::G29() {
|
|||
|
||||
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;
|
||||
eqnAMatrix[abl_probe_index + 0 * abl_points] = xProbe;
|
||||
eqnAMatrix[abl_probe_index + 1 * abl_points] = yProbe;
|
||||
eqnAMatrix[abl_probe_index + 2 * abl_points] = 1;
|
||||
|
||||
incremental_LSF(&lsf_results, xProbe, yProbe, measured_z);
|
||||
|
||||
|
@ -771,7 +776,7 @@ void GcodeSuite::G29() {
|
|||
plane_equation_coefficients[1] = -lsf_results.B; // but that is not yet tested.
|
||||
plane_equation_coefficients[2] = -lsf_results.D;
|
||||
|
||||
mean /= abl2;
|
||||
mean /= abl_points;
|
||||
|
||||
if (verbose_level) {
|
||||
SERIAL_PROTOCOLPGM("Eqn coefficients: a: ");
|
||||
|
@ -815,8 +820,8 @@ void GcodeSuite::G29() {
|
|||
for (uint8_t xx = 0; xx < abl_grid_points_x; xx++) {
|
||||
int ind = indexIntoAB[xx][yy];
|
||||
float diff = eqnBVector[ind] - mean,
|
||||
x_tmp = eqnAMatrix[ind + 0 * abl2],
|
||||
y_tmp = eqnAMatrix[ind + 1 * abl2],
|
||||
x_tmp = eqnAMatrix[ind + 0 * abl_points],
|
||||
y_tmp = eqnAMatrix[ind + 1 * abl_points],
|
||||
z_tmp = 0;
|
||||
|
||||
apply_rotation_xyz(planner.bed_level_matrix, x_tmp, y_tmp, z_tmp);
|
||||
|
@ -839,8 +844,8 @@ void GcodeSuite::G29() {
|
|||
for (int8_t yy = abl_grid_points_y - 1; yy >= 0; yy--) {
|
||||
for (uint8_t xx = 0; xx < abl_grid_points_x; xx++) {
|
||||
int ind = indexIntoAB[xx][yy];
|
||||
float x_tmp = eqnAMatrix[ind + 0 * abl2],
|
||||
y_tmp = eqnAMatrix[ind + 1 * abl2],
|
||||
float x_tmp = eqnAMatrix[ind + 0 * abl_points],
|
||||
y_tmp = eqnAMatrix[ind + 1 * abl_points],
|
||||
z_tmp = 0;
|
||||
|
||||
apply_rotation_xyz(planner.bed_level_matrix, x_tmp, y_tmp, z_tmp);
|
||||
|
|
Loading…
Reference in a new issue