Browse Source

Merge pull request #6548 from thinkyhead/rc_fix_dual_z_endstops

Fix Dual-Z endstop conditional test
Scott Lahteine 8 years ago
parent
commit
46a5cab6fb
4 changed files with 29 additions and 13 deletions
  1. 10
    9
      Marlin/Conditionals_post.h
  2. 3
    1
      Marlin/SanityCheck.h
  3. 7
    3
      Marlin/endstops.cpp
  4. 9
    0
      Marlin/pins.h

+ 10
- 9
Marlin/Conditionals_post.h View File

@@ -413,9 +413,10 @@
413 413
     #endif
414 414
   #endif
415 415
 
416
-  #define IS_Z2_OR_PROBE(P) (   (PIN_EXISTS(Z2_MIN)      && (P) == Z2_MIN_PIN)       \
417
-                             || (PIN_EXISTS(Z2_MAX)      && (P) == Z2_MAX_PIN)       \
418
-                             || (PIN_EXISTS(Z_MIN_PROBE) && (P) == Z_MIN_PROBE_PIN))
416
+  // Is an endstop plug used for the Z2 endstop or the bed probe?
417
+  #define IS_Z2_OR_PROBE(A,M) ( \
418
+       (ENABLED(Z_DUAL_ENDSTOPS) && Z2_USE_ENDSTOP == _##A##M##_) \
419
+    || (ENABLED(Z_MIN_PROBE_ENDSTOP) && Z_MIN_PROBE_PIN == A##_##M##_PIN ) )
419 420
 
420 421
   /**
421 422
    * Set ENDSTOPPULLUPS for active endstop switches
@@ -505,12 +506,12 @@
505 506
   #define HAS_SOLENOID_4    (PIN_EXISTS(SOL4))
506 507
 
507 508
   // Endstops and bed probe
508
-  #define HAS_X_MIN (PIN_EXISTS(X_MIN) && !IS_Z2_OR_PROBE(X_MIN_PIN))
509
-  #define HAS_X_MAX (PIN_EXISTS(X_MAX) && !IS_Z2_OR_PROBE(X_MAX_PIN))
510
-  #define HAS_Y_MIN (PIN_EXISTS(Y_MIN) && !IS_Z2_OR_PROBE(Y_MIN_PIN))
511
-  #define HAS_Y_MAX (PIN_EXISTS(Y_MAX) && !IS_Z2_OR_PROBE(Y_MAX_PIN))
512
-  #define HAS_Z_MIN (PIN_EXISTS(Z_MIN) && !IS_Z2_OR_PROBE(Z_MIN_PIN))
513
-  #define HAS_Z_MAX (PIN_EXISTS(Z_MAX) && !IS_Z2_OR_PROBE(Z_MAX_PIN))
509
+  #define HAS_X_MIN (PIN_EXISTS(X_MIN) && !IS_Z2_OR_PROBE(X,MIN))
510
+  #define HAS_X_MAX (PIN_EXISTS(X_MAX) && !IS_Z2_OR_PROBE(X,MAX))
511
+  #define HAS_Y_MIN (PIN_EXISTS(Y_MIN) && !IS_Z2_OR_PROBE(Y,MIN))
512
+  #define HAS_Y_MAX (PIN_EXISTS(Y_MAX) && !IS_Z2_OR_PROBE(Y,MAX))
513
+  #define HAS_Z_MIN (PIN_EXISTS(Z_MIN) && !IS_Z2_OR_PROBE(Z,MIN))
514
+  #define HAS_Z_MAX (PIN_EXISTS(Z_MAX) && !IS_Z2_OR_PROBE(Z,MAX))
514 515
   #define HAS_Z2_MIN (PIN_EXISTS(Z2_MIN))
515 516
   #define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX))
516 517
   #define HAS_Z_MIN_PROBE_PIN (PIN_EXISTS(Z_MIN_PROBE))

+ 3
- 1
Marlin/SanityCheck.h View File

@@ -77,7 +77,7 @@
77 77
 #elif defined(DISABLE_MAX_ENDSTOPS) || defined(DISABLE_MIN_ENDSTOPS)
78 78
   #error "DISABLE_MAX_ENDSTOPS and DISABLE_MIN_ENDSTOPS deprecated. Use individual USE_*_PLUG options instead."
79 79
 #elif ENABLED(Z_DUAL_ENDSTOPS) && !defined(Z2_USE_ENDSTOP)
80
-  #error "Z_DUAL_ENDSTOPS settings are simplified. Just set Z2_USE_ENDSTOP to the endstop you want to repurpose for Z2"
80
+  #error "Z_DUAL_ENDSTOPS settings are simplified. Just set Z2_USE_ENDSTOP to the endstop you want to repurpose for Z2."
81 81
 #elif defined(LANGUAGE_INCLUDE)
82 82
   #error "LANGUAGE_INCLUDE has been replaced by LCD_LANGUAGE. Please update your configuration."
83 83
 #elif defined(EXTRUDER_OFFSET_X) || defined(EXTRUDER_OFFSET_Y)
@@ -916,6 +916,8 @@ static_assert(1 >= 0
916 916
 #elif ENABLED(Z_DUAL_ENDSTOPS)
917 917
   #if !Z2_USE_ENDSTOP
918 918
     #error "You must set Z2_USE_ENDSTOP with Z_DUAL_ENDSTOPS."
919
+  #elif Z2_MAX_PIN == 0 && Z2_MIN_PIN == 0
920
+    #error "Z2_USE_ENDSTOP has been assigned to a nonexistent endstop!"
919 921
   #elif ENABLED(DELTA)
920 922
     #error "Z_DUAL_ENDSTOPS is not compatible with DELTA."
921 923
   #endif

+ 7
- 3
Marlin/endstops.cpp View File

@@ -157,11 +157,15 @@ void Endstops::report_state() {
157 157
       if (TEST(endstop_hit_bits, A ##_MIN) || TEST(endstop_hit_bits, A ##_MAX)) \
158 158
         _ENDSTOP_HIT_ECHO(A,C)
159 159
 
160
+    #define ENDSTOP_HIT_TEST_X() _ENDSTOP_HIT_TEST(X,'X')
161
+    #define ENDSTOP_HIT_TEST_Y() _ENDSTOP_HIT_TEST(Y,'Y')
162
+    #define ENDSTOP_HIT_TEST_Z() _ENDSTOP_HIT_TEST(Z,'Z')
163
+
160 164
     SERIAL_ECHO_START;
161 165
     SERIAL_ECHOPGM(MSG_ENDSTOPS_HIT);
162
-    _ENDSTOP_HIT_TEST(X, 'X');
163
-    _ENDSTOP_HIT_TEST(Y, 'Y');
164
-    _ENDSTOP_HIT_TEST(Z, 'Z');
166
+    ENDSTOP_HIT_TEST_X();
167
+    ENDSTOP_HIT_TEST_Y();
168
+    ENDSTOP_HIT_TEST_Z();
165 169
 
166 170
     #if ENABLED(Z_MIN_PROBE_ENDSTOP)
167 171
       #define P_AXIS Z_AXIS

+ 9
- 0
Marlin/pins.h View File

@@ -461,6 +461,9 @@
461 461
     #define X2_STEP_PIN   _EPIN(E_STEPPERS, STEP)
462 462
     #define X2_DIR_PIN    _EPIN(E_STEPPERS, DIR)
463 463
     #define X2_ENABLE_PIN _EPIN(E_STEPPERS, ENABLE)
464
+    #if X2_ENABLE_PIN == 0
465
+      #error "No E stepper plug left for X2!"
466
+    #endif
464 467
   #endif
465 468
   #undef _X2_PINS
466 469
   #define _X2_PINS X2_STEP_PIN, X2_DIR_PIN, X2_ENABLE_PIN,
@@ -475,6 +478,9 @@
475 478
     #define Y2_STEP_PIN   _EPIN(Y2_E_INDEX, STEP)
476 479
     #define Y2_DIR_PIN    _EPIN(Y2_E_INDEX, DIR)
477 480
     #define Y2_ENABLE_PIN _EPIN(Y2_E_INDEX, ENABLE)
481
+    #if Y2_ENABLE_PIN == 0
482
+      #error "No E stepper plug left for Y2!"
483
+    #endif
478 484
   #endif
479 485
   #undef _Y2_PINS
480 486
   #define _Y2_PINS Y2_STEP_PIN, Y2_DIR_PIN, Y2_ENABLE_PIN,
@@ -489,6 +495,9 @@
489 495
     #define Z2_STEP_PIN   _EPIN(Z2_E_INDEX, STEP)
490 496
     #define Z2_DIR_PIN    _EPIN(Z2_E_INDEX, DIR)
491 497
     #define Z2_ENABLE_PIN _EPIN(Z2_E_INDEX, ENABLE)
498
+    #if Z2_ENABLE_PIN == 0
499
+      #error "No E stepper plug left for Z2!"
500
+    #endif
492 501
   #endif
493 502
   #undef _Z2_PINS
494 503
   #define _Z2_PINS Z2_STEP_PIN, Z2_DIR_PIN, Z2_ENABLE_PIN,

Loading…
Cancel
Save