Implement support for Dual X and Y endstops

This commit is contained in:
Scott Lahteine
2017-10-29 03:43:44 -05:00
parent 7465ede058
commit 723f2a77f6
13 changed files with 736 additions and 239 deletions

View File

@ -1043,9 +1043,15 @@ void homeaxis(const AxisEnum axis) {
if (axis == Z_AXIS && DEPLOY_PROBE()) return;
#endif
// Set a flag for Z motor locking
// Set flags for X, Y, Z motor locking
#if ENABLED(X_DUAL_ENDSTOPS)
if (axis == X_AXIS) stepper.set_homing_flag_x(true);
#endif
#if ENABLED(Y_DUAL_ENDSTOPS)
if (axis == Y_AXIS) stepper.set_homing_flag_y(true);
#endif
#if ENABLED(Z_DUAL_ENDSTOPS)
if (axis == Z_AXIS) stepper.set_homing_flag(true);
if (axis == Z_AXIS) stepper.set_homing_flag_z(true);
#endif
// Disable stealthChop if used. Enable diag1 pin on driver.
@ -1087,25 +1093,41 @@ void homeaxis(const AxisEnum axis) {
do_homing_move(axis, 2 * bump, get_homing_bump_feedrate(axis));
}
#if ENABLED(Z_DUAL_ENDSTOPS)
if (axis == Z_AXIS) {
float adj = FABS(endstops.z_endstop_adj);
bool lockZ1;
if (axis_home_dir > 0) {
adj = -adj;
lockZ1 = (endstops.z_endstop_adj > 0);
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
const bool pos_dir = axis_home_dir > 0;
#if ENABLED(X_DUAL_ENDSTOPS)
if (axis == X_AXIS) {
const bool lock_x1 = pos_dir ? (endstops.x_endstop_adj > 0) : (endstops.x_endstop_adj < 0);
float adj = FABS(endstops.x_endstop_adj);
if (pos_dir) adj = -adj;
if (lock_x1) stepper.set_x_lock(true); else stepper.set_x2_lock(true);
do_homing_move(axis, adj);
if (lock_x1) stepper.set_x_lock(false); else stepper.set_x2_lock(false);
stepper.set_homing_flag_x(false);
}
else
lockZ1 = (endstops.z_endstop_adj < 0);
if (lockZ1) stepper.set_z_lock(true); else stepper.set_z2_lock(true);
// Move to the adjusted endstop height
do_homing_move(axis, adj);
if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false);
stepper.set_homing_flag(false);
} // Z_AXIS
#endif
#if ENABLED(Y_DUAL_ENDSTOPS)
if (axis == Y_AXIS) {
const bool lock_y1 = pos_dir ? (endstops.y_endstop_adj > 0) : (endstops.y_endstop_adj < 0);
float adj = FABS(endstops.y_endstop_adj);
if (pos_dir) adj = -adj;
if (lock_y1) stepper.set_y_lock(true); else stepper.set_y2_lock(true);
do_homing_move(axis, adj);
if (lock_y1) stepper.set_y_lock(false); else stepper.set_y2_lock(false);
stepper.set_homing_flag_y(false);
}
#endif
#if ENABLED(Z_DUAL_ENDSTOPS)
if (axis == Z_AXIS) {
const bool lock_z1 = pos_dir ? (endstops.z_endstop_adj > 0) : (endstops.z_endstop_adj < 0);
float adj = FABS(endstops.z_endstop_adj);
if (pos_dir) adj = -adj;
if (lock_z1) stepper.set_z_lock(true); else stepper.set_z2_lock(true);
do_homing_move(axis, adj);
if (lock_z1) stepper.set_z_lock(false); else stepper.set_z2_lock(false);
stepper.set_homing_flag_z(false);
}
#endif
#endif
#if IS_SCARA