Skip to content

Commit f53217b

Browse files
committed
πŸ§‘β€πŸ’» Probe flag in do_z_clearance
1 parent 185961f commit f53217b

File tree

6 files changed

+18
-25
lines changed

6 files changed

+18
-25
lines changed

β€ŽMarlin/src/feature/bedlevel/ubl/ubl_G29.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -916,15 +916,14 @@ void set_message_with_feedback(FSTR_P const fstr) {
916916
echo_and_take_a_measurement();
917917

918918
const float z1 = measure_point_with_encoder();
919-
do_blocking_move_to_z(current_position.z + SIZE_OF_LITTLE_RAISE);
920-
planner.synchronize();
919+
do_z_clearance_by(SIZE_OF_LITTLE_RAISE);
921920

922921
SERIAL_ECHOPGM("Remove shim");
923922
LCD_MESSAGE(MSG_UBL_BC_REMOVE);
924923
echo_and_take_a_measurement();
925924

926925
const float z2 = measure_point_with_encoder();
927-
do_blocking_move_to_z(current_position.z + Z_CLEARANCE_BETWEEN_PROBES);
926+
do_z_clearance_by(Z_CLEARANCE_BETWEEN_PROBES);
928927

929928
const float thickness = ABS(z1 - z2);
930929

β€ŽMarlin/src/module/motion.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -792,15 +792,18 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) {
792792
fr_mm_s
793793
);
794794
}
795-
void do_z_clearance(const_float_t zclear, const bool lower_allowed/*=false*/) {
796-
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("do_z_clearance(", zclear, ", ", lower_allowed, ")");
797-
const float zdest = _MIN(zclear, Z_MAX_POS);
798-
if (zdest == current_position.z || (!lower_allowed && zdest < current_position.z)) return;
795+
void do_z_clearance(const_float_t zclear, const bool with_probe/*=true*/, const bool lower_allowed/*=false*/) {
796+
UNUSED(with_probe);
797+
float zdest = zclear;
798+
TERN_(HAS_BED_PROBE, if (with_probe && probe.offset.z < 0) zdest -= probe.offset.z);
799+
NOMORE(zdest, Z_MAX_POS);
800+
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("do_z_clearance(", zclear, " [", current_position.z, " to ", zdest, "], ", lower_allowed, ")");
801+
if ((!lower_allowed && zdest < current_position.z) || zdest == current_position.z) return;
799802
do_blocking_move_to_z(zdest, TERN(HAS_BED_PROBE, z_probe_fast_mm_s, homing_feedrate(Z_AXIS)));
800803
}
801804
void do_z_clearance_by(const_float_t zclear) {
802805
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("do_z_clearance_by(", zclear, ")");
803-
do_z_clearance(current_position.z + zclear);
806+
do_z_clearance(current_position.z + zclear, false);
804807
}
805808
#endif
806809

β€ŽMarlin/src/module/motion.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,10 @@ void remember_feedrate_scaling_off();
403403
void restore_feedrate_and_scaling();
404404

405405
#if HAS_Z_AXIS
406-
void do_z_clearance(const_float_t zclear, const bool lower_allowed=false);
406+
void do_z_clearance(const_float_t zclear, const bool with_probe=true, const bool lower_allowed=false);
407407
void do_z_clearance_by(const_float_t zclear);
408408
#else
409-
inline void do_z_clearance(float, bool=false) {}
409+
inline void do_z_clearance(float, bool=true, bool=false) {}
410410
inline void do_z_clearance_by(float) {}
411411
#endif
412412

β€ŽMarlin/src/module/probe.cpp

+5-13
Original file line numberDiff line numberDiff line change
@@ -349,17 +349,6 @@ xyz_pos_t Probe::offset; // Initialized by settings.load()
349349

350350
#endif // HAS_QUIET_PROBING
351351

352-
/**
353-
* Raise Z to a minimum height to make room for a probe to move
354-
*/
355-
void Probe::do_z_raise(const float z_raise) {
356-
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Probe::do_z_raise(", z_raise, ")");
357-
float z_dest = z_raise;
358-
const float zoffs = DIFF_TERN(HAS_HOTEND_OFFSET, offset.z, hotend_offset[active_extruder].z);
359-
if (zoffs < 0) z_dest -= zoffs;
360-
do_z_clearance(z_dest);
361-
}
362-
363352
FORCE_INLINE void probe_specific_action(const bool deploy) {
364353
DEBUG_SECTION(log_psa, "Probe::probe_specific_action", DEBUGGING(LEVELING));
365354
#if ENABLED(PAUSE_BEFORE_DEPLOY_STOW)
@@ -522,8 +511,11 @@ bool Probe::set_deployed(const bool deploy, const bool no_return/*=false*/) {
522511
constexpr bool z_raise_wanted = true;
523512
#endif
524513

525-
if (z_raise_wanted)
526-
do_z_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
514+
if (z_raise_wanted) {
515+
const float zdest = DIFF_TERN(HAS_HOTEND_OFFSET, _MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE), hotend_offset[active_extruder].z);
516+
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Raise Z to ", zdest);
517+
do_z_clearance(zdest);
518+
}
527519

528520
#if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)
529521
if (homing_needed_error(TERN_(Z_PROBE_SLED, _BV(X_AXIS)))) {

β€ŽMarlin/src/module/probe.h

-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ class Probe {
352352

353353
private:
354354
static bool probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s);
355-
static void do_z_raise(const float z_raise);
356355
static float run_z_probe(const bool sanity_check=true);
357356
};
358357

β€ŽMarlin/src/module/temperature.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ volatile bool Temperature::raw_temps_ready = false;
982982
planner.sync_fan_speeds(fan_speed);
983983
#endif
984984

985-
do_z_clearance(MPC_TUNING_END_Z);
985+
do_z_clearance(MPC_TUNING_END_Z, false);
986986

987987
TERN_(TEMP_TUNING_MAINTAIN_FAN, adaptive_fan_slowing = true);
988988
}

0 commit comments

Comments
Β (0)