Browse Source

Tweaks to motion.h reachable tests

pull/1/head
Scott Lahteine 6 years ago
parent
commit
f0dbe61692
  1. 25
      Marlin/src/module/motion.h

25
Marlin/src/module/motion.h

@ -36,6 +36,9 @@
#include "../module/scara.h" #include "../module/scara.h"
#endif #endif
// Error margin to work around float imprecision
constexpr float slop = 0.0001;
extern bool relative_mode; extern bool relative_mode;
extern float current_position[XYZE], // High-level current tool position extern float current_position[XYZE], // High-level current tool position
@ -267,20 +270,14 @@ void homeaxis(const AxisEnum axis);
// Return true if the given position is within the machine bounds. // Return true if the given position is within the machine bounds.
inline bool position_is_reachable(const float &rx, const float &ry) { inline bool position_is_reachable(const float &rx, const float &ry) {
if (!WITHIN(ry, Y_MIN_POS - slop, Y_MAX_POS + slop)) return false;
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
if (active_extruder == 0) { if (active_extruder)
// Add 0.001 margin to deal with float imprecision return WITHIN(rx, X2_MIN_POS - slop, X2_MAX_POS + slop);
return WITHIN(rx, X1_MIN_POS - 0.001f, X1_MAX_POS + 0.001f) else
&& WITHIN(ry, Y_MIN_POS - 0.001f, Y_MAX_POS + 0.001f); return WITHIN(rx, X1_MIN_POS - slop, X1_MAX_POS + slop);
} else {
// Add 0.001 margin to deal with float imprecision
return WITHIN(rx, X2_MIN_POS - 0.001f, X2_MAX_POS + 0.001f)
&& WITHIN(ry, Y_MIN_POS - 0.001f, Y_MAX_POS + 0.001f);
}
#else #else
// Add 0.001 margin to deal with float imprecision return WITHIN(rx, X_MIN_POS - slop, X_MAX_POS + slop);
return WITHIN(rx, X_MIN_POS - 0.001f, X_MAX_POS + 0.001f)
&& WITHIN(ry, Y_MIN_POS - 0.001f, Y_MAX_POS + 0.001f);
#endif #endif
} }
@ -294,8 +291,8 @@ void homeaxis(const AxisEnum axis);
*/ */
inline bool position_is_reachable_by_probe(const float &rx, const float &ry) { inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
return position_is_reachable(rx - (X_PROBE_OFFSET_FROM_EXTRUDER), ry - (Y_PROBE_OFFSET_FROM_EXTRUDER)) return position_is_reachable(rx - (X_PROBE_OFFSET_FROM_EXTRUDER), ry - (Y_PROBE_OFFSET_FROM_EXTRUDER))
&& WITHIN(rx, MIN_PROBE_X - 0.001f, MAX_PROBE_X + 0.001f) && WITHIN(rx, MIN_PROBE_X - slop, MAX_PROBE_X + slop)
&& WITHIN(ry, MIN_PROBE_Y - 0.001f, MAX_PROBE_Y + 0.001f); && WITHIN(ry, MIN_PROBE_Y - slop, MAX_PROBE_Y + slop);
} }
#endif #endif

Loading…
Cancel
Save