homeaxis() can leave early

when no known axis needs to be homed.

Most changes are only caused from altering the indentation.
```
if (axis == X_AXIS ? HOMEAXIS_DO(X) : axis == Y_AXIS ? HOMEAXIS_DO(Y) : axis == Z_AXIS ? HOMEAXIS_DO(Z) : 0) {
  ...
}

to

if (!(axis == X_AXIS ? HOMEAXIS_DO(X) : axis == Y_AXIS ? HOMEAXIS_DO(Y) : axis == Z_AXIS ? HOMEAXIS_DO(Z) : 0)) return;
...

```
This commit is contained in:
AnHardt 2016-07-08 15:59:33 +02:00
parent eff7912243
commit 468f7f03a2

View File

@ -2344,135 +2344,134 @@ static void clean_up_after_endstop_or_probe_move() {
#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS) #define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
static void homeaxis(AxisEnum axis) { static void homeaxis(AxisEnum axis) {
#define HOMEAXIS_DO(LETTER) \
((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
if (!(axis == X_AXIS ? HOMEAXIS_DO(X) : axis == Y_AXIS ? HOMEAXIS_DO(Y) : axis == Z_AXIS ? HOMEAXIS_DO(Z) : 0)) return;
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR(">>> homeaxis(", axis); SERIAL_ECHOPAIR(">>> homeaxis(", axis);
SERIAL_ECHOLNPGM(")"); SERIAL_ECHOLNPGM(")");
} }
#endif #endif
#define HOMEAXIS_DO(LETTER) \
((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
if (axis == X_AXIS ? HOMEAXIS_DO(X) : axis == Y_AXIS ? HOMEAXIS_DO(Y) : axis == Z_AXIS ? HOMEAXIS_DO(Z) : 0) { int axis_home_dir =
#if ENABLED(DUAL_X_CARRIAGE)
(axis == X_AXIS) ? x_home_dir(active_extruder) :
#endif
home_dir(axis);
int axis_home_dir = // Homing Z towards the bed? Deploy the Z probe or endstop.
#if ENABLED(DUAL_X_CARRIAGE) #if HAS_BED_PROBE
(axis == X_AXIS) ? x_home_dir(active_extruder) : if (axis == Z_AXIS && axis_home_dir < 0) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
#endif #endif
home_dir(axis); if (DEPLOY_PROBE()) return;
}
#endif
// Homing Z towards the bed? Deploy the Z probe or endstop. // Set the axis position as setup for the move
#if HAS_BED_PROBE current_position[axis] = 0;
if (axis == Z_AXIS && axis_home_dir < 0) { sync_plan_position();
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> "); // Set a flag for Z motor locking
#endif #if ENABLED(Z_DUAL_ENDSTOPS)
if (DEPLOY_PROBE()) return; if (axis == Z_AXIS) stepper.set_homing_flag(true);
#endif
// Move towards the endstop until an endstop is triggered
destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
feedrate = homing_feedrate[axis];
line_to_destination();
stepper.synchronize();
// Set the axis position as setup for the move
current_position[axis] = 0;
sync_plan_position();
// Move away from the endstop by the axis HOME_BUMP_MM
destination[axis] = -home_bump_mm(axis) * axis_home_dir;
line_to_destination();
stepper.synchronize();
// Slow down the feedrate for the next move
set_homing_bump_feedrate(axis);
// Move slowly towards the endstop until triggered
destination[axis] = 2 * home_bump_mm(axis) * axis_home_dir;
line_to_destination();
stepper.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position);
#endif
#if ENABLED(Z_DUAL_ENDSTOPS)
if (axis == Z_AXIS) {
float adj = fabs(z_endstop_adj);
bool lockZ1;
if (axis_home_dir > 0) {
adj = -adj;
lockZ1 = (z_endstop_adj > 0);
} }
#endif else
lockZ1 = (z_endstop_adj < 0);
// Set the axis position as setup for the move if (lockZ1) stepper.set_z_lock(true); else stepper.set_z2_lock(true);
current_position[axis] = 0; sync_plan_position();
sync_plan_position();
// Set a flag for Z motor locking // Move to the adjusted endstop height
#if ENABLED(Z_DUAL_ENDSTOPS) feedrate = homing_feedrate[axis];
if (axis == Z_AXIS) stepper.set_homing_flag(true); destination[Z_AXIS] = adj;
#endif line_to_destination();
stepper.synchronize();
// Move towards the endstop until an endstop is triggered if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false);
destination[axis] = 1.5 * max_length(axis) * axis_home_dir; stepper.set_homing_flag(false);
feedrate = homing_feedrate[axis]; } // Z_AXIS
line_to_destination(); #endif
stepper.synchronize();
// Set the axis position as setup for the move #if ENABLED(DELTA)
current_position[axis] = 0; // retrace by the amount specified in endstop_adj
sync_plan_position(); if (endstop_adj[axis] * axis_home_dir < 0) {
sync_plan_position();
// Move away from the endstop by the axis HOME_BUMP_MM destination[axis] = endstop_adj[axis];
destination[axis] = -home_bump_mm(axis) * axis_home_dir; #if ENABLED(DEBUG_LEVELING_FEATURE)
line_to_destination(); if (DEBUGGING(LEVELING)) {
stepper.synchronize(); SERIAL_ECHOPAIR("> endstop_adj = ", endstop_adj[axis]);
DEBUG_POS("", destination);
// Slow down the feedrate for the next move
set_homing_bump_feedrate(axis);
// Move slowly towards the endstop until triggered
destination[axis] = 2 * home_bump_mm(axis) * axis_home_dir;
line_to_destination();
stepper.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position);
#endif
#if ENABLED(Z_DUAL_ENDSTOPS)
if (axis == Z_AXIS) {
float adj = fabs(z_endstop_adj);
bool lockZ1;
if (axis_home_dir > 0) {
adj = -adj;
lockZ1 = (z_endstop_adj > 0);
} }
else #endif
lockZ1 = (z_endstop_adj < 0); line_to_destination();
stepper.synchronize();
}
#endif
if (lockZ1) stepper.set_z_lock(true); else stepper.set_z2_lock(true); // Set the axis position to its home position (plus home offsets)
sync_plan_position(); set_axis_is_at_home(axis);
// Move to the adjusted endstop height SYNC_PLAN_POSITION_KINEMATIC();
feedrate = homing_feedrate[axis];
destination[Z_AXIS] = adj;
line_to_destination();
stepper.synchronize();
if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false); #if ENABLED(DEBUG_LEVELING_FEATURE)
stepper.set_homing_flag(false); if (DEBUGGING(LEVELING)) DEBUG_POS("> AFTER set_axis_is_at_home", current_position);
} // Z_AXIS #endif
#endif
#if ENABLED(DELTA) destination[axis] = current_position[axis];
// retrace by the amount specified in endstop_adj endstops.hit_on_purpose(); // clear endstop hit flags
if (endstop_adj[axis] * axis_home_dir < 0) { axis_known_position[axis] = true;
sync_plan_position(); axis_homed[axis] = true;
destination[axis] = endstop_adj[axis];
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("> endstop_adj = ", endstop_adj[axis]);
DEBUG_POS("", destination);
}
#endif
line_to_destination();
stepper.synchronize();
}
#endif
// Set the axis position to its home position (plus home offsets) // Put away the Z probe
set_axis_is_at_home(axis); #if HAS_BED_PROBE
if (axis == Z_AXIS && axis_home_dir < 0) {
SYNC_PLAN_POSITION_KINEMATIC(); #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
#if ENABLED(DEBUG_LEVELING_FEATURE) #endif
if (DEBUGGING(LEVELING)) DEBUG_POS("> AFTER set_axis_is_at_home", current_position); if (STOW_PROBE()) return;
#endif }
#endif
destination[axis] = current_position[axis];
endstops.hit_on_purpose(); // clear endstop hit flags
axis_known_position[axis] = true;
axis_homed[axis] = true;
// Put away the Z probe
#if HAS_BED_PROBE
if (axis == Z_AXIS && axis_home_dir < 0) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
#endif
if (STOW_PROBE()) return;
}
#endif
}
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {