Allow consecutive uses of G29

This commit is contained in:
Scott Lahteine 2017-12-25 06:32:33 -06:00
parent 4b49ea1e92
commit f2731c9f93

View File

@ -390,7 +390,8 @@ void GcodeSuite::G29() {
stepper.synchronize(); stepper.synchronize();
// Disable auto bed leveling during G29 // Disable auto bed leveling during G29
planner.leveling_active = false; // Be formal so G29 can be done successively without G28.
set_bed_leveling_enabled(false);
if (!dryrun) { if (!dryrun) {
// Re-orient the current position without leveling // Re-orient the current position without leveling
@ -404,7 +405,7 @@ void GcodeSuite::G29() {
#if HAS_BED_PROBE #if HAS_BED_PROBE
// Deploy the probe. Probe will raise if needed. // Deploy the probe. Probe will raise if needed.
if (DEPLOY_PROBE()) { if (DEPLOY_PROBE()) {
planner.leveling_active = abl_should_enable; set_bed_leveling_enabled(abl_should_enable);
return; return;
} }
#endif #endif
@ -421,10 +422,6 @@ void GcodeSuite::G29() {
|| left_probe_bed_position != bilinear_start[X_AXIS] || left_probe_bed_position != bilinear_start[X_AXIS]
|| front_probe_bed_position != bilinear_start[Y_AXIS] || front_probe_bed_position != bilinear_start[Y_AXIS]
) { ) {
if (dryrun) {
// Before reset bed level, re-enable to correct the position
planner.leveling_active = abl_should_enable;
}
// Reset grid to 0.0 or "not probed". (Also disables ABL) // Reset grid to 0.0 or "not probed". (Also disables ABL)
reset_bed_level(); reset_bed_level();
@ -468,7 +465,7 @@ void GcodeSuite::G29() {
#if HAS_SOFTWARE_ENDSTOPS #if HAS_SOFTWARE_ENDSTOPS
soft_endstops_enabled = enable_soft_endstops; soft_endstops_enabled = enable_soft_endstops;
#endif #endif
planner.leveling_active = abl_should_enable; set_bed_leveling_enabled(abl_should_enable);
g29_in_progress = false; g29_in_progress = false;
#if ENABLED(LCD_BED_LEVELING) #if ENABLED(LCD_BED_LEVELING)
lcd_wait_for_move = false; lcd_wait_for_move = false;
@ -673,7 +670,7 @@ void GcodeSuite::G29() {
measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level); measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
if (isnan(measured_z)) { if (isnan(measured_z)) {
planner.leveling_active = abl_should_enable; set_bed_leveling_enabled(abl_should_enable);
break; break;
} }
@ -709,7 +706,7 @@ void GcodeSuite::G29() {
yProbe = points[i].y; yProbe = points[i].y;
measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level); measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
if (isnan(measured_z)) { if (isnan(measured_z)) {
planner.leveling_active = abl_should_enable; set_bed_leveling_enabled(abl_should_enable);
break; break;
} }
points[i].z = measured_z; points[i].z = measured_z;
@ -732,7 +729,7 @@ void GcodeSuite::G29() {
// Raise to _Z_CLEARANCE_DEPLOY_PROBE. Stow the probe. // Raise to _Z_CLEARANCE_DEPLOY_PROBE. Stow the probe.
if (STOW_PROBE()) { if (STOW_PROBE()) {
planner.leveling_active = abl_should_enable; set_bed_leveling_enabled(abl_should_enable);
measured_z = NAN; measured_z = NAN;
} }
} }