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