|
|
@ -62,12 +62,12 @@ public:
|
|
|
|
#if HAS_PROBE_XY_OFFSET
|
|
|
|
#if HAS_PROBE_XY_OFFSET
|
|
|
|
// Return true if the both nozzle and the probe can reach the given point.
|
|
|
|
// Return true if the both nozzle and the probe can reach the given point.
|
|
|
|
// Note: This won't work on SCARA since the probe offset rotates with the arm.
|
|
|
|
// Note: This won't work on SCARA since the probe offset rotates with the arm.
|
|
|
|
static inline bool can_reach(const float &rx, const float &ry) {
|
|
|
|
static bool can_reach(const float &rx, const float &ry) {
|
|
|
|
return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y) // The nozzle can go where it needs to go?
|
|
|
|
return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y) // The nozzle can go where it needs to go?
|
|
|
|
&& position_is_reachable(rx, ry, ABS(PROBING_MARGIN)); // Can the nozzle also go near there?
|
|
|
|
&& position_is_reachable(rx, ry, ABS(PROBING_MARGIN)); // Can the nozzle also go near there?
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
FORCE_INLINE static bool can_reach(const float &rx, const float &ry) {
|
|
|
|
static bool can_reach(const float &rx, const float &ry) {
|
|
|
|
return position_is_reachable(rx, ry, PROBING_MARGIN);
|
|
|
|
return position_is_reachable(rx, ry, PROBING_MARGIN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -81,7 +81,7 @@ public:
|
|
|
|
* Example: For a probe offset of -10,+10, then for the probe to reach 0,0 the
|
|
|
|
* Example: For a probe offset of -10,+10, then for the probe to reach 0,0 the
|
|
|
|
* nozzle must be be able to reach +10,-10.
|
|
|
|
* nozzle must be be able to reach +10,-10.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static inline bool can_reach(const float &rx, const float &ry) {
|
|
|
|
static bool can_reach(const float &rx, const float &ry) {
|
|
|
|
return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y)
|
|
|
|
return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y)
|
|
|
|
&& WITHIN(rx, min_x() - fslop, max_x() + fslop)
|
|
|
|
&& WITHIN(rx, min_x() - fslop, max_x() + fslop)
|
|
|
|
&& WITHIN(ry, min_y() - fslop, max_y() + fslop);
|
|
|
|
&& WITHIN(ry, min_y() - fslop, max_y() + fslop);
|
|
|
@ -89,13 +89,13 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static inline void move_z_after_probing() {
|
|
|
|
static void move_z_after_probing() {
|
|
|
|
#ifdef Z_AFTER_PROBING
|
|
|
|
#ifdef Z_AFTER_PROBING
|
|
|
|
do_z_clearance(Z_AFTER_PROBING, true, true, true); // Move down still permitted
|
|
|
|
do_z_clearance(Z_AFTER_PROBING, true, true, true); // Move down still permitted
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true, const bool sanity_check=true);
|
|
|
|
static float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true, const bool sanity_check=true);
|
|
|
|
static inline float probe_at_point(const xy_pos_t &pos, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true, const bool sanity_check=true) {
|
|
|
|
static float probe_at_point(const xy_pos_t &pos, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true, const bool sanity_check=true) {
|
|
|
|
return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative, sanity_check);
|
|
|
|
return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative, sanity_check);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -105,11 +105,11 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
static bool set_deployed(const bool) { return false; }
|
|
|
|
static bool set_deployed(const bool) { return false; }
|
|
|
|
|
|
|
|
|
|
|
|
FORCE_INLINE static bool can_reach(const float &rx, const float &ry) { return position_is_reachable(rx, ry); }
|
|
|
|
static bool can_reach(const float &rx, const float &ry) { return position_is_reachable(rx, ry); }
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static inline void move_z_after_homing() {
|
|
|
|
static void move_z_after_homing() {
|
|
|
|
#ifdef Z_AFTER_HOMING
|
|
|
|
#ifdef Z_AFTER_HOMING
|
|
|
|
do_z_clearance(Z_AFTER_HOMING, true, true, true);
|
|
|
|
do_z_clearance(Z_AFTER_HOMING, true, true, true);
|
|
|
|
#elif BOTH(Z_AFTER_PROBING, HAS_BED_PROBE)
|
|
|
|
#elif BOTH(Z_AFTER_PROBING, HAS_BED_PROBE)
|
|
|
@ -117,9 +117,9 @@ public:
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FORCE_INLINE static bool can_reach(const xy_pos_t &pos) { return can_reach(pos.x, pos.y); }
|
|
|
|
static bool can_reach(const xy_pos_t &pos) { return can_reach(pos.x, pos.y); }
|
|
|
|
|
|
|
|
|
|
|
|
FORCE_INLINE static bool good_bounds(const xy_pos_t &lf, const xy_pos_t &rb) {
|
|
|
|
static bool good_bounds(const xy_pos_t &lf, const xy_pos_t &rb) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
#if IS_KINEMATIC
|
|
|
|
#if IS_KINEMATIC
|
|
|
|
can_reach(lf.x, 0) && can_reach(rb.x, 0) && can_reach(0, lf.y) && can_reach(0, rb.y)
|
|
|
|
can_reach(lf.x, 0) && can_reach(rb.x, 0) && can_reach(0, lf.y) && can_reach(0, rb.y)
|
|
|
@ -137,8 +137,8 @@ public:
|
|
|
|
static constexpr xy_pos_t offset_xy = xy_pos_t({ 0, 0 }); // See #16767
|
|
|
|
static constexpr xy_pos_t offset_xy = xy_pos_t({ 0, 0 }); // See #16767
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static inline bool deploy() { return set_deployed(true); }
|
|
|
|
static bool deploy() { return set_deployed(true); }
|
|
|
|
static inline bool stow() { return set_deployed(false); }
|
|
|
|
static bool stow() { return set_deployed(false); }
|
|
|
|
|
|
|
|
|
|
|
|
#if HAS_BED_PROBE || HAS_LEVELING
|
|
|
|
#if HAS_BED_PROBE || HAS_LEVELING
|
|
|
|
#if IS_KINEMATIC
|
|
|
|
#if IS_KINEMATIC
|
|
|
@ -146,41 +146,73 @@ public:
|
|
|
|
TERN_(DELTA, DELTA_PRINTABLE_RADIUS)
|
|
|
|
TERN_(DELTA, DELTA_PRINTABLE_RADIUS)
|
|
|
|
TERN_(IS_SCARA, SCARA_PRINTABLE_RADIUS)
|
|
|
|
TERN_(IS_SCARA, SCARA_PRINTABLE_RADIUS)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
static inline float probe_radius() {
|
|
|
|
static constexpr float probe_radius(const xy_pos_t &probe_offset_xy = offset_xy) {
|
|
|
|
return printable_radius - _MAX(PROBING_MARGIN, HYPOT(offset_xy.x, offset_xy.y));
|
|
|
|
return printable_radius - _MAX(PROBING_MARGIN, HYPOT(probe_offset_xy.x, probe_offset_xy.y));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static inline float min_x() {
|
|
|
|
static constexpr float _min_x(const xy_pos_t &probe_offset_xy = offset_xy) {
|
|
|
|
return TERN(IS_KINEMATIC,
|
|
|
|
return TERN(IS_KINEMATIC,
|
|
|
|
(X_CENTER) - probe_radius(),
|
|
|
|
(X_CENTER) - probe_radius(probe_offset_xy),
|
|
|
|
_MAX((X_MIN_BED) + (PROBING_MARGIN_LEFT), (X_MIN_POS) + offset_xy.x)
|
|
|
|
_MAX((X_MIN_BED) + (PROBING_MARGIN_LEFT), (X_MIN_POS) + probe_offset_xy.x)
|
|
|
|
) - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.x));
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static inline float max_x() {
|
|
|
|
static constexpr float _max_x(const xy_pos_t &probe_offset_xy = offset_xy) {
|
|
|
|
return TERN(IS_KINEMATIC,
|
|
|
|
return TERN(IS_KINEMATIC,
|
|
|
|
(X_CENTER) + probe_radius(),
|
|
|
|
(X_CENTER) + probe_radius(probe_offset_xy),
|
|
|
|
_MIN((X_MAX_BED) - (PROBING_MARGIN_RIGHT), (X_MAX_POS) + offset_xy.x)
|
|
|
|
_MIN((X_MAX_BED) - (PROBING_MARGIN_RIGHT), (X_MAX_POS) + probe_offset_xy.x)
|
|
|
|
) - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.x));
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static inline float min_y() {
|
|
|
|
static constexpr float _min_y(const xy_pos_t &probe_offset_xy = offset_xy) {
|
|
|
|
return TERN(IS_KINEMATIC,
|
|
|
|
return TERN(IS_KINEMATIC,
|
|
|
|
(Y_CENTER) - probe_radius(),
|
|
|
|
(Y_CENTER) - probe_radius(probe_offset_xy),
|
|
|
|
_MAX((Y_MIN_BED) + (PROBING_MARGIN_FRONT), (Y_MIN_POS) + offset_xy.y)
|
|
|
|
_MAX((Y_MIN_BED) + (PROBING_MARGIN_FRONT), (Y_MIN_POS) + probe_offset_xy.y)
|
|
|
|
) - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.y));
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static inline float max_y() {
|
|
|
|
static constexpr float _max_y(const xy_pos_t &probe_offset_xy = offset_xy) {
|
|
|
|
return TERN(IS_KINEMATIC,
|
|
|
|
return TERN(IS_KINEMATIC,
|
|
|
|
(Y_CENTER) + probe_radius(),
|
|
|
|
(Y_CENTER) + probe_radius(probe_offset_xy),
|
|
|
|
_MIN((Y_MAX_BED) - (PROBING_MARGIN_BACK), (Y_MAX_POS) + offset_xy.y)
|
|
|
|
_MIN((Y_MAX_BED) - (PROBING_MARGIN_BACK), (Y_MAX_POS) + probe_offset_xy.y)
|
|
|
|
) - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.y));
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static float min_x() { return _min_x() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.x)); }
|
|
|
|
|
|
|
|
static float max_x() { return _max_x() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.x)); }
|
|
|
|
|
|
|
|
static float min_y() { return _min_y() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.y)); }
|
|
|
|
|
|
|
|
static float max_y() { return _max_y() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.y)); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// constexpr helpers used in build-time static_asserts, relying on default probe offsets.
|
|
|
|
|
|
|
|
class build_time {
|
|
|
|
|
|
|
|
static constexpr xyz_pos_t default_probe_xyz_offset =
|
|
|
|
|
|
|
|
#if HAS_BED_PROBE
|
|
|
|
|
|
|
|
NOZZLE_TO_PROBE_OFFSET
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
{ 0 }
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
;
|
|
|
|
|
|
|
|
static constexpr xy_pos_t default_probe_xy_offset = { default_probe_xyz_offset.x, default_probe_xyz_offset.y };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static constexpr bool can_reach(float x, float y) {
|
|
|
|
|
|
|
|
#if IS_KINEMATIC
|
|
|
|
|
|
|
|
return HYPOT2(x, y) <= sq(probe_radius(default_probe_xy_offset));
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
return WITHIN(x, _min_x(default_probe_xy_offset) - fslop, _max_x(default_probe_xy_offset) + fslop)
|
|
|
|
|
|
|
|
&& WITHIN(y, _min_y(default_probe_xy_offset) - fslop, _max_y(default_probe_xy_offset) + fslop);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static constexpr bool can_reach(const xy_pos_t &point) { return can_reach(point.x, point.y); }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#if NEEDS_THREE_PROBE_POINTS
|
|
|
|
#if NEEDS_THREE_PROBE_POINTS
|
|
|
|
// Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used.
|
|
|
|
// Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used.
|
|
|
|
template <typename T>
|
|
|
|
template <typename T>
|
|
|
|
static inline void get_three_points(T points[3]) {
|
|
|
|
static void get_three_points(T points[3]) {
|
|
|
|
#if HAS_FIXED_3POINT
|
|
|
|
#if HAS_FIXED_3POINT
|
|
|
|
|
|
|
|
#define VALIDATE_PROBE_PT(N) static_assert(Probe::build_time::can_reach(xy_pos_t{PROBE_PT_##N##_X, PROBE_PT_##N##_Y}), \
|
|
|
|
|
|
|
|
"PROBE_PT_" STRINGIFY(N) "_(X|Y) is unreachable using default NOZZLE_TO_PROBE_OFFSET and PROBING_MARGIN");
|
|
|
|
|
|
|
|
VALIDATE_PROBE_PT(1); VALIDATE_PROBE_PT(2); VALIDATE_PROBE_PT(3);
|
|
|
|
points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y);
|
|
|
|
points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y);
|
|
|
|
points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y);
|
|
|
|
points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y);
|
|
|
|
points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y);
|
|
|
|
points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y);
|
|
|
|