From 70f31b6c766a9abfc2e9a314692ebeb8c4c38353 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 2 May 2017 15:08:16 -0500 Subject: [PATCH 1/4] Throw an error if no E stepper is free for X2, Y2, Z2 --- Marlin/pins.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Marlin/pins.h b/Marlin/pins.h index 33243bd5e1..f223e0c52d 100644 --- a/Marlin/pins.h +++ b/Marlin/pins.h @@ -461,6 +461,9 @@ #define X2_STEP_PIN _EPIN(E_STEPPERS, STEP) #define X2_DIR_PIN _EPIN(E_STEPPERS, DIR) #define X2_ENABLE_PIN _EPIN(E_STEPPERS, ENABLE) + #if X2_ENABLE_PIN == 0 + #error "No E stepper plug left for X2!" + #endif #endif #undef _X2_PINS #define _X2_PINS X2_STEP_PIN, X2_DIR_PIN, X2_ENABLE_PIN, @@ -475,6 +478,9 @@ #define Y2_STEP_PIN _EPIN(Y2_E_INDEX, STEP) #define Y2_DIR_PIN _EPIN(Y2_E_INDEX, DIR) #define Y2_ENABLE_PIN _EPIN(Y2_E_INDEX, ENABLE) + #if Y2_ENABLE_PIN == 0 + #error "No E stepper plug left for Y2!" + #endif #endif #undef _Y2_PINS #define _Y2_PINS Y2_STEP_PIN, Y2_DIR_PIN, Y2_ENABLE_PIN, @@ -489,6 +495,9 @@ #define Z2_STEP_PIN _EPIN(Z2_E_INDEX, STEP) #define Z2_DIR_PIN _EPIN(Z2_E_INDEX, DIR) #define Z2_ENABLE_PIN _EPIN(Z2_E_INDEX, ENABLE) + #if Z2_ENABLE_PIN == 0 + #error "No E stepper plug left for Z2!" + #endif #endif #undef _Z2_PINS #define _Z2_PINS Z2_STEP_PIN, Z2_DIR_PIN, Z2_ENABLE_PIN, From c03c62395131527feaf76afba4c1f9e2bd459eb4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 2 May 2017 15:38:39 -0500 Subject: [PATCH 2/4] Sanity-check Z2 endstop assigned to a nonexistent pin. --- Marlin/SanityCheck.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index 07e4224e23..722d7f5869 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -77,7 +77,7 @@ #elif defined(DISABLE_MAX_ENDSTOPS) || defined(DISABLE_MIN_ENDSTOPS) #error "DISABLE_MAX_ENDSTOPS and DISABLE_MIN_ENDSTOPS deprecated. Use individual USE_*_PLUG options instead." #elif ENABLED(Z_DUAL_ENDSTOPS) && !defined(Z2_USE_ENDSTOP) - #error "Z_DUAL_ENDSTOPS settings are simplified. Just set Z2_USE_ENDSTOP to the endstop you want to repurpose for Z2" + #error "Z_DUAL_ENDSTOPS settings are simplified. Just set Z2_USE_ENDSTOP to the endstop you want to repurpose for Z2." #elif defined(LANGUAGE_INCLUDE) #error "LANGUAGE_INCLUDE has been replaced by LCD_LANGUAGE. Please update your configuration." #elif defined(EXTRUDER_OFFSET_X) || defined(EXTRUDER_OFFSET_Y) @@ -916,6 +916,8 @@ static_assert(1 >= 0 #elif ENABLED(Z_DUAL_ENDSTOPS) #if !Z2_USE_ENDSTOP #error "You must set Z2_USE_ENDSTOP with Z_DUAL_ENDSTOPS." + #elif Z2_MAX_PIN == 0 && Z2_MIN_PIN == 0 + #error "Z2_USE_ENDSTOP has been assigned to a nonexistent endstop!" #elif ENABLED(DELTA) #error "Z_DUAL_ENDSTOPS is not compatible with DELTA." #endif From ef750ae86b0dfcb31593e3452312bc875e3f7a01 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 2 May 2017 14:29:18 -0500 Subject: [PATCH 3/4] Towards supporting Z2 in Endstops::report_state --- Marlin/endstops.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Marlin/endstops.cpp b/Marlin/endstops.cpp index 8cb04979c1..9a4a9c84b5 100644 --- a/Marlin/endstops.cpp +++ b/Marlin/endstops.cpp @@ -157,11 +157,15 @@ void Endstops::report_state() { if (TEST(endstop_hit_bits, A ##_MIN) || TEST(endstop_hit_bits, A ##_MAX)) \ _ENDSTOP_HIT_ECHO(A,C) + #define ENDSTOP_HIT_TEST_X() _ENDSTOP_HIT_TEST(X,'X') + #define ENDSTOP_HIT_TEST_Y() _ENDSTOP_HIT_TEST(Y,'Y') + #define ENDSTOP_HIT_TEST_Z() _ENDSTOP_HIT_TEST(Z,'Z') + SERIAL_ECHO_START; SERIAL_ECHOPGM(MSG_ENDSTOPS_HIT); - _ENDSTOP_HIT_TEST(X, 'X'); - _ENDSTOP_HIT_TEST(Y, 'Y'); - _ENDSTOP_HIT_TEST(Z, 'Z'); + ENDSTOP_HIT_TEST_X(); + ENDSTOP_HIT_TEST_Y(); + ENDSTOP_HIT_TEST_Z(); #if ENABLED(Z_MIN_PROBE_ENDSTOP) #define P_AXIS Z_AXIS From 7ce613db0a3ed8560ffe80c24f05651b3834a2ef Mon Sep 17 00:00:00 2001 From: Bob-the-Kuhn Date: Mon, 1 May 2017 02:07:54 -0500 Subject: [PATCH 4/4] Fix Conditionals test for endstop plug used by Z2 or probe. --- Marlin/Conditionals_post.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Marlin/Conditionals_post.h b/Marlin/Conditionals_post.h index 09c16f3522..978b6297b2 100644 --- a/Marlin/Conditionals_post.h +++ b/Marlin/Conditionals_post.h @@ -413,9 +413,10 @@ #endif #endif - #define IS_Z2_OR_PROBE(P) ( (PIN_EXISTS(Z2_MIN) && (P) == Z2_MIN_PIN) \ - || (PIN_EXISTS(Z2_MAX) && (P) == Z2_MAX_PIN) \ - || (PIN_EXISTS(Z_MIN_PROBE) && (P) == Z_MIN_PROBE_PIN)) + // Is an endstop plug used for the Z2 endstop or the bed probe? + #define IS_Z2_OR_PROBE(A,M) ( \ + (ENABLED(Z_DUAL_ENDSTOPS) && Z2_USE_ENDSTOP == _##A##M##_) \ + || (ENABLED(Z_MIN_PROBE_ENDSTOP) && Z_MIN_PROBE_PIN == A##_##M##_PIN ) ) /** * Set ENDSTOPPULLUPS for active endstop switches @@ -505,12 +506,12 @@ #define HAS_SOLENOID_4 (PIN_EXISTS(SOL4)) // Endstops and bed probe - #define HAS_X_MIN (PIN_EXISTS(X_MIN) && !IS_Z2_OR_PROBE(X_MIN_PIN)) - #define HAS_X_MAX (PIN_EXISTS(X_MAX) && !IS_Z2_OR_PROBE(X_MAX_PIN)) - #define HAS_Y_MIN (PIN_EXISTS(Y_MIN) && !IS_Z2_OR_PROBE(Y_MIN_PIN)) - #define HAS_Y_MAX (PIN_EXISTS(Y_MAX) && !IS_Z2_OR_PROBE(Y_MAX_PIN)) - #define HAS_Z_MIN (PIN_EXISTS(Z_MIN) && !IS_Z2_OR_PROBE(Z_MIN_PIN)) - #define HAS_Z_MAX (PIN_EXISTS(Z_MAX) && !IS_Z2_OR_PROBE(Z_MAX_PIN)) + #define HAS_X_MIN (PIN_EXISTS(X_MIN) && !IS_Z2_OR_PROBE(X,MIN)) + #define HAS_X_MAX (PIN_EXISTS(X_MAX) && !IS_Z2_OR_PROBE(X,MAX)) + #define HAS_Y_MIN (PIN_EXISTS(Y_MIN) && !IS_Z2_OR_PROBE(Y,MIN)) + #define HAS_Y_MAX (PIN_EXISTS(Y_MAX) && !IS_Z2_OR_PROBE(Y,MAX)) + #define HAS_Z_MIN (PIN_EXISTS(Z_MIN) && !IS_Z2_OR_PROBE(Z,MIN)) + #define HAS_Z_MAX (PIN_EXISTS(Z_MAX) && !IS_Z2_OR_PROBE(Z,MAX)) #define HAS_Z2_MIN (PIN_EXISTS(Z2_MIN)) #define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX)) #define HAS_Z_MIN_PROBE_PIN (PIN_EXISTS(Z_MIN_PROBE))