From f53217b2c5bf7d61d21ee6784ec251bc7a670eb3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 11 Apr 2023 18:43:01 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Probe=20fla?= =?UTF-8?q?g=20in=20do=5Fz=5Fclearance?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 5 ++--- Marlin/src/module/motion.cpp | 13 ++++++++----- Marlin/src/module/motion.h | 4 ++-- Marlin/src/module/probe.cpp | 18 +++++------------- Marlin/src/module/probe.h | 1 - Marlin/src/module/temperature.cpp | 2 +- 6 files changed, 18 insertions(+), 25 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index d9205b7577..a6206b398e 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -916,15 +916,14 @@ void set_message_with_feedback(FSTR_P const fstr) { echo_and_take_a_measurement(); const float z1 = measure_point_with_encoder(); - do_blocking_move_to_z(current_position.z + SIZE_OF_LITTLE_RAISE); - planner.synchronize(); + do_z_clearance_by(SIZE_OF_LITTLE_RAISE); SERIAL_ECHOPGM("Remove shim"); LCD_MESSAGE(MSG_UBL_BC_REMOVE); echo_and_take_a_measurement(); const float z2 = measure_point_with_encoder(); - do_blocking_move_to_z(current_position.z + Z_CLEARANCE_BETWEEN_PROBES); + do_z_clearance_by(Z_CLEARANCE_BETWEEN_PROBES); const float thickness = ABS(z1 - z2); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index ad5be12187..d5d9ca8d34 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -792,15 +792,18 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { fr_mm_s ); } - void do_z_clearance(const_float_t zclear, const bool lower_allowed/*=false*/) { - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("do_z_clearance(", zclear, ", ", lower_allowed, ")"); - const float zdest = _MIN(zclear, Z_MAX_POS); - if (zdest == current_position.z || (!lower_allowed && zdest < current_position.z)) return; + void do_z_clearance(const_float_t zclear, const bool with_probe/*=true*/, const bool lower_allowed/*=false*/) { + UNUSED(with_probe); + float zdest = zclear; + TERN_(HAS_BED_PROBE, if (with_probe && probe.offset.z < 0) zdest -= probe.offset.z); + NOMORE(zdest, Z_MAX_POS); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("do_z_clearance(", zclear, " [", current_position.z, " to ", zdest, "], ", lower_allowed, ")"); + if ((!lower_allowed && zdest < current_position.z) || zdest == current_position.z) return; do_blocking_move_to_z(zdest, TERN(HAS_BED_PROBE, z_probe_fast_mm_s, homing_feedrate(Z_AXIS))); } void do_z_clearance_by(const_float_t zclear) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("do_z_clearance_by(", zclear, ")"); - do_z_clearance(current_position.z + zclear); + do_z_clearance(current_position.z + zclear, false); } #endif diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index cdf1d7a969..c93b1ef205 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -403,10 +403,10 @@ void remember_feedrate_scaling_off(); void restore_feedrate_and_scaling(); #if HAS_Z_AXIS - void do_z_clearance(const_float_t zclear, const bool lower_allowed=false); + void do_z_clearance(const_float_t zclear, const bool with_probe=true, const bool lower_allowed=false); void do_z_clearance_by(const_float_t zclear); #else - inline void do_z_clearance(float, bool=false) {} + inline void do_z_clearance(float, bool=true, bool=false) {} inline void do_z_clearance_by(float) {} #endif diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index b2c1c2b8de..ff4ca58a6f 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -349,17 +349,6 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() #endif // HAS_QUIET_PROBING -/** - * Raise Z to a minimum height to make room for a probe to move - */ -void Probe::do_z_raise(const float z_raise) { - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Probe::do_z_raise(", z_raise, ")"); - float z_dest = z_raise; - const float zoffs = DIFF_TERN(HAS_HOTEND_OFFSET, offset.z, hotend_offset[active_extruder].z); - if (zoffs < 0) z_dest -= zoffs; - do_z_clearance(z_dest); -} - FORCE_INLINE void probe_specific_action(const bool deploy) { DEBUG_SECTION(log_psa, "Probe::probe_specific_action", DEBUGGING(LEVELING)); #if ENABLED(PAUSE_BEFORE_DEPLOY_STOW) @@ -522,8 +511,11 @@ bool Probe::set_deployed(const bool deploy, const bool no_return/*=false*/) { constexpr bool z_raise_wanted = true; #endif - if (z_raise_wanted) - do_z_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE)); + if (z_raise_wanted) { + const float zdest = DIFF_TERN(HAS_HOTEND_OFFSET, _MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE), hotend_offset[active_extruder].z); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Raise Z to ", zdest); + do_z_clearance(zdest); + } #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY) if (homing_needed_error(TERN_(Z_PROBE_SLED, _BV(X_AXIS)))) { diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index 03544690b5..4545daa31e 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -352,7 +352,6 @@ public: private: static bool probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s); - static void do_z_raise(const float z_raise); static float run_z_probe(const bool sanity_check=true); }; diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 29c3a787c5..43ef774948 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -982,7 +982,7 @@ volatile bool Temperature::raw_temps_ready = false; planner.sync_fan_speeds(fan_speed); #endif - do_z_clearance(MPC_TUNING_END_Z); + do_z_clearance(MPC_TUNING_END_Z, false); TERN_(TEMP_TUNING_MAINTAIN_FAN, adaptive_fan_slowing = true); }