diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index e736a99ec809..29d6c1ad2ba7 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -50,8 +50,7 @@ */ void GcodeSuite::G30() { - xy_pos_t old_pos = current_position, - probepos = current_position; + xy_pos_t probepos = current_position; const bool seenX = parser.seenval('X'); if (seenX) probepos.x = RAW_X_POSITION(parser.value_linear_units()); @@ -62,21 +61,28 @@ void GcodeSuite::G30() { if (probe.can_reach(probepos)) { - if (seenX) old_pos.x = probepos.x; - if (seenY) old_pos.y = probepos.y; - // Disable leveling so the planner won't mess with us TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); + // Disable feedrate scaling so movement speeds are correct remember_feedrate_scaling_off(); + // With VERBOSE_SINGLE_PROBE home only if needed TERN_(VERBOSE_SINGLE_PROBE, process_subcommands_now(F("G28O"))); + // Raise after based on the 'E' parameter const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; + // Use 'C' to set Probe Temperature Compensation ON/OFF (on by default) TERN_(HAS_PTC, ptc.set_enabled(parser.boolval('C', true))); + + // Probe the bed, optionally raise, and return the measured height const float measured_z = probe.probe_at_point(probepos, raise_after); + + // After probing always re-enable Probe Temperature Compensation TERN_(HAS_PTC, ptc.set_enabled(true)); + + // Report a good probe result to the host and LCD if (!isnan(measured_z)) { const xy_pos_t lpos = probepos.asLogical(); SString<30> msg( @@ -88,9 +94,11 @@ void GcodeSuite::G30() { TERN_(VERBOSE_SINGLE_PROBE, ui.set_status(msg)); } + // Restore feedrate scaling restore_feedrate_and_scaling(); - do_blocking_move_to(old_pos); + // Move the nozzle to the position of the probe + do_blocking_move_to(probepos); if (raise_after == PROBE_PT_STOW) probe.move_z_after_probing();