0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-01-22 09:42:34 +00:00

️ G30 optimize and comment

This commit is contained in:
Scott Lahteine 2024-09-02 19:11:11 -05:00
parent 7aaba66d4d
commit 7901eb97ad

View file

@ -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();