Browse Source

Simplify / undef extra endstops (#21808)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
ellensp 4 years ago
parent
commit
fb87b2d1ad
No account linked to committer's email address
3 changed files with 71 additions and 106 deletions
  1. 8
    10
      Marlin/src/inc/Conditionals_post.h
  2. 13
    90
      Marlin/src/inc/SanityCheck.h
  3. 50
    6
      Marlin/src/pins/pins_postprocess.h

+ 8
- 10
Marlin/src/inc/Conditionals_post.h View File

@@ -1983,15 +1983,6 @@
1983 1983
 #if _HAS_STOP(Z,MAX)
1984 1984
   #define HAS_Z_MAX 1
1985 1985
 #endif
1986
-#if _HAS_STOP(X,STOP)
1987
-  #define HAS_X_STOP 1
1988
-#endif
1989
-#if _HAS_STOP(Y,STOP)
1990
-  #define HAS_Y_STOP 1
1991
-#endif
1992
-#if _HAS_STOP(Z,STOP)
1993
-  #define HAS_Z_STOP 1
1994
-#endif
1995 1986
 #if PIN_EXISTS(X2_MIN)
1996 1987
   #define HAS_X2_MIN 1
1997 1988
 #endif
@@ -2022,10 +2013,17 @@
2022 2013
 #if PIN_EXISTS(Z4_MAX)
2023 2014
   #define HAS_Z4_MAX 1
2024 2015
 #endif
2025
-#if HAS_CUSTOM_PROBE_PIN && PIN_EXISTS(Z_MIN_PROBE)
2016
+#if BOTH(HAS_BED_PROBE, HAS_CUSTOM_PROBE_PIN) && PIN_EXISTS(Z_MIN_PROBE)
2026 2017
   #define HAS_Z_MIN_PROBE_PIN 1
2027 2018
 #endif
2028 2019
 
2020
+#undef IS_PROBE_PIN
2021
+#undef IS_X2_ENDSTOP
2022
+#undef IS_Y2_ENDSTOP
2023
+#undef IS_Z2_ENDSTOP
2024
+#undef IS_Z3_ENDSTOP
2025
+#undef IS_Z4_ENDSTOP
2026
+
2029 2027
 //
2030 2028
 // ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface)
2031 2029
 //

+ 13
- 90
Marlin/src/inc/SanityCheck.h View File

@@ -2103,105 +2103,28 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
2103 2103
 
2104 2104
 // Dual/multiple endstops requirements
2105 2105
 #if ENABLED(X_DUAL_ENDSTOPS)
2106
-  #if !X2_USE_ENDSTOP
2107
-    #error "You must set X2_USE_ENDSTOP with X_DUAL_ENDSTOPS."
2108
-  #elif X2_USE_ENDSTOP == _XMIN_ && DISABLED(USE_XMIN_PLUG)
2109
-    #error "USE_XMIN_PLUG is required when X2_USE_ENDSTOP is _XMIN_."
2110
-  #elif X2_USE_ENDSTOP == _XMAX_ && DISABLED(USE_XMAX_PLUG)
2111
-    #error "USE_XMAX_PLUG is required when X2_USE_ENDSTOP is _XMAX_."
2112
-  #elif X2_USE_ENDSTOP == _YMIN_ && DISABLED(USE_YMIN_PLUG)
2113
-    #error "USE_YMIN_PLUG is required when X2_USE_ENDSTOP is _YMIN_."
2114
-  #elif X2_USE_ENDSTOP == _YMAX_ && DISABLED(USE_YMAX_PLUG)
2115
-    #error "USE_YMAX_PLUG is required when X2_USE_ENDSTOP is _YMAX_."
2116
-  #elif X2_USE_ENDSTOP == _ZMIN_ && DISABLED(USE_ZMIN_PLUG)
2117
-    #error "USE_ZMIN_PLUG is required when X2_USE_ENDSTOP is _ZMIN_."
2118
-  #elif X2_USE_ENDSTOP == _ZMAX_ && DISABLED(USE_ZMAX_PLUG)
2119
-    #error "USE_ZMAX_PLUG is required when X2_USE_ENDSTOP is _ZMAX_."
2120
-  #elif !HAS_X2_MIN && !HAS_X2_MAX
2121
-    #error "X2_USE_ENDSTOP has been assigned to a nonexistent endstop!"
2122
-  #elif ENABLED(DELTA)
2106
+  #if ENABLED(DELTA)
2123 2107
     #error "X_DUAL_ENDSTOPS is not compatible with DELTA."
2108
+  #elif !X2_USE_ENDSTOP
2109
+    #error "X2_USE_ENDSTOP must be set with X_DUAL_ENDSTOPS."
2124 2110
   #endif
2125 2111
 #endif
2126 2112
 #if ENABLED(Y_DUAL_ENDSTOPS)
2127
-  #if !Y2_USE_ENDSTOP
2128
-    #error "You must set Y2_USE_ENDSTOP with Y_DUAL_ENDSTOPS."
2129
-  #elif Y2_USE_ENDSTOP == _XMIN_ && DISABLED(USE_XMIN_PLUG)
2130
-    #error "USE_XMIN_PLUG is required when Y2_USE_ENDSTOP is _XMIN_."
2131
-  #elif Y2_USE_ENDSTOP == _XMAX_ && DISABLED(USE_XMAX_PLUG)
2132
-    #error "USE_XMAX_PLUG is required when Y2_USE_ENDSTOP is _XMAX_."
2133
-  #elif Y2_USE_ENDSTOP == _YMIN_ && DISABLED(USE_YMIN_PLUG)
2134
-    #error "USE_YMIN_PLUG is required when Y2_USE_ENDSTOP is _YMIN_."
2135
-  #elif Y2_USE_ENDSTOP == _YMAX_ && DISABLED(USE_YMAX_PLUG)
2136
-    #error "USE_YMAX_PLUG is required when Y2_USE_ENDSTOP is _YMAX_."
2137
-  #elif Y2_USE_ENDSTOP == _ZMIN_ && DISABLED(USE_ZMIN_PLUG)
2138
-    #error "USE_ZMIN_PLUG is required when Y2_USE_ENDSTOP is _ZMIN_."
2139
-  #elif Y2_USE_ENDSTOP == _ZMAX_ && DISABLED(USE_ZMAX_PLUG)
2140
-    #error "USE_ZMAX_PLUG is required when Y2_USE_ENDSTOP is _ZMAX_."
2141
-  #elif !HAS_Y2_MIN && !HAS_Y2_MAX
2142
-    #error "Y2_USE_ENDSTOP has been assigned to a nonexistent endstop!"
2143
-  #elif ENABLED(DELTA)
2113
+  #if ENABLED(DELTA)
2144 2114
     #error "Y_DUAL_ENDSTOPS is not compatible with DELTA."
2115
+  #elif !Y2_USE_ENDSTOP
2116
+    #error "Y2_USE_ENDSTOP must be set with Y_DUAL_ENDSTOPS."
2145 2117
   #endif
2146 2118
 #endif
2147
-
2148 2119
 #if ENABLED(Z_MULTI_ENDSTOPS)
2149
-  #if !Z2_USE_ENDSTOP
2150
-    #error "You must set Z2_USE_ENDSTOP with Z_MULTI_ENDSTOPS when NUM_Z_STEPPER_DRIVERS >= 2."
2151
-  #elif Z2_USE_ENDSTOP == _XMIN_ && DISABLED(USE_XMIN_PLUG)
2152
-    #error "USE_XMIN_PLUG is required when Z2_USE_ENDSTOP is _XMIN_."
2153
-  #elif Z2_USE_ENDSTOP == _XMAX_ && DISABLED(USE_XMAX_PLUG)
2154
-    #error "USE_XMAX_PLUG is required when Z2_USE_ENDSTOP is _XMAX_."
2155
-  #elif Z2_USE_ENDSTOP == _YMIN_ && DISABLED(USE_YMIN_PLUG)
2156
-    #error "USE_YMIN_PLUG is required when Z2_USE_ENDSTOP is _YMIN_."
2157
-  #elif Z2_USE_ENDSTOP == _YMAX_ && DISABLED(USE_YMAX_PLUG)
2158
-    #error "USE_YMAX_PLUG is required when Z2_USE_ENDSTOP is _YMAX_."
2159
-  #elif Z2_USE_ENDSTOP == _ZMIN_ && DISABLED(USE_ZMIN_PLUG)
2160
-    #error "USE_ZMIN_PLUG is required when Z2_USE_ENDSTOP is _ZMIN_."
2161
-  #elif Z2_USE_ENDSTOP == _ZMAX_ && DISABLED(USE_ZMAX_PLUG)
2162
-    #error "USE_ZMAX_PLUG is required when Z2_USE_ENDSTOP is _ZMAX_."
2163
-  #elif !HAS_Z2_MIN && !HAS_Z2_MAX
2164
-    #error "Z2_USE_ENDSTOP has been assigned to a nonexistent endstop!"
2165
-  #elif ENABLED(DELTA)
2120
+  #if ENABLED(DELTA)
2166 2121
     #error "Z_MULTI_ENDSTOPS is not compatible with DELTA."
2167
-  #endif
2168
-  #if NUM_Z_STEPPER_DRIVERS >= 3
2169
-    #if !Z3_USE_ENDSTOP
2170
-      #error "You must set Z3_USE_ENDSTOP with Z_MULTI_ENDSTOPS when NUM_Z_STEPPER_DRIVERS >= 3."
2171
-    #elif Z3_USE_ENDSTOP == _XMIN_ && DISABLED(USE_XMIN_PLUG)
2172
-      #error "USE_XMIN_PLUG is required when Z3_USE_ENDSTOP is _XMIN_."
2173
-    #elif Z3_USE_ENDSTOP == _XMAX_ && DISABLED(USE_XMAX_PLUG)
2174
-      #error "USE_XMAX_PLUG is required when Z3_USE_ENDSTOP is _XMAX_."
2175
-    #elif Z3_USE_ENDSTOP == _YMIN_ && DISABLED(USE_YMIN_PLUG)
2176
-      #error "USE_YMIN_PLUG is required when Z3_USE_ENDSTOP is _YMIN_."
2177
-    #elif Z3_USE_ENDSTOP == _YMAX_ && DISABLED(USE_YMAX_PLUG)
2178
-      #error "USE_YMAX_PLUG is required when Z3_USE_ENDSTOP is _YMAX_."
2179
-    #elif Z3_USE_ENDSTOP == _ZMIN_ && DISABLED(USE_ZMIN_PLUG)
2180
-      #error "USE_ZMIN_PLUG is required when Z3_USE_ENDSTOP is _ZMIN_."
2181
-    #elif Z3_USE_ENDSTOP == _ZMAX_ && DISABLED(USE_ZMAX_PLUG)
2182
-      #error "USE_ZMAX_PLUG is required when Z3_USE_ENDSTOP is _ZMAX_."
2183
-    #elif !HAS_Z3_MIN && !HAS_Z3_MAX
2184
-      #error "Z3_USE_ENDSTOP has been assigned to a nonexistent endstop!"
2185
-    #endif
2186
-  #endif
2187
-  #if NUM_Z_STEPPER_DRIVERS >= 4
2188
-    #if !Z4_USE_ENDSTOP
2189
-      #error "You must set Z4_USE_ENDSTOP with Z_MULTI_ENDSTOPS when NUM_Z_STEPPER_DRIVERS >= 4."
2190
-    #elif Z4_USE_ENDSTOP == _XMIN_ && DISABLED(USE_XMIN_PLUG)
2191
-      #error "USE_XMIN_PLUG is required when Z4_USE_ENDSTOP is _XMIN_."
2192
-    #elif Z4_USE_ENDSTOP == _XMAX_ && DISABLED(USE_XMAX_PLUG)
2193
-      #error "USE_XMAX_PLUG is required when Z4_USE_ENDSTOP is _XMAX_."
2194
-    #elif Z4_USE_ENDSTOP == _YMIN_ && DISABLED(USE_YMIN_PLUG)
2195
-      #error "USE_YMIN_PLUG is required when Z4_USE_ENDSTOP is _YMIN_."
2196
-    #elif Z4_USE_ENDSTOP == _YMAX_ && DISABLED(USE_YMAX_PLUG)
2197
-      #error "USE_YMAX_PLUG is required when Z4_USE_ENDSTOP is _YMAX_."
2198
-    #elif Z4_USE_ENDSTOP == _ZMIN_ && DISABLED(USE_ZMIN_PLUG)
2199
-      #error "USE_ZMIN_PLUG is required when Z4_USE_ENDSTOP is _ZMIN_."
2200
-    #elif Z4_USE_ENDSTOP == _ZMAX_ && DISABLED(USE_ZMAX_PLUG)
2201
-      #error "USE_ZMAX_PLUG is required when Z4_USE_ENDSTOP is _ZMAX_."
2202
-    #elif !HAS_Z4_MIN && !HAS_Z4_MAX
2203
-      #error "Z4_USE_ENDSTOP has been assigned to a nonexistent endstop!"
2204
-    #endif
2122
+  #elif !Z2_USE_ENDSTOP
2123
+    #error "Z2_USE_ENDSTOP must be set with Z_MULTI_ENDSTOPS."
2124
+  #elif !Z3_USE_ENDSTOP && NUM_Z_STEPPER_DRIVERS >= 3
2125
+    #error "Z3_USE_ENDSTOP must be set with Z_MULTI_ENDSTOPS and NUM_Z_STEPPER_DRIVERS >= 3."
2126
+  #elif !Z4_USE_ENDSTOP && NUM_Z_STEPPER_DRIVERS >= 4
2127
+    #error "Z4_USE_ENDSTOP must be set with Z_MULTI_ENDSTOPS and NUM_Z_STEPPER_DRIVERS >= 4."
2205 2128
   #endif
2206 2129
 #endif
2207 2130
 

+ 50
- 6
Marlin/src/pins/pins_postprocess.h View File

@@ -441,40 +441,84 @@
441 441
 //
442 442
 // Disable unused endstop / probe pins
443 443
 //
444
+#define _STOP_IN_USE(N) (X2_USE_ENDSTOP == N || Y2_USE_ENDSTOP == N || Z2_USE_ENDSTOP == N || Z3_USE_ENDSTOP == N || Z4_USE_ENDSTOP == N)
445
+#if _STOP_IN_USE(_XMAX_)
446
+  #define USE_XMAX_PLUG
447
+#endif
448
+#if _STOP_IN_USE(_YMAX_)
449
+  #define USE_YMAX_PLUG
450
+#endif
451
+#if _STOP_IN_USE(_ZMAX_)
452
+  #define USE_ZMAX_PLUG
453
+#endif
454
+#if _STOP_IN_USE(_XMIN_)
455
+  #define USE_XMIN_PLUG
456
+#endif
457
+#if _STOP_IN_USE(_YMIN_)
458
+  #define USE_YMIN_PLUG
459
+#endif
460
+#if _STOP_IN_USE(_ZMIN_)
461
+  #define USE_ZMIN_PLUG
462
+#endif
463
+#undef _STOP_IN_USE
444 464
 #if !HAS_CUSTOM_PROBE_PIN
445 465
   #undef Z_MIN_PROBE_PIN
446 466
   #define Z_MIN_PROBE_PIN    -1
447 467
 #endif
448
-
449 468
 #if DISABLED(USE_XMAX_PLUG)
450 469
   #undef X_MAX_PIN
451 470
   #define X_MAX_PIN          -1
452 471
 #endif
453
-
454 472
 #if DISABLED(USE_YMAX_PLUG)
455 473
   #undef Y_MAX_PIN
456 474
   #define Y_MAX_PIN          -1
457 475
 #endif
458
-
459 476
 #if DISABLED(USE_ZMAX_PLUG)
460 477
   #undef Z_MAX_PIN
461 478
   #define Z_MAX_PIN          -1
462 479
 #endif
463
-
464 480
 #if DISABLED(USE_XMIN_PLUG)
465 481
   #undef X_MIN_PIN
466 482
   #define X_MIN_PIN          -1
467 483
 #endif
468
-
469 484
 #if DISABLED(USE_YMIN_PLUG)
470 485
   #undef Y_MIN_PIN
471 486
   #define Y_MIN_PIN          -1
472 487
 #endif
473
-
474 488
 #if DISABLED(USE_ZMIN_PLUG)
475 489
   #undef Z_MIN_PIN
476 490
   #define Z_MIN_PIN          -1
477 491
 #endif
492
+#if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_DIR > 0
493
+  #undef X2_MIN_PIN
494
+#endif
495
+#if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_DIR < 0
496
+  #undef X2_MAX_PIN
497
+#endif
498
+#if DISABLED(Y_DUAL_ENDSTOPS) || Y_HOME_DIR > 0
499
+  #undef Y2_MIN_PIN
500
+#endif
501
+#if DISABLED(Y_DUAL_ENDSTOPS) || Y_HOME_DIR < 0
502
+  #undef Y2_MAX_PIN
503
+#endif
504
+#if DISABLED(Z_MULTI_ENDSTOPS) || Z_HOME_DIR > 0
505
+  #undef Z2_MIN_PIN
506
+#endif
507
+#if DISABLED(Z_MULTI_ENDSTOPS) || Z_HOME_DIR < 0
508
+  #undef Z2_MAX_PIN
509
+#endif
510
+#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 3 || Z_HOME_DIR > 0
511
+  #undef Z3_MIN_PIN
512
+#endif
513
+#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 3 || Z_HOME_DIR < 0
514
+  #undef Z3_MAX_PIN
515
+#endif
516
+#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 4 || Z_HOME_DIR > 0
517
+  #undef Z4_MIN_PIN
518
+#endif
519
+#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 4 || Z_HOME_DIR < 0
520
+  #undef Z4_MAX_PIN
521
+#endif
478 522
 
479 523
 #if HAS_FILAMENT_SENSOR
480 524
   #define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN

Loading…
Cancel
Save