-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
/
Conditionals_post.h
3220 lines (3024 loc) · 86.5 KB
/
Conditionals_post.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* Conditionals_post.h
* Internal defines that depend on Configurations and Pins but are not user-editable.
*/
#ifdef GITHUB_ACTIONS
// Extras for CI testing
#endif
// ADC
#ifdef BOARD_ADC_VREF
#define ADC_VREF BOARD_ADC_VREF
#else
#define ADC_VREF HAL_ADC_VREF
#endif
// Linear advance uses Jerk since E is an isolated axis
#if BOTH(HAS_JUNCTION_DEVIATION, LIN_ADVANCE)
#define HAS_LINEAR_E_JERK 1
#endif
// Determine which type of 'EEPROM' is in use
#if ENABLED(EEPROM_SETTINGS)
// EEPROM type may be defined by compile flags, configs, HALs, or pins
// Set additional flags to let HALs choose in their Conditionals_post.h
#if ANY(FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION, SDCARD_EEPROM_EMULATION, QSPI_EEPROM)
#define USE_EMULATED_EEPROM 1
#elif EITHER(I2C_EEPROM, SPI_EEPROM)
#define USE_WIRED_EEPROM 1
#elif ENABLED(IIC_BL24CXX_EEPROM)
// nothing
#else
#define USE_FALLBACK_EEPROM 1
#endif
#else
#undef I2C_EEPROM
#undef SPI_EEPROM
#undef QSPI_EEPROM
#undef SDCARD_EEPROM_EMULATION
#undef SRAM_EEPROM_EMULATION
#undef FLASH_EEPROM_EMULATION
#undef IIC_BL24CXX_EEPROM
#endif
#ifdef TEENSYDUINO
#undef max
#define max(a,b) ((a)>(b)?(a):(b))
#undef min
#define min(a,b) ((a)<(b)?(a):(b))
#undef NOT_A_PIN // Override Teensyduino legacy CapSense define work-around
#define NOT_A_PIN 0 // For PINS_DEBUGGING
#endif
/**
* Axis lengths and center
*/
#if HAS_I_AXIS && !defined(AXIS4_NAME)
#define AXIS4_NAME 'A'
#endif
#if HAS_J_AXIS && !defined(AXIS5_NAME)
#define AXIS5_NAME 'B'
#endif
#if HAS_K_AXIS && !defined(AXIS6_NAME)
#define AXIS6_NAME 'C'
#endif
#if HAS_U_AXIS && !defined(AXIS7_NAME)
#define AXIS7_NAME 'U'
#endif
#if HAS_V_AXIS && !defined(AXIS8_NAME)
#define AXIS8_NAME 'V'
#endif
#if HAS_W_AXIS && !defined(AXIS9_NAME)
#define AXIS9_NAME 'W'
#endif
#if ANY(AXIS4_ROTATES, AXIS5_ROTATES, AXIS6_ROTATES, AXIS7_ROTATES, AXIS8_ROTATES, AXIS9_ROTATES)
#define HAS_ROTATIONAL_AXES 1
#endif
#define X_MAX_LENGTH (X_MAX_POS - (X_MIN_POS))
#if HAS_Y_AXIS
#define Y_MAX_LENGTH (Y_MAX_POS - (Y_MIN_POS))
#endif
#if HAS_Z_AXIS
#define Z_MAX_LENGTH (Z_MAX_POS - (Z_MIN_POS))
#else
#undef CONTROLLER_FAN_USE_Z_ONLY
#endif
#if HAS_I_AXIS
#define I_MAX_LENGTH (I_MAX_POS - (I_MIN_POS))
#endif
#if HAS_J_AXIS
#define J_MAX_LENGTH (J_MAX_POS - (J_MIN_POS))
#endif
#if HAS_K_AXIS
#define K_MAX_LENGTH (K_MAX_POS - (K_MIN_POS))
#endif
#if HAS_U_AXIS
#define U_MAX_LENGTH (U_MAX_POS - (U_MIN_POS))
#endif
#if HAS_V_AXIS
#define V_MAX_LENGTH (V_MAX_POS - (V_MIN_POS))
#endif
#if HAS_W_AXIS
#define W_MAX_LENGTH (W_MAX_POS - (W_MIN_POS))
#endif
// Defined only if the sanity-check is bypassed
#ifndef X_BED_SIZE
#define X_BED_SIZE X_MAX_LENGTH
#endif
#if HAS_Y_AXIS && !defined(Y_BED_SIZE)
#define Y_BED_SIZE Y_MAX_LENGTH
#endif
#if HAS_I_AXIS && !defined(I_BED_SIZE)
#define I_BED_SIZE I_MAX_LENGTH
#endif
#if HAS_J_AXIS && !defined(J_BED_SIZE)
#define J_BED_SIZE J_MAX_LENGTH
#endif
#if HAS_K_AXIS && !defined(K_BED_SIZE)
#define K_BED_SIZE K_MAX_LENGTH
#endif
#if HAS_U_AXIS && !defined(U_BED_SIZE)
#define U_BED_SIZE U_MAX_LENGTH
#endif
#if HAS_V_AXIS && !defined(V_BED_SIZE)
#define V_BED_SIZE V_MAX_LENGTH
#endif
#if HAS_W_AXIS && !defined(W_BED_SIZE)
#define W_BED_SIZE W_MAX_LENGTH
#endif
// Require 0,0 bed center for Delta, SCARA, and Polargraph
#if IS_KINEMATIC
#define BED_CENTER_AT_0_0
#endif
// Define center values for future use
#define _X_HALF_BED ((X_BED_SIZE) / 2)
#if HAS_Y_AXIS
#define _Y_HALF_BED ((Y_BED_SIZE) / 2)
#endif
#if HAS_I_AXIS
#define _I_HALF_IMAX ((I_BED_SIZE) / 2)
#endif
#if HAS_J_AXIS
#define _J_HALF_JMAX ((J_BED_SIZE) / 2)
#endif
#if HAS_K_AXIS
#define _K_HALF_KMAX ((K_BED_SIZE) / 2)
#endif
#if HAS_U_AXIS
#define _U_HALF_UMAX ((U_BED_SIZE) / 2)
#endif
#if HAS_V_AXIS
#define _V_HALF_VMAX ((V_BED_SIZE) / 2)
#endif
#if HAS_W_AXIS
#define _W_HALF_WMAX ((W_BED_SIZE) / 2)
#endif
#define X_CENTER TERN(BED_CENTER_AT_0_0, 0, _X_HALF_BED)
#if HAS_Y_AXIS
#define Y_CENTER TERN(BED_CENTER_AT_0_0, 0, _Y_HALF_BED)
#define XY_CENTER { X_CENTER, Y_CENTER }
#endif
#if HAS_I_AXIS
#define I_CENTER _I_HALF_BED
#endif
#if HAS_J_AXIS
#define J_CENTER _J_HALF_BED
#endif
#if HAS_K_AXIS
#define K_CENTER _K_HALF_BED
#endif
#if HAS_U_AXIS
#define U_CENTER _U_HALF_BED
#endif
#if HAS_V_AXIS
#define V_CENTER _V_HALF_BED
#endif
#if HAS_W_AXIS
#define W_CENTER _W_HALF_BED
#endif
// Get the linear boundaries of the bed
#define X_MIN_BED (X_CENTER - _X_HALF_BED)
#define X_MAX_BED (X_MIN_BED + X_BED_SIZE)
#if HAS_Y_AXIS
#define Y_MIN_BED (Y_CENTER - _Y_HALF_BED)
#define Y_MAX_BED (Y_MIN_BED + Y_BED_SIZE)
#endif
#if HAS_I_AXIS
#define I_MINIM (I_CENTER - _I_HALF_BED_SIZE)
#define I_MAXIM (I_MINIM + I_BED_SIZE)
#endif
#if HAS_J_AXIS
#define J_MINIM (J_CENTER - _J_HALF_BED_SIZE)
#define J_MAXIM (J_MINIM + J_BED_SIZE)
#endif
#if HAS_K_AXIS
#define K_MINIM (K_CENTER - _K_HALF_BED_SIZE)
#define K_MAXIM (K_MINIM + K_BED_SIZE)
#endif
#if HAS_U_AXIS
#define U_MINIM (U_CENTER - _U_HALF_BED_SIZE)
#define U_MAXIM (U_MINIM + U_BED_SIZE)
#endif
#if HAS_V_AXIS
#define V_MINIM (V_CENTER - _V_HALF_BED_SIZE)
#define V_MAXIM (V_MINIM + V_BED_SIZE)
#endif
#if HAS_W_AXIS
#define W_MINIM (W_CENTER - _W_HALF_BED_SIZE)
#define W_MAXIM (W_MINIM + W_BED_SIZE)
#endif
/**
* Dual X Carriage
*/
#if ENABLED(DUAL_X_CARRIAGE)
#ifndef X1_MIN_POS
#define X1_MIN_POS X_MIN_POS
#endif
#ifndef X1_MAX_POS
#define X1_MAX_POS X_BED_SIZE
#endif
#endif
// Calibration codes only for non-core axes
#if EITHER(BACKLASH_GCODE, CALIBRATION_GCODE)
#if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX)
#define CAN_CALIBRATE(A,B) TERN0(HAS_##A##_AXIS, (_AXIS(A) == B))
#else
#define CAN_CALIBRATE(A,B) ENABLED(HAS_##A##_AXIS)
#endif
#define AXIS_CAN_CALIBRATE(A) CAN_CALIBRATE(A,NORMAL_AXIS)
#else
#define AXIS_CAN_CALIBRATE(A) false
#endif
/**
* No adjustable bed on non-cartesians
*/
#if IS_KINEMATIC
#undef LCD_BED_TRAMMING
#undef SLOWDOWN
#endif
/**
* SCARA cannot use SLOWDOWN and requires QUICKHOME
* Printable radius assumes joints can fully extend
*/
#if IS_SCARA
#if ENABLED(AXEL_TPARA)
#define PRINTABLE_RADIUS (TPARA_LINKAGE_1 + TPARA_LINKAGE_2)
#else
#define QUICK_HOME
#define PRINTABLE_RADIUS (SCARA_LINKAGE_1 + SCARA_LINKAGE_2)
#endif
#endif
/**
* Set the home position based on settings or manual overrides
*/
#ifdef MANUAL_X_HOME_POS
#define X_HOME_POS MANUAL_X_HOME_POS
#else
#define X_END_POS TERN(X_HOME_TO_MIN, X_MIN_POS, X_MAX_POS)
#if ENABLED(BED_CENTER_AT_0_0)
#define X_HOME_POS TERN(DELTA, 0, X_END_POS)
#else
#define X_HOME_POS TERN(DELTA, X_MIN_POS + (X_BED_SIZE) * 0.5, X_END_POS)
#endif
#endif
#if HAS_Y_AXIS
#ifdef MANUAL_Y_HOME_POS
#define Y_HOME_POS MANUAL_Y_HOME_POS
#else
#define Y_END_POS TERN(Y_HOME_TO_MIN, Y_MIN_POS, Y_MAX_POS)
#if ENABLED(BED_CENTER_AT_0_0)
#define Y_HOME_POS TERN(DELTA, 0, Y_END_POS)
#else
#define Y_HOME_POS TERN(DELTA, Y_MIN_POS + (Y_BED_SIZE) * 0.5, Y_END_POS)
#endif
#endif
#endif
#ifdef MANUAL_Z_HOME_POS
#define Z_HOME_POS MANUAL_Z_HOME_POS
#else
#define Z_HOME_POS TERN(Z_HOME_TO_MIN, Z_MIN_POS, Z_MAX_POS)
#endif
#if HAS_I_AXIS
#ifdef MANUAL_I_HOME_POS
#define I_HOME_POS MANUAL_I_HOME_POS
#else
#define I_HOME_POS TERN(I_HOME_TO_MIN, I_MIN_POS, I_MAX_POS)
#endif
#endif
#if HAS_J_AXIS
#ifdef MANUAL_J_HOME_POS
#define J_HOME_POS MANUAL_J_HOME_POS
#else
#define J_HOME_POS TERN(J_HOME_TO_MIN, J_MIN_POS, J_MAX_POS)
#endif
#endif
#if HAS_K_AXIS
#ifdef MANUAL_K_HOME_POS
#define K_HOME_POS MANUAL_K_HOME_POS
#else
#define K_HOME_POS TERN(K_HOME_TO_MIN, K_MIN_POS, K_MAX_POS)
#endif
#endif
#if HAS_U_AXIS
#ifdef MANUAL_U_HOME_POS
#define U_HOME_POS MANUAL_U_HOME_POS
#else
#define U_HOME_POS TERN(U_HOME_TO_MIN, U_MIN_POS, U_MAX_POS)
#endif
#endif
#if HAS_V_AXIS
#ifdef MANUAL_V_HOME_POS
#define V_HOME_POS MANUAL_V_HOME_POS
#else
#define V_HOME_POS TERN(V_HOME_TO_MIN, V_MIN_POS, V_MAX_POS)
#endif
#endif
#if HAS_W_AXIS
#ifdef MANUAL_W_HOME_POS
#define W_HOME_POS MANUAL_W_HOME_POS
#else
#define W_HOME_POS TERN(W_HOME_TO_MIN, W_MIN_POS, W_MAX_POS)
#endif
#endif
/**
* If DELTA_HEIGHT isn't defined use the old setting
*/
#if ENABLED(DELTA) && !defined(DELTA_HEIGHT)
#define DELTA_HEIGHT Z_HOME_POS
#endif
/**
* Z Sled Probe requires Z_SAFE_HOMING
*/
#if ENABLED(Z_PROBE_SLED)
#define Z_SAFE_HOMING
#endif
/**
* DELTA should ignore Z_SAFE_HOMING and SLOWDOWN
*/
#if ENABLED(DELTA)
#undef Z_SAFE_HOMING
#endif
#ifndef MESH_INSET
#define MESH_INSET 0
#endif
/**
* Safe Homing Options
*/
#if ENABLED(Z_SAFE_HOMING)
#if ENABLED(AUTO_BED_LEVELING_UBL)
// Home close to center so grid points have z heights very close to 0
#define _SAFE_POINT(A) (((GRID_MAX_POINTS_##A) / 2) * (A##_BED_SIZE - 2 * (MESH_INSET)) / (GRID_MAX_POINTS_##A - 1) + MESH_INSET)
#else
#define _SAFE_POINT(A) A##_CENTER
#endif
#ifndef Z_SAFE_HOMING_X_POINT
#define Z_SAFE_HOMING_X_POINT _SAFE_POINT(X)
#endif
#ifndef Z_SAFE_HOMING_Y_POINT
#define Z_SAFE_HOMING_Y_POINT _SAFE_POINT(Y)
#endif
#endif
#ifdef GRID_MAX_POINTS_X
#define GRID_MAX_CELLS_X (GRID_MAX_POINTS_X - 1)
#define GRID_MAX_CELLS_Y (GRID_MAX_POINTS_Y - 1)
#endif
/**
* Host keep alive
*/
#ifndef DEFAULT_KEEPALIVE_INTERVAL
#define DEFAULT_KEEPALIVE_INTERVAL 2
#endif
/**
* Provide a MAX_AUTORETRACT for older configs
*/
#if ENABLED(FWRETRACT) && !defined(MAX_AUTORETRACT)
#define MAX_AUTORETRACT 99
#endif
/**
* Provide a DEFAULT_VOLUMETRIC_EXTRUDER_LIMIT in case NO_VOLUMETRICS is enabled
*/
#ifndef DEFAULT_VOLUMETRIC_EXTRUDER_LIMIT
#define DEFAULT_VOLUMETRIC_EXTRUDER_LIMIT 0.00
#endif
/**
* LCD Contrast for Graphical Displays
*/
#if ENABLED(CARTESIO_UI)
#define _LCD_CONTRAST_MIN 60
#define _LCD_CONTRAST_INIT 90
#define _LCD_CONTRAST_MAX 140
#elif ENABLED(miniVIKI)
#define _LCD_CONTRAST_MIN 75
#define _LCD_CONTRAST_INIT 95
#define _LCD_CONTRAST_MAX 115
#elif ENABLED(VIKI2)
#define _LCD_CONTRAST_INIT 140
#elif ENABLED(WYH_L12864)
#define _LCD_CONTRAST_INIT 190
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define _LCD_CONTRAST_MIN 90
#define _LCD_CONTRAST_INIT 110
#define _LCD_CONTRAST_MAX 130
#elif ENABLED(AZSMZ_12864)
#define _LCD_CONTRAST_MIN 120
#define _LCD_CONTRAST_INIT 190
#elif EITHER(MKS_LCD12864A, MKS_LCD12864B)
#define _LCD_CONTRAST_MIN 120
#define _LCD_CONTRAST_INIT 205
#elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY)
#define _LCD_CONTRAST_MIN 120
#define _LCD_CONTRAST_INIT 195
#elif EITHER(MKS_MINI_12864_V3, BTT_MINI_12864_V1)
#define _LCD_CONTRAST_MIN 255
#define _LCD_CONTRAST_INIT 255
#elif ENABLED(FYSETC_MINI_12864)
#define _LCD_CONTRAST_MIN 180
#define _LCD_CONTRAST_INIT 220
#elif ENABLED(ULTI_CONTROLLER)
#define _LCD_CONTRAST_INIT 127
#define _LCD_CONTRAST_MAX 254
#elif ENABLED(MAKRPANEL)
#define _LCD_CONTRAST_INIT 17
#elif ENABLED(MINIPANEL)
#define _LCD_CONTRAST_INIT 150
#elif ENABLED(ZONESTAR_12864OLED)
#define _LCD_CONTRAST_MIN 64
#define _LCD_CONTRAST_INIT 128
#elif ENABLED(EMOTION_TECH_LCD)
#define _LCD_CONTRAST_INIT 140
#elif IS_TFTGLCD_PANEL
#define _LCD_CONTRAST_INIT 250
#endif
#ifdef _LCD_CONTRAST_INIT
#define HAS_LCD_CONTRAST 1
#ifndef LCD_CONTRAST_MIN
#ifdef _LCD_CONTRAST_MIN
#define LCD_CONTRAST_MIN _LCD_CONTRAST_MIN
#else
#define LCD_CONTRAST_MIN 0
#endif
#endif
#ifndef LCD_CONTRAST_INIT
#define LCD_CONTRAST_INIT _LCD_CONTRAST_INIT
#endif
#ifndef LCD_CONTRAST_MAX
#ifdef _LCD_CONTRAST_MAX
#define LCD_CONTRAST_MAX _LCD_CONTRAST_MAX
#elif _LCD_CONTRAST_INIT > 63
#define LCD_CONTRAST_MAX 255
#else
#define LCD_CONTRAST_MAX 63 // ST7567 6-bits contrast
#endif
#endif
#ifndef LCD_CONTRAST_DEFAULT
#define LCD_CONTRAST_DEFAULT LCD_CONTRAST_INIT
#endif
#endif
/**
* Override the SD_DETECT_STATE set in Configuration_adv.h
* and enable sharing of onboard SD host drives (all platforms but AGCM4)
*/
#if HAS_MEDIA
#if HAS_SD_HOST_DRIVE && SD_CONNECTION_IS(ONBOARD)
//
// The external SD card is not used. Hardware SPI is used to access the card.
// When sharing the SD card with a PC we want the menu options to
// mount/unmount the card and refresh it. So we disable card detect.
//
#undef SD_DETECT_PIN
#define HAS_SHARED_MEDIA 1
#endif
// Extender cable doesn't support SD_DETECT_PIN
#if ENABLED(NO_SD_DETECT)
#undef SD_DETECT_PIN
#endif
// Not onboard or custom cable
#if SD_CONNECTION_IS(LCD) || !defined(SDCARD_CONNECTION)
#define SD_CONNECTION_TYPICAL 1
#endif
// Set SD_DETECT_STATE based on hardware if not overridden
#if PIN_EXISTS(SD_DETECT)
#define HAS_SD_DETECT 1
#ifndef SD_DETECT_STATE
#if ALL(SD_CONNECTION_TYPICAL, HAS_MARLINUI_MENU, ELB_FULL_GRAPHIC_CONTROLLER)
#define SD_DETECT_STATE HIGH
#else
#define SD_DETECT_STATE LOW
#endif
#endif
#endif
#if DISABLED(USB_FLASH_DRIVE_SUPPORT) || BOTH(MULTI_VOLUME, VOLUME_SD_ONBOARD)
#if ENABLED(ONBOARD_SDIO)
#define NEED_SD2CARD_SDIO 1
#else
#define NEED_SD2CARD_SPI 1
#endif
#endif
#if HAS_SD_DETECT && NONE(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI, EXTENSIBLE_UI, HAS_DWIN_E3V2)
#define REINIT_NOISY_LCD 1 // Have the LCD re-init on SD insertion
#endif
#endif
/**
* Power Supply
*/
#ifndef PSU_NAME
#if DISABLED(PSU_CONTROL)
#define PSU_NAME "Generic" // No control
#elif PSU_ACTIVE_STATE
#define PSU_NAME "XBox" // X-Box 360 (203W)
#else
#define PSU_NAME "ATX" // ATX style
#endif
#endif
#if ENABLED(PSU_CONTROL)
#ifndef PSU_POWERUP_DELAY
#define PSU_POWERUP_DELAY 250
#endif
#ifndef POWER_OFF_DELAY
#define POWER_OFF_DELAY 0
#endif
#endif
/**
* Temp Sensor defines; set up pins as needed.
*/
// Usurp a sensor to do redundant readings
#if TEMP_SENSOR_REDUNDANT
#ifndef TEMP_SENSOR_REDUNDANT_SOURCE
#define TEMP_SENSOR_REDUNDANT_SOURCE E1
#endif
#ifndef TEMP_SENSOR_REDUNDANT_TARGET
#define TEMP_SENSOR_REDUNDANT_TARGET E0
#endif
#if !PIN_EXISTS(TEMP_REDUNDANT)
#ifndef TEMP_SENSOR_REDUNDANT_MAX_DIFF
#define TEMP_SENSOR_REDUNDANT_MAX_DIFF 10
#endif
#if REDUNDANT_TEMP_MATCH(SOURCE, BOARD)
#if !PIN_EXISTS(TEMP_BOARD)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to BOARD requires TEMP_BOARD_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_BOARD_PIN
#endif
#elif REDUNDANT_TEMP_MATCH(SOURCE, COOLER)
#if !PIN_EXISTS(TEMP_COOLER)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to COOLER requires TEMP_COOLER_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_COOLER_PIN
#endif
#elif REDUNDANT_TEMP_MATCH(SOURCE, PROBE)
#if !PIN_EXISTS(TEMP_PROBE)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to PROBE requires TEMP_PROBE_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_PROBE_PIN
#endif
#elif REDUNDANT_TEMP_MATCH(SOURCE, CHAMBER)
#if !PIN_EXISTS(TEMP_CHAMBER)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to CHAMBER requires TEMP_CHAMBER_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_CHAMBER_PIN
#endif
#elif REDUNDANT_TEMP_MATCH(SOURCE, BED)
#if !PIN_EXISTS(TEMP_BED)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to BED requires TEMP_BED_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_BED_PIN
#endif
#elif REDUNDANT_TEMP_MATCH(SOURCE, E0)
#if !PIN_EXISTS(TEMP_0)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to E0 requires TEMP_0_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_0_PIN
#endif
#elif REDUNDANT_TEMP_MATCH(SOURCE, E1)
#if !PIN_EXISTS(TEMP_1)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to E1 requires TEMP_1_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_1_PIN
#endif
#elif REDUNDANT_TEMP_MATCH(SOURCE, E2)
#if !PIN_EXISTS(TEMP_2)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to E2 requires TEMP_2_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_2_PIN
#endif
#elif REDUNDANT_TEMP_MATCH(SOURCE, E3)
#if !PIN_EXISTS(TEMP_3)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to E3 requires TEMP_3_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_3_PIN
#endif
#elif REDUNDANT_TEMP_MATCH(SOURCE, E4)
#if !PIN_EXISTS(TEMP_4)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to E4 requires TEMP_4_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_4_PIN
#endif
#elif REDUNDANT_TEMP_MATCH(SOURCE, E5)
#if !PIN_EXISTS(TEMP_5)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to E5 requires TEMP_5_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_5_PIN
#endif
#elif REDUNDANT_TEMP_MATCH(SOURCE, E6)
#if !PIN_EXISTS(TEMP_6)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to E6 requires TEMP_6_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_6_PIN
#endif
#elif REDUNDANT_TEMP_MATCH(SOURCE, E7)
#if !PIN_EXISTS(TEMP_7)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to E7 requires TEMP_7_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_7_PIN
#endif
#endif
#endif
#endif
/**
* Compatibility layer for MAX (SPI) temp boards
*/
#if HAS_MAX_TC
// Software SPI - enable if MISO/SCK are defined.
#if (TEMP_SENSOR_IS_MAX_TC(0) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1))) \
&& PIN_EXISTS(TEMP_0_MISO) && PIN_EXISTS(TEMP_0_SCK) && DISABLED(TEMP_SENSOR_0_FORCE_HW_SPI)
#if TEMP_SENSOR_0_IS_MAX31865 && !PIN_EXISTS(TEMP_0_MOSI)
#error "TEMP_SENSOR_0 MAX31865 requires TEMP_0_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_0_FORCE_HW_SPI."
#else
#define TEMP_SENSOR_0_HAS_SPI_PINS 1
#endif
#endif
#if (TEMP_SENSOR_IS_MAX_TC(1) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1))) \
&& PIN_EXISTS(TEMP_1_MISO) && PIN_EXISTS(TEMP_1_SCK) && DISABLED(TEMP_SENSOR_1_FORCE_HW_SPI)
#if TEMP_SENSOR_1_IS_MAX31865 && !PIN_EXISTS(TEMP_1_MOSI)
#error "TEMP_SENSOR_1 MAX31865 requires TEMP_1_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_1_FORCE_HW_SPI."
#else
#define TEMP_SENSOR_1_HAS_SPI_PINS 1
#endif
#endif
#if (TEMP_SENSOR_IS_MAX_TC(2) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E2))) \
&& PIN_EXISTS(TEMP_2_MISO) && PIN_EXISTS(TEMP_2_SCK) && DISABLED(TEMP_SENSOR_2_FORCE_HW_SPI)
#if TEMP_SENSOR_2_IS_MAX31865 && !PIN_EXISTS(TEMP_2_MOSI)
#error "TEMP_SENSOR_2 MAX31865 requires TEMP_2_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_2_FORCE_HW_SPI."
#else
#define TEMP_SENSOR_2_HAS_SPI_PINS 1
#endif
#endif
//
// User-defined thermocouple libraries
//
// Add LIB_MAX6675 / LIB_MAX31855 / LIB_MAX31865 to the build_flags
// to select a USER library for MAX6675, MAX31855, MAX31865
//
#if BOTH(HAS_MAX6675, LIB_MAX6675)
#define USE_LIB_MAX6675 1
#endif
#if BOTH(HAS_MAX31855, LIB_MAX31855)
#define USE_ADAFRUIT_MAX31855 1
#endif
#if BOTH(HAS_MAX31865, LIB_MAX31865)
#define USE_ADAFRUIT_MAX31865 1
#elif HAS_MAX31865
#define LIB_INTERNAL_MAX31865 1
#endif
#endif // HAS_MAX_TC
/**
* X_DUAL_ENDSTOPS endstop reassignment
*/
#if ENABLED(X_DUAL_ENDSTOPS)
#if X_HOME_TO_MAX
#ifndef X2_MAX_ENDSTOP_HIT_STATE
#if X2_USE_ENDSTOP == _XMIN_
#define X2_MAX_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
#elif X2_USE_ENDSTOP == _XMAX_
#define X2_MAX_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
#elif X2_USE_ENDSTOP == _YMIN_
#define X2_MAX_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
#elif X2_USE_ENDSTOP == _YMAX_
#define X2_MAX_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
#elif X2_USE_ENDSTOP == _ZMIN_
#define X2_MAX_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
#elif X2_USE_ENDSTOP == _ZMAX_
#define X2_MAX_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
#endif
#endif
#if !PIN_EXISTS(X2_MAX)
#undef X2_MAX_PIN
#if PIN_EXISTS(X2_STOP)
#define X2_MAX_PIN X2_STOP_PIN
#endif
#endif
#else
#ifndef X2_MIN_ENDSTOP_HIT_STATE
#if X2_USE_ENDSTOP == _XMIN_
#define X2_MIN_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
#elif X2_USE_ENDSTOP == _XMAX_
#define X2_MIN_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
#elif X2_USE_ENDSTOP == _YMIN_
#define X2_MIN_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
#elif X2_USE_ENDSTOP == _YMAX_
#define X2_MIN_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
#elif X2_USE_ENDSTOP == _ZMIN_
#define X2_MIN_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
#elif X2_USE_ENDSTOP == _ZMAX_
#define X2_MIN_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
#endif
#endif
#if !PIN_EXISTS(X2_MIN)
#undef X2_MIN_PIN
#if PIN_EXISTS(X2_STOP)
#define X2_MIN_PIN X2_STOP_PIN
#endif
#endif
#endif
#ifndef X2_MAX_ENDSTOP_HIT_STATE
#define X2_MAX_ENDSTOP_HIT_STATE HIGH
#endif
#ifndef X2_MIN_ENDSTOP_HIT_STATE
#define X2_MIN_ENDSTOP_HIT_STATE HIGH
#endif
#endif
/**
* Y_DUAL_ENDSTOPS endstop reassignment
*/
#if ENABLED(Y_DUAL_ENDSTOPS)
#if Y_HOME_TO_MAX
#ifndef Y2_MAX_ENDSTOP_HIT_STATE
#if Y2_USE_ENDSTOP == _XMIN_
#define Y2_MAX_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
#elif Y2_USE_ENDSTOP == _XMAX_
#define Y2_MAX_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
#elif Y2_USE_ENDSTOP == _YMIN_
#define Y2_MAX_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
#elif Y2_USE_ENDSTOP == _YMAX_
#define Y2_MAX_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
#elif Y2_USE_ENDSTOP == _ZMIN_
#define Y2_MAX_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
#elif Y2_USE_ENDSTOP == _ZMAX_
#define Y2_MAX_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
#endif
#endif
#if !PIN_EXISTS(Y2_MAX)
#undef Y2_MAX_PIN
#if PIN_EXISTS(Y2_STOP)
#define Y2_MAX_PIN Y2_STOP_PIN
#endif
#endif
#else
#ifndef Y2_MIN_ENDSTOP_HIT_STATE
#if Y2_USE_ENDSTOP == _XMIN_
#define Y2_MIN_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
#elif Y2_USE_ENDSTOP == _XMAX_
#define Y2_MIN_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
#elif Y2_USE_ENDSTOP == _YMIN_
#define Y2_MIN_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
#elif Y2_USE_ENDSTOP == _YMAX_
#define Y2_MIN_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
#elif Y2_USE_ENDSTOP == _ZMIN_
#define Y2_MIN_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
#elif Y2_USE_ENDSTOP == _ZMAX_
#define Y2_MIN_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
#endif
#endif
#if !PIN_EXISTS(Y2_MIN)
#undef Y2_MIN_PIN
#if PIN_EXISTS(Y2_STOP)
#define Y2_MIN_PIN Y2_STOP_PIN
#endif
#endif
#endif
#ifndef Y2_MAX_ENDSTOP_HIT_STATE
#define Y2_MAX_ENDSTOP_HIT_STATE HIGH
#endif
#ifndef Y2_MIN_ENDSTOP_HIT_STATE
#define Y2_MIN_ENDSTOP_HIT_STATE HIGH
#endif
#endif
/**
* Z_MULTI_ENDSTOPS endstop reassignment
*/
#if ENABLED(Z_MULTI_ENDSTOPS)
#if Z_HOME_TO_MAX
#ifndef Z2_MAX_ENDSTOP_HIT_STATE
#if Z2_USE_ENDSTOP == _XMIN_
#define Z2_MAX_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
#elif Z2_USE_ENDSTOP == _XMAX_
#define Z2_MAX_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
#elif Z2_USE_ENDSTOP == _YMIN_
#define Z2_MAX_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
#elif Z2_USE_ENDSTOP == _YMAX_
#define Z2_MAX_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
#elif Z2_USE_ENDSTOP == _ZMIN_
#define Z2_MAX_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
#elif Z2_USE_ENDSTOP == _ZMAX_
#define Z2_MAX_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
#endif
#endif
#if !PIN_EXISTS(Z2_MAX)
#undef Z2_MAX_PIN
#if PIN_EXISTS(Z2_STOP)
#define Z2_MAX_PIN Z2_STOP_PIN
#endif
#endif
#else
#ifndef Z2_MIN_ENDSTOP_HIT_STATE
#if Z2_USE_ENDSTOP == _XMIN_
#define Z2_MIN_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
#elif Z2_USE_ENDSTOP == _XMAX_
#define Z2_MIN_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
#elif Z2_USE_ENDSTOP == _YMIN_
#define Z2_MIN_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
#elif Z2_USE_ENDSTOP == _YMAX_
#define Z2_MIN_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
#elif Z2_USE_ENDSTOP == _ZMIN_
#define Z2_MIN_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
#elif Z2_USE_ENDSTOP == _ZMAX_
#define Z2_MIN_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
#endif
#endif
#if !PIN_EXISTS(Z2_MIN)
#undef Z2_MIN_PIN
#if PIN_EXISTS(Z2_STOP)
#define Z2_MIN_PIN Z2_STOP_PIN
#endif
#endif
#endif
#ifndef Z2_MAX_ENDSTOP_HIT_STATE
#define Z2_MAX_ENDSTOP_HIT_STATE HIGH
#endif
#ifndef Z2_MIN_ENDSTOP_HIT_STATE
#define Z2_MIN_ENDSTOP_HIT_STATE HIGH
#endif
#if NUM_Z_STEPPERS >= 3
#if Z_HOME_TO_MAX
#ifndef Z3_MAX_ENDSTOP_HIT_STATE
#if Z3_USE_ENDSTOP == _XMIN_
#define Z3_MAX_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
#elif Z3_USE_ENDSTOP == _XMAX_
#define Z3_MAX_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
#elif Z3_USE_ENDSTOP == _YMIN_
#define Z3_MAX_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
#elif Z3_USE_ENDSTOP == _YMAX_
#define Z3_MAX_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
#elif Z3_USE_ENDSTOP == _ZMIN_
#define Z3_MAX_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
#elif Z3_USE_ENDSTOP == _ZMAX_
#define Z3_MAX_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
#endif
#endif
#if !PIN_EXISTS(Z3_MAX)
#undef Z3_MAX_PIN
#if PIN_EXISTS(Z3_STOP)
#define Z3_MAX_PIN Z3_STOP_PIN
#endif
#endif
#else
#ifndef Z3_MIN_ENDSTOP_HIT_STATE
#if Z3_USE_ENDSTOP == _XMIN_
#define Z3_MIN_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
#elif Z3_USE_ENDSTOP == _XMAX_
#define Z3_MIN_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
#elif Z3_USE_ENDSTOP == _YMIN_
#define Z3_MIN_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
#elif Z3_USE_ENDSTOP == _YMAX_
#define Z3_MIN_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
#elif Z3_USE_ENDSTOP == _ZMIN_
#define Z3_MIN_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
#elif Z3_USE_ENDSTOP == _ZMAX_
#define Z3_MIN_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
#endif
#endif
#if !PIN_EXISTS(Z3_MIN)
#undef Z3_MIN_PIN
#if PIN_EXISTS(Z3_STOP)
#define Z3_MIN_PIN Z3_STOP_PIN
#endif
#endif
#endif
#ifndef Z3_MAX_ENDSTOP_HIT_STATE
#define Z3_MAX_ENDSTOP_HIT_STATE HIGH
#endif
#ifndef Z3_MIN_ENDSTOP_HIT_STATE
#define Z3_MIN_ENDSTOP_HIT_STATE HIGH
#endif
#endif
#if NUM_Z_STEPPERS >= 4
#if Z_HOME_TO_MAX
#ifndef Z4_MAX_ENDSTOP_HIT_STATE
#if Z4_USE_ENDSTOP == _XMIN_
#define Z4_MAX_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
#elif Z4_USE_ENDSTOP == _XMAX_
#define Z4_MAX_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
#elif Z4_USE_ENDSTOP == _YMIN_
#define Z4_MAX_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
#elif Z4_USE_ENDSTOP == _YMAX_
#define Z4_MAX_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
#elif Z4_USE_ENDSTOP == _ZMIN_
#define Z4_MAX_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
#elif Z4_USE_ENDSTOP == _ZMAX_
#define Z4_MAX_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
#endif
#endif
#if !PIN_EXISTS(Z4_MAX)
#undef Z4_MAX_PIN
#if PIN_EXISTS(Z4_STOP)
#define Z4_MAX_PIN Z4_STOP_PIN
#endif
#endif
#else
#ifndef Z4_MIN_ENDSTOP_HIT_STATE
#if Z4_USE_ENDSTOP == _XMIN_
#define Z4_MIN_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
#elif Z4_USE_ENDSTOP == _XMAX_
#define Z4_MIN_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
#elif Z4_USE_ENDSTOP == _YMIN_
#define Z4_MIN_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
#elif Z4_USE_ENDSTOP == _YMAX_
#define Z4_MIN_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
#elif Z4_USE_ENDSTOP == _ZMIN_
#define Z4_MIN_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
#elif Z4_USE_ENDSTOP == _ZMAX_
#define Z4_MIN_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
#endif
#endif
#if !PIN_EXISTS(Z4_MIN)
#undef Z4_MIN_PIN
#if PIN_EXISTS(Z4_STOP)