Fix G34 move in wrong direction (#18188)

This commit is contained in:
MoellerDi 2020-06-05 02:09:01 +02:00 committed by GitHub
parent a500862dc6
commit fcb8c5a1c1
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23

View file

@ -294,11 +294,14 @@ void GcodeSuite::G34() {
// Check for less accuracy compared to last move
if (last_z_align_move[zstepper] < z_align_abs * 0.7f) {
SERIAL_ECHOLNPGM("Decreasing accuracy detected.");
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " last_z_align_move = ", last_z_align_move[zstepper]);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " z_align_abs = ", z_align_abs);
adjustment_reverse = !adjustment_reverse;
}
// Remember the alignment for the next iteration
last_z_align_move[zstepper] = z_align_abs;
// Remember the alignment for the next iteration, but only if steppers move,
// otherwise it would be just zero (in case this stepper was at z_measured_min already)
if (z_align_abs > 0) last_z_align_move[zstepper] = z_align_abs;
#endif
// Stop early if all measured points achieve accuracy target
@ -312,8 +315,10 @@ void GcodeSuite::G34() {
#if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
// Decreasing accuracy was detected so move was inverted.
// Will match reversed Z steppers on dual steppers. Triple will need more work to map.
if (adjustment_reverse)
if (adjustment_reverse) {
z_align_move = -z_align_move;
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " correction reversed to ", z_align_move);
}
#endif
// Do a move to correct part of the misalignment for the current stepper