My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Conditionals_post.h 33KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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. /**
  23. * Conditionals_post.h
  24. * Defines that depend on configuration but are not editable.
  25. */
  26. #ifndef CONDITIONALS_POST_H
  27. #define CONDITIONALS_POST_H
  28. #define IS_SCARA (ENABLED(MORGAN_SCARA) || ENABLED(MAKERARM_SCARA))
  29. #define IS_KINEMATIC (ENABLED(DELTA) || IS_SCARA)
  30. #define IS_CARTESIAN !IS_KINEMATIC
  31. /**
  32. * Axis lengths and center
  33. */
  34. #define X_MAX_LENGTH (X_MAX_POS - (X_MIN_POS))
  35. #define Y_MAX_LENGTH (Y_MAX_POS - (Y_MIN_POS))
  36. #define Z_MAX_LENGTH (Z_MAX_POS - (Z_MIN_POS))
  37. // Defined only if the sanity-check is bypassed
  38. #ifndef X_BED_SIZE
  39. #define X_BED_SIZE X_MAX_LENGTH
  40. #endif
  41. #ifndef Y_BED_SIZE
  42. #define Y_BED_SIZE Y_MAX_LENGTH
  43. #endif
  44. // Require 0,0 bed center for Delta and SCARA
  45. #if IS_KINEMATIC
  46. #define BED_CENTER_AT_0_0
  47. #endif
  48. // Define center values for future use
  49. #if ENABLED(BED_CENTER_AT_0_0)
  50. #define X_CENTER 0
  51. #define Y_CENTER 0
  52. #else
  53. #define X_CENTER ((X_BED_SIZE) / 2)
  54. #define Y_CENTER ((Y_BED_SIZE) / 2)
  55. #endif
  56. #define Z_CENTER ((Z_MIN_POS + Z_MAX_POS) / 2)
  57. // Get the linear boundaries of the bed
  58. #define X_MIN_BED (X_CENTER - (X_BED_SIZE) / 2)
  59. #define X_MAX_BED (X_CENTER + (X_BED_SIZE) / 2)
  60. #define Y_MIN_BED (Y_CENTER - (Y_BED_SIZE) / 2)
  61. #define Y_MAX_BED (Y_CENTER + (Y_BED_SIZE) / 2)
  62. /**
  63. * CoreXY, CoreXZ, and CoreYZ - and their reverse
  64. */
  65. #define CORE_IS_XY (ENABLED(COREXY) || ENABLED(COREYX))
  66. #define CORE_IS_XZ (ENABLED(COREXZ) || ENABLED(COREZX))
  67. #define CORE_IS_YZ (ENABLED(COREYZ) || ENABLED(COREZY))
  68. #define IS_CORE (CORE_IS_XY || CORE_IS_XZ || CORE_IS_YZ)
  69. #if IS_CORE
  70. #if CORE_IS_XY
  71. #define CORE_AXIS_1 A_AXIS
  72. #define CORE_AXIS_2 B_AXIS
  73. #define NORMAL_AXIS Z_AXIS
  74. #elif CORE_IS_XZ
  75. #define CORE_AXIS_1 A_AXIS
  76. #define NORMAL_AXIS Y_AXIS
  77. #define CORE_AXIS_2 C_AXIS
  78. #elif CORE_IS_YZ
  79. #define NORMAL_AXIS X_AXIS
  80. #define CORE_AXIS_1 B_AXIS
  81. #define CORE_AXIS_2 C_AXIS
  82. #endif
  83. #if (ENABLED(COREYX) || ENABLED(COREZX) || ENABLED(COREZY))
  84. #define CORESIGN(n) (-(n))
  85. #else
  86. #define CORESIGN(n) (n)
  87. #endif
  88. #endif
  89. /**
  90. * No adjustable bed on non-cartesians
  91. */
  92. #if IS_KINEMATIC
  93. #undef LEVEL_BED_CORNERS
  94. #endif
  95. /**
  96. * SCARA cannot use SLOWDOWN and requires QUICKHOME
  97. */
  98. #if IS_SCARA
  99. #undef SLOWDOWN
  100. #define QUICK_HOME
  101. #endif
  102. /**
  103. * Set the home position based on settings or manual overrides
  104. */
  105. #ifdef MANUAL_X_HOME_POS
  106. #define X_HOME_POS MANUAL_X_HOME_POS
  107. #elif ENABLED(BED_CENTER_AT_0_0)
  108. #if ENABLED(DELTA)
  109. #define X_HOME_POS 0
  110. #else
  111. #define X_HOME_POS ((X_BED_SIZE) * (X_HOME_DIR) * 0.5)
  112. #endif
  113. #else
  114. #if ENABLED(DELTA)
  115. #define X_HOME_POS (X_MIN_POS + (X_BED_SIZE) * 0.5)
  116. #else
  117. #define X_HOME_POS (X_HOME_DIR < 0 ? X_MIN_POS : X_MAX_POS)
  118. #endif
  119. #endif
  120. #ifdef MANUAL_Y_HOME_POS
  121. #define Y_HOME_POS MANUAL_Y_HOME_POS
  122. #elif ENABLED(BED_CENTER_AT_0_0)
  123. #if ENABLED(DELTA)
  124. #define Y_HOME_POS 0
  125. #else
  126. #define Y_HOME_POS ((Y_BED_SIZE) * (Y_HOME_DIR) * 0.5)
  127. #endif
  128. #else
  129. #if ENABLED(DELTA)
  130. #define Y_HOME_POS (Y_MIN_POS + (Y_BED_SIZE) * 0.5)
  131. #else
  132. #define Y_HOME_POS (Y_HOME_DIR < 0 ? Y_MIN_POS : Y_MAX_POS)
  133. #endif
  134. #endif
  135. #ifdef MANUAL_Z_HOME_POS
  136. #define Z_HOME_POS MANUAL_Z_HOME_POS
  137. #else
  138. #define Z_HOME_POS (Z_HOME_DIR < 0 ? Z_MIN_POS : Z_MAX_POS)
  139. #endif
  140. /**
  141. * If DELTA_HEIGHT isn't defined use the old setting
  142. */
  143. #if ENABLED(DELTA) && !defined(DELTA_HEIGHT)
  144. #define DELTA_HEIGHT Z_HOME_POS
  145. #endif
  146. /**
  147. * Auto Bed Leveling and Z Probe Repeatability Test
  148. */
  149. #define HOMING_Z_WITH_PROBE (HAS_BED_PROBE && Z_HOME_DIR < 0 && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN))
  150. /**
  151. * Z Sled Probe requires Z_SAFE_HOMING
  152. */
  153. #if ENABLED(Z_PROBE_SLED)
  154. #define Z_SAFE_HOMING
  155. #endif
  156. /**
  157. * DELTA should ignore Z_SAFE_HOMING and SLOWDOWN
  158. */
  159. #if ENABLED(DELTA)
  160. #undef Z_SAFE_HOMING
  161. #undef SLOWDOWN
  162. #endif
  163. /**
  164. * Safe Homing Options
  165. */
  166. #if ENABLED(Z_SAFE_HOMING)
  167. #ifndef Z_SAFE_HOMING_X_POINT
  168. #define Z_SAFE_HOMING_X_POINT X_CENTER
  169. #endif
  170. #ifndef Z_SAFE_HOMING_Y_POINT
  171. #define Z_SAFE_HOMING_Y_POINT Y_CENTER
  172. #endif
  173. #define X_TILT_FULCRUM Z_SAFE_HOMING_X_POINT
  174. #define Y_TILT_FULCRUM Z_SAFE_HOMING_Y_POINT
  175. #else
  176. #define X_TILT_FULCRUM X_HOME_POS
  177. #define Y_TILT_FULCRUM Y_HOME_POS
  178. #endif
  179. /**
  180. * Host keep alive
  181. */
  182. #ifndef DEFAULT_KEEPALIVE_INTERVAL
  183. #define DEFAULT_KEEPALIVE_INTERVAL 2
  184. #endif
  185. #ifdef CPU_32_BIT
  186. /**
  187. * Hidden options for developer
  188. */
  189. // Double stepping starts at STEP_DOUBLER_FREQUENCY + 1, quad stepping starts at STEP_DOUBLER_FREQUENCY * 2 + 1
  190. #ifndef STEP_DOUBLER_FREQUENCY
  191. #if ENABLED(LIN_ADVANCE)
  192. #define STEP_DOUBLER_FREQUENCY 60000 // Hz
  193. #else
  194. #define STEP_DOUBLER_FREQUENCY 80000 // Hz
  195. #endif
  196. #endif
  197. // Disable double / quad stepping
  198. //#define DISABLE_MULTI_STEPPING
  199. #endif
  200. /**
  201. * Provide a MAX_AUTORETRACT for older configs
  202. */
  203. #if ENABLED(FWRETRACT) && !defined(MAX_AUTORETRACT)
  204. #define MAX_AUTORETRACT 99
  205. #endif
  206. /**
  207. * MAX_STEP_FREQUENCY differs for TOSHIBA
  208. */
  209. #if ENABLED(CONFIG_STEPPERS_TOSHIBA)
  210. #ifdef CPU_32_BIT
  211. #define MAX_STEP_FREQUENCY STEP_DOUBLER_FREQUENCY // Max step frequency for Toshiba Stepper Controllers, 96kHz is close to maximum for an Arduino Due
  212. #else
  213. #define MAX_STEP_FREQUENCY 10000 // Max step frequency for Toshiba Stepper Controllers
  214. #endif
  215. #else
  216. #ifdef CPU_32_BIT
  217. #define MAX_STEP_FREQUENCY (STEP_DOUBLER_FREQUENCY * 4) // Max step frequency for the Due is approx. 330kHz
  218. #else
  219. #define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step)
  220. #endif
  221. #endif
  222. // MS1 MS2 Stepper Driver Microstepping mode table
  223. #define MICROSTEP1 LOW,LOW
  224. #define MICROSTEP2 HIGH,LOW
  225. #define MICROSTEP4 LOW,HIGH
  226. #define MICROSTEP8 HIGH,HIGH
  227. #ifdef __SAM3X8E__
  228. #if MB(ALLIGATOR)
  229. #define MICROSTEP16 LOW,LOW
  230. #define MICROSTEP32 HIGH,HIGH
  231. #else
  232. #define MICROSTEP16 HIGH,HIGH
  233. #endif
  234. #else
  235. #define MICROSTEP16 HIGH,HIGH
  236. #endif
  237. /**
  238. * Override here because this is set in Configuration_adv.h
  239. */
  240. #if ENABLED(ULTIPANEL) && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER)
  241. #undef SD_DETECT_INVERTED
  242. #endif
  243. /**
  244. * Set defaults for missing (newer) options
  245. */
  246. #ifndef DISABLE_INACTIVE_X
  247. #define DISABLE_INACTIVE_X DISABLE_X
  248. #endif
  249. #ifndef DISABLE_INACTIVE_Y
  250. #define DISABLE_INACTIVE_Y DISABLE_Y
  251. #endif
  252. #ifndef DISABLE_INACTIVE_Z
  253. #define DISABLE_INACTIVE_Z DISABLE_Z
  254. #endif
  255. #ifndef DISABLE_INACTIVE_E
  256. #define DISABLE_INACTIVE_E DISABLE_E
  257. #endif
  258. // Power Signal Control Definitions
  259. // By default use ATX definition
  260. #ifndef POWER_SUPPLY
  261. #define POWER_SUPPLY 1
  262. #endif
  263. #if (POWER_SUPPLY == 1) // 1 = ATX
  264. #define PS_ON_AWAKE LOW
  265. #define PS_ON_ASLEEP HIGH
  266. #elif (POWER_SUPPLY == 2) // 2 = X-Box 360 203W
  267. #define PS_ON_AWAKE HIGH
  268. #define PS_ON_ASLEEP LOW
  269. #endif
  270. #define HAS_POWER_SWITCH (POWER_SUPPLY > 0 && PIN_EXISTS(PS_ON))
  271. /**
  272. * Temp Sensor defines
  273. */
  274. #if TEMP_SENSOR_0 == -3
  275. #define HEATER_0_USES_MAX6675
  276. #define MAX6675_IS_MAX31855
  277. #define MAX6675_TMIN -270
  278. #define MAX6675_TMAX 1800
  279. #elif TEMP_SENSOR_0 == -2
  280. #define HEATER_0_USES_MAX6675
  281. #define MAX6675_TMIN 0
  282. #define MAX6675_TMAX 1024
  283. #elif TEMP_SENSOR_0 == -1
  284. #define HEATER_0_USES_AD595
  285. #elif TEMP_SENSOR_0 == 0
  286. #undef HEATER_0_MINTEMP
  287. #undef HEATER_0_MAXTEMP
  288. #elif TEMP_SENSOR_0 > 0
  289. #define THERMISTORHEATER_0 TEMP_SENSOR_0
  290. #define HEATER_0_USES_THERMISTOR
  291. #endif
  292. #if TEMP_SENSOR_1 <= -2
  293. #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_1"
  294. #elif TEMP_SENSOR_1 == -1
  295. #define HEATER_1_USES_AD595
  296. #elif TEMP_SENSOR_1 == 0
  297. #undef HEATER_1_MINTEMP
  298. #undef HEATER_1_MAXTEMP
  299. #elif TEMP_SENSOR_1 > 0
  300. #define THERMISTORHEATER_1 TEMP_SENSOR_1
  301. #define HEATER_1_USES_THERMISTOR
  302. #endif
  303. #if TEMP_SENSOR_2 <= -2
  304. #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_2"
  305. #elif TEMP_SENSOR_2 == -1
  306. #define HEATER_2_USES_AD595
  307. #elif TEMP_SENSOR_2 == 0
  308. #undef HEATER_2_MINTEMP
  309. #undef HEATER_2_MAXTEMP
  310. #elif TEMP_SENSOR_2 > 0
  311. #define THERMISTORHEATER_2 TEMP_SENSOR_2
  312. #define HEATER_2_USES_THERMISTOR
  313. #endif
  314. #if TEMP_SENSOR_3 <= -2
  315. #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_3"
  316. #elif TEMP_SENSOR_3 == -1
  317. #define HEATER_3_USES_AD595
  318. #elif TEMP_SENSOR_3 == 0
  319. #undef HEATER_3_MINTEMP
  320. #undef HEATER_3_MAXTEMP
  321. #elif TEMP_SENSOR_3 > 0
  322. #define THERMISTORHEATER_3 TEMP_SENSOR_3
  323. #define HEATER_3_USES_THERMISTOR
  324. #endif
  325. #if TEMP_SENSOR_4 <= -2
  326. #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_4"
  327. #elif TEMP_SENSOR_4 == -1
  328. #define HEATER_4_USES_AD595
  329. #elif TEMP_SENSOR_4 == 0
  330. #undef HEATER_4_MINTEMP
  331. #undef HEATER_4_MAXTEMP
  332. #elif TEMP_SENSOR_4 > 0
  333. #define THERMISTORHEATER_4 TEMP_SENSOR_4
  334. #define HEATER_4_USES_THERMISTOR
  335. #endif
  336. #if TEMP_SENSOR_BED <= -2
  337. #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_BED"
  338. #elif TEMP_SENSOR_BED == -1
  339. #define BED_USES_AD595
  340. #elif TEMP_SENSOR_BED == 0
  341. #undef BED_MINTEMP
  342. #undef BED_MAXTEMP
  343. #elif TEMP_SENSOR_BED > 0
  344. #define THERMISTORBED TEMP_SENSOR_BED
  345. #define BED_USES_THERMISTOR
  346. #endif
  347. #ifdef __SAM3X8E__
  348. #define HEATER_USES_AD595 (ENABLED(HEATER_0_USES_AD595) || ENABLED(HEATER_1_USES_AD595) || ENABLED(HEATER_2_USES_AD595) || ENABLED(HEATER_3_USES_AD595))
  349. #endif
  350. /**
  351. * Flags for PID handling
  352. */
  353. #define HAS_PID_HEATING (ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED))
  354. #define HAS_PID_FOR_BOTH (ENABLED(PIDTEMP) && ENABLED(PIDTEMPBED))
  355. /**
  356. * Default hotend offsets, if not defined
  357. */
  358. #if HOTENDS > 1
  359. #ifndef HOTEND_OFFSET_X
  360. #define HOTEND_OFFSET_X { 0 } // X offsets for each extruder
  361. #endif
  362. #ifndef HOTEND_OFFSET_Y
  363. #define HOTEND_OFFSET_Y { 0 } // Y offsets for each extruder
  364. #endif
  365. #if !defined(HOTEND_OFFSET_Z) && (ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_NOZZLE))
  366. #define HOTEND_OFFSET_Z { 0 }
  367. #endif
  368. #endif
  369. /**
  370. * ARRAY_BY_EXTRUDERS based on EXTRUDERS
  371. */
  372. #define ARRAY_BY_EXTRUDERS(...) ARRAY_N(EXTRUDERS, __VA_ARGS__)
  373. #define ARRAY_BY_EXTRUDERS1(v1) ARRAY_BY_EXTRUDERS(v1, v1, v1, v1, v1, v1)
  374. /**
  375. * ARRAY_BY_HOTENDS based on HOTENDS
  376. */
  377. #define ARRAY_BY_HOTENDS(...) ARRAY_N(HOTENDS, __VA_ARGS__)
  378. #define ARRAY_BY_HOTENDS1(v1) ARRAY_BY_HOTENDS(v1, v1, v1, v1, v1, v1)
  379. /**
  380. * Z_DUAL_ENDSTOPS endstop reassignment
  381. */
  382. #if ENABLED(Z_DUAL_ENDSTOPS)
  383. #define _XMIN_ 100
  384. #define _YMIN_ 200
  385. #define _ZMIN_ 300
  386. #define _XMAX_ 101
  387. #define _YMAX_ 201
  388. #define _ZMAX_ 301
  389. #if Z2_USE_ENDSTOP == _XMIN_
  390. #define USE_XMIN_PLUG
  391. #elif Z2_USE_ENDSTOP == _XMAX_
  392. #define USE_XMAX_PLUG
  393. #elif Z2_USE_ENDSTOP == _YMIN_
  394. #define USE_YMIN_PLUG
  395. #elif Z2_USE_ENDSTOP == _YMAX_
  396. #define USE_YMAX_PLUG
  397. #elif Z2_USE_ENDSTOP == _ZMIN_
  398. #define USE_ZMIN_PLUG
  399. #elif Z2_USE_ENDSTOP == _ZMAX_
  400. #define USE_ZMAX_PLUG
  401. #endif
  402. #if Z_HOME_DIR > 0
  403. #if Z2_USE_ENDSTOP == _XMIN_
  404. #define Z2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
  405. #define Z2_MAX_PIN X_MIN_PIN
  406. #elif Z2_USE_ENDSTOP == _XMAX_
  407. #define Z2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
  408. #define Z2_MAX_PIN X_MAX_PIN
  409. #elif Z2_USE_ENDSTOP == _YMIN_
  410. #define Z2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
  411. #define Z2_MAX_PIN Y_MIN_PIN
  412. #elif Z2_USE_ENDSTOP == _YMAX_
  413. #define Z2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
  414. #define Z2_MAX_PIN Y_MAX_PIN
  415. #elif Z2_USE_ENDSTOP == _ZMIN_
  416. #define Z2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
  417. #define Z2_MAX_PIN Z_MIN_PIN
  418. #elif Z2_USE_ENDSTOP == _ZMAX_
  419. #define Z2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
  420. #define Z2_MAX_PIN Z_MAX_PIN
  421. #else
  422. #define Z2_MAX_ENDSTOP_INVERTING false
  423. #endif
  424. #else
  425. #if Z2_USE_ENDSTOP == _XMIN_
  426. #define Z2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
  427. #define Z2_MIN_PIN X_MIN_PIN
  428. #elif Z2_USE_ENDSTOP == _XMAX_
  429. #define Z2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
  430. #define Z2_MIN_PIN X_MAX_PIN
  431. #elif Z2_USE_ENDSTOP == _YMIN_
  432. #define Z2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
  433. #define Z2_MIN_PIN Y_MIN_PIN
  434. #elif Z2_USE_ENDSTOP == _YMAX_
  435. #define Z2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
  436. #define Z2_MIN_PIN Y_MAX_PIN
  437. #elif Z2_USE_ENDSTOP == _ZMIN_
  438. #define Z2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
  439. #define Z2_MIN_PIN Z_MIN_PIN
  440. #elif Z2_USE_ENDSTOP == _ZMAX_
  441. #define Z2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
  442. #define Z2_MIN_PIN Z_MAX_PIN
  443. #else
  444. #define Z2_MIN_ENDSTOP_INVERTING false
  445. #endif
  446. #endif
  447. #endif
  448. // Is an endstop plug used for the Z2 endstop or the bed probe?
  449. #define IS_Z2_OR_PROBE(A,M) ( \
  450. (ENABLED(Z_DUAL_ENDSTOPS) && Z2_USE_ENDSTOP == _##A##M##_) \
  451. || (ENABLED(Z_MIN_PROBE_ENDSTOP) && Z_MIN_PROBE_PIN == A##_##M##_PIN ) )
  452. /**
  453. * Set ENDSTOPPULLUPS for active endstop switches
  454. */
  455. #if ENABLED(ENDSTOPPULLUPS)
  456. #if ENABLED(USE_XMAX_PLUG)
  457. #define ENDSTOPPULLUP_XMAX
  458. #endif
  459. #if ENABLED(USE_YMAX_PLUG)
  460. #define ENDSTOPPULLUP_YMAX
  461. #endif
  462. #if ENABLED(USE_ZMAX_PLUG)
  463. #define ENDSTOPPULLUP_ZMAX
  464. #endif
  465. #if ENABLED(USE_XMIN_PLUG)
  466. #define ENDSTOPPULLUP_XMIN
  467. #endif
  468. #if ENABLED(USE_YMIN_PLUG)
  469. #define ENDSTOPPULLUP_YMIN
  470. #endif
  471. #if ENABLED(USE_ZMIN_PLUG)
  472. #define ENDSTOPPULLUP_ZMIN
  473. #endif
  474. #endif
  475. /**
  476. * Shorthand for pin tests, used wherever needed
  477. */
  478. // Steppers
  479. #define HAS_X_ENABLE (PIN_EXISTS(X_ENABLE))
  480. #define HAS_X_DIR (PIN_EXISTS(X_DIR))
  481. #define HAS_X_STEP (PIN_EXISTS(X_STEP))
  482. #define HAS_X_MICROSTEPS (PIN_EXISTS(X_MS1))
  483. #define HAS_X2_ENABLE (PIN_EXISTS(X2_ENABLE))
  484. #define HAS_X2_DIR (PIN_EXISTS(X2_DIR))
  485. #define HAS_X2_STEP (PIN_EXISTS(X2_STEP))
  486. #define HAS_Y_MICROSTEPS (PIN_EXISTS(Y_MS1))
  487. #define HAS_Y_ENABLE (PIN_EXISTS(Y_ENABLE))
  488. #define HAS_Y_DIR (PIN_EXISTS(Y_DIR))
  489. #define HAS_Y_STEP (PIN_EXISTS(Y_STEP))
  490. #define HAS_Z_MICROSTEPS (PIN_EXISTS(Z_MS1))
  491. #define HAS_Y2_ENABLE (PIN_EXISTS(Y2_ENABLE))
  492. #define HAS_Y2_DIR (PIN_EXISTS(Y2_DIR))
  493. #define HAS_Y2_STEP (PIN_EXISTS(Y2_STEP))
  494. #define HAS_Z_ENABLE (PIN_EXISTS(Z_ENABLE))
  495. #define HAS_Z_DIR (PIN_EXISTS(Z_DIR))
  496. #define HAS_Z_STEP (PIN_EXISTS(Z_STEP))
  497. #define HAS_Z2_ENABLE (PIN_EXISTS(Z2_ENABLE))
  498. #define HAS_Z2_DIR (PIN_EXISTS(Z2_DIR))
  499. #define HAS_Z2_STEP (PIN_EXISTS(Z2_STEP))
  500. // Extruder steppers and solenoids
  501. #define HAS_E0_ENABLE (PIN_EXISTS(E0_ENABLE))
  502. #define HAS_E0_DIR (PIN_EXISTS(E0_DIR))
  503. #define HAS_E0_STEP (PIN_EXISTS(E0_STEP))
  504. #define HAS_E0_MICROSTEPS (PIN_EXISTS(E0_MS1))
  505. #define HAS_SOLENOID_0 (PIN_EXISTS(SOL0))
  506. #define HAS_E1_ENABLE (PIN_EXISTS(E1_ENABLE))
  507. #define HAS_E1_DIR (PIN_EXISTS(E1_DIR))
  508. #define HAS_E1_STEP (PIN_EXISTS(E1_STEP))
  509. #define HAS_E1_MICROSTEPS (PIN_EXISTS(E1_MS1))
  510. #define HAS_SOLENOID_1 (PIN_EXISTS(SOL1))
  511. #define HAS_E2_ENABLE (PIN_EXISTS(E2_ENABLE))
  512. #define HAS_E2_DIR (PIN_EXISTS(E2_DIR))
  513. #define HAS_E2_STEP (PIN_EXISTS(E2_STEP))
  514. #define HAS_E2_MICROSTEPS (PIN_EXISTS(E2_MS1))
  515. #define HAS_SOLENOID_2 (PIN_EXISTS(SOL2))
  516. #define HAS_E3_ENABLE (PIN_EXISTS(E3_ENABLE))
  517. #define HAS_E3_DIR (PIN_EXISTS(E3_DIR))
  518. #define HAS_E3_STEP (PIN_EXISTS(E3_STEP))
  519. #define HAS_E3_MICROSTEPS (PIN_EXISTS(E3_MS1))
  520. #define HAS_SOLENOID_3 (PIN_EXISTS(SOL3))
  521. #define HAS_E4_ENABLE (PIN_EXISTS(E4_ENABLE))
  522. #define HAS_E4_DIR (PIN_EXISTS(E4_DIR))
  523. #define HAS_E4_STEP (PIN_EXISTS(E4_STEP))
  524. #define HAS_E4_MICROSTEPS (PIN_EXISTS(E4_MS1))
  525. #define HAS_SOLENOID_4 (PIN_EXISTS(SOL4))
  526. // Endstops and bed probe
  527. #define HAS_X_MIN (PIN_EXISTS(X_MIN) && !IS_Z2_OR_PROBE(X,MIN))
  528. #define HAS_X_MAX (PIN_EXISTS(X_MAX) && !IS_Z2_OR_PROBE(X,MAX))
  529. #define HAS_Y_MIN (PIN_EXISTS(Y_MIN) && !IS_Z2_OR_PROBE(Y,MIN))
  530. #define HAS_Y_MAX (PIN_EXISTS(Y_MAX) && !IS_Z2_OR_PROBE(Y,MAX))
  531. #define HAS_Z_MIN (PIN_EXISTS(Z_MIN) && !IS_Z2_OR_PROBE(Z,MIN))
  532. #define HAS_Z_MAX (PIN_EXISTS(Z_MAX) && !IS_Z2_OR_PROBE(Z,MAX))
  533. #define HAS_Z2_MIN (PIN_EXISTS(Z2_MIN))
  534. #define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX))
  535. #define HAS_Z_MIN_PROBE_PIN (PIN_EXISTS(Z_MIN_PROBE))
  536. // Thermistors
  537. #define HAS_TEMP_0 (PIN_EXISTS(TEMP_0) && TEMP_SENSOR_0 != 0 && TEMP_SENSOR_0 > -2)
  538. #define HAS_TEMP_1 (PIN_EXISTS(TEMP_1) && TEMP_SENSOR_1 != 0 && TEMP_SENSOR_1 > -2)
  539. #define HAS_TEMP_2 (PIN_EXISTS(TEMP_2) && TEMP_SENSOR_2 != 0 && TEMP_SENSOR_2 > -2)
  540. #define HAS_TEMP_3 (PIN_EXISTS(TEMP_3) && TEMP_SENSOR_3 != 0 && TEMP_SENSOR_3 > -2)
  541. #define HAS_TEMP_4 (PIN_EXISTS(TEMP_4) && TEMP_SENSOR_4 != 0 && TEMP_SENSOR_4 > -2)
  542. #define HAS_TEMP_HOTEND (HAS_TEMP_0 || ENABLED(HEATER_0_USES_MAX6675))
  543. #define HAS_TEMP_BED (PIN_EXISTS(TEMP_BED) && TEMP_SENSOR_BED != 0 && TEMP_SENSOR_BED > -2)
  544. // Heaters
  545. #define HAS_HEATER_0 (PIN_EXISTS(HEATER_0))
  546. #define HAS_HEATER_1 (PIN_EXISTS(HEATER_1))
  547. #define HAS_HEATER_2 (PIN_EXISTS(HEATER_2))
  548. #define HAS_HEATER_3 (PIN_EXISTS(HEATER_3))
  549. #define HAS_HEATER_4 (PIN_EXISTS(HEATER_4))
  550. #define HAS_HEATER_BED (PIN_EXISTS(HEATER_BED))
  551. // Thermal protection
  552. #define HAS_THERMALLY_PROTECTED_BED (ENABLED(THERMAL_PROTECTION_BED) && HAS_TEMP_BED && HAS_HEATER_BED)
  553. #define WATCH_HOTENDS (ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0)
  554. #define WATCH_THE_BED (HAS_THERMALLY_PROTECTED_BED && WATCH_BED_TEMP_PERIOD > 0)
  555. // Auto fans
  556. #define HAS_AUTO_FAN_0 (PIN_EXISTS(E0_AUTO_FAN))
  557. #define HAS_AUTO_FAN_1 (HOTENDS > 1 && PIN_EXISTS(E1_AUTO_FAN))
  558. #define HAS_AUTO_FAN_2 (HOTENDS > 2 && PIN_EXISTS(E2_AUTO_FAN))
  559. #define HAS_AUTO_FAN_3 (HOTENDS > 3 && PIN_EXISTS(E3_AUTO_FAN))
  560. #define HAS_AUTO_FAN_4 (HOTENDS > 4 && PIN_EXISTS(E4_AUTO_FAN))
  561. #define HAS_AUTO_FAN (HAS_AUTO_FAN_0 || HAS_AUTO_FAN_1 || HAS_AUTO_FAN_2 || HAS_AUTO_FAN_3)
  562. #define AUTO_1_IS_0 (E1_AUTO_FAN_PIN == E0_AUTO_FAN_PIN)
  563. #define AUTO_2_IS_0 (E2_AUTO_FAN_PIN == E0_AUTO_FAN_PIN)
  564. #define AUTO_2_IS_1 (E2_AUTO_FAN_PIN == E1_AUTO_FAN_PIN)
  565. #define AUTO_3_IS_0 (E3_AUTO_FAN_PIN == E0_AUTO_FAN_PIN)
  566. #define AUTO_3_IS_1 (E3_AUTO_FAN_PIN == E1_AUTO_FAN_PIN)
  567. #define AUTO_3_IS_2 (E3_AUTO_FAN_PIN == E2_AUTO_FAN_PIN)
  568. #define AUTO_4_IS_0 (E4_AUTO_FAN_PIN == E0_AUTO_FAN_PIN)
  569. #define AUTO_4_IS_1 (E4_AUTO_FAN_PIN == E1_AUTO_FAN_PIN)
  570. #define AUTO_4_IS_2 (E4_AUTO_FAN_PIN == E2_AUTO_FAN_PIN)
  571. #define AUTO_4_IS_3 (E4_AUTO_FAN_PIN == E3_AUTO_FAN_PIN)
  572. // Other fans
  573. #define HAS_FAN0 (PIN_EXISTS(FAN))
  574. #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)
  575. #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)
  576. #define HAS_CONTROLLER_FAN (PIN_EXISTS(CONTROLLER_FAN))
  577. // Servos
  578. #define HAS_SERVOS (defined(NUM_SERVOS) && NUM_SERVOS > 0)
  579. #define HAS_SERVO_0 (PIN_EXISTS(SERVO0))
  580. #define HAS_SERVO_1 (PIN_EXISTS(SERVO1))
  581. #define HAS_SERVO_2 (PIN_EXISTS(SERVO2))
  582. #define HAS_SERVO_3 (PIN_EXISTS(SERVO3))
  583. // Sensors
  584. #define HAS_FILAMENT_WIDTH_SENSOR (PIN_EXISTS(FILWIDTH))
  585. #define HAS_FIL_RUNOUT (PIN_EXISTS(FIL_RUNOUT))
  586. // User Interface
  587. #define HAS_HOME (PIN_EXISTS(HOME))
  588. #define HAS_KILL (PIN_EXISTS(KILL))
  589. #define HAS_SUICIDE (PIN_EXISTS(SUICIDE))
  590. #define HAS_PHOTOGRAPH (PIN_EXISTS(PHOTOGRAPH))
  591. #define HAS_BUZZER (PIN_EXISTS(BEEPER) || ENABLED(LCD_USE_I2C_BUZZER))
  592. #define HAS_CASE_LIGHT (PIN_EXISTS(CASE_LIGHT) && ENABLED(CASE_LIGHT_ENABLE))
  593. // Digital control
  594. #define HAS_MICROSTEPS (HAS_X_MICROSTEPS || HAS_Y_MICROSTEPS || HAS_Z_MICROSTEPS || HAS_E0_MICROSTEPS || HAS_E1_MICROSTEPS || HAS_E2_MICROSTEPS || HAS_E3_MICROSTEPS || HAS_E4_MICROSTEPS)
  595. #define HAS_STEPPER_RESET (PIN_EXISTS(STEPPER_RESET))
  596. #define HAS_DIGIPOTSS (PIN_EXISTS(DIGIPOTSS))
  597. #define HAS_MOTOR_CURRENT_PWM (PIN_EXISTS(MOTOR_CURRENT_PWM_XY) || PIN_EXISTS(MOTOR_CURRENT_PWM_Z) || PIN_EXISTS(MOTOR_CURRENT_PWM_E))
  598. /**
  599. * This setting is also used by M109 when trying to calculate
  600. * a ballpark safe margin to prevent wait-forever situation.
  601. */
  602. #ifndef EXTRUDE_MINTEMP
  603. #define EXTRUDE_MINTEMP 170
  604. #endif
  605. /**
  606. * Helper Macros for heaters and extruder fan
  607. */
  608. #define WRITE_HEATER_0P(v) WRITE(HEATER_0_PIN, v)
  609. #if HOTENDS > 1 || ENABLED(HEATERS_PARALLEL)
  610. #define WRITE_HEATER_1(v) WRITE(HEATER_1_PIN, v)
  611. #if HOTENDS > 2
  612. #define WRITE_HEATER_2(v) WRITE(HEATER_2_PIN, v)
  613. #if HOTENDS > 3
  614. #define WRITE_HEATER_3(v) WRITE(HEATER_3_PIN, v)
  615. #if HOTENDS > 4
  616. #define WRITE_HEATER_4(v) WRITE(HEATER_4_PIN, v)
  617. #endif // HOTENDS > 4
  618. #endif // HOTENDS > 3
  619. #endif // HOTENDS > 2
  620. #endif // HOTENDS > 1
  621. #if ENABLED(HEATERS_PARALLEL)
  622. #define WRITE_HEATER_0(v) { WRITE_HEATER_0P(v); WRITE_HEATER_1(v); }
  623. #else
  624. #define WRITE_HEATER_0(v) WRITE_HEATER_0P(v)
  625. #endif
  626. /**
  627. * Heated bed requires settings
  628. */
  629. #if HAS_HEATER_BED
  630. #ifndef MAX_BED_POWER
  631. #define MAX_BED_POWER 255
  632. #endif
  633. #ifndef HEATER_BED_INVERTING
  634. #define HEATER_BED_INVERTING false
  635. #endif
  636. #define WRITE_HEATER_BED(v) WRITE(HEATER_BED_PIN, (v) ^ HEATER_BED_INVERTING)
  637. #endif
  638. /**
  639. * Up to 3 PWM fans
  640. */
  641. #if HAS_FAN2
  642. #define FAN_COUNT 3
  643. #elif HAS_FAN1
  644. #define FAN_COUNT 2
  645. #elif HAS_FAN0
  646. #define FAN_COUNT 1
  647. #else
  648. #define FAN_COUNT 0
  649. #endif
  650. #if HAS_FAN0
  651. #define WRITE_FAN(v) WRITE(FAN_PIN, v)
  652. #define WRITE_FAN0(v) WRITE_FAN(v)
  653. #endif
  654. #if HAS_FAN1
  655. #define WRITE_FAN1(v) WRITE(FAN1_PIN, v)
  656. #endif
  657. #if HAS_FAN2
  658. #define WRITE_FAN2(v) WRITE(FAN2_PIN, v)
  659. #endif
  660. #define WRITE_FAN_N(n, v) WRITE_FAN##n(v)
  661. /**
  662. * Part Cooling fan multipliexer
  663. */
  664. #define HAS_FANMUX PIN_EXISTS(FANMUX0)
  665. /**
  666. * Servos and probes
  667. */
  668. #if HAS_SERVOS
  669. #ifndef Z_ENDSTOP_SERVO_NR
  670. #define Z_ENDSTOP_SERVO_NR -1
  671. #endif
  672. #endif
  673. #define PROBE_PIN_CONFIGURED (HAS_Z_MIN_PROBE_PIN || (HAS_Z_MIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)))
  674. #define HAS_BED_PROBE (PROBE_SELECTED && PROBE_PIN_CONFIGURED && DISABLED(PROBE_MANUALLY))
  675. #if ENABLED(Z_PROBE_ALLEN_KEY)
  676. #define PROBE_IS_TRIGGERED_WHEN_STOWED_TEST
  677. #endif
  678. /**
  679. * Bed Probe dependencies
  680. */
  681. #if HAS_BED_PROBE
  682. #if ENABLED(ENDSTOPPULLUPS) && HAS_Z_MIN_PROBE_PIN
  683. #define ENDSTOPPULLUP_ZMIN_PROBE
  684. #endif
  685. #ifndef Z_PROBE_OFFSET_RANGE_MIN
  686. #define Z_PROBE_OFFSET_RANGE_MIN -20
  687. #endif
  688. #ifndef Z_PROBE_OFFSET_RANGE_MAX
  689. #define Z_PROBE_OFFSET_RANGE_MAX 20
  690. #endif
  691. #ifndef XY_PROBE_SPEED
  692. #ifdef HOMING_FEEDRATE_XY
  693. #define XY_PROBE_SPEED HOMING_FEEDRATE_XY
  694. #else
  695. #define XY_PROBE_SPEED 4000
  696. #endif
  697. #endif
  698. #if Z_CLEARANCE_BETWEEN_PROBES > Z_CLEARANCE_DEPLOY_PROBE
  699. #define _Z_CLEARANCE_DEPLOY_PROBE Z_CLEARANCE_BETWEEN_PROBES
  700. #else
  701. #define _Z_CLEARANCE_DEPLOY_PROBE Z_CLEARANCE_DEPLOY_PROBE
  702. #endif
  703. #else
  704. #undef X_PROBE_OFFSET_FROM_EXTRUDER
  705. #undef Y_PROBE_OFFSET_FROM_EXTRUDER
  706. #undef Z_PROBE_OFFSET_FROM_EXTRUDER
  707. #define X_PROBE_OFFSET_FROM_EXTRUDER 0
  708. #define Y_PROBE_OFFSET_FROM_EXTRUDER 0
  709. #define Z_PROBE_OFFSET_FROM_EXTRUDER 0
  710. #endif
  711. /**
  712. * Heater & Fan Pausing
  713. */
  714. #if FAN_COUNT == 0
  715. #undef PROBING_FANS_OFF
  716. #endif
  717. #define QUIET_PROBING (HAS_BED_PROBE && (ENABLED(PROBING_HEATERS_OFF) || ENABLED(PROBING_FANS_OFF) || DELAY_BEFORE_PROBING > 0))
  718. #define HEATER_IDLE_HANDLER (ENABLED(ADVANCED_PAUSE_FEATURE) || ENABLED(PROBING_HEATERS_OFF))
  719. /**
  720. * Delta radius/rod trimmers/angle trimmers
  721. */
  722. #if ENABLED(DELTA)
  723. #ifndef DELTA_CALIBRATION_RADIUS
  724. #define DELTA_CALIBRATION_RADIUS DELTA_PRINTABLE_RADIUS - 10
  725. #endif
  726. #ifndef DELTA_ENDSTOP_ADJ
  727. #define DELTA_ENDSTOP_ADJ { 0, 0, 0 }
  728. #endif
  729. #ifndef DELTA_TOWER_ANGLE_TRIM
  730. #define DELTA_TOWER_ANGLE_TRIM {0, 0, 0}
  731. #endif
  732. #ifndef DELTA_RADIUS_TRIM_TOWER
  733. #define DELTA_RADIUS_TRIM_TOWER {0, 0, 0}
  734. #endif
  735. #ifndef DELTA_DIAGONAL_ROD_TRIM_TOWER
  736. #define DELTA_DIAGONAL_ROD_TRIM_TOWER {0, 0, 0}
  737. #endif
  738. #endif
  739. /**
  740. * Set granular options based on the specific type of leveling
  741. */
  742. #define UBL_DELTA (ENABLED(AUTO_BED_LEVELING_UBL) && (ENABLED(DELTA) || ENABLED(UBL_GRANULAR_SEGMENTATION_FOR_CARTESIAN)))
  743. #define ABL_PLANAR (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_3POINT))
  744. #define ABL_GRID (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR))
  745. #define OLDSCHOOL_ABL (ABL_PLANAR || ABL_GRID)
  746. #define HAS_ABL (OLDSCHOOL_ABL || ENABLED(AUTO_BED_LEVELING_UBL))
  747. #define HAS_LEVELING (HAS_ABL || ENABLED(MESH_BED_LEVELING))
  748. #define HAS_AUTOLEVEL (HAS_ABL && DISABLED(PROBE_MANUALLY))
  749. #define HAS_MESH (ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(MESH_BED_LEVELING))
  750. #define PLANNER_LEVELING (OLDSCHOOL_ABL || ENABLED(MESH_BED_LEVELING) || UBL_DELTA)
  751. #define HAS_PROBING_PROCEDURE (HAS_ABL || ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST))
  752. #if HAS_PROBING_PROCEDURE
  753. #define PROBE_BED_WIDTH abs(RIGHT_PROBE_BED_POSITION - (LEFT_PROBE_BED_POSITION))
  754. #define PROBE_BED_HEIGHT abs(BACK_PROBE_BED_POSITION - (FRONT_PROBE_BED_POSITION))
  755. #endif
  756. /**
  757. * Buzzer/Speaker
  758. */
  759. #if ENABLED(LCD_USE_I2C_BUZZER)
  760. #ifndef LCD_FEEDBACK_FREQUENCY_HZ
  761. #define LCD_FEEDBACK_FREQUENCY_HZ 1000
  762. #endif
  763. #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
  764. #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100
  765. #endif
  766. #else
  767. #ifndef LCD_FEEDBACK_FREQUENCY_HZ
  768. #define LCD_FEEDBACK_FREQUENCY_HZ 5000
  769. #endif
  770. #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
  771. #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2
  772. #endif
  773. #endif
  774. /**
  775. * VIKI2 and miniVIKI require DOGLCD_SCK and DOGLCD_MOSI to be defined.
  776. */
  777. #if ENABLED(VIKI2) || ENABLED(miniVIKI)
  778. #ifndef DOGLCD_SCK
  779. #define DOGLCD_SCK SCK_PIN
  780. #endif
  781. #ifndef DOGLCD_MOSI
  782. #define DOGLCD_MOSI MOSI_PIN
  783. #endif
  784. #endif
  785. /**
  786. * Z_HOMING_HEIGHT / Z_CLEARANCE_BETWEEN_PROBES
  787. */
  788. #ifndef Z_HOMING_HEIGHT
  789. #ifndef Z_CLEARANCE_BETWEEN_PROBES
  790. #define Z_HOMING_HEIGHT 0
  791. #else
  792. #define Z_HOMING_HEIGHT Z_CLEARANCE_BETWEEN_PROBES
  793. #endif
  794. #endif
  795. #ifndef Z_CLEARANCE_BETWEEN_PROBES
  796. #define Z_CLEARANCE_BETWEEN_PROBES Z_HOMING_HEIGHT
  797. #endif
  798. #if Z_CLEARANCE_BETWEEN_PROBES > Z_HOMING_HEIGHT
  799. #define MANUAL_PROBE_HEIGHT Z_CLEARANCE_BETWEEN_PROBES
  800. #else
  801. #define MANUAL_PROBE_HEIGHT Z_HOMING_HEIGHT
  802. #endif
  803. /**
  804. * Bed Probing rectangular bounds
  805. * These can be further constrained in code for Delta and SCARA
  806. */
  807. #if ENABLED(DELTA)
  808. #ifndef DELTA_PROBEABLE_RADIUS
  809. #define DELTA_PROBEABLE_RADIUS DELTA_PRINTABLE_RADIUS
  810. #endif
  811. // Probing points may be verified at compile time within the radius
  812. // using static_assert(HYPOT2(X2-X1,Y2-Y1)<=sq(DELTA_PRINTABLE_RADIUS),"bad probe point!")
  813. // so that may be added to SanityCheck.h in the future.
  814. #define MIN_PROBE_X (X_CENTER - (DELTA_PROBEABLE_RADIUS))
  815. #define MIN_PROBE_Y (Y_CENTER - (DELTA_PROBEABLE_RADIUS))
  816. #define MAX_PROBE_X (X_CENTER + DELTA_PROBEABLE_RADIUS)
  817. #define MAX_PROBE_Y (Y_CENTER + DELTA_PROBEABLE_RADIUS)
  818. #elif IS_SCARA
  819. #define SCARA_PRINTABLE_RADIUS (SCARA_LINKAGE_1 + SCARA_LINKAGE_2)
  820. #define MIN_PROBE_X (X_CENTER - (SCARA_PRINTABLE_RADIUS))
  821. #define MIN_PROBE_Y (Y_CENTER - (SCARA_PRINTABLE_RADIUS))
  822. #define MAX_PROBE_X (X_CENTER + SCARA_PRINTABLE_RADIUS)
  823. #define MAX_PROBE_Y (Y_CENTER + SCARA_PRINTABLE_RADIUS)
  824. #else
  825. // Boundaries for Cartesian probing based on set limits
  826. #if ENABLED(BED_CENTER_AT_0_0)
  827. #define MIN_PROBE_X (max(X_PROBE_OFFSET_FROM_EXTRUDER, 0) - (X_BED_SIZE) / 2)
  828. #define MIN_PROBE_Y (max(Y_PROBE_OFFSET_FROM_EXTRUDER, 0) - (Y_BED_SIZE) / 2)
  829. #define MAX_PROBE_X (min(X_BED_SIZE + X_PROBE_OFFSET_FROM_EXTRUDER, X_BED_SIZE) - (X_BED_SIZE) / 2)
  830. #define MAX_PROBE_Y (min(Y_BED_SIZE + Y_PROBE_OFFSET_FROM_EXTRUDER, Y_BED_SIZE) - (Y_BED_SIZE) / 2)
  831. #else
  832. #define MIN_PROBE_X (max(X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER, 0))
  833. #define MIN_PROBE_Y (max(Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER, 0))
  834. #define MAX_PROBE_X (min(X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER, X_BED_SIZE))
  835. #define MAX_PROBE_Y (min(Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER, Y_BED_SIZE))
  836. #endif
  837. #endif
  838. // Stepper pulse duration, in cycles
  839. #define STEP_PULSE_CYCLES ((MINIMUM_STEPPER_PULSE) * CYCLES_PER_MICROSECOND)
  840. #ifdef CPU_32_BIT
  841. // Add additional delay for between direction signal and pulse signal of stepper
  842. #ifndef STEPPER_DIRECTION_DELAY
  843. #define STEPPER_DIRECTION_DELAY 0 // time in microseconds
  844. #endif
  845. #endif
  846. #ifndef __SAM3X8E__ //todo: hal: broken hal encapsulation
  847. #undef UI_VOLTAGE_LEVEL
  848. #undef RADDS_DISPLAY
  849. #undef MOTOR_CURRENT
  850. #endif
  851. #if ENABLED(SDCARD_SORT_ALPHA)
  852. #define HAS_FOLDER_SORTING (FOLDER_SORTING || ENABLED(SDSORT_GCODE))
  853. #endif
  854. // Updated G92 behavior shifts the workspace
  855. #define HAS_POSITION_SHIFT DISABLED(NO_WORKSPACE_OFFSETS)
  856. // The home offset also shifts the coordinate space
  857. #define HAS_HOME_OFFSET (DISABLED(NO_WORKSPACE_OFFSETS) || ENABLED(DELTA))
  858. // Either offset yields extra calculations on all moves
  859. #define HAS_WORKSPACE_OFFSET (HAS_POSITION_SHIFT || HAS_HOME_OFFSET)
  860. // M206 doesn't apply to DELTA
  861. #define HAS_M206_COMMAND (HAS_HOME_OFFSET && DISABLED(DELTA))
  862. // LCD timeout to status screen default is 15s
  863. #ifndef LCD_TIMEOUT_TO_STATUS
  864. #define LCD_TIMEOUT_TO_STATUS 15000
  865. #endif
  866. /**
  867. * DELTA_SEGMENT_MIN_LENGTH for UBL_DELTA
  868. */
  869. #if UBL_DELTA
  870. #ifndef DELTA_SEGMENT_MIN_LENGTH
  871. #if IS_SCARA
  872. #define DELTA_SEGMENT_MIN_LENGTH 0.25 // SCARA minimum segment size is 0.25mm
  873. #elif ENABLED(DELTA)
  874. #define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DELTA_SEGMENTS_PER_SECOND)
  875. #else // CARTESIAN
  876. #define DELTA_SEGMENT_MIN_LENGTH 1.00 // mm (similar to G2/G3 arc segmentation)
  877. #endif
  878. #endif
  879. #endif
  880. // Shorthand
  881. #define GRID_MAX_POINTS ((GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y))
  882. // Add commands that need sub-codes to this list
  883. #define USE_GCODE_SUBCODES ENABLED(G38_PROBE_TARGET)
  884. // MESH_BED_LEVELING overrides PROBE_MANUALLY
  885. #if ENABLED(MESH_BED_LEVELING)
  886. #undef PROBE_MANUALLY
  887. #endif
  888. // Parking Extruder
  889. #if ENABLED(PARKING_EXTRUDER)
  890. #ifndef PARKING_EXTRUDER_GRAB_DISTANCE
  891. #define PARKING_EXTRUDER_GRAB_DISTANCE 0
  892. #endif
  893. #ifndef PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE
  894. #define PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE HIGH
  895. #endif
  896. #endif
  897. // Use float instead of double. Needs profiling.
  898. #if defined(ARDUINO_ARCH_SAM) && ENABLED(DELTA_FAST_SQRT)
  899. #undef ATAN2
  900. #undef FABS
  901. #undef POW
  902. #undef SQRT
  903. #undef CEIL
  904. #undef FLOOR
  905. #undef LROUND
  906. #undef FMOD
  907. #define ATAN2(y, x) atan2f(y, x)
  908. #define FABS(x) fabsf(x)
  909. #define POW(x, y) powf(x, y)
  910. #define SQRT(x) sqrtf(x)
  911. #define CEIL(x) ceilf(x)
  912. #define FLOOR(x) floorf(x)
  913. #define LROUND(x) lroundf(x)
  914. #define FMOD(x, y) fmodf(x, y)
  915. #endif
  916. #ifdef TEENSYDUINO
  917. #undef max
  918. #define max(a,b) ((a)>(b)?(a):(b))
  919. #undef min
  920. #define min(a,b) ((a)<(b)?(a):(b))
  921. #define NOT_A_PIN 0 // For PINS_DEBUGGING
  922. #endif
  923. #endif // CONDITIONALS_POST_H