Poll *all* enabled endstop pins (#15525)

This commit is contained in:
Piotr 2019-10-15 21:28:04 +03:00 committed by Scott Lahteine
parent 93097af0ed
commit fe4c69b64a
8 changed files with 23 additions and 35 deletions

View File

@ -123,7 +123,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
} }
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
#if USES_Z_MIN_PROBE_ENDSTOP #if HAS_CUSTOM_PROBE_PIN
#define TEST_PROBE_PIN (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING) #define TEST_PROBE_PIN (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING)
#else #else
#define TEST_PROBE_PIN (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) #define TEST_PROBE_PIN (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING)

View File

@ -501,8 +501,8 @@
#define PROBE_SELECTED (HAS_BED_PROBE || EITHER(PROBE_MANUALLY, MESH_BED_LEVELING)) #define PROBE_SELECTED (HAS_BED_PROBE || EITHER(PROBE_MANUALLY, MESH_BED_LEVELING))
#if HAS_BED_PROBE #if HAS_BED_PROBE
#define USES_Z_MIN_PROBE_ENDSTOP DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) #define HAS_CUSTOM_PROBE_PIN DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
#define HOMING_Z_WITH_PROBE (Z_HOME_DIR < 0 && !USES_Z_MIN_PROBE_ENDSTOP) #define HOMING_Z_WITH_PROBE (Z_HOME_DIR < 0 && !HAS_CUSTOM_PROBE_PIN)
#ifndef Z_PROBE_LOW_POINT #ifndef Z_PROBE_LOW_POINT
#define Z_PROBE_LOW_POINT -5 #define Z_PROBE_LOW_POINT -5
#endif #endif

View File

