Skip to content

Commit

Permalink
Extra insurance against endstop false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Sep 22, 2018
1 parent 8c454bd commit 57d63f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
27 changes: 12 additions & 15 deletions Marlin/endstops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void Endstops::not_homing() {

// Enable / disable endstop z-probe checking
#if HAS_BED_PROBE
void Endstops::enable_z_probe(bool onoff) {
void Endstops::enable_z_probe(const bool onoff) {
z_probe_enabled = onoff;

#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
Expand Down Expand Up @@ -412,7 +412,7 @@ void Endstops::update() {
if (stepper.axis_is_moving(X_AXIS)) {
if (stepper.motor_direction(X_AXIS_HEAD)) { // -direction
#if HAS_X_MIN
#if ENABLED(X_DUAL_ENDSTOPS)
#if ENABLED(X_DUAL_ENDSTOPS) && X_HOME_DIR < 0
UPDATE_ENDSTOP_BIT(X, MIN);
#if HAS_X2_MIN
UPDATE_ENDSTOP_BIT(X2, MIN);
Expand All @@ -426,7 +426,7 @@ void Endstops::update() {
}
else { // +direction
#if HAS_X_MAX
#if ENABLED(X_DUAL_ENDSTOPS)
#if ENABLED(X_DUAL_ENDSTOPS) && X_HOME_DIR > 0
UPDATE_ENDSTOP_BIT(X, MAX);
#if HAS_X2_MAX
UPDATE_ENDSTOP_BIT(X2, MAX);
Expand All @@ -442,7 +442,7 @@ void Endstops::update() {

if (stepper.axis_is_moving(Y_AXIS)) {
if (stepper.motor_direction(Y_AXIS_HEAD)) { // -direction
#if HAS_Y_MIN
#if HAS_Y_MIN && Y_HOME_DIR < 0
#if ENABLED(Y_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(Y, MIN);
#if HAS_Y2_MIN
Expand All @@ -456,7 +456,7 @@ void Endstops::update() {
#endif
}
else { // +direction
#if HAS_Y_MAX
#if HAS_Y_MAX && Y_HOME_DIR > 0
#if ENABLED(Y_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(Y, MAX);
#if HAS_Y2_MAX
Expand All @@ -474,19 +474,17 @@ void Endstops::update() {
if (stepper.axis_is_moving(Z_AXIS)) {
if (stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up.
#if HAS_Z_MIN
#if ENABLED(Z_DUAL_ENDSTOPS)
#if ENABLED(Z_DUAL_ENDSTOPS) && Z_HOME_DIR < 0
UPDATE_ENDSTOP_BIT(Z, MIN);
#if HAS_Z2_MIN
UPDATE_ENDSTOP_BIT(Z2, MIN);
#else
COPY_BIT(live_state, Z_MIN, Z2_MIN);
#endif
#else
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
if (z_probe_enabled) UPDATE_ENDSTOP_BIT(Z, MIN);
#else
UPDATE_ENDSTOP_BIT(Z, MIN);
#endif
#elif ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
if (z_probe_enabled) UPDATE_ENDSTOP_BIT(Z, MIN);
#elif Z_HOME_DIR < 0
UPDATE_ENDSTOP_BIT(Z, MIN);
#endif
#endif

Expand All @@ -496,7 +494,7 @@ void Endstops::update() {
#endif
}
else { // Z +direction. Gantry up, bed down.
#if HAS_Z_MAX
#if HAS_Z_MAX && Z_HOME_DIR > 0
// Check both Z dual endstops
#if ENABLED(Z_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(Z, MAX);
Expand All @@ -505,9 +503,8 @@ void Endstops::update() {
#else
COPY_BIT(live_state, Z_MAX, Z2_MAX);
#endif
// If this pin is not hijacked for the bed probe
// then it belongs to the Z endstop
#elif DISABLED(Z_MIN_PROBE_ENDSTOP) || Z_MAX_PIN != Z_MIN_PROBE_PIN
// If this pin isn't the bed probe it's the Z endstop
UPDATE_ENDSTOP_BIT(Z, MAX);
#endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/endstops.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class Endstops {
// Enable / disable endstop z-probe checking
#if HAS_BED_PROBE
static volatile bool z_probe_enabled;
static void enable_z_probe(bool onoff=true);
static void enable_z_probe(const bool onoff=true);
#endif

// Debugging of endstops
Expand Down

0 comments on commit 57d63f1

Please sign in to comment.