Extra insurance against endstop false positives (#11013)

This commit is contained in:
Scott Lahteine 2018-06-13 01:22:02 -05:00 committed by GitHub
parent 81edbfa665
commit 4c8d6df13c
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 16 deletions

View file

@ -265,7 +265,7 @@ void Endstops::not_homing() {
// Enable / disable endstop z-probe checking // Enable / disable endstop z-probe checking
#if HAS_BED_PROBE #if HAS_BED_PROBE
void Endstops::enable_z_probe(bool onoff) { void Endstops::enable_z_probe(const bool onoff) {
z_probe_enabled = onoff; z_probe_enabled = onoff;
#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE) #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
@ -439,7 +439,7 @@ void Endstops::update() {
if (stepper.axis_is_moving(X_AXIS)) { if (stepper.axis_is_moving(X_AXIS)) {
if (stepper.motor_direction(X_AXIS_HEAD)) { // -direction if (stepper.motor_direction(X_AXIS_HEAD)) { // -direction
#if HAS_X_MIN #if HAS_X_MIN
#if ENABLED(X_DUAL_ENDSTOPS) #if ENABLED(X_DUAL_ENDSTOPS) && X_HOME_DIR < 0
UPDATE_ENDSTOP_BIT(X, MIN); UPDATE_ENDSTOP_BIT(X, MIN);
#if HAS_X2_MIN #if HAS_X2_MIN
UPDATE_ENDSTOP_BIT(X2, MIN); UPDATE_ENDSTOP_BIT(X2, MIN);
@ -453,7 +453,7 @@ void Endstops::update() {
} }
else { // +direction else { // +direction
#if HAS_X_MAX #if HAS_X_MAX
#if ENABLED(X_DUAL_ENDSTOPS) #if ENABLED(X_DUAL_ENDSTOPS) && X_HOME_DIR > 0
UPDATE_ENDSTOP_BIT(X, MAX); UPDATE_ENDSTOP_BIT(X, MAX);
#if HAS_X2_MAX #if HAS_X2_MAX
UPDATE_ENDSTOP_BIT(X2, MAX); UPDATE_ENDSTOP_BIT(X2, MAX);
@ -469,7 +469,7 @@ void Endstops::update() {
if (stepper.axis_is_moving(Y_AXIS)) { if (stepper.axis_is_moving(Y_AXIS)) {
if (stepper.motor_direction(Y_AXIS_HEAD)) { // -direction 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) #if ENABLED(Y_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(Y, MIN); UPDATE_ENDSTOP_BIT(Y, MIN);
#if HAS_Y2_MIN #if HAS_Y2_MIN
@ -483,7 +483,7 @@ void Endstops::update() {
#endif #endif
} }
else { // +direction else { // +direction
#if HAS_Y_MAX #if HAS_Y_MAX && Y_HOME_DIR > 0
#if ENABLED(Y_DUAL_ENDSTOPS) #if ENABLED(Y_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(Y, MAX); UPDATE_ENDSTOP_BIT(Y, MAX);
#if HAS_Y2_MAX #if HAS_Y2_MAX
@ -501,21 +501,19 @@ void Endstops::update() {
if (stepper.axis_is_moving(Z_AXIS)) { if (stepper.axis_is_moving(Z_AXIS)) {
if (stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up. if (stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up.
#if HAS_Z_MIN #if HAS_Z_MIN
#if ENABLED(Z_DUAL_ENDSTOPS) #if ENABLED(Z_DUAL_ENDSTOPS) && Z_HOME_DIR < 0
UPDATE_ENDSTOP_BIT(Z, MIN); UPDATE_ENDSTOP_BIT(Z, MIN);
#if HAS_Z2_MIN #if HAS_Z2_MIN
UPDATE_ENDSTOP_BIT(Z2, MIN); UPDATE_ENDSTOP_BIT(Z2, MIN);
#else #else
COPY_BIT(live_state, Z_MIN, Z2_MIN); COPY_BIT(live_state, Z_MIN, Z2_MIN);
#endif #endif
#else #elif ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
if (z_probe_enabled) UPDATE_ENDSTOP_BIT(Z, MIN); if (z_probe_enabled) UPDATE_ENDSTOP_BIT(Z, MIN);
#else #elif Z_HOME_DIR < 0
UPDATE_ENDSTOP_BIT(Z, MIN); UPDATE_ENDSTOP_BIT(Z, MIN);
#endif #endif
#endif #endif
#endif
// When closing the gap check the enabled probe // When closing the gap check the enabled probe
#if ENABLED(Z_MIN_PROBE_ENDSTOP) #if ENABLED(Z_MIN_PROBE_ENDSTOP)
@ -523,7 +521,7 @@ void Endstops::update() {
#endif #endif
} }
else { // Z +direction. Gantry up, bed down. else { // Z +direction. Gantry up, bed down.
#if HAS_Z_MAX #if HAS_Z_MAX && Z_HOME_DIR > 0
// Check both Z dual endstops // Check both Z dual endstops
#if ENABLED(Z_DUAL_ENDSTOPS) #if ENABLED(Z_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(Z, MAX); UPDATE_ENDSTOP_BIT(Z, MAX);
@ -532,9 +530,8 @@ void Endstops::update() {
#else #else
COPY_BIT(live_state, Z_MAX, Z2_MAX); COPY_BIT(live_state, Z_MAX, Z2_MAX);
#endif #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 #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); UPDATE_ENDSTOP_BIT(Z, MAX);
#endif #endif
#endif #endif

View file

@ -143,7 +143,7 @@ class Endstops {
// Enable / disable endstop z-probe checking // Enable / disable endstop z-probe checking
#if HAS_BED_PROBE #if HAS_BED_PROBE
static volatile bool z_probe_enabled; static volatile bool z_probe_enabled;
static void enable_z_probe(bool onoff=true); static void enable_z_probe(const bool onoff=true);
#endif #endif
// Debugging of endstops // Debugging of endstops