@ -825,12 +825,12 @@
// Is an endstop plug used for the Z2 endstop or the bed probe? // Is an endstop plug used for the Z2 endstop or the bed probe?
#define IS_Z2_OR_PROBE(A,M) ( \ #define IS_Z2_OR_PROBE(A,M) ( \
(Z_MULTI_ENDSTOPS && Z2_USE_ENDSTOP == _##A##M##_) \ (Z_MULTI_ENDSTOPS && Z2_USE_ENDSTOP == _##A##M##_) \
|| (USES_Z_MIN_PROBE_ENDSTOP && Z_MIN_PROBE_PIN == A##_##M##_PIN ) ) || (HAS_CUSTOM_PROBE_PIN && Z_MIN_PROBE_PIN == A##_##M##_PIN ) )
// Is an endstop plug used for the Z3 endstop or the bed probe? // Is an endstop plug used for the Z3 endstop or the bed probe?
#define IS_Z3_OR_PROBE(A,M) ( \ #define IS_Z3_OR_PROBE(A,M) ( \
(ENABLED(Z_TRIPLE_ENDSTOPS) && Z3_USE_ENDSTOP == _##A##M##_) \ (ENABLED(Z_TRIPLE_ENDSTOPS) && Z3_USE_ENDSTOP == _##A##M##_) \
|| (USES_Z_MIN_PROBE_ENDSTOP && Z_MIN_PROBE_PIN == A##_##M##_PIN ) ) || (HAS_CUSTOM_PROBE_PIN && Z_MIN_PROBE_PIN == A##_##M##_PIN ) )
/** /**
* Set ENDSTOPPULLUPS for active endstop switches * Set ENDSTOPPULLUPS for active endstop switches
@ -1005,7 +1005,7 @@
#define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX)) #define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX))
#define HAS_Z3_MIN (PIN_EXISTS(Z3_MIN)) #define HAS_Z3_MIN (PIN_EXISTS(Z3_MIN))
#define HAS_Z3_MAX (PIN_EXISTS(Z3_MAX)) #define HAS_Z3_MAX (PIN_EXISTS(Z3_MAX))
#define HAS_Z_MIN_PROBE_PIN (USES_Z_MIN_PROBE_ENDSTOP && PIN_EXISTS(Z_MIN_PROBE)) #define HAS_Z_MIN_PROBE_PIN (HAS_CUSTOM_PROBE_PIN && PIN_EXISTS(Z_MIN_PROBE))
#define HAS_CALIBRATION_PIN (PIN_EXISTS(CALIBRATION)) #define HAS_CALIBRATION_PIN (PIN_EXISTS(CALIBRATION))
// ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface) // ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface)

View File

@ -243,7 +243,7 @@ void Endstops::init() {
#endif #endif
#endif #endif
#if USES_Z_MIN_PROBE_ENDSTOP #if HAS_CUSTOM_PROBE_PIN
#if ENABLED(ENDSTOPPULLUP_ZMIN_PROBE) #if ENABLED(ENDSTOPPULLUP_ZMIN_PROBE)
SET_INPUT_PULLUP(Z_MIN_PROBE_PIN); SET_INPUT_PULLUP(Z_MIN_PROBE_PIN);
#elif ENABLED(ENDSTOPPULLDOWN_ZMIN_PROBE) #elif ENABLED(ENDSTOPPULLDOWN_ZMIN_PROBE)
@ -366,7 +366,7 @@ void Endstops::event_handler() {
ENDSTOP_HIT_TEST_Y(); ENDSTOP_HIT_TEST_Y();
ENDSTOP_HIT_TEST_Z(); ENDSTOP_HIT_TEST_Z();
#if USES_Z_MIN_PROBE_ENDSTOP #if HAS_CUSTOM_PROBE_PIN
#define P_AXIS Z_AXIS #define P_AXIS Z_AXIS
if (TEST(hit_state, Z_MIN_PROBE)) _ENDSTOP_HIT_ECHO(P, 'P'); if (TEST(hit_state, Z_MIN_PROBE)) _ENDSTOP_HIT_ECHO(P, 'P');
#endif #endif
@ -443,7 +443,7 @@ void _O2 Endstops::M119() {
#if HAS_Z3_MAX #if HAS_Z3_MAX
ES_REPORT(Z3_MAX); ES_REPORT(Z3_MAX);
#endif #endif
#if USES_Z_MIN_PROBE_ENDSTOP #if HAS_CUSTOM_PROBE_PIN
print_es_state(READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING, PSTR(MSG_Z_PROBE)); print_es_state(READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING, PSTR(MSG_Z_PROBE));
#endif #endif
#if HAS_FILAMENT_SENSOR #if HAS_FILAMENT_SENSOR
@ -538,60 +538,52 @@ void Endstops::update() {
* Check and update endstops * Check and update endstops
*/ */
#if HAS_X_MIN && !X_SPI_SENSORLESS #if HAS_X_MIN && !X_SPI_SENSORLESS
#if ENABLED(X_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(X, MIN); UPDATE_ENDSTOP_BIT(X, MIN);
#if ENABLED(X_DUAL_ENDSTOPS)
#if HAS_X2_MIN #if HAS_X2_MIN
UPDATE_ENDSTOP_BIT(X2, MIN); UPDATE_ENDSTOP_BIT(X2, MIN);
#else #else
COPY_LIVE_STATE(X_MIN, X2_MIN); COPY_LIVE_STATE(X_MIN, X2_MIN);
#endif #endif
#else
UPDATE_ENDSTOP_BIT(X, MIN);
#endif #endif
#endif #endif
#if HAS_X_MAX && !X_SPI_SENSORLESS #if HAS_X_MAX && !X_SPI_SENSORLESS
#if ENABLED(X_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(X, MAX); UPDATE_ENDSTOP_BIT(X, MAX);
#if ENABLED(X_DUAL_ENDSTOPS)
#if HAS_X2_MAX #if HAS_X2_MAX
UPDATE_ENDSTOP_BIT(X2, MAX); UPDATE_ENDSTOP_BIT(X2, MAX);
#else #else
COPY_LIVE_STATE(X_MAX, X2_MAX); COPY_LIVE_STATE(X_MAX, X2_MAX);
#endif #endif
#else
UPDATE_ENDSTOP_BIT(X, MAX);
#endif #endif
#endif #endif
#if HAS_Y_MIN && !Y_SPI_SENSORLESS #if HAS_Y_MIN && !Y_SPI_SENSORLESS
#if ENABLED(Y_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(Y, MIN); UPDATE_ENDSTOP_BIT(Y, MIN);
#if ENABLED(Y_DUAL_ENDSTOPS)
#if HAS_Y2_MIN #if HAS_Y2_MIN
UPDATE_ENDSTOP_BIT(Y2, MIN); UPDATE_ENDSTOP_BIT(Y2, MIN);
#else #else
COPY_LIVE_STATE(Y_MIN, Y2_MIN); COPY_LIVE_STATE(Y_MIN, Y2_MIN);
#endif #endif
#else
UPDATE_ENDSTOP_BIT(Y, MIN);
#endif #endif
#endif #endif
#if HAS_Y_MAX && !Y_SPI_SENSORLESS #if HAS_Y_MAX && !Y_SPI_SENSORLESS
#if ENABLED(Y_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(Y, MAX); UPDATE_ENDSTOP_BIT(Y, MAX);
#if ENABLED(Y_DUAL_ENDSTOPS)
#if HAS_Y2_MAX #if HAS_Y2_MAX
UPDATE_ENDSTOP_BIT(Y2, MAX); UPDATE_ENDSTOP_BIT(Y2, MAX);
#else #else
COPY_LIVE_STATE(Y_MAX, Y2_MAX); COPY_LIVE_STATE(Y_MAX, Y2_MAX);
#endif #endif
#else
UPDATE_ENDSTOP_BIT(Y, MAX);
#endif #endif
#endif #endif
#if HAS_Z_MIN && !Z_SPI_SENSORLESS #if HAS_Z_MIN && !Z_SPI_SENSORLESS
#if Z_MULTI_ENDSTOPS
UPDATE_ENDSTOP_BIT(Z, MIN); UPDATE_ENDSTOP_BIT(Z, MIN);
#if Z_MULTI_ENDSTOPS
#if HAS_Z2_MIN #if HAS_Z2_MIN
UPDATE_ENDSTOP_BIT(Z2, MIN); UPDATE_ENDSTOP_BIT(Z2, MIN);
#else #else
@ -604,15 +596,11 @@ void Endstops::update() {
COPY_LIVE_STATE(Z_MIN, Z3_MIN); COPY_LIVE_STATE(Z_MIN, Z3_MIN);
#endif #endif
#endif #endif
#elif ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
UPDATE_ENDSTOP_BIT(Z, MIN);
#elif Z_HOME_DIR < 0
UPDATE_ENDSTOP_BIT(Z, MIN);
#endif #endif
#endif #endif
// When closing the gap check the enabled probe // When closing the gap check the enabled probe
#if USES_Z_MIN_PROBE_ENDSTOP #if HAS_CUSTOM_PROBE_PIN
UPDATE_ENDSTOP_BIT(Z, MIN_PROBE); UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
#endif #endif
@ -632,7 +620,7 @@ void Endstops::update() {
COPY_LIVE_STATE(Z_MAX, Z3_MAX); COPY_LIVE_STATE(Z_MAX, Z3_MAX);
#endif #endif
#endif #endif
#elif !USES_Z_MIN_PROBE_ENDSTOP || Z_MAX_PIN != Z_MIN_PROBE_PIN #elif !HAS_CUSTOM_PROBE_PIN || Z_MAX_PIN != Z_MIN_PROBE_PIN
// If this pin isn't the bed probe it's the Z endstop // 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
@ -765,7 +753,7 @@ void Endstops::update() {
#else #else
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
if (z_probe_enabled) PROCESS_ENDSTOP(Z, MIN); if (z_probe_enabled) PROCESS_ENDSTOP(Z, MIN);
#elif USES_Z_MIN_PROBE_ENDSTOP #elif HAS_CUSTOM_PROBE_PIN
if (!z_probe_enabled) PROCESS_ENDSTOP(Z, MIN); if (!z_probe_enabled) PROCESS_ENDSTOP(Z, MIN);
#else #else
PROCESS_ENDSTOP(Z, MIN); PROCESS_ENDSTOP(Z, MIN);
@ -774,7 +762,7 @@ void Endstops::update() {
#endif #endif
// When closing the gap check the enabled probe // When closing the gap check the enabled probe
#if USES_Z_MIN_PROBE_ENDSTOP #if HAS_CUSTOM_PROBE_PIN
if (z_probe_enabled) PROCESS_ENDSTOP(Z, MIN_PROBE); if (z_probe_enabled) PROCESS_ENDSTOP(Z, MIN_PROBE);
#endif #endif
} }
@ -784,7 +772,7 @@ void Endstops::update() {
PROCESS_TRIPLE_ENDSTOP(Z, Z2, Z3, MAX); PROCESS_TRIPLE_ENDSTOP(Z, Z2, Z3, MAX);
#elif ENABLED(Z_DUAL_ENDSTOPS) #elif ENABLED(Z_DUAL_ENDSTOPS)
PROCESS_DUAL_ENDSTOP(Z, Z2, MAX); PROCESS_DUAL_ENDSTOP(Z, Z2, MAX);
#elif !USES_Z_MIN_PROBE_ENDSTOP || Z_MAX_PIN != Z_MIN_PROBE_PIN #elif !HAS_CUSTOM_PROBE_PIN || Z_MAX_PIN != Z_MIN_PROBE_PIN
// If this pin is not hijacked for the bed probe // If this pin is not hijacked for the bed probe
// then it belongs to the Z endstop // then it belongs to the Z endstop
PROCESS_ENDSTOP(Z, MAX); PROCESS_ENDSTOP(Z, MAX);

View File

@ -387,7 +387,7 @@ bool set_probe_deployed(const bool deploy) {
const xy_pos_t old_xy = current_position; const xy_pos_t old_xy = current_position;
#if ENABLED(PROBE_TRIGGERED_WHEN_STOWED_TEST) #if ENABLED(PROBE_TRIGGERED_WHEN_STOWED_TEST)
#if USES_Z_MIN_PROBE_ENDSTOP #if HAS_CUSTOM_PROBE_PIN
#define PROBE_STOWED() (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING) #define PROBE_STOWED() (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING)
#else #else
#define PROBE_STOWED() (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) #define PROBE_STOWED() (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING)

View File

@ -904,7 +904,7 @@
// //
// Disable unused endstop / probe pins // Disable unused endstop / probe pins
// //
#if !USES_Z_MIN_PROBE_ENDSTOP #if !HAS_CUSTOM_PROBE_PIN
#undef Z_MIN_PROBE_PIN #undef Z_MIN_PROBE_PIN
#define Z_MIN_PROBE_PIN -1 #define Z_MIN_PROBE_PIN -1
#endif #endif

View File

@ -118,7 +118,7 @@
//#define E3_MS2_PIN ? //#define E3_MS2_PIN ?
//#define E3_MS3_PIN ? //#define E3_MS3_PIN ?
#if USES_Z_MIN_PROBE_ENDSTOP #if HAS_CUSTOM_PROBE_PIN
#define Z_MIN_PROBE_PIN 49 #define Z_MIN_PROBE_PIN 49
#endif #endif

View File

@ -106,7 +106,7 @@
#define E2_CS_PIN 61 #define E2_CS_PIN 61
#endif #endif
#if USES_Z_MIN_PROBE_ENDSTOP #if HAS_CUSTOM_PROBE_PIN
#define Z_MIN_PROBE_PIN 49 #define Z_MIN_PROBE_PIN 49
#endif #endif