Standard function to turn bed leveling on/off
This commit is contained in:
parent
ecf7cdde65
commit
510ef5d14a
@ -2132,30 +2132,69 @@ static void clean_up_after_endstop_or_probe_move() {
|
|||||||
|
|
||||||
#endif // HAS_BED_PROBE
|
#endif // HAS_BED_PROBE
|
||||||
|
|
||||||
#if HAS_ABL
|
#if PLANNER_LEVELING
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset calibration results to zero.
|
* Turn bed leveling on or off, fixing the current
|
||||||
|
* position as-needed.
|
||||||
*
|
*
|
||||||
* TODO: Proper functions to disable / enable
|
* Disable: Current position = physical position
|
||||||
* bed leveling via a flag, correcting the
|
* Enable: Current position = "unleveled" physical position
|
||||||
* current position in each case.
|
|
||||||
*/
|
*/
|
||||||
void reset_bed_level() {
|
void set_bed_leveling_enabled(bool enable=true) {
|
||||||
planner.abl_enabled = false;
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
||||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("reset_bed_level");
|
if (!enable && mbl.active())
|
||||||
#endif
|
current_position[Z_AXIS] +=
|
||||||
#if ABL_PLANAR
|
mbl.get_z(RAW_CURRENT_POSITION(X_AXIS), RAW_CURRENT_POSITION(Y_AXIS)) - (MESH_HOME_SEARCH_Z);
|
||||||
planner.bed_level_matrix.set_to_identity();
|
|
||||||
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
mbl.set_active(enable && mbl.has_mesh()); // was set_has_mesh(). Is this not correct?
|
||||||
for (uint8_t x = 0; x < ABL_GRID_POINTS_X; x++)
|
|
||||||
for (uint8_t y = 0; y < ABL_GRID_POINTS_Y; y++)
|
#elif HAS_ABL
|
||||||
bed_level_grid[x][y] = 1000.0;
|
|
||||||
|
if (enable != planner.abl_enabled) {
|
||||||
|
planner.abl_enabled = !planner.abl_enabled;
|
||||||
|
if (!planner.abl_enabled)
|
||||||
|
set_current_from_steppers_for_axis(
|
||||||
|
#if ABL_PLANAR
|
||||||
|
ALL_AXES
|
||||||
|
#else
|
||||||
|
Z_AXIS
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
else
|
||||||
|
planner.unapply_leveling(current_position);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAS_ABL
|
|
||||||
|
/**
|
||||||
|
* Reset calibration results to zero.
|
||||||
|
*/
|
||||||
|
void reset_bed_level() {
|
||||||
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
|
if (mbl.has_mesh()) {
|
||||||
|
set_bed_leveling_enabled(false);
|
||||||
|
mbl.reset();
|
||||||
|
mbl.set_has_mesh(false);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
planner.abl_enabled = false;
|
||||||
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||||
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("reset_bed_level");
|
||||||
|
#endif
|
||||||
|
#if ABL_PLANAR
|
||||||
|
planner.bed_level_matrix.set_to_identity();
|
||||||
|
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||||
|
for (uint8_t x = 0; x < ABL_GRID_POINTS_X; x++)
|
||||||
|
for (uint8_t y = 0; y < ABL_GRID_POINTS_Y; y++)
|
||||||
|
bed_level_grid[x][y] = 1000.0;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PLANNER_LEVELING
|
||||||
|
|
||||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user