mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-23 12:04:19 +00:00
🎨 Misc. probe-related cleanup
This commit is contained in:
parent
39e42ebe6a
commit
580a35be33
@ -244,7 +244,7 @@ void GcodeSuite::G34() {
|
||||
|
||||
// Add height to each value, to provide a more useful target height for
|
||||
// the next iteration of probing. This allows adjustments to be made away from the bed.
|
||||
z_measured[iprobe] = z_probed_height + Z_CLEARANCE_BETWEEN_PROBES;
|
||||
z_measured[iprobe] = z_probed_height + (Z_CLEARANCE_BETWEEN_PROBES);
|
||||
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Z", iprobe + 1, " measured position is ", z_measured[iprobe]);
|
||||
|
||||
@ -446,7 +446,7 @@ void GcodeSuite::G34() {
|
||||
// Use the probed height from the last iteration to determine the Z height.
|
||||
// z_measured_min is used, because all steppers are aligned to z_measured_min.
|
||||
// Ideally, this would be equal to the 'z_probe * 0.5f' which was added earlier.
|
||||
current_position.z -= z_measured_min - (float)Z_CLEARANCE_BETWEEN_PROBES;
|
||||
current_position.z -= z_measured_min - float(Z_CLEARANCE_BETWEEN_PROBES);
|
||||
sync_plan_position();
|
||||
#endif
|
||||
|
||||
|
@ -62,7 +62,9 @@ void GcodeSuite::M401() {
|
||||
*/
|
||||
void GcodeSuite::M402() {
|
||||
probe.stow();
|
||||
probe.move_z_after_probing();
|
||||
#ifdef Z_AFTER_PROBING
|
||||
do_z_clearance(Z_AFTER_PROBING);
|
||||
#endif
|
||||
report_current_position();
|
||||
}
|
||||
|
||||
|
@ -783,6 +783,10 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) {
|
||||
if (!lower_allowed) NOLESS(zdest, current_position.z);
|
||||
do_blocking_move_to_z(_MIN(zdest, Z_MAX_POS), 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);
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
@ -2340,15 +2344,10 @@ void set_axis_is_at_home(const AxisEnum axis) {
|
||||
#if HAS_BED_PROBE && Z_HOME_TO_MIN
|
||||
if (axis == Z_AXIS) {
|
||||
#if HOMING_Z_WITH_PROBE
|
||||
|
||||
current_position.z -= probe.offset.z;
|
||||
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> probe.offset.z = ", probe.offset.z);
|
||||
|
||||
#else
|
||||
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("*** Z homed to ENDSTOP ***");
|
||||
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("*** Z HOMED TO ENDSTOP ***");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -400,8 +400,10 @@ 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_by(const_float_t zclear);
|
||||
#else
|
||||
inline void do_z_clearance(float, bool=false) {}
|
||||
inline void do_z_clearance_by(float) {}
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -744,8 +744,8 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
||||
if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s,
|
||||
sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN;
|
||||
|
||||
const float first_probe_z = DIFF_TERN(HAS_DELTA_SENSORLESS_PROBING, current_position.z, largest_sensorless_adj);
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("1st Probe Z:", first_probe_z);
|
||||
const float z1 = DIFF_TERN(HAS_DELTA_SENSORLESS_PROBING, current_position.z, largest_sensorless_adj);
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("1st Probe Z:", z1);
|
||||
|
||||
// Raise to give the probe clearance
|
||||
do_blocking_move_to_z(current_position.z + Z_CLEARANCE_MULTI_PROBE, z_probe_fast_mm_s);
|
||||
@ -754,7 +754,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
||||
|
||||
// If the nozzle is well over the travel height then
|
||||
// move down quickly before doing the slow probe
|
||||
const float z = Z_CLEARANCE_DEPLOY_PROBE + 5.0 + (offset.z < 0 ? -offset.z : 0);
|
||||
const float z = (Z_CLEARANCE_DEPLOY_PROBE) + 5.0f + (offset.z < 0 ? -offset.z : 0);
|
||||
if (current_position.z > z) {
|
||||
// Probe down fast. If the probe never triggered, raise for probe clearance
|
||||
if (!probe_down_to_z(z, z_probe_fast_mm_s))
|
||||
@ -839,10 +839,10 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
||||
|
||||
const float z2 = DIFF_TERN(HAS_DELTA_SENSORLESS_PROBING, current_position.z, largest_sensorless_adj);
|
||||
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("2nd Probe Z:", z2, " Discrepancy:", first_probe_z - z2);
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("2nd Probe Z:", z2, " Discrepancy:", z1 - z2);
|
||||
|
||||
// Return a weighted average of the fast and slow probes
|
||||
const float measured_z = (z2 * 3.0 + first_probe_z * 2.0) * 0.2;
|
||||
const float measured_z = (z2 * 3.0f + z1 * 2.0f) * 0.2f;
|
||||
|
||||
#else
|
||||
|
||||
|
@ -33,6 +33,9 @@
|
||||
#include "../lcd/e3v2/proui/dwin.h"
|
||||
#endif
|
||||
|
||||
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
#include "../core/debug_out.h"
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
enum ProbePtRaise : uint8_t {
|
||||
PROBE_PT_NONE, // No raise or stow after run_z_probe
|
||||
@ -139,6 +142,7 @@ public:
|
||||
#endif // !IS_KINEMATIC
|
||||
|
||||
static void move_z_after_probing() {
|
||||
DEBUG_SECTION(mzah, "move_z_after_probing", DEBUGGING(LEVELING));
|
||||
#ifdef Z_AFTER_PROBING
|
||||
do_z_clearance(Z_AFTER_PROBING, true); // Move down still permitted
|
||||
#endif
|
||||
@ -159,6 +163,7 @@ public:
|
||||
#endif // !HAS_BED_PROBE
|
||||
|
||||
static void move_z_after_homing() {
|
||||
DEBUG_SECTION(mzah, "move_z_after_homing", DEBUGGING(LEVELING));
|
||||
#if ALL(DWIN_LCD_PROUI, INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) || defined(Z_AFTER_HOMING)
|
||||
do_z_clearance(Z_POST_CLEARANCE, true);
|
||||
#elif HAS_BED_PROBE
|
||||
|
Loading…
Reference in New Issue
Block a user