|
@@ -62,12 +62,12 @@ public:
|
62
|
62
|
#if HAS_PROBE_XY_OFFSET
|
63
|
63
|
// Return true if the both nozzle and the probe can reach the given point.
|
64
|
64
|
// Note: This won't work on SCARA since the probe offset rotates with the arm.
|
65
|
|
- static inline bool can_reach(const float &rx, const float &ry) {
|
|
65
|
+ static bool can_reach(const float &rx, const float &ry) {
|
66
|
66
|
return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y) // The nozzle can go where it needs to go?
|
67
|
67
|
&& position_is_reachable(rx, ry, ABS(PROBING_MARGIN)); // Can the nozzle also go near there?
|
68
|
68
|
}
|
69
|
69
|
#else
|
70
|
|
- FORCE_INLINE static bool can_reach(const float &rx, const float &ry) {
|
|
70
|
+ static bool can_reach(const float &rx, const float &ry) {
|
71
|
71
|
return position_is_reachable(rx, ry, PROBING_MARGIN);
|
72
|
72
|
}
|
73
|
73
|
#endif
|
|
@@ -81,7 +81,7 @@ public:
|
81
|
81
|
* Example: For a probe offset of -10,+10, then for the probe to reach 0,0 the
|
82
|
82
|
* nozzle must be be able to reach +10,-10.
|
83
|
83
|
*/
|
84
|
|
- static inline bool can_reach(const float &rx, const float &ry) {
|
|
84
|
+ static bool can_reach(const float &rx, const float &ry) {
|
85
|
85
|
return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y)
|
86
|
86
|
&& WITHIN(rx, min_x() - fslop, max_x() + fslop)
|
87
|
87
|
&& WITHIN(ry, min_y() - fslop, max_y() + fslop);
|
|
@@ -89,13 +89,13 @@ public:
|
89
|
89
|
|
90
|
90
|
#endif
|
91
|
91
|
|
92
|
|
- static inline void move_z_after_probing() {
|
|
92
|
+ static void move_z_after_probing() {
|
93
|
93
|
#ifdef Z_AFTER_PROBING
|
94
|
94
|
do_z_clearance(Z_AFTER_PROBING, true, true, true); // Move down still permitted
|
95
|
95
|
#endif
|
96
|
96
|
}
|
97
|
97
|
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);
|
98
|
|
- 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) {
|
|
98
|
+ 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) {
|
99
|
99
|
return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative, sanity_check);
|
100
|
100
|
}
|
101
|
101
|
|
|
@@ -105,21 +105,21 @@ public:
|
105
|
105
|
|
106
|
106
|
static bool set_deployed(const bool) { return false; }
|
107
|
107
|
|
108
|
|
- FORCE_INLINE static bool can_reach(const float &rx, const float &ry) { return position_is_reachable(rx, ry); }
|
|
108
|
+ static bool can_reach(const float &rx, const float &ry) { return position_is_reachable(rx, ry); }
|
109
|
109
|
|
110
|
110
|
#endif
|
111
|
111
|
|
112
|
|
- static inline void move_z_after_homing() {
|
|
112
|
+ static void move_z_after_homing() {
|
113
|
113
|
#ifdef Z_AFTER_HOMING
|
114
|
114
|
do_z_clearance(Z_AFTER_HOMING, true, true, true);
|
115
|
|
- #elif BOTH(Z_AFTER_PROBING,HAS_BED_PROBE)
|
|
115
|
+ #elif BOTH(Z_AFTER_PROBING, HAS_BED_PROBE)
|
116
|
116
|
move_z_after_probing();
|
117
|
117
|
#endif
|
118
|
118
|
}
|
119
|
119
|
|
120
|
|
- FORCE_INLINE static bool can_reach(const xy_pos_t &pos) { return can_reach(pos.x, pos.y); }
|
|
120
|
+ static bool can_reach(const xy_pos_t &pos) { return can_reach(pos.x, pos.y); }
|
121
|
121
|
|
122
|
|
- FORCE_INLINE static bool good_bounds(const xy_pos_t &lf, const xy_pos_t &rb) {
|
|
122
|
+ static bool good_bounds(const xy_pos_t &lf, const xy_pos_t &rb) {
|
123
|
123
|
return (
|
124
|
124
|
#if IS_KINEMATIC
|
125
|
125
|
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:
|
137
|
137
|
static constexpr xy_pos_t offset_xy = xy_pos_t({ 0, 0 }); // See #16767
|
138
|
138
|
#endif
|
139
|
139
|
|
140
|
|
- static inline bool deploy() { return set_deployed(true); }
|
141
|
|
- static inline bool stow() { return set_deployed(false); }
|
|
140
|
+ static bool deploy() { return set_deployed(true); }
|
|
141
|
+ static bool stow() { return set_deployed(false); }
|
142
|
142
|
|
143
|
143
|
#if HAS_BED_PROBE || HAS_LEVELING
|
144
|
144
|
#if IS_KINEMATIC
|
|
@@ -146,41 +146,73 @@ public:
|
146
|
146
|
TERN_(DELTA, DELTA_PRINTABLE_RADIUS)
|
147
|
147
|
TERN_(IS_SCARA, SCARA_PRINTABLE_RADIUS)
|
148
|
148
|
);
|
149
|
|
- static inline float probe_radius() {
|
150
|
|
- return printable_radius - _MAX(PROBING_MARGIN, HYPOT(offset_xy.x, offset_xy.y));
|
|
149
|
+ static constexpr float probe_radius(const xy_pos_t &probe_offset_xy = offset_xy) {
|
|
150
|
+ return printable_radius - _MAX(PROBING_MARGIN, HYPOT(probe_offset_xy.x, probe_offset_xy.y));
|
151
|
151
|
}
|
152
|
152
|
#endif
|
153
|
153
|
|
154
|
|
- static inline float min_x() {
|
|
154
|
+ static constexpr float _min_x(const xy_pos_t &probe_offset_xy = offset_xy) {
|
155
|
155
|
return TERN(IS_KINEMATIC,
|
156
|
|
- (X_CENTER) - probe_radius(),
|
157
|
|
- _MAX((X_MIN_BED) + (PROBING_MARGIN_LEFT), (X_MIN_POS) + offset_xy.x)
|
158
|
|
- ) - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.x));
|
|
156
|
+ (X_CENTER) - probe_radius(probe_offset_xy),
|
|
157
|
+ _MAX((X_MIN_BED) + (PROBING_MARGIN_LEFT), (X_MIN_POS) + probe_offset_xy.x)
|
|
158
|
+ );
|
159
|
159
|
}
|
160
|
|
- static inline float max_x() {
|
|
160
|
+ static constexpr float _max_x(const xy_pos_t &probe_offset_xy = offset_xy) {
|
161
|
161
|
return TERN(IS_KINEMATIC,
|
162
|
|
- (X_CENTER) + probe_radius(),
|
163
|
|
- _MIN((X_MAX_BED) - (PROBING_MARGIN_RIGHT), (X_MAX_POS) + offset_xy.x)
|
164
|
|
- ) - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.x));
|
|
162
|
+ (X_CENTER) + probe_radius(probe_offset_xy),
|
|
163
|
+ _MIN((X_MAX_BED) - (PROBING_MARGIN_RIGHT), (X_MAX_POS) + probe_offset_xy.x)
|
|
164
|
+ );
|
165
|
165
|
}
|
166
|
|
- static inline float min_y() {
|
|
166
|
+ static constexpr float _min_y(const xy_pos_t &probe_offset_xy = offset_xy) {
|
167
|
167
|
return TERN(IS_KINEMATIC,
|
168
|
|
- (Y_CENTER) - probe_radius(),
|
169
|
|
- _MAX((Y_MIN_BED) + (PROBING_MARGIN_FRONT), (Y_MIN_POS) + offset_xy.y)
|
170
|
|
- ) - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.y));
|
|
168
|
+ (Y_CENTER) - probe_radius(probe_offset_xy),
|
|
169
|
+ _MAX((Y_MIN_BED) + (PROBING_MARGIN_FRONT), (Y_MIN_POS) + probe_offset_xy.y)
|
|
170
|
+ );
|
171
|
171
|
}
|
172
|
|
- static inline float max_y() {
|
|
172
|
+ static constexpr float _max_y(const xy_pos_t &probe_offset_xy = offset_xy) {
|
173
|
173
|
return TERN(IS_KINEMATIC,
|
174
|
|
- (Y_CENTER) + probe_radius(),
|
175
|
|
- _MIN((Y_MAX_BED) - (PROBING_MARGIN_BACK), (Y_MAX_POS) + offset_xy.y)
|
176
|
|
- ) - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.y));
|
|
174
|
+ (Y_CENTER) + probe_radius(probe_offset_xy),
|
|
175
|
+ _MIN((Y_MAX_BED) - (PROBING_MARGIN_BACK), (Y_MAX_POS) + probe_offset_xy.y)
|
|
176
|
+ );
|
177
|
177
|
}
|
178
|
178
|
|
|
179
|
+ static float min_x() { return _min_x() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.x)); }
|
|
180
|
+ static float max_x() { return _max_x() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.x)); }
|
|
181
|
+ static float min_y() { return _min_y() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.y)); }
|
|
182
|
+ static float max_y() { return _max_y() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.y)); }
|
|
183
|
+
|
|
184
|
+ // constexpr helpers used in build-time static_asserts, relying on default probe offsets.
|
|
185
|
+ class build_time {
|
|
186
|
+ static constexpr xyz_pos_t default_probe_xyz_offset =
|
|
187
|
+ #if HAS_BED_PROBE
|
|
188
|
+ NOZZLE_TO_PROBE_OFFSET
|
|
189
|
+ #else
|
|
190
|
+ { 0 }
|
|
191
|
+ #endif
|
|
192
|
+ ;
|
|
193
|
+ static constexpr xy_pos_t default_probe_xy_offset = { default_probe_xyz_offset.x, default_probe_xyz_offset.y };
|
|
194
|
+
|
|
195
|
+ public:
|
|
196
|
+ static constexpr bool can_reach(float x, float y) {
|
|
197
|
+ #if IS_KINEMATIC
|
|
198
|
+ return HYPOT2(x, y) <= sq(probe_radius(default_probe_xy_offset));
|
|
199
|
+ #else
|
|
200
|
+ return WITHIN(x, _min_x(default_probe_xy_offset) - fslop, _max_x(default_probe_xy_offset) + fslop)
|
|
201
|
+ && WITHIN(y, _min_y(default_probe_xy_offset) - fslop, _max_y(default_probe_xy_offset) + fslop);
|
|
202
|
+ #endif
|
|
203
|
+ }
|
|
204
|
+
|
|
205
|
+ static constexpr bool can_reach(const xy_pos_t &point) { return can_reach(point.x, point.y); }
|
|
206
|
+ };
|
|
207
|
+
|
179
|
208
|
#if NEEDS_THREE_PROBE_POINTS
|
180
|
209
|
// Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used.
|
181
|
210
|
template <typename T>
|
182
|
|
- static inline void get_three_points(T points[3]) {
|
|
211
|
+ static void get_three_points(T points[3]) {
|
183
|
212
|
#if HAS_FIXED_3POINT
|
|
213
|
+ #define VALIDATE_PROBE_PT(N) static_assert(Probe::build_time::can_reach(xy_pos_t{PROBE_PT_##N##_X, PROBE_PT_##N##_Y}), \
|
|
214
|
+ "PROBE_PT_" STRINGIFY(N) "_(X|Y) is unreachable using default NOZZLE_TO_PROBE_OFFSET and PROBING_MARGIN");
|
|
215
|
+ VALIDATE_PROBE_PT(1); VALIDATE_PROBE_PT(2); VALIDATE_PROBE_PT(3);
|
184
|
216
|
points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y);
|
185
|
217
|
points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y);
|
186
|
218
|
points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y);
|