Prusa MINI Firmware overview
Conditionals_post.h
Go to the documentation of this file.
1 /**
2  * Marlin 3D Printer Firmware
3  * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4  *
5  * Based on Sprinter and grbl.
6  * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 #pragma once
23 
24 /**
25  * Conditionals_post.h
26  * Defines that depend on configuration but are not editable.
27  */
28 
29 #define AVR_ATmega2560_FAMILY_PLUS_70 ( \
30  MB(BQ_ZUM_MEGA_3D) \
31  || MB(MIGHTYBOARD_REVE) \
32  || MB(MINIRAMBO) \
33  || MB(SCOOVO_X9H) \
34 )
35 
36 #ifdef TEENSYDUINO
37  #undef max
38  #define max(a,b) ((a)>(b)?(a):(b))
39  #undef min
40  #define min(a,b) ((a)<(b)?(a):(b))
41 
42  #undef NOT_A_PIN // Override Teensyduino legacy CapSense define work-around
43  #define NOT_A_PIN 0 // For PINS_DEBUGGING
44 #endif
45 
46 #define HAS_CLASSIC_JERK (ENABLED(CLASSIC_JERK) || IS_KINEMATIC)
47 #define HAS_CLASSIC_E_JERK (HAS_CLASSIC_JERK && DISABLED(LIN_ADVANCE))
48 
49 /**
50  * Axis lengths and center
51  */
52 #define X_MAX_LENGTH (X_MAX_POS - (X_MIN_POS))
53 #define Y_MAX_LENGTH (Y_MAX_POS - (Y_MIN_POS))
54 #define Z_MAX_LENGTH (Z_MAX_POS - (Z_MIN_POS))
55 
56 // Defined only if the sanity-check is bypassed
57 #ifndef X_BED_SIZE
58  #define X_BED_SIZE X_MAX_LENGTH
59 #endif
60 #ifndef Y_BED_SIZE
61  #define Y_BED_SIZE Y_MAX_LENGTH
62 #endif
63 
64 // Require 0,0 bed center for Delta and SCARA
65 #if IS_KINEMATIC
66  #define BED_CENTER_AT_0_0
67 #endif
68 
69 // Define center values for future use
70 #define _X_HALF_BED ((X_BED_SIZE) / 2)
71 #define _Y_HALF_BED ((Y_BED_SIZE) / 2)
72 #if ENABLED(BED_CENTER_AT_0_0)
73  #define X_CENTER 0
74  #define Y_CENTER 0
75 #else
76  #define X_CENTER _X_HALF_BED
77  #define Y_CENTER _Y_HALF_BED
78 #endif
79 
80 // Get the linear boundaries of the bed
81 #define X_MIN_BED (X_CENTER - _X_HALF_BED)
82 #define X_MAX_BED (X_MIN_BED + X_BED_SIZE)
83 #define Y_MIN_BED (Y_CENTER - _Y_HALF_BED)
84 #define Y_MAX_BED (Y_MIN_BED + Y_BED_SIZE)
85 
86 /**
87  * Dual X Carriage
88  */
89 #if ENABLED(DUAL_X_CARRIAGE)
90  #ifndef X1_MIN_POS
91  #define X1_MIN_POS X_MIN_POS
92  #endif
93  #ifndef X1_MAX_POS
94  #define X1_MAX_POS X_BED_SIZE
95  #endif
96 #endif
97 
98 /**
99  * CoreXY, CoreXZ, and CoreYZ - and their reverse
100  */
101 #define CORE_IS_XY EITHER(COREXY, COREYX)
102 #define CORE_IS_XZ EITHER(COREXZ, COREZX)
103 #define CORE_IS_YZ EITHER(COREYZ, COREZY)
104 #define IS_CORE (CORE_IS_XY || CORE_IS_XZ || CORE_IS_YZ)
105 #if IS_CORE
106  #if CORE_IS_XY
107  #define CORE_AXIS_1 A_AXIS
108  #define CORE_AXIS_2 B_AXIS
109  #define NORMAL_AXIS Z_AXIS
110  #elif CORE_IS_XZ
111  #define CORE_AXIS_1 A_AXIS
112  #define NORMAL_AXIS Y_AXIS
113  #define CORE_AXIS_2 C_AXIS
114  #elif CORE_IS_YZ
115  #define NORMAL_AXIS X_AXIS
116  #define CORE_AXIS_1 B_AXIS
117  #define CORE_AXIS_2 C_AXIS
118  #endif
119  #if ANY(COREYX, COREZX, COREZY)
120  #define CORESIGN(n) (-(n))
121  #else
122  #define CORESIGN(n) (n)
123  #endif
124 #endif
125 
126 /**
127  * No adjustable bed on non-cartesians
128  */
129 #if IS_KINEMATIC
130  #undef LEVEL_BED_CORNERS
131 #endif
132 
133 /**
134  * SCARA cannot use SLOWDOWN and requires QUICKHOME
135  */
136 #if IS_SCARA
137  #undef SLOWDOWN
138  #define QUICK_HOME
139 #endif
140 
141 /**
142  * Set the home position based on settings or manual overrides
143  */
144 #ifdef MANUAL_X_HOME_POS
145  #define X_HOME_POS MANUAL_X_HOME_POS
146 #elif ENABLED(BED_CENTER_AT_0_0)
147  #if ENABLED(DELTA)
148  #define X_HOME_POS 0
149  #else
150  #define X_HOME_POS (X_HOME_DIR < 0 ? X_MIN_POS : X_MAX_POS)
151  #endif
152 #else
153  #if ENABLED(DELTA)
154  #define X_HOME_POS (X_MIN_POS + (X_BED_SIZE) * 0.5)
155  #else
156  #define X_HOME_POS (X_HOME_DIR < 0 ? X_MIN_POS : X_MAX_POS)
157  #endif
158 #endif
159 
160 #ifdef MANUAL_Y_HOME_POS
161  #define Y_HOME_POS MANUAL_Y_HOME_POS
162 #elif ENABLED(BED_CENTER_AT_0_0)
163  #if ENABLED(DELTA)
164  #define Y_HOME_POS 0
165  #else
166  #define Y_HOME_POS (Y_HOME_DIR < 0 ? Y_MIN_POS : Y_MAX_POS)
167  #endif
168 #else
169  #if ENABLED(DELTA)
170  #define Y_HOME_POS (Y_MIN_POS + (Y_BED_SIZE) * 0.5)
171  #else
172  #define Y_HOME_POS (Y_HOME_DIR < 0 ? Y_MIN_POS : Y_MAX_POS)
173  #endif
174 #endif
175 
176 #ifdef MANUAL_Z_HOME_POS
177  #define Z_HOME_POS MANUAL_Z_HOME_POS
178 #else
179  #define Z_HOME_POS (Z_HOME_DIR < 0 ? Z_MIN_POS : Z_MAX_POS)
180 #endif
181 
182 /**
183  * If DELTA_HEIGHT isn't defined use the old setting
184  */
185 #if ENABLED(DELTA) && !defined(DELTA_HEIGHT)
186  #define DELTA_HEIGHT Z_HOME_POS
187 #endif
188 
189 /**
190  * Z Sled Probe requires Z_SAFE_HOMING
191  */
192 #if ENABLED(Z_PROBE_SLED)
193  #define Z_SAFE_HOMING
194 #endif
195 
196 /**
197  * DELTA should ignore Z_SAFE_HOMING and SLOWDOWN
198  */
199 #if ENABLED(DELTA)
200  #undef Z_SAFE_HOMING
201  #undef SLOWDOWN
202 #endif
203 
204 #ifndef MESH_INSET
205  #define MESH_INSET 0
206 #endif
207 
208 /**
209  * Safe Homing Options
210  */
211 #if ENABLED(Z_SAFE_HOMING)
212  #if ENABLED(AUTO_BED_LEVELING_UBL)
213  // Home close to center so grid points have z heights very close to 0
214  #define _SAFE_POINT(A) (((GRID_MAX_POINTS_##A) / 2) * (A##_BED_SIZE - 2 * (MESH_INSET)) / (GRID_MAX_POINTS_##A - 1) + MESH_INSET)
215  #else
216  #define _SAFE_POINT(A) A##_CENTER
217  #endif
218  #ifndef Z_SAFE_HOMING_X_POINT
219  #define Z_SAFE_HOMING_X_POINT _SAFE_POINT(X)
220  #endif
221  #ifndef Z_SAFE_HOMING_Y_POINT
222  #define Z_SAFE_HOMING_Y_POINT _SAFE_POINT(Y)
223  #endif
224 #endif
225 
226 /**
227  * Host keep alive
228  */
229 #ifndef DEFAULT_KEEPALIVE_INTERVAL
230  #define DEFAULT_KEEPALIVE_INTERVAL 2
231 #endif
232 
233 /**
234  * Provide a MAX_AUTORETRACT for older configs
235  */
236 #if ENABLED(FWRETRACT) && !defined(MAX_AUTORETRACT)
237  #define MAX_AUTORETRACT 99
238 #endif
239 
240 /**
241  * LCD Contrast for Graphical Displays
242  */
243 #if ENABLED(CARTESIO_UI)
244  #define _LCD_CONTRAST_MIN 60
245  #define _LCD_CONTRAST_INIT 90
246  #define _LCD_CONTRAST_MAX 140
247 #elif ENABLED(miniVIKI)
248  #define _LCD_CONTRAST_MIN 75
249  #define _LCD_CONTRAST_INIT 95
250  #define _LCD_CONTRAST_MAX 115
251 #elif ENABLED(VIKI2)
252  #define _LCD_CONTRAST_INIT 140
253 #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
254  #define _LCD_CONTRAST_MIN 90
255  #define _LCD_CONTRAST_INIT 110
256  #define _LCD_CONTRAST_MAX 130
257 #elif ENABLED(AZSMZ_12864)
258  #define _LCD_CONTRAST_MIN 120
259  #define _LCD_CONTRAST_INIT 190
260 #elif ENABLED(MKS_MINI_12864)
261  #define _LCD_CONTRAST_MIN 120
262  #define _LCD_CONTRAST_INIT 195
263 #elif ANY(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1)
264  #define _LCD_CONTRAST_INIT 220
265 #elif ENABLED(ULTI_CONTROLLER)
266  #define _LCD_CONTRAST_INIT 127
267  #define _LCD_CONTRAST_MAX 254
268 #elif EITHER(MAKRPANEL, MINIPANEL)
269  #define _LCD_CONTRAST_INIT 17
270 #endif
271 
272 #define HAS_LCD_CONTRAST defined(_LCD_CONTRAST_INIT)
273 #if HAS_LCD_CONTRAST
274  #ifndef LCD_CONTRAST_MIN
275  #ifdef _LCD_CONTRAST_MIN
276  #define LCD_CONTRAST_MIN _LCD_CONTRAST_MIN
277  #else
278  #define LCD_CONTRAST_MIN 0
279  #endif
280  #endif
281  #ifndef LCD_CONTRAST_INIT
282  #define LCD_CONTRAST_INIT _LCD_CONTRAST_INIT
283  #endif
284  #ifndef LCD_CONTRAST_MAX
285  #ifdef _LCD_CONTRAST_MAX
286  #define LCD_CONTRAST_MAX _LCD_CONTRAST_MAX
287  #elif _LCD_CONTRAST_INIT > 63
288  #define LCD_CONTRAST_MAX 255
289  #else
290  #define LCD_CONTRAST_MAX 63 // ST7567 6-bits contrast
291  #endif
292  #endif
293  #ifndef DEFAULT_LCD_CONTRAST
294  #define DEFAULT_LCD_CONTRAST LCD_CONTRAST_INIT
295  #endif
296 #endif
297 
298 /**
299  * Override here because this is set in Configuration_adv.h
300  */
301 #if HAS_LCD_MENU && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER)
302  #undef SD_DETECT_INVERTED
303 #endif
304 
305 /**
306  * Set defaults for missing (newer) options
307  */
308 #ifndef DISABLE_INACTIVE_X
309  #define DISABLE_INACTIVE_X DISABLE_X
310 #endif
311 #ifndef DISABLE_INACTIVE_Y
312  #define DISABLE_INACTIVE_Y DISABLE_Y
313 #endif
314 #ifndef DISABLE_INACTIVE_Z
315  #define DISABLE_INACTIVE_Z DISABLE_Z
316 #endif
317 #ifndef DISABLE_INACTIVE_E
318  #define DISABLE_INACTIVE_E DISABLE_E
319 #endif
320 
321 /**
322  * Power Supply Control
323  */
324 #ifndef PSU_NAME
325  #if ENABLED(PSU_CONTROL)
326  #if PSU_ACTIVE_HIGH
327  #define PSU_NAME "XBox" // X-Box 360 (203W)
328  #else
329  #define PSU_NAME "ATX" // ATX style
330  #endif
331  #else
332  #define PSU_NAME "Generic" // No control
333  #endif
334 #endif
335 
336 #define HAS_POWER_SWITCH (ENABLED(PSU_CONTROL) && PIN_EXISTS(PS_ON))
337 
338 /**
339  * Temp Sensor defines
340  */
341 
342 #define ANY_TEMP_SENSOR_IS(n) (TEMP_SENSOR_0 == (n) || TEMP_SENSOR_1 == (n) || TEMP_SENSOR_2 == (n) || TEMP_SENSOR_3 == (n) || TEMP_SENSOR_4 == (n) || TEMP_SENSOR_5 == (n) || TEMP_SENSOR_BED == (n) || TEMP_SENSOR_CHAMBER == (n))
343 
344 #define HAS_USER_THERMISTORS ANY_TEMP_SENSOR_IS(1000)
345 
346 #if TEMP_SENSOR_0 == -4
347  #define HEATER_0_USES_AD8495
348 #elif TEMP_SENSOR_0 == -3
349  #define HEATER_0_USES_MAX6675
350  #define MAX6675_IS_MAX31855
351  #define HEATER_0_MAX6675_TMIN -270
352  #define HEATER_0_MAX6675_TMAX 1800
353 #elif TEMP_SENSOR_0 == -2
354  #define HEATER_0_USES_MAX6675
355  #define HEATER_0_MAX6675_TMIN 0
356  #define HEATER_0_MAX6675_TMAX 1024
357 #elif TEMP_SENSOR_0 == -1
358  #define HEATER_0_USES_AD595
359 #elif TEMP_SENSOR_0 > 0
360  #define THERMISTOR_HEATER_0 TEMP_SENSOR_0
361  #define HEATER_0_USES_THERMISTOR
362  #if TEMP_SENSOR_0 == 1000
363  #define HEATER_0_USER_THERMISTOR
364  #endif
365 #else
366  #undef HEATER_0_MINTEMP
367  #undef HEATER_0_MAXTEMP
368 #endif
369 
370 #if TEMP_SENSOR_1 == -4
371  #define HEATER_1_USES_AD8495
372 #elif TEMP_SENSOR_1 == -3
373  #if TEMP_SENSOR_0 == -2
374  #error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_1 then TEMP_SENSOR_0 must match."
375  #endif
376  #define HEATER_1_USES_MAX6675
377  #define HEATER_1_MAX6675_TMIN -270
378  #define HEATER_1_MAX6675_TMAX 1800
379 #elif TEMP_SENSOR_1 == -2
380  #if TEMP_SENSOR_0 == -3
381  #error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_0 then TEMP_SENSOR_1 must match."
382  #endif
383  #define HEATER_1_USES_MAX6675
384  #define HEATER_1_MAX6675_TMIN 0
385  #define HEATER_1_MAX6675_TMAX 1024
386 #elif TEMP_SENSOR_1 == -1
387  #define HEATER_1_USES_AD595
388 #elif TEMP_SENSOR_1 > 0
389  #define THERMISTOR_HEATER_1 TEMP_SENSOR_1
390  #define HEATER_1_USES_THERMISTOR
391  #if TEMP_SENSOR_1 == 1000
392  #define HEATER_1_USER_THERMISTOR
393  #endif
394 #else
395  #undef HEATER_1_MINTEMP
396  #undef HEATER_1_MAXTEMP
397 #endif
398 
399 #if TEMP_SENSOR_2 == -4
400  #define HEATER_2_USES_AD8495
401 #elif TEMP_SENSOR_2 == -3
402  #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_2."
403 #elif TEMP_SENSOR_2 == -2
404  #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_2."
405 #elif TEMP_SENSOR_2 == -1
406  #define HEATER_2_USES_AD595
407 #elif TEMP_SENSOR_2 > 0
408  #define THERMISTOR_HEATER_2 TEMP_SENSOR_2
409  #define HEATER_2_USES_THERMISTOR
410  #if TEMP_SENSOR_2 == 1000
411  #define HEATER_2_USER_THERMISTOR
412  #endif
413 #else
414  #undef HEATER_2_MINTEMP
415  #undef HEATER_2_MAXTEMP
416 #endif
417 
418 #if TEMP_SENSOR_3 == -4
419  #define HEATER_3_USES_AD8495
420 #elif TEMP_SENSOR_3 == -3
421  #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_3."
422 #elif TEMP_SENSOR_3 == -2
423  #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_3."
424 #elif TEMP_SENSOR_3 == -1
425  #define HEATER_3_USES_AD595
426 #elif TEMP_SENSOR_3 > 0
427  #define THERMISTOR_HEATER_3 TEMP_SENSOR_3
428  #define HEATER_3_USES_THERMISTOR
429  #if TEMP_SENSOR_3 == 1000
430  #define HEATER_3_USER_THERMISTOR
431  #endif
432 #else
433  #undef HEATER_3_MINTEMP
434  #undef HEATER_3_MAXTEMP
435 #endif
436 
437 #if TEMP_SENSOR_4 == -4
438  #define HEATER_4_USES_AD8495
439 #elif TEMP_SENSOR_4 == -3
440  #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_4."
441 #elif TEMP_SENSOR_4 == -2
442  #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_4."
443 #elif TEMP_SENSOR_4 == -1
444  #define HEATER_4_USES_AD595
445 #elif TEMP_SENSOR_4 > 0
446  #define THERMISTOR_HEATER_4 TEMP_SENSOR_4
447  #define HEATER_4_USES_THERMISTOR
448  #if TEMP_SENSOR_4 == 1000
449  #define HEATER_4_USER_THERMISTOR
450  #endif
451 #else
452  #undef HEATER_4_MINTEMP
453  #undef HEATER_4_MAXTEMP
454 #endif
455 
456 #if TEMP_SENSOR_5 == -4
457  #define HEATER_5_USES_AD8495
458 #elif TEMP_SENSOR_5 == -3
459  #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_5."
460 #elif TEMP_SENSOR_5 == -2
461  #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_5."
462 #elif TEMP_SENSOR_5 == -1
463  #define HEATER_5_USES_AD595
464 #elif TEMP_SENSOR_5 > 0
465  #define THERMISTOR_HEATER_5 TEMP_SENSOR_5
466  #define HEATER_5_USES_THERMISTOR
467  #if TEMP_SENSOR_5 == 1000
468  #define HEATER_5_USER_THERMISTOR
469  #endif
470 #else
471  #undef HEATER_5_MINTEMP
472  #undef HEATER_5_MAXTEMP
473 #endif
474 
475 #if TEMP_SENSOR_BED == -4
476  #define HEATER_BED_USES_AD8495
477 #elif TEMP_SENSOR_BED == -3
478  #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BED."
479 #elif TEMP_SENSOR_BED == -2
480  #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_BED."
481 #elif TEMP_SENSOR_BED == -1
482  #define HEATER_BED_USES_AD595
483 #elif TEMP_SENSOR_BED > 0
484  #define THERMISTORBED TEMP_SENSOR_BED
485  #define HEATER_BED_USES_THERMISTOR
486  #if TEMP_SENSOR_BED == 1000
487  #define HEATER_BED_USER_THERMISTOR
488  #endif
489 #else
490  #undef BED_MINTEMP
491  #undef BED_MAXTEMP
492 #endif
493 
494 #if TEMP_SENSOR_CHAMBER == -4
495  #define HEATER_CHAMBER_USES_AD8495
496 #elif TEMP_SENSOR_CHAMBER == -3
497  #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_CHAMBER."
498 #elif TEMP_SENSOR_CHAMBER == -2
499  #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_CHAMBER."
500 #elif TEMP_SENSOR_CHAMBER == -1
501  #define HEATER_CHAMBER_USES_AD595
502 #elif TEMP_SENSOR_CHAMBER > 0
503  #define THERMISTORCHAMBER TEMP_SENSOR_CHAMBER
504  #define HEATER_CHAMBER_USES_THERMISTOR
505  #if TEMP_SENSOR_CHAMBER == 1000
506  #define HEATER_CHAMBER_USER_THERMISTOR
507  #endif
508 #else
509  #undef CHAMBER_MINTEMP
510  #undef CHAMBER_MAXTEMP
511 #endif
512 
513 #define HOTEND_USES_THERMISTOR ANY(HEATER_0_USES_THERMISTOR, HEATER_1_USES_THERMISTOR, HEATER_2_USES_THERMISTOR, HEATER_3_USES_THERMISTOR, HEATER_4_USES_THERMISTOR)
514 
515 /**
516  * Default hotend offsets, if not defined
517  */
518 #if HAS_HOTEND_OFFSET
519  #ifndef HOTEND_OFFSET_X
520  #define HOTEND_OFFSET_X { 0 } // X offsets for each extruder
521  #endif
522  #ifndef HOTEND_OFFSET_Y
523  #define HOTEND_OFFSET_Y { 0 } // Y offsets for each extruder
524  #endif
525  #ifndef HOTEND_OFFSET_Z
526  #define HOTEND_OFFSET_Z { 0 } // Z offsets for each extruder
527  #endif
528 #endif
529 
530 /**
531  * ARRAY_BY_EXTRUDERS based on EXTRUDERS
532  */
533 #define ARRAY_BY_EXTRUDERS(V...) ARRAY_N(EXTRUDERS, V)
534 #define ARRAY_BY_EXTRUDERS1(v1) ARRAY_BY_EXTRUDERS(v1, v1, v1, v1, v1, v1)
535 
536 /**
537  * ARRAY_BY_HOTENDS based on HOTENDS
538  */
539 #define ARRAY_BY_HOTENDS(V...) ARRAY_N(HOTENDS, V)
540 #define ARRAY_BY_HOTENDS1(v1) ARRAY_BY_HOTENDS(v1, v1, v1, v1, v1, v1)
541 
542 /**
543  * Driver Timings
544  * NOTE: Driver timing order is longest-to-shortest duration.
545  * Preserve this ordering when adding new drivers.
546  */
547 
548 #define TRINAMICS (HAS_TRINAMIC || HAS_DRIVER(TMC2130_STANDALONE) || HAS_DRIVER(TMC2208_STANDALONE) || HAS_DRIVER(TMC2209_STANDALONE) || HAS_DRIVER(TMC26X_STANDALONE) || HAS_DRIVER(TMC2660_STANDALONE) || HAS_DRIVER(TMC5130_STANDALONE) || HAS_DRIVER(TMC5160_STANDALONE) || HAS_DRIVER(TMC2160_STANDALONE))
549 
550 #ifndef MINIMUM_STEPPER_POST_DIR_DELAY
551  #if HAS_DRIVER(TB6560)
552  #define MINIMUM_STEPPER_POST_DIR_DELAY 15000
553  #elif HAS_DRIVER(TB6600)
554  #define MINIMUM_STEPPER_POST_DIR_DELAY 1500
555  #elif HAS_DRIVER(DRV8825)
556  #define MINIMUM_STEPPER_POST_DIR_DELAY 650
557  #elif HAS_DRIVER(LV8729)
558  #define MINIMUM_STEPPER_POST_DIR_DELAY 500
559  #elif HAS_DRIVER(A5984)
560  #define MINIMUM_STEPPER_POST_DIR_DELAY 400
561  #elif HAS_DRIVER(A4988)
562  #define MINIMUM_STEPPER_POST_DIR_DELAY 200
563  #elif TRINAMICS
564  #define MINIMUM_STEPPER_POST_DIR_DELAY 20
565  #else
566  #define MINIMUM_STEPPER_POST_DIR_DELAY 0 // Expect at least 10µS since one Stepper ISR must transpire
567  #endif
568 #endif
569 
570 #ifndef MINIMUM_STEPPER_PRE_DIR_DELAY
571  #define MINIMUM_STEPPER_PRE_DIR_DELAY MINIMUM_STEPPER_POST_DIR_DELAY
572 #endif
573 
574 #ifndef MINIMUM_STEPPER_PULSE
575  #if HAS_DRIVER(TB6560)
576  #define MINIMUM_STEPPER_PULSE 30
577  #elif HAS_DRIVER(TB6600)
578  #define MINIMUM_STEPPER_PULSE 3
579  #elif HAS_DRIVER(DRV8825)
580  #define MINIMUM_STEPPER_PULSE 2
581  #elif HAS_DRIVER(A4988) || HAS_DRIVER(A5984)
582  #define MINIMUM_STEPPER_PULSE 1
583  #elif HAS_DRIVER(LV8729)
584  #define MINIMUM_STEPPER_PULSE 0
585  #elif TRINAMICS
586  #define MINIMUM_STEPPER_PULSE 0
587  #else
588  #define MINIMUM_STEPPER_PULSE 2
589  #endif
590 #endif
591 
592 #ifndef MAXIMUM_STEPPER_RATE
593  #if HAS_DRIVER(TB6560)
594  #define MAXIMUM_STEPPER_RATE 15000
595  #elif HAS_DRIVER(TB6600)
596  #define MAXIMUM_STEPPER_RATE 150000
597  #elif HAS_DRIVER(LV8729)
598  #define MAXIMUM_STEPPER_RATE 200000
599  #elif HAS_DRIVER(DRV8825)
600  #define MAXIMUM_STEPPER_RATE 250000
601  #elif TRINAMICS
602  #define MAXIMUM_STEPPER_RATE 400000
603  #elif HAS_DRIVER(A4988)
604  #define MAXIMUM_STEPPER_RATE 500000
605  #else
606  #define MAXIMUM_STEPPER_RATE 250000
607  #endif
608 #endif
609 
610 /**
611  * X_DUAL_ENDSTOPS endstop reassignment
612  */
613 #if ENABLED(X_DUAL_ENDSTOPS)
614  #if X_HOME_DIR > 0
615  #if X2_USE_ENDSTOP == _XMIN_
616  #define X2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
617  #define X2_MAX_PIN X_MIN_PIN
618  #elif X2_USE_ENDSTOP == _XMAX_
619  #define X2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
620  #define X2_MAX_PIN X_MAX_PIN
621  #elif X2_USE_ENDSTOP == _YMIN_
622  #define X2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
623  #define X2_MAX_PIN Y_MIN_PIN
624  #elif X2_USE_ENDSTOP == _YMAX_
625  #define X2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
626  #define X2_MAX_PIN Y_MAX_PIN
627  #elif X2_USE_ENDSTOP == _ZMIN_
628  #define X2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
629  #define X2_MAX_PIN Z_MIN_PIN
630  #elif X2_USE_ENDSTOP == _ZMAX_
631  #define X2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
632  #define X2_MAX_PIN Z_MAX_PIN
633  #else
634  #define X2_MAX_ENDSTOP_INVERTING false
635  #endif
636  #define X2_MIN_ENDSTOP_INVERTING false
637  #else
638  #if X2_USE_ENDSTOP == _XMIN_
639  #define X2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
640  #define X2_MIN_PIN X_MIN_PIN
641  #elif X2_USE_ENDSTOP == _XMAX_
642  #define X2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
643  #define X2_MIN_PIN X_MAX_PIN
644  #elif X2_USE_ENDSTOP == _YMIN_
645  #define X2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
646  #define X2_MIN_PIN Y_MIN_PIN
647  #elif X2_USE_ENDSTOP == _YMAX_
648  #define X2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
649  #define X2_MIN_PIN Y_MAX_PIN
650  #elif X2_USE_ENDSTOP == _ZMIN_
651  #define X2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
652  #define X2_MIN_PIN Z_MIN_PIN
653  #elif X2_USE_ENDSTOP == _ZMAX_
654  #define X2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
655  #define X2_MIN_PIN Z_MAX_PIN
656  #else
657  #define X2_MIN_ENDSTOP_INVERTING false
658  #endif
659  #define X2_MAX_ENDSTOP_INVERTING false
660  #endif
661 #endif
662 
663 // Is an endstop plug used for the X2 endstop?
664 #define IS_X2_ENDSTOP(A,M) (ENABLED(X_DUAL_ENDSTOPS) && X2_USE_ENDSTOP == _##A##M##_)
665 
666 /**
667  * Y_DUAL_ENDSTOPS endstop reassignment
668  */
669 #if ENABLED(Y_DUAL_ENDSTOPS)
670  #if Y_HOME_DIR > 0
671  #if Y2_USE_ENDSTOP == _XMIN_
672  #define Y2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
673  #define Y2_MAX_PIN X_MIN_PIN
674  #elif Y2_USE_ENDSTOP == _XMAX_
675  #define Y2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
676  #define Y2_MAX_PIN X_MAX_PIN
677  #elif Y2_USE_ENDSTOP == _YMIN_
678  #define Y2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
679  #define Y2_MAX_PIN Y_MIN_PIN
680  #elif Y2_USE_ENDSTOP == _YMAX_
681  #define Y2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
682  #define Y2_MAX_PIN Y_MAX_PIN
683  #elif Y2_USE_ENDSTOP == _ZMIN_
684  #define Y2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
685  #define Y2_MAX_PIN Z_MIN_PIN
686  #elif Y2_USE_ENDSTOP == _ZMAX_
687  #define Y2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
688  #define Y2_MAX_PIN Z_MAX_PIN
689  #else
690  #define Y2_MAX_ENDSTOP_INVERTING false
691  #endif
692  #define Y2_MIN_ENDSTOP_INVERTING false
693  #else
694  #if Y2_USE_ENDSTOP == _XMIN_
695  #define Y2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
696  #define Y2_MIN_PIN X_MIN_PIN
697  #elif Y2_USE_ENDSTOP == _XMAX_
698  #define Y2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
699  #define Y2_MIN_PIN X_MAX_PIN
700  #elif Y2_USE_ENDSTOP == _YMIN_
701  #define Y2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
702  #define Y2_MIN_PIN Y_MIN_PIN
703  #elif Y2_USE_ENDSTOP == _YMAX_
704  #define Y2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
705  #define Y2_MIN_PIN Y_MAX_PIN
706  #elif Y2_USE_ENDSTOP == _ZMIN_
707  #define Y2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
708  #define Y2_MIN_PIN Z_MIN_PIN
709  #elif Y2_USE_ENDSTOP == _ZMAX_
710  #define Y2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
711  #define Y2_MIN_PIN Z_MAX_PIN
712  #else
713  #define Y2_MIN_ENDSTOP_INVERTING false
714  #endif
715  #define Y2_MAX_ENDSTOP_INVERTING false
716  #endif
717 #endif
718 
719 // Is an endstop plug used for the Y2 endstop or the bed probe?
720 #define IS_Y2_ENDSTOP(A,M) (ENABLED(Y_DUAL_ENDSTOPS) && Y2_USE_ENDSTOP == _##A##M##_)
721 
722 /**
723  * Z_DUAL_ENDSTOPS endstop reassignment
724  */
725 #if Z_MULTI_ENDSTOPS
726  #if Z_HOME_DIR > 0
727  #if Z2_USE_ENDSTOP == _XMIN_
728  #define Z2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
729  #define Z2_MAX_PIN X_MIN_PIN
730  #elif Z2_USE_ENDSTOP == _XMAX_
731  #define Z2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
732  #define Z2_MAX_PIN X_MAX_PIN
733  #elif Z2_USE_ENDSTOP == _YMIN_
734  #define Z2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
735  #define Z2_MAX_PIN Y_MIN_PIN
736  #elif Z2_USE_ENDSTOP == _YMAX_
737  #define Z2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
738  #define Z2_MAX_PIN Y_MAX_PIN
739  #elif Z2_USE_ENDSTOP == _ZMIN_
740  #define Z2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
741  #define Z2_MAX_PIN Z_MIN_PIN
742  #elif Z2_USE_ENDSTOP == _ZMAX_
743  #define Z2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
744  #define Z2_MAX_PIN Z_MAX_PIN
745  #else
746  #define Z2_MAX_ENDSTOP_INVERTING false
747  #endif
748  #define Z2_MIN_ENDSTOP_INVERTING false
749  #else
750  #if Z2_USE_ENDSTOP == _XMIN_
751  #define Z2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
752  #define Z2_MIN_PIN X_MIN_PIN
753  #elif Z2_USE_ENDSTOP == _XMAX_
754  #define Z2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
755  #define Z2_MIN_PIN X_MAX_PIN
756  #elif Z2_USE_ENDSTOP == _YMIN_
757  #define Z2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
758  #define Z2_MIN_PIN Y_MIN_PIN
759  #elif Z2_USE_ENDSTOP == _YMAX_
760  #define Z2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
761  #define Z2_MIN_PIN Y_MAX_PIN
762  #elif Z2_USE_ENDSTOP == _ZMIN_
763  #define Z2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
764  #define Z2_MIN_PIN Z_MIN_PIN
765  #elif Z2_USE_ENDSTOP == _ZMAX_
766  #define Z2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
767  #define Z2_MIN_PIN Z_MAX_PIN
768  #else
769  #define Z2_MIN_ENDSTOP_INVERTING false
770  #endif
771  #define Z2_MAX_ENDSTOP_INVERTING false
772  #endif
773 #endif
774 
775 #if ENABLED(Z_TRIPLE_ENDSTOPS)
776  #if Z_HOME_DIR > 0
777  #if Z3_USE_ENDSTOP == _XMIN_
778  #define Z3_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
779  #define Z3_MAX_PIN X_MIN_PIN
780  #elif Z3_USE_ENDSTOP == _XMAX_
781  #define Z3_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
782  #define Z3_MAX_PIN X_MAX_PIN
783  #elif Z3_USE_ENDSTOP == _YMIN_
784  #define Z3_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
785  #define Z3_MAX_PIN Y_MIN_PIN
786  #elif Z3_USE_ENDSTOP == _YMAX_
787  #define Z3_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
788  #define Z3_MAX_PIN Y_MAX_PIN
789  #elif Z3_USE_ENDSTOP == _ZMIN_
790  #define Z3_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
791  #define Z3_MAX_PIN Z_MIN_PIN
792  #elif Z3_USE_ENDSTOP == _ZMAX_
793  #define Z3_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
794  #define Z3_MAX_PIN Z_MAX_PIN
795  #else
796  #define Z3_MAX_ENDSTOP_INVERTING false
797  #endif
798  #define Z3_MIN_ENDSTOP_INVERTING false
799  #else
800  #if Z3_USE_ENDSTOP == _XMIN_
801  #define Z3_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
802  #define Z3_MIN_PIN X_MIN_PIN
803  #elif Z3_USE_ENDSTOP == _XMAX_
804  #define Z3_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
805  #define Z3_MIN_PIN X_MAX_PIN
806  #elif Z3_USE_ENDSTOP == _YMIN_
807  #define Z3_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
808  #define Z3_MIN_PIN Y_MIN_PIN
809  #elif Z3_USE_ENDSTOP == _YMAX_
810  #define Z3_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
811  #define Z3_MIN_PIN Y_MAX_PIN
812  #elif Z3_USE_ENDSTOP == _ZMIN_
813  #define Z3_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
814  #define Z3_MIN_PIN Z_MIN_PIN
815  #elif Z3_USE_ENDSTOP == _ZMAX_
816  #define Z3_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
817  #define Z3_MIN_PIN Z_MAX_PIN
818  #else
819  #define Z3_MIN_ENDSTOP_INVERTING false
820  #endif
821  #define Z3_MAX_ENDSTOP_INVERTING false
822  #endif
823 #endif
824 
825 // Is an endstop plug used for the Z2 endstop or the bed probe?
826 #define IS_Z2_OR_PROBE(A,M) ( \
827  (Z_MULTI_ENDSTOPS && Z2_USE_ENDSTOP == _##A##M##_) \
828  || (HAS_CUSTOM_PROBE_PIN && Z_MIN_PROBE_PIN == A##_##M##_PIN ) )
829 
830 // Is an endstop plug used for the Z3 endstop or the bed probe?
831 #define IS_Z3_OR_PROBE(A,M) ( \
832  (ENABLED(Z_TRIPLE_ENDSTOPS) && Z3_USE_ENDSTOP == _##A##M##_) \
833  || (HAS_CUSTOM_PROBE_PIN && Z_MIN_PROBE_PIN == A##_##M##_PIN ) )
834 
835 /**
836  * Set ENDSTOPPULLUPS for active endstop switches
837  */
838 #if ENABLED(ENDSTOPPULLUPS)
839  #if ENABLED(USE_XMAX_PLUG)
840  #define ENDSTOPPULLUP_XMAX
841  #endif
842  #if ENABLED(USE_YMAX_PLUG)
843  #define ENDSTOPPULLUP_YMAX
844  #endif
845  #if ENABLED(USE_ZMAX_PLUG)
846  #define ENDSTOPPULLUP_ZMAX
847  #endif
848  #if ENABLED(USE_XMIN_PLUG)
849  #define ENDSTOPPULLUP_XMIN
850  #endif
851  #if ENABLED(USE_YMIN_PLUG)
852  #define ENDSTOPPULLUP_YMIN
853  #endif
854  #if ENABLED(USE_ZMIN_PLUG)
855  #define ENDSTOPPULLUP_ZMIN
856  #endif
857 #endif
858 
859 /**
860  * Set ENDSTOPPULLDOWNS for active endstop switches
861  */
862 #if ENABLED(ENDSTOPPULLDOWNS)
863  #if ENABLED(USE_XMAX_PLUG)
864  #define ENDSTOPPULLDOWN_XMAX
865  #endif
866  #if ENABLED(USE_YMAX_PLUG)
867  #define ENDSTOPPULLDOWN_YMAX
868  #endif
869  #if ENABLED(USE_ZMAX_PLUG)
870  #define ENDSTOPPULLDOWN_ZMAX
871  #endif
872  #if ENABLED(USE_XMIN_PLUG)
873  #define ENDSTOPPULLDOWN_XMIN
874  #endif
875  #if ENABLED(USE_YMIN_PLUG)
876  #define ENDSTOPPULLDOWN_YMIN
877  #endif
878  #if ENABLED(USE_ZMIN_PLUG)
879  #define ENDSTOPPULLDOWN_ZMIN
880  #endif
881 #endif
882 
883 /**
884  * Shorthand for pin tests, used wherever needed
885  */
886 
887 // Steppers
888 #define HAS_X_ENABLE (PIN_EXISTS(X_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X)))
889 #define HAS_X_DIR (PIN_EXISTS(X_DIR))
890 #define HAS_X_STEP (PIN_EXISTS(X_STEP))
891 #define HAS_X_MICROSTEPS (PIN_EXISTS(X_MS1))
892 
893 #define HAS_X2_ENABLE (PIN_EXISTS(X2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X2)))
894 #define HAS_X2_DIR (PIN_EXISTS(X2_DIR))
895 #define HAS_X2_STEP (PIN_EXISTS(X2_STEP))
896 #define HAS_X2_MICROSTEPS (PIN_EXISTS(X2_MS1))
897 
898 #define HAS_Y_ENABLE (PIN_EXISTS(Y_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y)))
899 #define HAS_Y_DIR (PIN_EXISTS(Y_DIR))
900 #define HAS_Y_STEP (PIN_EXISTS(Y_STEP))
901 #define HAS_Y_MICROSTEPS (PIN_EXISTS(Y_MS1))
902 
903 #define HAS_Y2_ENABLE (PIN_EXISTS(Y2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y2)))
904 #define HAS_Y2_DIR (PIN_EXISTS(Y2_DIR))
905 #define HAS_Y2_STEP (PIN_EXISTS(Y2_STEP))
906 #define HAS_Y2_MICROSTEPS (PIN_EXISTS(Y2_MS1))
907 
908 #define HAS_Z_ENABLE (PIN_EXISTS(Z_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z)))
909 #define HAS_Z_DIR (PIN_EXISTS(Z_DIR))
910 #define HAS_Z_STEP (PIN_EXISTS(Z_STEP))
911 #define HAS_Z_MICROSTEPS (PIN_EXISTS(Z_MS1))
912 
913 #define HAS_Z2_ENABLE (PIN_EXISTS(Z2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)))
914 #define HAS_Z2_DIR (PIN_EXISTS(Z2_DIR))
915 #define HAS_Z2_STEP (PIN_EXISTS(Z2_STEP))
916 #define HAS_Z2_MICROSTEPS (PIN_EXISTS(Z2_MS1))
917 
918 #define HAS_Z3_ENABLE (PIN_EXISTS(Z3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3)))
919 #define HAS_Z3_DIR (PIN_EXISTS(Z3_DIR))
920 #define HAS_Z3_STEP (PIN_EXISTS(Z3_STEP))
921 #define HAS_Z3_MICROSTEPS (PIN_EXISTS(Z3_MS1))
922 
923 // Extruder steppers and solenoids
924 #define HAS_E0_ENABLE (PIN_EXISTS(E0_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)))
925 #define HAS_E0_DIR (PIN_EXISTS(E0_DIR))
926 #define HAS_E0_STEP (PIN_EXISTS(E0_STEP))
927 #define HAS_E0_MICROSTEPS (PIN_EXISTS(E0_MS1))
928 #define HAS_SOLENOID_0 (PIN_EXISTS(SOL0))
929 
930 #define HAS_E1_ENABLE (PIN_EXISTS(E1_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)))
931 #define HAS_E1_DIR (PIN_EXISTS(E1_DIR))
932 #define HAS_E1_STEP (PIN_EXISTS(E1_STEP))
933 #define HAS_E1_MICROSTEPS (PIN_EXISTS(E1_MS1))
934 #define HAS_SOLENOID_1 (PIN_EXISTS(SOL1))
935 
936 #define HAS_E2_ENABLE (PIN_EXISTS(E2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)))
937 #define HAS_E2_DIR (PIN_EXISTS(E2_DIR))
938 #define HAS_E2_STEP (PIN_EXISTS(E2_STEP))
939 #define HAS_E2_MICROSTEPS (PIN_EXISTS(E2_MS1))
940 #define HAS_SOLENOID_2 (PIN_EXISTS(SOL2))
941 
942 #define HAS_E3_ENABLE (PIN_EXISTS(E3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)))
943 #define HAS_E3_DIR (PIN_EXISTS(E3_DIR))
944 #define HAS_E3_STEP (PIN_EXISTS(E3_STEP))
945 #define HAS_E3_MICROSTEPS (PIN_EXISTS(E3_MS1))
946 #define HAS_SOLENOID_3 (PIN_EXISTS(SOL3))
947 
948 #define HAS_E4_ENABLE (PIN_EXISTS(E4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)))
949 #define HAS_E4_DIR (PIN_EXISTS(E4_DIR))
950 #define HAS_E4_STEP (PIN_EXISTS(E4_STEP))
951 #define HAS_E4_MICROSTEPS (PIN_EXISTS(E4_MS1))
952 #define HAS_SOLENOID_4 (PIN_EXISTS(SOL4))
953 
954 #define HAS_E5_ENABLE (PIN_EXISTS(E5_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)))
955 #define HAS_E5_DIR (PIN_EXISTS(E5_DIR))
956 #define HAS_E5_STEP (PIN_EXISTS(E5_STEP))
957 #define HAS_E5_MICROSTEPS (PIN_EXISTS(E5_MS1))
958 #define HAS_SOLENOID_5 (PIN_EXISTS(SOL5))
959 
960 // Trinamic Stepper Drivers
961 #if HAS_TRINAMIC
962  #define HAS_TMCX1X0 (HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160))
963  #define TMC_HAS_SPI (HAS_TMCX1X0 || HAS_DRIVER(TMC2660))
964  #define HAS_STALLGUARD (HAS_TMCX1X0 || HAS_DRIVER(TMC2209) || HAS_DRIVER(TMC2660))
965  #define HAS_STEALTHCHOP (HAS_TMCX1X0 || HAS_TMC220x)
966 
967  #define STEALTHCHOP_ENABLED ANY(STEALTHCHOP_XY, STEALTHCHOP_Z, STEALTHCHOP_E)
968  #define USE_SENSORLESS EITHER(SENSORLESS_HOMING, SENSORLESS_PROBING)
969  // Disable Z axis sensorless homing if a probe is used to home the Z axis
970  #if HOMING_Z_WITH_PROBE
971  #undef Z_STALL_SENSITIVITY
972  #endif
973  #define X_SENSORLESS (AXIS_HAS_STALLGUARD(X) && defined(X_STALL_SENSITIVITY))
974  #define X2_SENSORLESS (AXIS_HAS_STALLGUARD(X2) && defined(X2_STALL_SENSITIVITY))
975  #define Y_SENSORLESS (AXIS_HAS_STALLGUARD(Y) && defined(Y_STALL_SENSITIVITY))
976  #define Y2_SENSORLESS (AXIS_HAS_STALLGUARD(Y2) && defined(Y2_STALL_SENSITIVITY))
977  #define Z_SENSORLESS (AXIS_HAS_STALLGUARD(Z) && defined(Z_STALL_SENSITIVITY))
978  #define Z2_SENSORLESS (AXIS_HAS_STALLGUARD(Z2) && defined(Z2_STALL_SENSITIVITY))
979  #define Z3_SENSORLESS (AXIS_HAS_STALLGUARD(Z3) && defined(Z3_STALL_SENSITIVITY))
980  #if ENABLED(SPI_ENDSTOPS)
981  #define X_SPI_SENSORLESS X_SENSORLESS
982  #define Y_SPI_SENSORLESS Y_SENSORLESS
983  #define Z_SPI_SENSORLESS Z_SENSORLESS
984  #endif
985 #endif
986 
987 #define HAS_E_STEPPER_ENABLE (HAS_E_DRIVER(TMC2660) \
988  || ( E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != X_ENABLE_PIN \
989  && E0_ENABLE_PIN != Y_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN ) \
990 )
991 
992 // Endstops and bed probe
993 #define _HAS_STOP(A,M) (PIN_EXISTS(A##_##M) && !IS_X2_ENDSTOP(A,M) && !IS_Y2_ENDSTOP(A,M) && !IS_Z2_OR_PROBE(A,M))
994 #define HAS_X_MIN _HAS_STOP(X,MIN)
995 #define HAS_X_MAX _HAS_STOP(X,MAX)
996 #define HAS_Y_MIN _HAS_STOP(Y,MIN)
997 #define HAS_Y_MAX _HAS_STOP(Y,MAX)
998 #define HAS_Z_MIN _HAS_STOP(Z,MIN)
999 #define HAS_Z_MAX _HAS_STOP(Z,MAX)
1000 #define HAS_X2_MIN (PIN_EXISTS(X2_MIN))
1001 #define HAS_X2_MAX (PIN_EXISTS(X2_MAX))
1002 #define HAS_Y2_MIN (PIN_EXISTS(Y2_MIN))
1003 #define HAS_Y2_MAX (PIN_EXISTS(Y2_MAX))
1004 #define HAS_Z2_MIN (PIN_EXISTS(Z2_MIN))
1005 #define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX))
1006 #define HAS_Z3_MIN (PIN_EXISTS(Z3_MIN))
1007 #define HAS_Z3_MAX (PIN_EXISTS(Z3_MAX))
1008 #define HAS_Z_MIN_PROBE_PIN (HAS_CUSTOM_PROBE_PIN && PIN_EXISTS(Z_MIN_PROBE))
1009 #define HAS_CALIBRATION_PIN (PIN_EXISTS(CALIBRATION))
1010 
1011 // ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface)
1012 #define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && DISABLED(HEATER_##P##_USES_MAX6675))
1013 #define HAS_TEMP_ADC_0 HAS_ADC_TEST(0)
1014 #define HAS_TEMP_ADC_1 HAS_ADC_TEST(1)
1015 #define HAS_TEMP_ADC_2 HAS_ADC_TEST(2)
1016 #define HAS_TEMP_ADC_3 HAS_ADC_TEST(3)
1017 #define HAS_TEMP_ADC_4 HAS_ADC_TEST(4)
1018 #define HAS_TEMP_ADC_5 HAS_ADC_TEST(5)
1019 #define HAS_TEMP_ADC_BED HAS_ADC_TEST(BED)
1020 #define HAS_TEMP_ADC_CHAMBER HAS_ADC_TEST(CHAMBER)
1021 
1022 #define HAS_TEMP_HOTEND (HAS_TEMP_ADC_0 || ENABLED(HEATER_0_USES_MAX6675))
1023 #define HAS_TEMP_BED HAS_TEMP_ADC_BED
1024 #define HAS_TEMP_CHAMBER HAS_TEMP_ADC_CHAMBER
1025 #define HAS_HEATED_CHAMBER (HAS_TEMP_CHAMBER && PIN_EXISTS(HEATER_CHAMBER))
1026 
1027 #if ENABLED(JOYSTICK)
1028  #define HAS_JOY_ADC_X PIN_EXISTS(JOY_X)
1029  #define HAS_JOY_ADC_Y PIN_EXISTS(JOY_Y)
1030  #define HAS_JOY_ADC_Z PIN_EXISTS(JOY_Z)
1031  #define HAS_JOY_ADC_EN PIN_EXISTS(JOY_EN)
1032 #endif
1033 
1034 // Heaters
1035 #define HAS_HEATER_0 (PIN_EXISTS(HEATER_0))
1036 #define HAS_HEATER_1 (PIN_EXISTS(HEATER_1))
1037 #define HAS_HEATER_2 (PIN_EXISTS(HEATER_2))
1038 #define HAS_HEATER_3 (PIN_EXISTS(HEATER_3))
1039 #define HAS_HEATER_4 (PIN_EXISTS(HEATER_4))
1040 #define HAS_HEATER_5 (PIN_EXISTS(HEATER_5))
1041 #define HAS_HEATER_BED (PIN_EXISTS(HEATER_BED))
1042 
1043 // Shorthand for common combinations
1044 #define HAS_HEATED_BED (HAS_TEMP_BED && HAS_HEATER_BED)
1045 #define BED_OR_CHAMBER (HAS_HEATED_BED || HAS_TEMP_CHAMBER)
1046 #define HAS_TEMP_SENSOR (HAS_TEMP_HOTEND || BED_OR_CHAMBER)
1047 
1048 #if !HAS_TEMP_SENSOR
1049  #undef AUTO_REPORT_TEMPERATURES
1050 #endif
1051 
1052 // PID heating
1053 #if !HAS_HEATED_BED
1054  #undef PIDTEMPBED
1055 #endif
1056 #define HAS_PID_HEATING EITHER(PIDTEMP, PIDTEMPBED)
1057 #define HAS_PID_FOR_BOTH BOTH(PIDTEMP, PIDTEMPBED)
1058 
1059 // Thermal protection
1060 #define HAS_THERMALLY_PROTECTED_BED (HAS_HEATED_BED && ENABLED(THERMAL_PROTECTION_BED))
1061 #define WATCH_HOTENDS (ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0)
1062 #define WATCH_BED (HAS_THERMALLY_PROTECTED_BED && WATCH_BED_TEMP_PERIOD > 0)
1063 #define WATCH_CHAMBER (HAS_HEATED_CHAMBER && ENABLED(THERMAL_PROTECTION_CHAMBER) && WATCH_CHAMBER_TEMP_PERIOD > 0)
1064 
1065 // Auto fans
1066 #define HAS_AUTO_FAN_0 (HOTENDS > 0 && PIN_EXISTS(E0_AUTO_FAN))
1067 #define HAS_AUTO_FAN_1 (HOTENDS > 1 && PIN_EXISTS(E1_AUTO_FAN))
1068 #define HAS_AUTO_FAN_2 (HOTENDS > 2 && PIN_EXISTS(E2_AUTO_FAN))
1069 #define HAS_AUTO_FAN_3 (HOTENDS > 3 && PIN_EXISTS(E3_AUTO_FAN))
1070 #define HAS_AUTO_FAN_4 (HOTENDS > 4 && PIN_EXISTS(E4_AUTO_FAN))
1071 #define HAS_AUTO_FAN_5 (HOTENDS > 5 && PIN_EXISTS(E5_AUTO_FAN))
1072 #define HAS_AUTO_CHAMBER_FAN (HAS_TEMP_CHAMBER && PIN_EXISTS(CHAMBER_AUTO_FAN))
1073 
1074 #define HAS_AUTO_FAN (HAS_AUTO_FAN_0 || HAS_AUTO_FAN_1 || HAS_AUTO_FAN_2 || HAS_AUTO_FAN_3 || HAS_AUTO_FAN_4 || HAS_AUTO_FAN_5 || HAS_AUTO_CHAMBER_FAN)
1075 #define _FANOVERLAP(A,B) (A##_AUTO_FAN_PIN == E##B##_AUTO_FAN_PIN)
1076 #if HAS_AUTO_FAN
1077  #define AUTO_CHAMBER_IS_E (_FANOVERLAP(CHAMBER,0) || _FANOVERLAP(CHAMBER,1) || _FANOVERLAP(CHAMBER,2) || _FANOVERLAP(CHAMBER,3) || _FANOVERLAP(CHAMBER,4) || _FANOVERLAP(CHAMBER,5))
1078 #endif
1079 
1080 #if !HAS_AUTO_CHAMBER_FAN || AUTO_CHAMBER_IS_E
1081  #undef AUTO_POWER_CHAMBER_FAN
1082 #endif
1083 
1084 // Other fans
1085 #define HAS_FAN0 (PIN_EXISTS(FAN))
1086 #define HAS_FAN1 (PIN_EXISTS(FAN1) && CONTROLLER_FAN_PIN != FAN1_PIN && E0_AUTO_FAN_PIN != FAN1_PIN && E1_AUTO_FAN_PIN != FAN1_PIN && E2_AUTO_FAN_PIN != FAN1_PIN && E3_AUTO_FAN_PIN != FAN1_PIN && E4_AUTO_FAN_PIN != FAN1_PIN && E5_AUTO_FAN_PIN != FAN1_PIN)
1087 #define HAS_FAN2 (PIN_EXISTS(FAN2) && CONTROLLER_FAN_PIN != FAN2_PIN && E0_AUTO_FAN_PIN != FAN2_PIN && E1_AUTO_FAN_PIN != FAN2_PIN && E2_AUTO_FAN_PIN != FAN2_PIN && E3_AUTO_FAN_PIN != FAN2_PIN && E4_AUTO_FAN_PIN != FAN2_PIN && E5_AUTO_FAN_PIN != FAN2_PIN)
1088 #define HAS_CONTROLLER_FAN (PIN_EXISTS(CONTROLLER_FAN))
1089 
1090 // Servos
1091 #define HAS_SERVO_0 (PIN_EXISTS(SERVO0) && NUM_SERVOS > 0)
1092 #define HAS_SERVO_1 (PIN_EXISTS(SERVO1) && NUM_SERVOS > 1)
1093 #define HAS_SERVO_2 (PIN_EXISTS(SERVO2) && NUM_SERVOS > 2)
1094 #define HAS_SERVO_3 (PIN_EXISTS(SERVO3) && NUM_SERVOS > 3)
1095 #define HAS_SERVOS (NUM_SERVOS > 0)
1096 
1097 #if HAS_SERVOS && !defined(Z_PROBE_SERVO_NR)
1098  #define Z_PROBE_SERVO_NR -1
1099 #endif
1100 
1101 #define HAS_SERVO_ANGLES (EITHER(SWITCHING_EXTRUDER, SWITCHING_NOZZLE) || (HAS_Z_SERVO_PROBE && defined(Z_PROBE_SERVO_NR)))
1102 
1103 #if !HAS_SERVO_ANGLES || ENABLED(BLTOUCH)
1104  #undef EDITABLE_SERVO_ANGLES
1105 #endif
1106 
1107 // Sensors
1108 #define HAS_FILAMENT_WIDTH_SENSOR (PIN_EXISTS(FILWIDTH))
1109 
1110 // User Interface
1111 #define HAS_HOME (PIN_EXISTS(HOME))
1112 #define HAS_KILL (PIN_EXISTS(KILL))
1113 #define HAS_SUICIDE (PIN_EXISTS(SUICIDE))
1114 #define HAS_PHOTOGRAPH (PIN_EXISTS(PHOTOGRAPH))
1115 #define HAS_BUZZER (PIN_EXISTS(BEEPER) || EITHER(LCD_USE_I2C_BUZZER, PCA9632_BUZZER))
1116 #define USE_BEEPER (HAS_BUZZER && DISABLED(LCD_USE_I2C_BUZZER, PCA9632_BUZZER))
1117 #define HAS_CASE_LIGHT (PIN_EXISTS(CASE_LIGHT) && ENABLED(CASE_LIGHT_ENABLE))
1118 
1119 // Digital control
1120 #define HAS_STEPPER_RESET (PIN_EXISTS(STEPPER_RESET))
1121 #define HAS_DIGIPOTSS (PIN_EXISTS(DIGIPOTSS))
1122 #define HAS_MOTOR_CURRENT_PWM ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_Z, MOTOR_CURRENT_PWM_E)
1123 
1124 #define HAS_MICROSTEPS (HAS_X_MICROSTEPS || HAS_X2_MICROSTEPS || HAS_Y_MICROSTEPS || HAS_Y2_MICROSTEPS || HAS_Z_MICROSTEPS || HAS_Z2_MICROSTEPS || HAS_Z3_MICROSTEPS || HAS_E0_MICROSTEPS || HAS_E1_MICROSTEPS || HAS_E2_MICROSTEPS || HAS_E3_MICROSTEPS || HAS_E4_MICROSTEPS || HAS_E5_MICROSTEPS)
1125 
1126 #if HAS_MICROSTEPS
1127 
1128  // MS1 MS2 MS3 Stepper Driver Microstepping mode table
1129  #ifndef MICROSTEP1
1130  #define MICROSTEP1 LOW,LOW,LOW
1131  #endif
1132  #if ENABLED(HEROIC_STEPPER_DRIVERS)
1133  #ifndef MICROSTEP128
1134  #define MICROSTEP128 LOW,HIGH,LOW
1135  #endif
1136  #else
1137  #ifndef MICROSTEP2
1138  #define MICROSTEP2 HIGH,LOW,LOW
1139  #endif
1140  #ifndef MICROSTEP4
1141  #define MICROSTEP4 LOW,HIGH,LOW
1142  #endif
1143  #endif
1144  #ifndef MICROSTEP8
1145  #define MICROSTEP8 HIGH,HIGH,LOW
1146  #endif
1147  #ifdef __SAM3X8E__
1148  #if MB(ALLIGATOR)
1149  #ifndef MICROSTEP16
1150  #define MICROSTEP16 LOW,LOW,LOW
1151  #endif
1152  #ifndef MICROSTEP32
1153  #define MICROSTEP32 HIGH,HIGH,LOW
1154  #endif
1155  #else
1156  #ifndef MICROSTEP16
1157  #define MICROSTEP16 HIGH,HIGH,LOW
1158  #endif
1159  #endif
1160  #else
1161  #ifndef MICROSTEP16
1162  #define MICROSTEP16 HIGH,HIGH,LOW
1163  #endif
1164  #endif
1165 
1166  #define HAS_MICROSTEP1 defined(MICROSTEP1)
1167  #define HAS_MICROSTEP2 defined(MICROSTEP2)
1168  #define HAS_MICROSTEP4 defined(MICROSTEP4)
1169  #define HAS_MICROSTEP8 defined(MICROSTEP8)
1170  #define HAS_MICROSTEP16 defined(MICROSTEP16)
1171  #define HAS_MICROSTEP32 defined(MICROSTEP32)
1172  #define HAS_MICROSTEP64 defined(MICROSTEP64)
1173  #define HAS_MICROSTEP128 defined(MICROSTEP128)
1174 
1175 #endif // HAS_MICROSTEPS
1176 
1177 #if !HAS_TEMP_SENSOR
1178  #undef AUTO_REPORT_TEMPERATURES
1179 #endif
1180 
1181 #define HAS_AUTO_REPORTING EITHER(AUTO_REPORT_TEMPERATURES, AUTO_REPORT_SD_STATUS)
1182 
1183 /**
1184  * This setting is also used by M109 when trying to calculate
1185  * a ballpark safe margin to prevent wait-forever situation.
1186  */
1187 #ifndef EXTRUDE_MINTEMP
1188  #define EXTRUDE_MINTEMP 170
1189 #endif
1190 
1191 /**
1192  * Heater signal inversion defaults
1193  */
1194 
1195 #if HAS_HEATER_0 && !defined(HEATER_0_INVERTING)
1196  #define HEATER_0_INVERTING false
1197 #endif
1198 
1199 #if HAS_HEATER_1 && !defined(HEATER_1_INVERTING)
1200  #define HEATER_1_INVERTING false
1201 #endif
1202 
1203 #if HAS_HEATER_2 && !defined(HEATER_2_INVERTING)
1204  #define HEATER_2_INVERTING false
1205 #endif
1206 
1207 #if HAS_HEATER_3 && !defined(HEATER_3_INVERTING)
1208  #define HEATER_3_INVERTING false
1209 #endif
1210 
1211 #if HAS_HEATER_4 && !defined(HEATER_4_INVERTING)
1212  #define HEATER_4_INVERTING false
1213 #endif
1214 
1215 #if HAS_HEATER_5 && !defined(HEATER_5_INVERTING)
1216  #define HEATER_5_INVERTING false
1217 #endif
1218 
1219 /**
1220  * Helper Macros for heaters and extruder fan
1221  */
1222 
1223 #define WRITE_HEATER_0P(v) WRITE(HEATER_0_PIN, (v) ^ HEATER_0_INVERTING)
1224 #if HOTENDS > 1 || ENABLED(HEATERS_PARALLEL)
1225  #define WRITE_HEATER_1(v) WRITE(HEATER_1_PIN, (v) ^ HEATER_1_INVERTING)
1226  #if HOTENDS > 2
1227  #define WRITE_HEATER_2(v) WRITE(HEATER_2_PIN, (v) ^ HEATER_2_INVERTING)
1228  #if HOTENDS > 3
1229  #define WRITE_HEATER_3(v) WRITE(HEATER_3_PIN, (v) ^ HEATER_3_INVERTING)
1230  #if HOTENDS > 4
1231  #define WRITE_HEATER_4(v) WRITE(HEATER_4_PIN, (v) ^ HEATER_4_INVERTING)
1232  #if HOTENDS > 5
1233  #define WRITE_HEATER_5(v) WRITE(HEATER_5_PIN, (v) ^ HEATER_5_INVERTING)
1234  #endif // HOTENDS > 5
1235  #endif // HOTENDS > 4
1236  #endif // HOTENDS > 3
1237  #endif // HOTENDS > 2
1238 #endif // HOTENDS > 1
1239 #if ENABLED(HEATERS_PARALLEL)
1240  #define WRITE_HEATER_0(v) { WRITE_HEATER_0P(v); WRITE_HEATER_1(v); }
1241 #else
1242  #define WRITE_HEATER_0(v) WRITE_HEATER_0P(v)
1243 #endif
1244 
1245 #ifndef MIN_POWER
1246  #define MIN_POWER 0
1247 #endif
1248 
1249 /**
1250  * Heated bed requires settings
1251  */
1252 #if HAS_HEATED_BED
1253  #ifndef MIN_BED_POWER
1254  #define MIN_BED_POWER 0
1255  #endif
1256  #ifndef MAX_BED_POWER
1257  #define MAX_BED_POWER 255
1258  #endif
1259  #ifndef HEATER_BED_INVERTING
1260  #define HEATER_BED_INVERTING false
1261  #endif
1262  #define WRITE_HEATER_BED(v) WRITE(HEATER_BED_PIN, (v) ^ HEATER_BED_INVERTING)
1263 #endif
1264 
1265 /**
1266  * Heated chamber requires settings
1267  */
1268 #if HAS_HEATED_CHAMBER
1269  #ifndef MAX_CHAMBER_POWER
1270  #define MAX_CHAMBER_POWER 255
1271  #endif
1272  #ifndef HEATER_CHAMBER_INVERTING
1273  #define HEATER_CHAMBER_INVERTING false
1274  #endif
1275  #define WRITE_HEATER_CHAMBER(v) WRITE(HEATER_CHAMBER_PIN, (v) ^ HEATER_CHAMBER_INVERTING)
1276 #endif
1277 
1278 /**
1279  * Up to 3 PWM fans
1280  */
1281 #ifndef FAN_INVERTING
1282  #define FAN_INVERTING false
1283 #endif
1284 
1285 #if HAS_FAN2
1286  #define FAN_COUNT 3
1287 #elif HAS_FAN1
1288  #define FAN_COUNT 2
1289 #elif HAS_FAN0
1290  #define FAN_COUNT 1
1291 #else
1292  #define FAN_COUNT 0
1293 #endif
1294 
1295 #if FAN_COUNT > 0
1296  #define WRITE_FAN(n, v) WRITE(FAN##n##_PIN, (v) ^ FAN_INVERTING)
1297 #endif
1298 
1299 /**
1300  * Part Cooling fan multipliexer
1301  */
1302 #define HAS_FANMUX PIN_EXISTS(FANMUX0)
1303 
1304 /**
1305  * MIN/MAX fan PWM scaling
1306  */
1307 #ifndef FAN_MIN_PWM
1308  #define FAN_MIN_PWM 0
1309 #endif
1310 #ifndef FAN_MAX_PWM
1311  #define FAN_MAX_PWM 255
1312 #endif
1313 #if FAN_MIN_PWM < 0 || FAN_MIN_PWM > 255
1314  #error "FAN_MIN_PWM must be a value from 0 to 255."
1315 #elif FAN_MAX_PWM < 0 || FAN_MAX_PWM > 255
1316  #error "FAN_MAX_PWM must be a value from 0 to 255."
1317 #elif FAN_MIN_PWM > FAN_MAX_PWM
1318  #error "FAN_MIN_PWM must be less than or equal to FAN_MAX_PWM."
1319 #endif
1320 
1321 /**
1322  * FAST PWM FAN Settings
1323  */
1324 #if ENABLED(FAST_PWM_FAN) && !defined(FAST_PWM_FAN_FREQUENCY)
1325  #define FAST_PWM_FAN_FREQUENCY ((F_CPU) / (2 * 255 * 1)) // Fan frequency default
1326 #endif
1327 
1328 /**
1329  * MIN/MAX case light PWM scaling
1330  */
1331 #if HAS_CASE_LIGHT
1332  #ifndef CASE_LIGHT_MAX_PWM
1333  #define CASE_LIGHT_MAX_PWM 255
1334  #elif !WITHIN(CASE_LIGHT_MAX_PWM, 1, 255)
1335  #error "CASE_LIGHT_MAX_PWM must be a value from 1 to 255."
1336  #endif
1337 #endif
1338 
1339 /**
1340  * Bed Probe dependencies
1341  */
1342 #if HAS_BED_PROBE
1343  #if ENABLED(ENDSTOPPULLUPS) && HAS_Z_MIN_PROBE_PIN
1344  #define ENDSTOPPULLUP_ZMIN_PROBE
1345  #endif
1346  #ifndef Z_PROBE_OFFSET_RANGE_MIN
1347  #define Z_PROBE_OFFSET_RANGE_MIN -20
1348  #endif
1349  #ifndef Z_PROBE_OFFSET_RANGE_MAX
1350  #define Z_PROBE_OFFSET_RANGE_MAX 20
1351  #endif
1352  #ifndef XY_PROBE_SPEED
1353  #ifdef HOMING_FEEDRATE_XY
1354  #define XY_PROBE_SPEED HOMING_FEEDRATE_XY
1355  #else
1356  #define XY_PROBE_SPEED 4000
1357  #endif
1358  #endif
1359 #else
1360  #undef NOZZLE_TO_PROBE_OFFSET
1361 #endif
1362 
1363 /**
1364  * XYZ Bed Skew Correction
1365  */
1366 #if ENABLED(SKEW_CORRECTION)
1367  #define SKEW_FACTOR_MIN -1
1368  #define SKEW_FACTOR_MAX 1
1369 
1370  #define _GET_SIDE(a,b,c) (SQRT(2*sq(a)+2*sq(b)-4*sq(c))*0.5)
1371  #define _SKEW_SIDE(a,b,c) tan(M_PI*0.5-acos((sq(a)-sq(b)-sq(c))/(2*c*b)))
1372  #define _SKEW_FACTOR(a,b,c) _SKEW_SIDE(float(a),_GET_SIDE(float(a),float(b),float(c)),float(c))
1373 
1374  #ifndef XY_SKEW_FACTOR
1375  #if defined(XY_DIAG_AC) && defined(XY_DIAG_BD) && defined(XY_SIDE_AD)
1376  #define XY_SKEW_FACTOR _SKEW_FACTOR(XY_DIAG_AC, XY_DIAG_BD, XY_SIDE_AD)
1377  #else
1378  #define XY_SKEW_FACTOR 0.0
1379  #endif
1380  #endif
1381  #ifndef XZ_SKEW_FACTOR
1382  #if defined(XY_SIDE_AD) && !defined(XZ_SIDE_AD)
1383  #define XZ_SIDE_AD XY_SIDE_AD
1384  #endif
1385  #if defined(XZ_DIAG_AC) && defined(XZ_DIAG_BD) && defined(XZ_SIDE_AD)
1386  #define XZ_SKEW_FACTOR _SKEW_FACTOR(XZ_DIAG_AC, XZ_DIAG_BD, XZ_SIDE_AD)
1387  #else
1388  #define XZ_SKEW_FACTOR 0.0
1389  #endif
1390  #endif
1391  #ifndef YZ_SKEW_FACTOR
1392  #if defined(YZ_DIAG_AC) && defined(YZ_DIAG_BD) && defined(YZ_SIDE_AD)
1393  #define YZ_SKEW_FACTOR _SKEW_FACTOR(YZ_DIAG_AC, YZ_DIAG_BD, YZ_SIDE_AD)
1394  #else
1395  #define YZ_SKEW_FACTOR 0.0
1396  #endif
1397  #endif
1398 #endif // SKEW_CORRECTION
1399 
1400 /**
1401  * Set granular options based on the specific type of leveling
1402  */
1403 #define UBL_SEGMENTED BOTH(AUTO_BED_LEVELING_UBL, DELTA)
1404 #define ABL_PLANAR EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT)
1405 #define ABL_GRID EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)
1406 #define HAS_ABL_NOT_UBL (ABL_PLANAR || ABL_GRID)
1407 #define HAS_ABL_OR_UBL (HAS_ABL_NOT_UBL || ENABLED(AUTO_BED_LEVELING_UBL))
1408 #define HAS_LEVELING (HAS_ABL_OR_UBL || ENABLED(MESH_BED_LEVELING))
1409 #define HAS_AUTOLEVEL (HAS_ABL_OR_UBL && DISABLED(PROBE_MANUALLY))
1410 #define HAS_MESH ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING)
1411 #define PLANNER_LEVELING (HAS_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL))
1412 #define HAS_PROBING_PROCEDURE (HAS_ABL_OR_UBL || ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST))
1413 #define HAS_POSITION_MODIFIERS (ENABLED(FWRETRACT) || HAS_LEVELING || ENABLED(SKEW_CORRECTION))
1414 
1415 #if ENABLED(AUTO_BED_LEVELING_UBL)
1416  #undef LCD_BED_LEVELING
1417 #endif
1418 
1419 /**
1420  * Heater, Fan, and Probe interactions
1421  */
1422 #if FAN_COUNT == 0
1423  #undef PROBING_FANS_OFF
1424  #undef ADAPTIVE_FAN_SLOWING
1425  #undef NO_FAN_SLOWING_IN_PID_TUNING
1426 #endif
1427 
1428 #define QUIET_PROBING (HAS_BED_PROBE && (EITHER(PROBING_HEATERS_OFF, PROBING_FANS_OFF) || DELAY_BEFORE_PROBING > 0))
1429 #define HEATER_IDLE_HANDLER EITHER(ADVANCED_PAUSE_FEATURE, PROBING_HEATERS_OFF)
1430 
1431 #if ENABLED(ADVANCED_PAUSE_FEATURE) && !defined(FILAMENT_CHANGE_SLOW_LOAD_LENGTH)
1432  #define FILAMENT_CHANGE_SLOW_LOAD_LENGTH 0
1433 #endif
1434 
1435 #if EXTRUDERS > 1 && !defined(TOOLCHANGE_FIL_EXTRA_PRIME)
1436  #define TOOLCHANGE_FIL_EXTRA_PRIME 0
1437 #endif
1438 
1439 /**
1440  * Only constrain Z on DELTA / SCARA machines
1441  */
1442 #if IS_KINEMATIC
1443  #undef MIN_SOFTWARE_ENDSTOP_X
1444  #undef MIN_SOFTWARE_ENDSTOP_Y
1445  #undef MAX_SOFTWARE_ENDSTOP_X
1446  #undef MAX_SOFTWARE_ENDSTOP_Y
1447 #endif
1448 
1449 /**
1450  * Bed Probing rectangular bounds
1451  * These can be further constrained in code for Delta and SCARA
1452  */
1453 #ifndef MIN_PROBE_EDGE
1454  #define MIN_PROBE_EDGE 0
1455 #endif
1456 #ifndef MIN_PROBE_EDGE_LEFT
1457  #define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE
1458 #endif
1459 #ifndef MIN_PROBE_EDGE_RIGHT
1460  #define MIN_PROBE_EDGE_RIGHT MIN_PROBE_EDGE
1461 #endif
1462 #ifndef MIN_PROBE_EDGE_FRONT
1463  #define MIN_PROBE_EDGE_FRONT MIN_PROBE_EDGE
1464 #endif
1465 #ifndef MIN_PROBE_EDGE_BACK
1466  #define MIN_PROBE_EDGE_BACK MIN_PROBE_EDGE
1467 #endif
1468 
1469 #ifndef NOZZLE_TO_PROBE_OFFSET
1470  #define NOZZLE_TO_PROBE_OFFSET { 0, 0, 0 }
1471 #endif
1472 
1473 #if ENABLED(DELTA)
1474  /**
1475  * Delta radius/rod trimmers/angle trimmers
1476  */
1477  #define _PROBE_RADIUS (DELTA_PRINTABLE_RADIUS - (MIN_PROBE_EDGE))
1478  #ifndef DELTA_CALIBRATION_RADIUS
1479  #ifdef NOZZLE_TO_PROBE_OFFSET
1480  #define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - _MAX(ABS(nozzle_to_probe_offset.x), ABS(nozzle_to_probe_offset.y), ABS(MIN_PROBE_EDGE)))
1481  #else
1482  #define DELTA_CALIBRATION_RADIUS _PROBE_RADIUS
1483  #endif
1484  #endif
1485  #ifndef DELTA_ENDSTOP_ADJ
1486  #define DELTA_ENDSTOP_ADJ { 0, 0, 0 }
1487  #endif
1488  #ifndef DELTA_TOWER_ANGLE_TRIM
1489  #define DELTA_TOWER_ANGLE_TRIM { 0, 0, 0 }
1490  #endif
1491  #ifndef DELTA_RADIUS_TRIM_TOWER
1492  #define DELTA_RADIUS_TRIM_TOWER { 0, 0, 0 }
1493  #endif
1494  #ifndef DELTA_DIAGONAL_ROD_TRIM_TOWER
1495  #define DELTA_DIAGONAL_ROD_TRIM_TOWER { 0, 0, 0 }
1496  #endif
1497 
1498  // Probing points may be verified at compile time within the radius
1499  // using static_assert(HYPOT2(X2-X1,Y2-Y1)<=sq(DELTA_PRINTABLE_RADIUS),"bad probe point!")
1500  // so that may be added to SanityCheck.h in the future.
1501  #define PROBE_X_MIN (X_CENTER - (_PROBE_RADIUS))
1502  #define PROBE_Y_MIN (Y_CENTER - (_PROBE_RADIUS))
1503  #define PROBE_X_MAX (X_CENTER + _PROBE_RADIUS)
1504  #define PROBE_Y_MAX (Y_CENTER + _PROBE_RADIUS)
1505 
1506 #elif IS_SCARA
1507 
1508  #define SCARA_PRINTABLE_RADIUS (SCARA_LINKAGE_1 + SCARA_LINKAGE_2)
1509  #define _PROBE_RADIUS (SCARA_PRINTABLE_RADIUS - (MIN_PROBE_EDGE))
1510  #define PROBE_X_MIN (X_CENTER - (SCARA_PRINTABLE_RADIUS) + MIN_PROBE_EDGE_LEFT)
1511  #define PROBE_Y_MIN (Y_CENTER - (SCARA_PRINTABLE_RADIUS) + MIN_PROBE_EDGE_FRONT)
1512  #define PROBE_X_MAX (X_CENTER + SCARA_PRINTABLE_RADIUS - (MIN_PROBE_EDGE_RIGHT))
1513  #define PROBE_Y_MAX (Y_CENTER + SCARA_PRINTABLE_RADIUS - (MIN_PROBE_EDGE_BACK))
1514 
1515 #endif
1516 
1517 #if ENABLED(SEGMENT_LEVELED_MOVES) && !defined(LEVELED_SEGMENT_LENGTH)
1518  #define LEVELED_SEGMENT_LENGTH 5
1519 #endif
1520 
1521 /**
1522  * Default mesh area is an area with an inset margin on the print area.
1523  */
1524 #if HAS_LEVELING
1525  #if IS_KINEMATIC
1526  // Probing points may be verified at compile time within the radius
1527  // using static_assert(HYPOT2(X2-X1,Y2-Y1)<=sq(DELTA_PRINTABLE_RADIUS),"bad probe point!")
1528  // so that may be added to SanityCheck.h in the future.
1529  #define _MESH_MIN_X (X_MIN_BED + MESH_INSET)
1530  #define _MESH_MIN_Y (Y_MIN_BED + MESH_INSET)
1531  #define _MESH_MAX_X (X_MAX_BED - (MESH_INSET))
1532  #define _MESH_MAX_Y (Y_MAX_BED - (MESH_INSET))
1533  #else
1534  // Boundaries for Cartesian probing based on set limits
1535  #if EITHER(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL)
1536  #define _MESH_MIN_X (_MAX(X_MIN_BED + MESH_INSET, X_MIN_POS)) // UBL is careful not to probe off the bed. It does not
1537  #define _MESH_MIN_Y (_MAX(Y_MIN_BED + MESH_INSET, Y_MIN_POS)) // need NOZZLE_TO_PROBE_OFFSET in the mesh dimensions
1538  #define _MESH_MAX_X (_MIN(X_MAX_BED - (MESH_INSET), X_MAX_POS))
1539  #define _MESH_MAX_Y (_MIN(Y_MAX_BED - (MESH_INSET), Y_MAX_POS))
1540  #else
1541  #define _MESH_MIN_X (_MAX(X_MIN_BED + MESH_INSET, X_MIN_POS + nozzle_to_probe_offset.x))
1542  #define _MESH_MIN_Y (_MAX(Y_MIN_BED + MESH_INSET, Y_MIN_POS + nozzle_to_probe_offset.y))
1543  #define _MESH_MAX_X (_MIN(X_MAX_BED - (MESH_INSET), X_MAX_POS + nozzle_to_probe_offset.x))
1544  #define _MESH_MAX_Y (_MIN(Y_MAX_BED - (MESH_INSET), Y_MAX_POS + nozzle_to_probe_offset.y))
1545  #endif
1546  #endif
1547 
1548  // These may be overridden in Configuration.h if a smaller area is desired
1549  #ifndef MESH_MIN_X
1550  #define MESH_MIN_X _MESH_MIN_X
1551  #endif
1552  #ifndef MESH_MIN_Y
1553  #define MESH_MIN_Y _MESH_MIN_Y
1554  #endif
1555  #ifndef MESH_MAX_X
1556  #define MESH_MAX_X _MESH_MAX_X
1557  #endif
1558  #ifndef MESH_MAX_Y
1559  #define MESH_MAX_Y _MESH_MAX_Y
1560  #endif
1561 
1562 #endif // MESH_BED_LEVELING || AUTO_BED_LEVELING_UBL
1563 
1564 #if ALL(PROBE_PT_1_X, PROBE_PT_2_X, PROBE_PT_3_X, PROBE_PT_1_Y, PROBE_PT_2_Y, PROBE_PT_3_Y)
1565  #define HAS_FIXED_3POINT;
1566 #endif
1567 
1568 #if EITHER(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_3POINT) && IS_KINEMATIC
1569  #define HAS_FIXED_3POINT
1570  #define SIN0 0.0
1571  #define SIN120 0.866025
1572  #define SIN240 -0.866025
1573  #define COS0 1.0
1574  #define COS120 -0.5
1575  #define COS240 -0.5
1576  #ifndef PROBE_PT_1_X
1577  #define PROBE_PT_1_X (X_CENTER + (_PROBE_RADIUS) * COS0)
1578  #endif
1579  #ifndef PROBE_PT_1_Y
1580  #define PROBE_PT_1_Y (Y_CENTER + (_PROBE_RADIUS) * SIN0)
1581  #endif
1582  #ifndef PROBE_PT_2_X
1583  #define PROBE_PT_2_X (X_CENTER + (_PROBE_RADIUS) * COS120)
1584  #endif
1585  #ifndef PROBE_PT_2_Y
1586  #define PROBE_PT_2_Y (Y_CENTER + (_PROBE_RADIUS) * SIN120)
1587  #endif
1588  #ifndef PROBE_PT_3_X
1589  #define PROBE_PT_3_X (X_CENTER + (_PROBE_RADIUS) * COS240)
1590  #endif
1591  #ifndef PROBE_PT_3_Y
1592  #define PROBE_PT_3_Y (Y_CENTER + (_PROBE_RADIUS) * SIN240)
1593  #endif
1594 #endif
1595 
1596 /**
1597  * Buzzer/Speaker
1598  */
1599 #if ENABLED(LCD_USE_I2C_BUZZER)
1600  #ifndef LCD_FEEDBACK_FREQUENCY_HZ
1601  #define LCD_FEEDBACK_FREQUENCY_HZ 1000
1602  #endif
1603  #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
1604  #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100
1605  #endif
1606 #elif HAS_BUZZER
1607  #ifndef LCD_FEEDBACK_FREQUENCY_HZ
1608  #define LCD_FEEDBACK_FREQUENCY_HZ 5000
1609  #endif
1610  #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
1611  #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2
1612  #endif
1613 #endif
1614 
1615 /**
1616  * Make sure DOGLCD_SCK and DOGLCD_MOSI are defined.
1617  */
1618 #if HAS_GRAPHICAL_LCD
1619  #ifndef DOGLCD_SCK
1620  #define DOGLCD_SCK SCK_PIN
1621  #endif
1622  #ifndef DOGLCD_MOSI
1623  #define DOGLCD_MOSI MOSI_PIN
1624  #endif
1625 #endif
1626 
1627 /**
1628  * Z_HOMING_HEIGHT / Z_CLEARANCE_BETWEEN_PROBES
1629  */
1630 #ifndef Z_HOMING_HEIGHT
1631  #ifndef Z_CLEARANCE_BETWEEN_PROBES
1632  #define Z_HOMING_HEIGHT 0
1633  #else
1634  #define Z_HOMING_HEIGHT Z_CLEARANCE_BETWEEN_PROBES
1635  #endif
1636 #endif
1637 
1638 #if PROBE_SELECTED
1639  #ifndef Z_CLEARANCE_BETWEEN_PROBES
1640  #define Z_CLEARANCE_BETWEEN_PROBES Z_HOMING_HEIGHT
1641  #endif
1642  #if Z_CLEARANCE_BETWEEN_PROBES > Z_HOMING_HEIGHT
1643  #define MANUAL_PROBE_HEIGHT Z_CLEARANCE_BETWEEN_PROBES
1644  #else
1645  #define MANUAL_PROBE_HEIGHT Z_HOMING_HEIGHT
1646  #endif
1647  #ifndef Z_CLEARANCE_MULTI_PROBE
1648  #define Z_CLEARANCE_MULTI_PROBE Z_CLEARANCE_BETWEEN_PROBES
1649  #endif
1650  #if ENABLED(BLTOUCH) && !defined(BLTOUCH_DELAY)
1651  #define BLTOUCH_DELAY 500
1652  #endif
1653 #endif
1654 
1655 #ifndef __SAM3X8E__ //todo: hal: broken hal encapsulation
1656  #undef UI_VOLTAGE_LEVEL
1657  #undef RADDS_DISPLAY
1658  #undef MOTOR_CURRENT
1659 #endif
1660 
1661 // Updated G92 behavior shifts the workspace
1662 #define HAS_POSITION_SHIFT DISABLED(NO_WORKSPACE_OFFSETS)
1663 // The home offset also shifts the coordinate space
1664 #define HAS_HOME_OFFSET (DISABLED(NO_WORKSPACE_OFFSETS) && IS_CARTESIAN)
1665 // The SCARA home offset applies only on G28
1666 #define HAS_SCARA_OFFSET (DISABLED(NO_WORKSPACE_OFFSETS) && IS_SCARA)
1667 // Cumulative offset to workspace to save some calculation
1668 #define HAS_WORKSPACE_OFFSET (HAS_POSITION_SHIFT && HAS_HOME_OFFSET)
1669 // M206 sets the home offset for Cartesian machines
1670 #define HAS_M206_COMMAND (HAS_HOME_OFFSET && !IS_SCARA)
1671 
1672 // LCD timeout to status screen default is 15s
1673 #ifndef LCD_TIMEOUT_TO_STATUS
1674  #define LCD_TIMEOUT_TO_STATUS 15000
1675 #endif
1676 
1677 // Add commands that need sub-codes to this list
1678 #define USE_GCODE_SUBCODES ANY(G38_PROBE_TARGET, CNC_COORDINATE_SYSTEMS, POWER_LOSS_RECOVERY)
1679 
1680 // Parking Extruder
1681 #if ENABLED(PARKING_EXTRUDER)
1682  #ifndef PARKING_EXTRUDER_GRAB_DISTANCE
1683  #define PARKING_EXTRUDER_GRAB_DISTANCE 0
1684  #endif
1685  #ifndef PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE
1686  #define PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE HIGH
1687  #endif
1688 #endif
1689 
1690 // Number of VFAT entries used. Each entry has 13 UTF-16 characters
1691 #if ENABLED(SCROLL_LONG_FILENAMES)
1692  #define MAX_VFAT_ENTRIES (5)
1693 #else
1694  #define MAX_VFAT_ENTRIES (2)
1695 #endif
1696 
1697 // Set defaults for unspecified LED user colors
1698 #if ENABLED(LED_CONTROL_MENU)
1699  #ifndef LED_USER_PRESET_RED
1700  #define LED_USER_PRESET_RED 255
1701  #endif
1702  #ifndef LED_USER_PRESET_GREEN
1703  #define LED_USER_PRESET_GREEN 255
1704  #endif
1705  #ifndef LED_USER_PRESET_BLUE
1706  #define LED_USER_PRESET_BLUE 255
1707  #endif
1708  #ifndef LED_USER_PRESET_WHITE
1709  #define LED_USER_PRESET_WHITE 0
1710  #endif
1711  #ifndef LED_USER_PRESET_BRIGHTNESS
1712  #ifdef NEOPIXEL_BRIGHTNESS
1713  #define LED_USER_PRESET_BRIGHTNESS NEOPIXEL_BRIGHTNESS
1714  #else
1715  #define LED_USER_PRESET_BRIGHTNESS 255
1716  #endif
1717  #endif
1718 #endif
1719 
1720 // Nozzle park for Delta
1721 #if BOTH(NOZZLE_PARK_FEATURE, DELTA)
1722  #undef NOZZLE_PARK_Z_FEEDRATE
1723  #define NOZZLE_PARK_Z_FEEDRATE NOZZLE_PARK_XY_FEEDRATE
1724 #endif
1725 
1726 // Force SDCARD_SORT_ALPHA to be enabled for Graphical LCD on LPC1768
1727 // on boards where SD card and LCD display share the same SPI bus
1728 // because of a bug in the shared SPI implementation. (See #8122)
1729 #if defined(TARGET_LPC1768) && ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && (SCK_PIN == LCD_PINS_D4)
1730  #define SDCARD_SORT_ALPHA // Keeps one directory level in RAM. Changing
1731  // directory levels still glitches the screen,
1732  // but the following LCD update cleans it up.
1733  #undef SDSORT_LIMIT
1734  #undef SDSORT_USES_RAM
1735  #undef SDSORT_USES_STACK
1736  #undef SDSORT_CACHE_NAMES
1737  #define SDSORT_LIMIT 64
1738  #define SDSORT_USES_RAM true
1739  #define SDSORT_USES_STACK false
1740  #define SDSORT_CACHE_NAMES true
1741  #ifndef FOLDER_SORTING
1742  #define FOLDER_SORTING -1
1743  #endif
1744  #ifndef SDSORT_GCODE
1745  #define SDSORT_GCODE false
1746  #endif
1747  #ifndef SDSORT_DYNAMIC_RAM
1748  #define SDSORT_DYNAMIC_RAM false
1749  #endif
1750  #ifndef SDSORT_CACHE_VFATS
1751  #define SDSORT_CACHE_VFATS 2
1752  #endif
1753 #endif
1754 
1755 // Defined here to catch the above defines
1756 #if ENABLED(SDCARD_SORT_ALPHA)
1757  #define HAS_FOLDER_SORTING (FOLDER_SORTING || ENABLED(SDSORT_GCODE))
1758 #endif
1759 
1760 // If platform requires early initialization of watchdog to properly boot
1761 #define EARLY_WATCHDOG (ENABLED(USE_WATCHDOG) && defined(ARDUINO_ARCH_SAM))
1762 
1763 #if ENABLED(Z_TRIPLE_STEPPER_DRIVERS)
1764  #define Z_STEPPER_COUNT 3
1765 #elif ENABLED(Z_DUAL_STEPPER_DRIVERS)
1766  #define Z_STEPPER_COUNT 2
1767 #else
1768  #define Z_STEPPER_COUNT 1
1769 #endif
1770 
1771 #if HAS_SPI_LCD
1772  // Get LCD character width/height, which may be overridden by pins, configs, etc.
1773  #ifndef LCD_WIDTH
1774  #if HAS_GRAPHICAL_LCD
1775  #define LCD_WIDTH 21
1776  #elif ENABLED(ULTIPANEL)
1777  #define LCD_WIDTH 20
1778  #else
1779  #define LCD_WIDTH 16
1780  #endif
1781  #endif
1782  #ifndef LCD_HEIGHT
1783  #if HAS_GRAPHICAL_LCD
1784  #define LCD_HEIGHT 5
1785  #elif ENABLED(ULTIPANEL)
1786  #define LCD_HEIGHT 4
1787  #else
1788  #define LCD_HEIGHT 2
1789  #endif
1790  #endif
1791 #endif
1792 
1793 #if ENABLED(SDSUPPORT)
1794  #if SD_CONNECTION_IS(ONBOARD) && DISABLED(NO_SD_HOST_DRIVE)
1795  //
1796  // The external SD card is not used. Hardware SPI is used to access the card.
1797  // When sharing the SD card with a PC we want the menu options to
1798  // mount/unmount the card and refresh it. So we disable card detect.
1799  //
1800  #undef SD_DETECT_PIN
1801  #define SHARED_SD_CARD
1802  #endif
1803  #if DISABLED(SHARED_SD_CARD)
1804  #define INIT_SDCARD_ON_BOOT
1805  #endif
1806 #endif
1807 
1808 #if !NUM_SERIAL
1809  #undef BAUD_RATE_GCODE
1810 #endif
1811 
1812 #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
1813  #undef Z_STEPPER_ALIGN_AMP
1814 #endif
1815 #ifndef Z_STEPPER_ALIGN_AMP
1816  #define Z_STEPPER_ALIGN_AMP 1.0
1817 #endif