From c2520984591de8da9661d7ec1a99752e1d793e10 Mon Sep 17 00:00:00 2001 From: Nick Weedon Date: Sat, 9 Nov 2024 16:37:41 -0500 Subject: [PATCH] Added new 'P' (precise probing) option to G28 * This new flag causes G28 to execute the same probing algorithm that is used when bed leveling in order to increase accuracy. Provides a good alternative to 'bump' probing for probes that are still intermittently innacurate (I recommend disabling HOMING_BUMP_MM for the Z axis when using this option exclusively). * Only avaialbe when 'HAS_BED_PROBE' is enabled and is configurable via all the same options as the bed level probe. --- Marlin/src/gcode/calibrate/G28.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index ac90756ded8d..393feccaa50c 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -530,6 +530,18 @@ void GcodeSuite::G28() { #endif // DUAL_X_CARRIAGE + #if HAS_BED_PROBE + // Perform precise homing using the same probing procedure as bed leveling + if (parser.seen_test('P')) { + xy_pos_t xyPos = { current_position.x, current_position.y }; + float probedZHeight = probe.probe_at_point(xyPos, PROBE_PT_RAISE, 0, false); + DEBUG_ECHOLNPGM("Probed ZHeight (correction amount): ", probedZHeight); + + current_position.z -= probedZHeight; + sync_plan_position(); + } + #endif + endstops.not_homing(); // Clear endstop state for polled stallGuard endstops