Update position for UBL non-segmented activate/deactivate

This commit is contained in:
Scott Lahteine 2018-04-16 03:35:12 -05:00
parent c0f6eebded
commit 6f156d01d9

View File

@ -2461,7 +2461,21 @@ void clean_up_after_endstop_or_probe_move() {
planner.unapply_leveling(current_position);
}
#else
planner.leveling_active = enable; // just flip the bit, current_position will be wrong until next move.
// UBL equivalents for apply/unapply_leveling
#if ENABLED(SKEW_CORRECTION)
float pos[XYZ] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };
planner.skew(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS]);
#else
const float (&pos)[XYZE] = current_position;
#endif
if (planner.leveling_active) {
current_position[Z_AXIS] += ubl.get_z_correction(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS]);
planner.leveling_active = false;
}
else {
planner.leveling_active = true;
current_position[Z_AXIS] -= ubl.get_z_correction(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS]);
}
#endif
#else // ABL