Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Probe flag in do_z_clearance
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Apr 11, 2023
1 parent 185961f commit f53217b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 25 deletions.
5 changes: 2 additions & 3 deletions Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
13 changes: 8 additions & 5 deletions Marlin/src/module/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/module/motion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 5 additions & 13 deletions Marlin/src/module/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)))) {
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/module/probe.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ class Probe {

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);
};

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit f53217b

Please sign in to comment.