Only constrain motion on homed axes (#16533)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
FlyingSamson 2020-01-12 00:06:52 +01:00 committed by Scott Lahteine
parent 536778812f
commit fbf2f36cae
2 changed files with 40 additions and 22 deletions

View File

@ -592,10 +592,14 @@ void restore_feedrate_and_scaling() {
*/ */
void apply_motion_limits(xyz_pos_t &target) { void apply_motion_limits(xyz_pos_t &target) {
if (!soft_endstops_enabled || !all_axes_homed()) return; if (!soft_endstops_enabled) return;
#if IS_KINEMATIC #if IS_KINEMATIC
#if ENABLED(DELTA)
if (!all_axes_homed()) return;
#endif
#if HAS_HOTEND_OFFSET && ENABLED(DELTA) #if HAS_HOTEND_OFFSET && ENABLED(DELTA)
// The effector center position will be the target minus the hotend offset. // The effector center position will be the target minus the hotend offset.
const xy_pos_t offs = hotend_offset[active_extruder]; const xy_pos_t offs = hotend_offset[active_extruder];
@ -604,33 +608,46 @@ void restore_feedrate_and_scaling() {
constexpr xy_pos_t offs{0}; constexpr xy_pos_t offs{0};
#endif #endif
const float dist_2 = HYPOT2(target.x - offs.x, target.y - offs.y); if (true
if (dist_2 > delta_max_radius_2) #if IS_SCARA
target *= delta_max_radius / SQRT(dist_2); // 200 / 300 = 0.66 && TEST(axis_homed, X_AXIS) && TEST(axis_homed, Y_AXIS)
#endif
) {
const float dist_2 = HYPOT2(target.x - offs.x, target.y - offs.y);
if (dist_2 > delta_max_radius_2)
target *= delta_max_radius / SQRT(dist_2); // 200 / 300 = 0.66
}
#else #else
#if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_X) if (TEST(axis_homed, X_AXIS)) {
NOLESS(target.x, soft_endstop.min.x); #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_X)
#endif NOLESS(target.x, soft_endstop.min.x);
#if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MAX_SOFTWARE_ENDSTOP_X) #endif
NOMORE(target.x, soft_endstop.max.x); #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MAX_SOFTWARE_ENDSTOP_X)
#endif NOMORE(target.x, soft_endstop.max.x);
#if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_Y) #endif
NOLESS(target.y, soft_endstop.min.y); }
#endif
#if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MAX_SOFTWARE_ENDSTOP_Y) if (TEST(axis_homed, Y_AXIS)) {
NOMORE(target.y, soft_endstop.max.y); #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_Y)
#endif NOLESS(target.y, soft_endstop.min.y);
#endif
#if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MAX_SOFTWARE_ENDSTOP_Y)
NOMORE(target.y, soft_endstop.max.y);
#endif
}
#endif #endif
#if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_Z) if (TEST(axis_homed, Z_AXIS)) {
NOLESS(target.z, soft_endstop.min.z); #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_Z)
#endif NOLESS(target.z, soft_endstop.min.z);
#if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MAX_SOFTWARE_ENDSTOP_Z) #endif
NOMORE(target.z, soft_endstop.max.z); #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MAX_SOFTWARE_ENDSTOP_Z)
#endif NOMORE(target.z, soft_endstop.max.z);
#endif
}
} }
#endif // HAS_SOFTWARE_ENDSTOPS #endif // HAS_SOFTWARE_ENDSTOPS

View File

@ -41,6 +41,7 @@
// Axis homed and known-position states // Axis homed and known-position states
extern uint8_t axis_homed, axis_known_position; extern uint8_t axis_homed, axis_known_position;
constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS); constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS);
FORCE_INLINE bool no_axes_homed() { return !axis_homed; }
FORCE_INLINE bool all_axes_homed() { return (axis_homed & xyz_bits) == xyz_bits; } FORCE_INLINE bool all_axes_homed() { return (axis_homed & xyz_bits) == xyz_bits; }
FORCE_INLINE bool all_axes_known() { return (axis_known_position & xyz_bits) == xyz_bits; } FORCE_INLINE bool all_axes_known() { return (axis_known_position & xyz_bits) == xyz_bits; }
FORCE_INLINE void set_all_unhomed() { axis_homed = 0; } FORCE_INLINE void set_all_unhomed() { axis_homed = 0; }