Cleanup for dual endstops homing

This commit is contained in:
Scott Lahteine
2018-06-02 20:39:00 -05:00
parent 61181b7f24
commit ad8d3150aa
4 changed files with 58 additions and 62 deletions

View File

@ -1052,9 +1052,14 @@ static void do_homing_move(const AxisEnum axis, const float distance, const floa
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR(">>> do_homing_move(", axis_codes[axis]);
SERIAL_ECHOPAIR(", ", distance);
SERIAL_ECHOPAIR(", ", fr_mm_s);
SERIAL_ECHOPAIR(" [", fr_mm_s ? fr_mm_s : homing_feedrate(axis));
SERIAL_ECHOLNPGM("])");
SERIAL_ECHOPGM(", ");
if (fr_mm_s)
SERIAL_ECHO(fr_mm_s);
else {
SERIAL_ECHOPAIR("[", homing_feedrate(axis));
SERIAL_CHAR(']');
}
SERIAL_ECHOLNPGM(")");
}
#endif
@ -1262,11 +1267,12 @@ void homeaxis(const AxisEnum axis) {
}
#endif
const int axis_home_dir =
const int axis_home_dir = (
#if ENABLED(DUAL_X_CARRIAGE)
(axis == X_AXIS) ? x_home_dir(active_extruder) :
axis == X_AXIS ? x_home_dir(active_extruder) :
#endif
home_dir(axis);
home_dir(axis)
);
// Homing Z towards the bed? Deploy the Z probe or endstop.
#if HOMING_Z_WITH_PROBE
@ -1274,14 +1280,20 @@ void homeaxis(const AxisEnum axis) {
#endif
// 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_z(true);
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
switch (axis) {
#if ENABLED(X_DUAL_ENDSTOPS)
case X_AXIS:
#endif
#if ENABLED(Y_DUAL_ENDSTOPS)
case Y_AXIS:
#endif
#if ENABLED(Z_DUAL_ENDSTOPS)
case Z_AXIS:
#endif
stepper.set_homing_dual_axis(true);
default: break;
}
#endif
// Fast move towards endstop until triggered
@ -1321,37 +1333,32 @@ void homeaxis(const AxisEnum axis) {
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 = ABS(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);
const float adj = ABS(endstops.x_endstop_adj);
if (pos_dir ? (endstops.x_endstop_adj > 0) : (endstops.x_endstop_adj < 0)) stepper.set_x_lock(true); else stepper.set_x2_lock(true);
do_homing_move(axis, pos_dir ? adj : -adj);
stepper.set_x_lock(false);
stepper.set_x2_lock(false);
}
#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 = ABS(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);
const float adj = ABS(endstops.y_endstop_adj);
if (pos_dir ? (endstops.y_endstop_adj > 0) : (endstops.y_endstop_adj < 0)) stepper.set_y_lock(true); else stepper.set_y2_lock(true);
do_homing_move(axis, pos_dir ? adj : -adj);
stepper.set_y_lock(false);
stepper.set_y2_lock(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 = ABS(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);
const float adj = ABS(endstops.z_endstop_adj);
if (pos_dir ? (endstops.z_endstop_adj > 0) : (endstops.z_endstop_adj < 0)) stepper.set_z_lock(true); else stepper.set_z2_lock(true);
do_homing_move(axis, pos_dir ? adj : -adj);
stepper.set_z_lock(false);
stepper.set_z2_lock(false);
}
#endif
stepper.set_homing_dual_axis(false);
#endif
#if IS_SCARA
@ -1393,10 +1400,9 @@ void homeaxis(const AxisEnum axis) {
if (axis == Z_AXIS && STOW_PROBE()) return;
#endif
// Clear z_lift if homing the Z axis
// Clear retracted status if homing the Z axis
#if ENABLED(FWRETRACT)
if (axis == Z_AXIS)
fwretract.hop_amount = 0.0;
if (axis == Z_AXIS) fwretract.hop_amount = 0.0;
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
@ -1470,7 +1476,7 @@ void homeaxis(const AxisEnum axis) {
#endif
#if ENABLED(DELTA)
switch(axis) {
switch (axis) {
#if HAS_SOFTWARE_ENDSTOPS
case X_AXIS:
case Y_AXIS: