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.
 
 
 
 
 

1576 lines
49 KiB

  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 AVR_ATmega2560_FAMILY_PLUS_70 ( \
  29. MB(BQ_ZUM_MEGA_3D) \
  30. || MB(MIGHTYBOARD_REVE) \
  31. || MB(MINIRAMBO) \
  32. || MB(SCOOVO_X9H) \
  33. )
  34. #ifdef TEENSYDUINO
  35. #undef max
  36. #define max(a,b) ((a)>(b)?(a):(b))
  37. #undef min
  38. #define min(a,b) ((a)<(b)?(a):(b))
  39. #undef NOT_A_PIN // Override Teensyduino legacy CapSense define work-around
  40. #define NOT_A_PIN 0 // For PINS_DEBUGGING
  41. #endif
  42. #define IS_SCARA (ENABLED(MORGAN_SCARA) || ENABLED(MAKERARM_SCARA))
  43. #define IS_KINEMATIC (ENABLED(DELTA) || IS_SCARA)
  44. #define IS_CARTESIAN !IS_KINEMATIC
  45. /**
  46. * Axis lengths and center
  47. */
  48. #define X_MAX_LENGTH (X_MAX_POS - (X_MIN_POS))
  49. #define Y_MAX_LENGTH (Y_MAX_POS - (Y_MIN_POS))
  50. #define Z_MAX_LENGTH (Z_MAX_POS - (Z_MIN_POS))
  51. // Defined only if the sanity-check is bypassed
  52. #ifndef X_BED_SIZE
  53. #define X_BED_SIZE X_MAX_LENGTH
  54. #endif
  55. #ifndef Y_BED_SIZE
  56. #define Y_BED_SIZE Y_MAX_LENGTH
  57. #endif
  58. // Require 0,0 bed center for Delta and SCARA
  59. #if IS_KINEMATIC
  60. #define BED_CENTER_AT_0_0
  61. #endif
  62. // Define center values for future use
  63. #if ENABLED(BED_CENTER_AT_0_0)
  64. #define X_CENTER 0
  65. #define Y_CENTER 0
  66. #else
  67. #define X_CENTER ((X_BED_SIZE) / 2)
  68. #define Y_CENTER ((Y_BED_SIZE) / 2)
  69. #endif
  70. #define Z_CENTER ((Z_MIN_POS + Z_MAX_POS) / 2)
  71. // Get the linear boundaries of the bed
  72. #define X_MIN_BED (X_CENTER - (X_BED_SIZE) / 2)
  73. #define X_MAX_BED (X_CENTER + (X_BED_SIZE) / 2)
  74. #define Y_MIN_BED (Y_CENTER - (Y_BED_SIZE) / 2)
  75. #define Y_MAX_BED (Y_CENTER + (Y_BED_SIZE) / 2)
  76. /**
  77. * CoreXY, CoreXZ, and CoreYZ - and their reverse
  78. */
  79. #define CORE_IS_XY (ENABLED(COREXY) || ENABLED(COREYX))
  80. #define CORE_IS_XZ (ENABLED(COREXZ) || ENABLED(COREZX))
  81. #define CORE_IS_YZ (ENABLED(COREYZ) || ENABLED(COREZY))
  82. #define IS_CORE (CORE_IS_XY || CORE_IS_XZ || CORE_IS_YZ)
  83. #if IS_CORE
  84. #if CORE_IS_XY
  85. #define CORE_AXIS_1 A_AXIS
  86. #define CORE_AXIS_2 B_AXIS
  87. #define NORMAL_AXIS Z_AXIS
  88. #elif CORE_IS_XZ
  89. #define CORE_AXIS_1 A_AXIS
  90. #define NORMAL_AXIS Y_AXIS
  91. #define CORE_AXIS_2 C_AXIS
  92. #elif CORE_IS_YZ
  93. #define NORMAL_AXIS X_AXIS
  94. #define CORE_AXIS_1 B_AXIS
  95. #define CORE_AXIS_2 C_AXIS
  96. #endif
  97. #if ENABLED(COREYX) || ENABLED(COREZX) || ENABLED(COREZY)
  98. #define CORESIGN(n) (-(n))
  99. #else
  100. #define CORESIGN(n) (n)
  101. #endif
  102. #endif
  103. /**
  104. * No adjustable bed on non-cartesians
  105. */
  106. #if IS_KINEMATIC
  107. #undef LEVEL_BED_CORNERS
  108. #endif
  109. /**
  110. * SCARA cannot use SLOWDOWN and requires QUICKHOME
  111. */
  112. #if IS_SCARA
  113. #undef SLOWDOWN
  114. #define QUICK_HOME
  115. #endif
  116. /**
  117. * Set the home position based on settings or manual overrides
  118. */
  119. #ifdef MANUAL_X_HOME_POS
  120. #define X_HOME_POS MANUAL_X_HOME_POS
  121. #elif ENABLED(BED_CENTER_AT_0_0)
  122. #if ENABLED(DELTA)
  123. #define X_HOME_POS 0
  124. #else
  125. #define X_HOME_POS ((X_BED_SIZE) * (X_HOME_DIR) * 0.5)
  126. #endif
  127. #else
  128. #if ENABLED(DELTA)
  129. #define X_HOME_POS (X_MIN_POS + (X_BED_SIZE) * 0.5)
  130. #else
  131. #define X_HOME_POS (X_HOME_DIR < 0 ? X_MIN_POS : X_MAX_POS)
  132. #endif
  133. #endif
  134. #ifdef MANUAL_Y_HOME_POS
  135. #define Y_HOME_POS MANUAL_Y_HOME_POS
  136. #elif ENABLED(BED_CENTER_AT_0_0)
  137. #if ENABLED(DELTA)
  138. #define Y_HOME_POS 0
  139. #else
  140. #define Y_HOME_POS ((Y_BED_SIZE) * (Y_HOME_DIR) * 0.5)
  141. #endif
  142. #else
  143. #if ENABLED(DELTA)
  144. #define Y_HOME_POS (Y_MIN_POS + (Y_BED_SIZE) * 0.5)
  145. #else
  146. #define Y_HOME_POS (Y_HOME_DIR < 0 ? Y_MIN_POS : Y_MAX_POS)
  147. #endif
  148. #endif
  149. #ifdef MANUAL_Z_HOME_POS
  150. #define Z_HOME_POS MANUAL_Z_HOME_POS
  151. #else
  152. #define Z_HOME_POS (Z_HOME_DIR < 0 ? Z_MIN_POS : Z_MAX_POS)
  153. #endif
  154. /**
  155. * If DELTA_HEIGHT isn't defined use the old setting
  156. */
  157. #if ENABLED(DELTA) && !defined(DELTA_HEIGHT)
  158. #define DELTA_HEIGHT Z_HOME_POS
  159. #endif
  160. /**
  161. * Z Sled Probe requires Z_SAFE_HOMING
  162. */
  163. #if ENABLED(Z_PROBE_SLED)
  164. #define Z_SAFE_HOMING
  165. #endif
  166. /**
  167. * DELTA should ignore Z_SAFE_HOMING and SLOWDOWN
  168. */
  169. #if ENABLED(DELTA)
  170. #undef Z_SAFE_HOMING
  171. #undef SLOWDOWN
  172. #endif
  173. /**
  174. * Safe Homing Options
  175. */
  176. #if ENABLED(Z_SAFE_HOMING)
  177. #ifndef Z_SAFE_HOMING_X_POINT
  178. #define Z_SAFE_HOMING_X_POINT X_CENTER
  179. #endif
  180. #ifndef Z_SAFE_HOMING_Y_POINT
  181. #define Z_SAFE_HOMING_Y_POINT Y_CENTER
  182. #endif
  183. #define X_TILT_FULCRUM Z_SAFE_HOMING_X_POINT
  184. #define Y_TILT_FULCRUM Z_SAFE_HOMING_Y_POINT
  185. #else
  186. #define X_TILT_FULCRUM X_HOME_POS
  187. #define Y_TILT_FULCRUM Y_HOME_POS
  188. #endif
  189. /**
  190. * Host keep alive
  191. */
  192. #ifndef DEFAULT_KEEPALIVE_INTERVAL
  193. #define DEFAULT_KEEPALIVE_INTERVAL 2
  194. #endif
  195. /**
  196. * Provide a MAX_AUTORETRACT for older configs
  197. */
  198. #if ENABLED(FWRETRACT) && !defined(MAX_AUTORETRACT)
  199. #define MAX_AUTORETRACT 99
  200. #endif
  201. // MS1 MS2 Stepper Driver Microstepping mode table
  202. #define MICROSTEP1 LOW,LOW
  203. #if ENABLED(HEROIC_STEPPER_DRIVERS)
  204. #define MICROSTEP128 LOW,HIGH
  205. #else
  206. #define MICROSTEP2 HIGH,LOW
  207. #define MICROSTEP4 LOW,HIGH
  208. #endif
  209. #define MICROSTEP8 HIGH,HIGH
  210. #ifdef __SAM3X8E__
  211. #if MB(ALLIGATOR)
  212. #define MICROSTEP16 LOW,LOW
  213. #define MICROSTEP32 HIGH,HIGH
  214. #else
  215. #define MICROSTEP16 HIGH,HIGH
  216. #endif
  217. #else
  218. #define MICROSTEP16 HIGH,HIGH
  219. #endif
  220. /**
  221. * Override here because this is set in Configuration_adv.h
  222. */
  223. #if ENABLED(ULTIPANEL) && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER)
  224. #undef SD_DETECT_INVERTED
  225. #endif
  226. /**
  227. * Set defaults for missing (newer) options
  228. */
  229. #ifndef DISABLE_INACTIVE_X
  230. #define DISABLE_INACTIVE_X DISABLE_X
  231. #endif
  232. #ifndef DISABLE_INACTIVE_Y
  233. #define DISABLE_INACTIVE_Y DISABLE_Y
  234. #endif
  235. #ifndef DISABLE_INACTIVE_Z
  236. #define DISABLE_INACTIVE_Z DISABLE_Z
  237. #endif
  238. #ifndef DISABLE_INACTIVE_E
  239. #define DISABLE_INACTIVE_E DISABLE_E
  240. #endif
  241. // Power Signal Control Definitions
  242. // By default use ATX definition
  243. #ifndef POWER_SUPPLY
  244. #define POWER_SUPPLY 1
  245. #endif
  246. #if (POWER_SUPPLY == 1) // 1 = ATX
  247. #define PS_ON_AWAKE LOW
  248. #define PS_ON_ASLEEP HIGH
  249. #elif (POWER_SUPPLY == 2) // 2 = X-Box 360 203W
  250. #define PS_ON_AWAKE HIGH
  251. #define PS_ON_ASLEEP LOW
  252. #endif
  253. #define HAS_POWER_SWITCH (POWER_SUPPLY > 0 && PIN_EXISTS(PS_ON))
  254. /**
  255. * Temp Sensor defines
  256. */
  257. #if TEMP_SENSOR_0 == -4
  258. #define HEATER_0_USES_AD8495
  259. #elif TEMP_SENSOR_0 == -3
  260. #define HEATER_0_USES_MAX6675
  261. #define MAX6675_IS_MAX31855
  262. #define MAX6675_TMIN -270
  263. #define MAX6675_TMAX 1800
  264. #elif TEMP_SENSOR_0 == -2
  265. #define HEATER_0_USES_MAX6675
  266. #define MAX6675_TMIN 0
  267. #define MAX6675_TMAX 1024
  268. #elif TEMP_SENSOR_0 == -1
  269. #define HEATER_0_USES_AD595
  270. #elif TEMP_SENSOR_0 == 0
  271. #undef HEATER_0_MINTEMP
  272. #undef HEATER_0_MAXTEMP
  273. #elif TEMP_SENSOR_0 > 0
  274. #define THERMISTORHEATER_0 TEMP_SENSOR_0
  275. #define HEATER_0_USES_THERMISTOR
  276. #endif
  277. #if TEMP_SENSOR_1 == -4
  278. #define HEATER_1_USES_AD8495
  279. #elif TEMP_SENSOR_1 == -3
  280. #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_1."
  281. #elif TEMP_SENSOR_1 == -2
  282. #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_1."
  283. #elif TEMP_SENSOR_1 == -1
  284. #define HEATER_1_USES_AD595
  285. #elif TEMP_SENSOR_1 == 0
  286. #undef HEATER_1_MINTEMP
  287. #undef HEATER_1_MAXTEMP
  288. #elif TEMP_SENSOR_1 > 0
  289. #define THERMISTORHEATER_1 TEMP_SENSOR_1
  290. #define HEATER_1_USES_THERMISTOR
  291. #endif
  292. #if TEMP_SENSOR_2 == -4
  293. #define HEATER_2_USES_AD8495
  294. #elif TEMP_SENSOR_2 == -3
  295. #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_2."
  296. #elif TEMP_SENSOR_2 == -2
  297. #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_2."
  298. #elif TEMP_SENSOR_2 == -1
  299. #define HEATER_2_USES_AD595
  300. #elif TEMP_SENSOR_2 == 0
  301. #undef HEATER_2_MINTEMP
  302. #undef HEATER_2_MAXTEMP
  303. #elif TEMP_SENSOR_2 > 0
  304. #define THERMISTORHEATER_2 TEMP_SENSOR_2
  305. #define HEATER_2_USES_THERMISTOR
  306. #endif
  307. #if TEMP_SENSOR_3 == -4
  308. #define HEATER_3_USES_AD8495
  309. #elif TEMP_SENSOR_3 == -3
  310. #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_3."
  311. #elif TEMP_SENSOR_3 == -2
  312. #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_3."
  313. #elif TEMP_SENSOR_3 == -1
  314. #define HEATER_3_USES_AD595
  315. #elif TEMP_SENSOR_3 == 0
  316. #undef HEATER_3_MINTEMP
  317. #undef HEATER_3_MAXTEMP
  318. #elif TEMP_SENSOR_3 > 0
  319. #define THERMISTORHEATER_3 TEMP_SENSOR_3
  320. #define HEATER_3_USES_THERMISTOR
  321. #endif
  322. #if TEMP_SENSOR_4 == -4
  323. #define HEATER_4_USES_AD8495
  324. #elif TEMP_SENSOR_4 == -3
  325. #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_4."
  326. #elif TEMP_SENSOR_4 == -2
  327. #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_4."
  328. #elif TEMP_SENSOR_4 == -1
  329. #define HEATER_4_USES_AD595
  330. #elif TEMP_SENSOR_4 == 0
  331. #undef HEATER_4_MINTEMP
  332. #undef HEATER_4_MAXTEMP
  333. #elif TEMP_SENSOR_4 > 0
  334. #define THERMISTORHEATER_4 TEMP_SENSOR_4
  335. #define HEATER_4_USES_THERMISTOR
  336. #endif
  337. #if TEMP_SENSOR_BED == -4
  338. #define HEATER_BED_USES_AD8495
  339. #elif TEMP_SENSOR_BED == -3
  340. #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BED."
  341. #elif TEMP_SENSOR_BED == -2
  342. #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_BED."
  343. #elif TEMP_SENSOR_BED == -1
  344. #define HEATER_BED_USES_AD595
  345. #elif TEMP_SENSOR_BED == 0
  346. #undef BED_MINTEMP
  347. #undef BED_MAXTEMP
  348. #elif TEMP_SENSOR_BED > 0
  349. #define THERMISTORBED TEMP_SENSOR_BED
  350. #define HEATER_BED_USES_THERMISTOR
  351. #endif
  352. #if TEMP_SENSOR_CHAMBER == -4
  353. #define HEATER_CHAMBER_USES_AD8495
  354. #elif TEMP_SENSOR_CHAMBER == -3
  355. #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_CHAMBER."
  356. #elif TEMP_SENSOR_CHAMBER == -2
  357. #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_CHAMBER."
  358. #elif TEMP_SENSOR_CHAMBER == -1
  359. #define HEATER_CHAMBER_USES_AD595
  360. #elif TEMP_SENSOR_CHAMBER > 0
  361. #define THERMISTORCHAMBER TEMP_SENSOR_CHAMBER
  362. #define HEATER_CHAMBER_USES_THERMISTOR
  363. #endif
  364. #define HOTEND_USES_THERMISTOR (ENABLED(HEATER_0_USES_THERMISTOR) || ENABLED(HEATER_1_USES_THERMISTOR) || ENABLED(HEATER_2_USES_THERMISTOR) || ENABLED(HEATER_3_USES_THERMISTOR) || ENABLED(HEATER_4_USES_THERMISTOR))
  365. /**
  366. * Default hotend offsets, if not defined
  367. */
  368. #define HAS_HOTEND_OFFSET_Z (HOTENDS > 1 && (ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_NOZZLE) || ENABLED(PARKING_EXTRUDER)))
  369. #if HOTENDS > 1
  370. #ifndef HOTEND_OFFSET_X
  371. #define HOTEND_OFFSET_X { 0 } // X offsets for each extruder
  372. #endif
  373. #ifndef HOTEND_OFFSET_Y
  374. #define HOTEND_OFFSET_Y { 0 } // Y offsets for each extruder
  375. #endif
  376. #if HAS_HOTEND_OFFSET_Z && !defined(HOTEND_OFFSET_Z)
  377. #define HOTEND_OFFSET_Z { 0 }
  378. #endif
  379. #endif
  380. /**
  381. * ARRAY_BY_EXTRUDERS based on EXTRUDERS
  382. */
  383. #define ARRAY_BY_EXTRUDERS(...) ARRAY_N(EXTRUDERS, __VA_ARGS__)
  384. #define ARRAY_BY_EXTRUDERS1(v1) ARRAY_BY_EXTRUDERS(v1, v1, v1, v1, v1, v1)
  385. /**
  386. * ARRAY_BY_HOTENDS based on HOTENDS
  387. */
  388. #define ARRAY_BY_HOTENDS(...) ARRAY_N(HOTENDS, __VA_ARGS__)
  389. #define ARRAY_BY_HOTENDS1(v1) ARRAY_BY_HOTENDS(v1, v1, v1, v1, v1, v1)
  390. /**
  391. * X_DUAL_ENDSTOPS endstop reassignment
  392. */
  393. #if ENABLED(X_DUAL_ENDSTOPS)
  394. #if X_HOME_DIR > 0
  395. #if X2_USE_ENDSTOP == _XMIN_
  396. #define X2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
  397. #define X2_MAX_PIN X_MIN_PIN
  398. #elif X2_USE_ENDSTOP == _XMAX_
  399. #define X2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
  400. #define X2_MAX_PIN X_MAX_PIN
  401. #elif X2_USE_ENDSTOP == _YMIN_
  402. #define X2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
  403. #define X2_MAX_PIN Y_MIN_PIN
  404. #elif X2_USE_ENDSTOP == _YMAX_
  405. #define X2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
  406. #define X2_MAX_PIN Y_MAX_PIN
  407. #elif X2_USE_ENDSTOP == _ZMIN_
  408. #define X2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
  409. #define X2_MAX_PIN Z_MIN_PIN
  410. #elif X2_USE_ENDSTOP == _ZMAX_
  411. #define X2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
  412. #define X2_MAX_PIN Z_MAX_PIN
  413. #else
  414. #define X2_MAX_ENDSTOP_INVERTING false
  415. #endif
  416. #define X2_MIN_ENDSTOP_INVERTING false
  417. #else
  418. #if X2_USE_ENDSTOP == _XMIN_
  419. #define X2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
  420. #define X2_MIN_PIN X_MIN_PIN
  421. #elif X2_USE_ENDSTOP == _XMAX_
  422. #define X2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
  423. #define X2_MIN_PIN X_MAX_PIN
  424. #elif X2_USE_ENDSTOP == _YMIN_
  425. #define X2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
  426. #define X2_MIN_PIN Y_MIN_PIN
  427. #elif X2_USE_ENDSTOP == _YMAX_
  428. #define X2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
  429. #define X2_MIN_PIN Y_MAX_PIN
  430. #elif X2_USE_ENDSTOP == _ZMIN_
  431. #define X2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
  432. #define X2_MIN_PIN Z_MIN_PIN
  433. #elif X2_USE_ENDSTOP == _ZMAX_
  434. #define X2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
  435. #define X2_MIN_PIN Z_MAX_PIN
  436. #else
  437. #define X2_MIN_ENDSTOP_INVERTING false
  438. #endif
  439. #define X2_MAX_ENDSTOP_INVERTING false
  440. #endif
  441. #endif
  442. // Is an endstop plug used for the X2 endstop?
  443. #define IS_X2_ENDSTOP(A,M) (ENABLED(X_DUAL_ENDSTOPS) && X2_USE_ENDSTOP == _##A##M##_)
  444. /**
  445. * Y_DUAL_ENDSTOPS endstop reassignment
  446. */
  447. #if ENABLED(Y_DUAL_ENDSTOPS)
  448. #if Y_HOME_DIR > 0
  449. #if Y2_USE_ENDSTOP == _XMIN_
  450. #define Y2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
  451. #define Y2_MAX_PIN X_MIN_PIN
  452. #elif Y2_USE_ENDSTOP == _XMAX_
  453. #define Y2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
  454. #define Y2_MAX_PIN X_MAX_PIN
  455. #elif Y2_USE_ENDSTOP == _YMIN_
  456. #define Y2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
  457. #define Y2_MAX_PIN Y_MIN_PIN
  458. #elif Y2_USE_ENDSTOP == _YMAX_
  459. #define Y2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
  460. #define Y2_MAX_PIN Y_MAX_PIN
  461. #elif Y2_USE_ENDSTOP == _ZMIN_
  462. #define Y2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
  463. #define Y2_MAX_PIN Z_MIN_PIN
  464. #elif Y2_USE_ENDSTOP == _ZMAX_
  465. #define Y2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
  466. #define Y2_MAX_PIN Z_MAX_PIN
  467. #else
  468. #define Y2_MAX_ENDSTOP_INVERTING false
  469. #endif
  470. #define Y2_MIN_ENDSTOP_INVERTING false
  471. #else
  472. #if Y2_USE_ENDSTOP == _XMIN_
  473. #define Y2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
  474. #define Y2_MIN_PIN X_MIN_PIN
  475. #elif Y2_USE_ENDSTOP == _XMAX_
  476. #define Y2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
  477. #define Y2_MIN_PIN X_MAX_PIN
  478. #elif Y2_USE_ENDSTOP == _YMIN_
  479. #define Y2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
  480. #define Y2_MIN_PIN Y_MIN_PIN
  481. #elif Y2_USE_ENDSTOP == _YMAX_
  482. #define Y2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
  483. #define Y2_MIN_PIN Y_MAX_PIN
  484. #elif Y2_USE_ENDSTOP == _ZMIN_
  485. #define Y2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
  486. #define Y2_MIN_PIN Z_MIN_PIN
  487. #elif Y2_USE_ENDSTOP == _ZMAX_
  488. #define Y2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
  489. #define Y2_MIN_PIN Z_MAX_PIN
  490. #else
  491. #define Y2_MIN_ENDSTOP_INVERTING false
  492. #endif
  493. #define Y2_MAX_ENDSTOP_INVERTING false
  494. #endif
  495. #endif
  496. // Is an endstop plug used for the Y2 endstop or the bed probe?
  497. #define IS_Y2_ENDSTOP(A,M) (ENABLED(Y_DUAL_ENDSTOPS) && Y2_USE_ENDSTOP == _##A##M##_)
  498. /**
  499. * Z_DUAL_ENDSTOPS endstop reassignment
  500. */
  501. #if ENABLED(Z_DUAL_ENDSTOPS)
  502. #if Z_HOME_DIR > 0
  503. #if Z2_USE_ENDSTOP == _XMIN_
  504. #define Z2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
  505. #define Z2_MAX_PIN X_MIN_PIN
  506. #elif Z2_USE_ENDSTOP == _XMAX_
  507. #define Z2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
  508. #define Z2_MAX_PIN X_MAX_PIN
  509. #elif Z2_USE_ENDSTOP == _YMIN_
  510. #define Z2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
  511. #define Z2_MAX_PIN Y_MIN_PIN
  512. #elif Z2_USE_ENDSTOP == _YMAX_
  513. #define Z2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
  514. #define Z2_MAX_PIN Y_MAX_PIN
  515. #elif Z2_USE_ENDSTOP == _ZMIN_
  516. #define Z2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
  517. #define Z2_MAX_PIN Z_MIN_PIN
  518. #elif Z2_USE_ENDSTOP == _ZMAX_
  519. #define Z2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
  520. #define Z2_MAX_PIN Z_MAX_PIN
  521. #else
  522. #define Z2_MAX_ENDSTOP_INVERTING false
  523. #endif
  524. #define Z2_MIN_ENDSTOP_INVERTING false
  525. #else
  526. #if Z2_USE_ENDSTOP == _XMIN_
  527. #define Z2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
  528. #define Z2_MIN_PIN X_MIN_PIN
  529. #elif Z2_USE_ENDSTOP == _XMAX_
  530. #define Z2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
  531. #define Z2_MIN_PIN X_MAX_PIN
  532. #elif Z2_USE_ENDSTOP == _YMIN_
  533. #define Z2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
  534. #define Z2_MIN_PIN Y_MIN_PIN
  535. #elif Z2_USE_ENDSTOP == _YMAX_
  536. #define Z2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
  537. #define Z2_MIN_PIN Y_MAX_PIN
  538. #elif Z2_USE_ENDSTOP == _ZMIN_
  539. #define Z2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
  540. #define Z2_MIN_PIN Z_MIN_PIN
  541. #elif Z2_USE_ENDSTOP == _ZMAX_
  542. #define Z2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
  543. #define Z2_MIN_PIN Z_MAX_PIN
  544. #else
  545. #define Z2_MIN_ENDSTOP_INVERTING false
  546. #endif
  547. #define Z2_MAX_ENDSTOP_INVERTING false
  548. #endif
  549. #endif
  550. // Is an endstop plug used for the Z2 endstop or the bed probe?
  551. #define IS_Z2_OR_PROBE(A,M) ( \
  552. (ENABLED(Z_DUAL_ENDSTOPS) && Z2_USE_ENDSTOP == _##A##M##_) \
  553. || (ENABLED(Z_MIN_PROBE_ENDSTOP) && Z_MIN_PROBE_PIN == A##_##M##_PIN ) )
  554. /**
  555. * Set ENDSTOPPULLUPS for active endstop switches
  556. */
  557. #if ENABLED(ENDSTOPPULLUPS)
  558. #if ENABLED(USE_XMAX_PLUG)
  559. #define ENDSTOPPULLUP_XMAX
  560. #endif
  561. #if ENABLED(USE_YMAX_PLUG)
  562. #define ENDSTOPPULLUP_YMAX
  563. #endif
  564. #if ENABLED(USE_ZMAX_PLUG)
  565. #define ENDSTOPPULLUP_ZMAX
  566. #endif
  567. #if ENABLED(USE_XMIN_PLUG)
  568. #define ENDSTOPPULLUP_XMIN
  569. #endif
  570. #if ENABLED(USE_YMIN_PLUG)
  571. #define ENDSTOPPULLUP_YMIN
  572. #endif
  573. #if ENABLED(USE_ZMIN_PLUG)
  574. #define ENDSTOPPULLUP_ZMIN
  575. #endif
  576. #endif
  577. /**
  578. * Set ENDSTOPPULLDOWNS for active endstop switches
  579. */
  580. #if ENABLED(ENDSTOPPULLDOWNS)
  581. #if ENABLED(USE_XMAX_PLUG)
  582. #define ENDSTOPPULLDOWN_XMAX
  583. #endif
  584. #if ENABLED(USE_YMAX_PLUG)
  585. #define ENDSTOPPULLDOWN_YMAX
  586. #endif
  587. #if ENABLED(USE_ZMAX_PLUG)
  588. #define ENDSTOPPULLDOWN_ZMAX
  589. #endif
  590. #if ENABLED(USE_XMIN_PLUG)
  591. #define ENDSTOPPULLDOWN_XMIN
  592. #endif
  593. #if ENABLED(USE_YMIN_PLUG)
  594. #define ENDSTOPPULLDOWN_YMIN
  595. #endif
  596. #if ENABLED(USE_ZMIN_PLUG)
  597. #define ENDSTOPPULLDOWN_ZMIN
  598. #endif
  599. #endif
  600. /**
  601. * Shorthand for pin tests, used wherever needed
  602. */
  603. // Steppers
  604. #define HAS_X_ENABLE (PIN_EXISTS(X_ENABLE))
  605. #define HAS_X_DIR (PIN_EXISTS(X_DIR))
  606. #define HAS_X_STEP (PIN_EXISTS(X_STEP))
  607. #define HAS_X_MICROSTEPS (PIN_EXISTS(X_MS1))
  608. #define HAS_X2_ENABLE (PIN_EXISTS(X2_ENABLE))
  609. #define HAS_X2_DIR (PIN_EXISTS(X2_DIR))
  610. #define HAS_X2_STEP (PIN_EXISTS(X2_STEP))
  611. #define HAS_Y_MICROSTEPS (PIN_EXISTS(Y_MS1))
  612. #define HAS_Y_ENABLE (PIN_EXISTS(Y_ENABLE))
  613. #define HAS_Y_DIR (PIN_EXISTS(Y_DIR))
  614. #define HAS_Y_STEP (PIN_EXISTS(Y_STEP))
  615. #define HAS_Z_MICROSTEPS (PIN_EXISTS(Z_MS1))
  616. #define HAS_Y2_ENABLE (PIN_EXISTS(Y2_ENABLE))
  617. #define HAS_Y2_DIR (PIN_EXISTS(Y2_DIR))
  618. #define HAS_Y2_STEP (PIN_EXISTS(Y2_STEP))
  619. #define HAS_Z_ENABLE (PIN_EXISTS(Z_ENABLE))
  620. #define HAS_Z_DIR (PIN_EXISTS(Z_DIR))
  621. #define HAS_Z_STEP (PIN_EXISTS(Z_STEP))
  622. #define HAS_Z2_ENABLE (PIN_EXISTS(Z2_ENABLE))
  623. #define HAS_Z2_DIR (PIN_EXISTS(Z2_DIR))
  624. #define HAS_Z2_STEP (PIN_EXISTS(Z2_STEP))
  625. // Extruder steppers and solenoids
  626. #define HAS_E0_ENABLE (PIN_EXISTS(E0_ENABLE))
  627. #define HAS_E0_DIR (PIN_EXISTS(E0_DIR))
  628. #define HAS_E0_STEP (PIN_EXISTS(E0_STEP))
  629. #define HAS_E0_MICROSTEPS (PIN_EXISTS(E0_MS1))
  630. #define HAS_SOLENOID_0 (PIN_EXISTS(SOL0))
  631. #define HAS_E1_ENABLE (PIN_EXISTS(E1_ENABLE))
  632. #define HAS_E1_DIR (PIN_EXISTS(E1_DIR))
  633. #define HAS_E1_STEP (PIN_EXISTS(E1_STEP))
  634. #define HAS_E1_MICROSTEPS (PIN_EXISTS(E1_MS1))
  635. #define HAS_SOLENOID_1 (PIN_EXISTS(SOL1))
  636. #define HAS_E2_ENABLE (PIN_EXISTS(E2_ENABLE))
  637. #define HAS_E2_DIR (PIN_EXISTS(E2_DIR))
  638. #define HAS_E2_STEP (PIN_EXISTS(E2_STEP))
  639. #define HAS_E2_MICROSTEPS (PIN_EXISTS(E2_MS1))
  640. #define HAS_SOLENOID_2 (PIN_EXISTS(SOL2))
  641. #define HAS_E3_ENABLE (PIN_EXISTS(E3_ENABLE))
  642. #define HAS_E3_DIR (PIN_EXISTS(E3_DIR))
  643. #define HAS_E3_STEP (PIN_EXISTS(E3_STEP))
  644. #define HAS_E3_MICROSTEPS (PIN_EXISTS(E3_MS1))
  645. #define HAS_SOLENOID_3 (PIN_EXISTS(SOL3))
  646. #define HAS_E4_ENABLE (PIN_EXISTS(E4_ENABLE))
  647. #define HAS_E4_DIR (PIN_EXISTS(E4_DIR))
  648. #define HAS_E4_STEP (PIN_EXISTS(E4_STEP))
  649. #define HAS_E4_MICROSTEPS (PIN_EXISTS(E4_MS1))
  650. #define HAS_SOLENOID_4 (PIN_EXISTS(SOL4))
  651. // Trinamic Stepper Drivers
  652. #define HAS_TRINAMIC (ENABLED(HAVE_TMC2130) || ENABLED(HAVE_TMC2208) || ENABLED(IS_TRAMS))
  653. #define X_IS_TRINAMIC (ENABLED( X_IS_TMC2130) || ENABLED( X_IS_TMC2208) || ENABLED(IS_TRAMS))
  654. #define X2_IS_TRINAMIC (ENABLED(X2_IS_TMC2130) || ENABLED(X2_IS_TMC2208))
  655. #define Y_IS_TRINAMIC (ENABLED( Y_IS_TMC2130) || ENABLED( Y_IS_TMC2208) || ENABLED(IS_TRAMS))
  656. #define Y2_IS_TRINAMIC (ENABLED(Y2_IS_TMC2130) || ENABLED(Y2_IS_TMC2208))
  657. #define Z_IS_TRINAMIC (ENABLED( Z_IS_TMC2130) || ENABLED( Z_IS_TMC2208) || ENABLED(IS_TRAMS))
  658. #define Z2_IS_TRINAMIC (ENABLED(Z2_IS_TMC2130) || ENABLED(Z2_IS_TMC2208))
  659. #define E0_IS_TRINAMIC (ENABLED(E0_IS_TMC2130) || ENABLED(E0_IS_TMC2208) || ENABLED(IS_TRAMS))
  660. #define E1_IS_TRINAMIC (ENABLED(E1_IS_TMC2130) || ENABLED(E1_IS_TMC2208))
  661. #define E2_IS_TRINAMIC (ENABLED(E2_IS_TMC2130) || ENABLED(E2_IS_TMC2208))
  662. #define E3_IS_TRINAMIC (ENABLED(E3_IS_TMC2130) || ENABLED(E3_IS_TMC2208))
  663. #define E4_IS_TRINAMIC (ENABLED(E4_IS_TMC2130) || ENABLED(E4_IS_TMC2208))
  664. #if ENABLED(SENSORLESS_HOMING)
  665. // Disable Z axis sensorless homing if a probe is used to home the Z axis
  666. #if HOMING_Z_WITH_PROBE
  667. #undef Z_HOMING_SENSITIVITY
  668. #endif
  669. #define X_SENSORLESS (ENABLED(X_IS_TMC2130) && defined(X_HOMING_SENSITIVITY))
  670. #define Y_SENSORLESS (ENABLED(Y_IS_TMC2130) && defined(Y_HOMING_SENSITIVITY))
  671. #define Z_SENSORLESS (ENABLED(Z_IS_TMC2130) && defined(Z_HOMING_SENSITIVITY))
  672. #endif
  673. // Endstops and bed probe
  674. #define HAS_STOP_TEST(A,M) (PIN_EXISTS(A##_##M) && !IS_X2_ENDSTOP(A,M) && !IS_Y2_ENDSTOP(A,M) && !IS_Z2_OR_PROBE(A,M))
  675. #define HAS_X_MIN HAS_STOP_TEST(X,MIN)
  676. #define HAS_X_MAX HAS_STOP_TEST(X,MAX)
  677. #define HAS_Y_MIN HAS_STOP_TEST(Y,MIN)
  678. #define HAS_Y_MAX HAS_STOP_TEST(Y,MAX)
  679. #define HAS_Z_MIN HAS_STOP_TEST(Z,MIN)
  680. #define HAS_Z_MAX HAS_STOP_TEST(Z,MAX)
  681. #define HAS_X2_MIN (PIN_EXISTS(X2_MIN))
  682. #define HAS_X2_MAX (PIN_EXISTS(X2_MAX))
  683. #define HAS_Y2_MIN (PIN_EXISTS(Y2_MIN))
  684. #define HAS_Y2_MAX (PIN_EXISTS(Y2_MAX))
  685. #define HAS_Z2_MIN (PIN_EXISTS(Z2_MIN))
  686. #define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX))
  687. #define HAS_Z_MIN_PROBE_PIN (PIN_EXISTS(Z_MIN_PROBE))
  688. // ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface)
  689. #define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && DISABLED(HEATER_##P##_USES_MAX6675))
  690. #define HAS_TEMP_ADC_0 HAS_ADC_TEST(0)
  691. #define HAS_TEMP_ADC_1 HAS_ADC_TEST(1)
  692. #define HAS_TEMP_ADC_2 HAS_ADC_TEST(2)
  693. #define HAS_TEMP_ADC_3 HAS_ADC_TEST(3)
  694. #define HAS_TEMP_ADC_4 HAS_ADC_TEST(4)
  695. #define HAS_TEMP_ADC_BED HAS_ADC_TEST(BED)
  696. #define HAS_TEMP_ADC_CHAMBER HAS_ADC_TEST(CHAMBER)
  697. #define HAS_TEMP_HOTEND (HAS_TEMP_ADC_0 || ENABLED(HEATER_0_USES_MAX6675))
  698. #define HAS_TEMP_BED HAS_TEMP_ADC_BED
  699. #define HAS_TEMP_CHAMBER HAS_TEMP_ADC_CHAMBER
  700. // Heaters
  701. #define HAS_HEATER_0 (PIN_EXISTS(HEATER_0))
  702. #define HAS_HEATER_1 (PIN_EXISTS(HEATER_1))
  703. #define HAS_HEATER_2 (PIN_EXISTS(HEATER_2))
  704. #define HAS_HEATER_3 (PIN_EXISTS(HEATER_3))
  705. #define HAS_HEATER_4 (PIN_EXISTS(HEATER_4))
  706. #define HAS_HEATER_BED (PIN_EXISTS(HEATER_BED))
  707. // Shorthand for common combinations
  708. #define HAS_HEATED_BED (HAS_TEMP_BED && HAS_HEATER_BED)
  709. #define HAS_TEMP_SENSOR (HAS_TEMP_HOTEND || HAS_HEATED_BED || HAS_TEMP_CHAMBER)
  710. // PID heating
  711. #if !HAS_HEATED_BED
  712. #undef PIDTEMPBED
  713. #endif
  714. #define HAS_PID_HEATING (ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED))
  715. #define HAS_PID_FOR_BOTH (ENABLED(PIDTEMP) && ENABLED(PIDTEMPBED))
  716. // Thermal protection
  717. #define HAS_THERMALLY_PROTECTED_BED (HAS_HEATED_BED && ENABLED(THERMAL_PROTECTION_BED))
  718. #define WATCH_HOTENDS (ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0)
  719. #define WATCH_THE_BED (HAS_THERMALLY_PROTECTED_BED && WATCH_BED_TEMP_PERIOD > 0)
  720. // Auto fans
  721. #define HAS_AUTO_FAN_0 (PIN_EXISTS(E0_AUTO_FAN))
  722. #define HAS_AUTO_FAN_1 (HOTENDS > 1 && PIN_EXISTS(E1_AUTO_FAN))
  723. #define HAS_AUTO_FAN_2 (HOTENDS > 2 && PIN_EXISTS(E2_AUTO_FAN))
  724. #define HAS_AUTO_FAN_3 (HOTENDS > 3 && PIN_EXISTS(E3_AUTO_FAN))
  725. #define HAS_AUTO_FAN_4 (HOTENDS > 4 && PIN_EXISTS(E4_AUTO_FAN))
  726. #define HAS_AUTO_CHAMBER_FAN (PIN_EXISTS(CHAMBER_AUTO_FAN))
  727. #define HAS_AUTO_FAN (HAS_AUTO_FAN_0 || HAS_AUTO_FAN_1 || HAS_AUTO_FAN_2 || HAS_AUTO_FAN_3 || HAS_AUTO_CHAMBER_FAN)
  728. #define AUTO_1_IS_0 (E1_AUTO_FAN_PIN == E0_AUTO_FAN_PIN)
  729. #define AUTO_2_IS_0 (E2_AUTO_FAN_PIN == E0_AUTO_FAN_PIN)
  730. #define AUTO_2_IS_1 (E2_AUTO_FAN_PIN == E1_AUTO_FAN_PIN)
  731. #define AUTO_3_IS_0 (E3_AUTO_FAN_PIN == E0_AUTO_FAN_PIN)
  732. #define AUTO_3_IS_1 (E3_AUTO_FAN_PIN == E1_AUTO_FAN_PIN)
  733. #define AUTO_3_IS_2 (E3_AUTO_FAN_PIN == E2_AUTO_FAN_PIN)
  734. #define AUTO_4_IS_0 (E4_AUTO_FAN_PIN == E0_AUTO_FAN_PIN)
  735. #define AUTO_4_IS_1 (E4_AUTO_FAN_PIN == E1_AUTO_FAN_PIN)
  736. #define AUTO_4_IS_2 (E4_AUTO_FAN_PIN == E2_AUTO_FAN_PIN)
  737. #define AUTO_4_IS_3 (E4_AUTO_FAN_PIN == E3_AUTO_FAN_PIN)
  738. #define AUTO_CHAMBER_IS_0 (CHAMBER_AUTO_FAN_PIN == E0_AUTO_FAN_PIN)
  739. #define AUTO_CHAMBER_IS_1 (CHAMBER_AUTO_FAN_PIN == E1_AUTO_FAN_PIN)
  740. #define AUTO_CHAMBER_IS_2 (CHAMBER_AUTO_FAN_PIN == E2_AUTO_FAN_PIN)
  741. #define AUTO_CHAMBER_IS_3 (CHAMBER_AUTO_FAN_PIN == E3_AUTO_FAN_PIN)
  742. #define AUTO_CHAMBER_IS_4 (CHAMBER_AUTO_FAN_PIN == E4_AUTO_FAN_PIN)
  743. // Other fans
  744. #define HAS_FAN0 (PIN_EXISTS(FAN))
  745. #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)
  746. #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)
  747. #define HAS_CONTROLLER_FAN (PIN_EXISTS(CONTROLLER_FAN))
  748. // Servos
  749. #define HAS_SERVO_0 (PIN_EXISTS(SERVO0))
  750. #define HAS_SERVO_1 (PIN_EXISTS(SERVO1))
  751. #define HAS_SERVO_2 (PIN_EXISTS(SERVO2))
  752. #define HAS_SERVO_3 (PIN_EXISTS(SERVO3))
  753. #define HAS_SERVOS (defined(NUM_SERVOS) && NUM_SERVOS > 0)
  754. #if HAS_SERVOS && !defined(Z_PROBE_SERVO_NR)
  755. #define Z_PROBE_SERVO_NR -1
  756. #endif
  757. // Sensors
  758. #define HAS_FILAMENT_WIDTH_SENSOR (PIN_EXISTS(FILWIDTH))
  759. // User Interface
  760. #define HAS_HOME (PIN_EXISTS(HOME))
  761. #define HAS_KILL (PIN_EXISTS(KILL))
  762. #define HAS_SUICIDE (PIN_EXISTS(SUICIDE))
  763. #define HAS_PHOTOGRAPH (PIN_EXISTS(PHOTOGRAPH))
  764. #define HAS_BUZZER (PIN_EXISTS(BEEPER) || ENABLED(LCD_USE_I2C_BUZZER))
  765. #define HAS_CASE_LIGHT (PIN_EXISTS(CASE_LIGHT) && ENABLED(CASE_LIGHT_ENABLE))
  766. // Digital control
  767. #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)
  768. #define HAS_STEPPER_RESET (PIN_EXISTS(STEPPER_RESET))
  769. #define HAS_DIGIPOTSS (PIN_EXISTS(DIGIPOTSS))
  770. #define HAS_MOTOR_CURRENT_PWM (PIN_EXISTS(MOTOR_CURRENT_PWM_XY) || PIN_EXISTS(MOTOR_CURRENT_PWM_Z) || PIN_EXISTS(MOTOR_CURRENT_PWM_E))
  771. #if !HAS_TEMP_SENSOR
  772. #undef AUTO_REPORT_TEMPERATURES
  773. #endif
  774. #define HAS_AUTO_REPORTING (ENABLED(AUTO_REPORT_TEMPERATURES) || ENABLED(AUTO_REPORT_SD_STATUS))
  775. /**
  776. * This setting is also used by M109 when trying to calculate
  777. * a ballpark safe margin to prevent wait-forever situation.
  778. */
  779. #ifndef EXTRUDE_MINTEMP
  780. #define EXTRUDE_MINTEMP 170
  781. #endif
  782. /**
  783. * Heater signal inversion defaults
  784. */
  785. #if HAS_HEATER_0 && !defined(HEATER_0_INVERTING)
  786. #define HEATER_0_INVERTING false
  787. #endif
  788. #if HAS_HEATER_1 && !defined(HEATER_1_INVERTING)
  789. #define HEATER_1_INVERTING false
  790. #endif
  791. #if HAS_HEATER_2 && !defined(HEATER_2_INVERTING)
  792. #define HEATER_2_INVERTING false
  793. #endif
  794. #if HAS_HEATER_3 && !defined(HEATER_3_INVERTING)
  795. #define HEATER_3_INVERTING false
  796. #endif
  797. #if HAS_HEATER_4 && !defined(HEATER_4_INVERTING)
  798. #define HEATER_4_INVERTING false
  799. #endif
  800. /**
  801. * Helper Macros for heaters and extruder fan
  802. */
  803. #define WRITE_HEATER_0P(v) WRITE(HEATER_0_PIN, (v) ^ HEATER_0_INVERTING)
  804. #if HOTENDS > 1 || ENABLED(HEATERS_PARALLEL)
  805. #define WRITE_HEATER_1(v) WRITE(HEATER_1_PIN, (v) ^ HEATER_1_INVERTING)
  806. #if HOTENDS > 2
  807. #define WRITE_HEATER_2(v) WRITE(HEATER_2_PIN, (v) ^ HEATER_2_INVERTING)
  808. #if HOTENDS > 3
  809. #define WRITE_HEATER_3(v) WRITE(HEATER_3_PIN, (v) ^ HEATER_3_INVERTING)
  810. #if HOTENDS > 4
  811. #define WRITE_HEATER_4(v) WRITE(HEATER_4_PIN, (v) ^ HEATER_4_INVERTING)
  812. #endif // HOTENDS > 4
  813. #endif // HOTENDS > 3
  814. #endif // HOTENDS > 2
  815. #endif // HOTENDS > 1
  816. #if ENABLED(HEATERS_PARALLEL)
  817. #define WRITE_HEATER_0(v) { WRITE_HEATER_0P(v); WRITE_HEATER_1(v); }
  818. #else
  819. #define WRITE_HEATER_0(v) WRITE_HEATER_0P(v)
  820. #endif
  821. /**
  822. * Heated bed requires settings
  823. */
  824. #if HAS_HEATED_BED
  825. #ifndef MAX_BED_POWER
  826. #define MAX_BED_POWER 255
  827. #endif
  828. #ifndef HEATER_BED_INVERTING
  829. #define HEATER_BED_INVERTING false
  830. #endif
  831. #define WRITE_HEATER_BED(v) WRITE(HEATER_BED_PIN, (v) ^ HEATER_BED_INVERTING)
  832. #endif
  833. /**
  834. * Up to 3 PWM fans
  835. */
  836. #if HAS_FAN2
  837. #define FAN_COUNT 3
  838. #elif HAS_FAN1
  839. #define FAN_COUNT 2
  840. #elif HAS_FAN0
  841. #define FAN_COUNT 1
  842. #else
  843. #define FAN_COUNT 0
  844. #endif
  845. #if HAS_FAN0
  846. #define WRITE_FAN(v) WRITE(FAN_PIN, v)
  847. #define WRITE_FAN0(v) WRITE_FAN(v)
  848. #endif
  849. #if HAS_FAN1
  850. #define WRITE_FAN1(v) WRITE(FAN1_PIN, v)
  851. #endif
  852. #if HAS_FAN2
  853. #define WRITE_FAN2(v) WRITE(FAN2_PIN, v)
  854. #endif
  855. #define WRITE_FAN_N(n, v) WRITE_FAN##n(v)
  856. /**
  857. * Part Cooling fan multipliexer
  858. */
  859. #define HAS_FANMUX PIN_EXISTS(FANMUX0)
  860. /**
  861. * MIN/MAX fan PWM scaling
  862. */
  863. #ifndef FAN_MIN_PWM
  864. #define FAN_MIN_PWM 0
  865. #endif
  866. #ifndef FAN_MAX_PWM
  867. #define FAN_MAX_PWM 255
  868. #endif
  869. #if FAN_MIN_PWM < 0 || FAN_MIN_PWM > 255
  870. #error "FAN_MIN_PWM must be a value from 0 to 255."
  871. #elif FAN_MAX_PWM < 0 || FAN_MAX_PWM > 255
  872. #error "FAN_MAX_PWM must be a value from 0 to 255."
  873. #elif FAN_MIN_PWM > FAN_MAX_PWM
  874. #error "FAN_MIN_PWM must be less than or equal to FAN_MAX_PWM."
  875. #endif
  876. /**
  877. * Bed Probe dependencies
  878. */
  879. #if HAS_BED_PROBE
  880. #if ENABLED(ENDSTOPPULLUPS) && HAS_Z_MIN_PROBE_PIN
  881. #define ENDSTOPPULLUP_ZMIN_PROBE
  882. #endif
  883. #ifndef Z_PROBE_OFFSET_RANGE_MIN
  884. #define Z_PROBE_OFFSET_RANGE_MIN -20
  885. #endif
  886. #ifndef Z_PROBE_OFFSET_RANGE_MAX
  887. #define Z_PROBE_OFFSET_RANGE_MAX 20
  888. #endif
  889. #ifndef XY_PROBE_SPEED
  890. #ifdef HOMING_FEEDRATE_XY
  891. #define XY_PROBE_SPEED HOMING_FEEDRATE_XY
  892. #else
  893. #define XY_PROBE_SPEED 4000
  894. #endif
  895. #endif
  896. #else
  897. #undef X_PROBE_OFFSET_FROM_EXTRUDER
  898. #undef Y_PROBE_OFFSET_FROM_EXTRUDER
  899. #undef Z_PROBE_OFFSET_FROM_EXTRUDER
  900. #define X_PROBE_OFFSET_FROM_EXTRUDER 0
  901. #define Y_PROBE_OFFSET_FROM_EXTRUDER 0
  902. #define Z_PROBE_OFFSET_FROM_EXTRUDER 0
  903. #endif
  904. /**
  905. * XYZ Bed Skew Correction
  906. */
  907. #if ENABLED(SKEW_CORRECTION)
  908. #define SKEW_FACTOR_MIN -1
  909. #define SKEW_FACTOR_MAX 1
  910. #define _GET_SIDE(a,b,c) (SQRT(2*sq(a)+2*sq(b)-4*sq(c))*0.5)
  911. #define _SKEW_SIDE(a,b,c) tan(M_PI*0.5-acos((sq(a)-sq(b)-sq(c))/(2*c*b)))
  912. #define _SKEW_FACTOR(a,b,c) _SKEW_SIDE(float(a),_GET_SIDE(float(a),float(b),float(c)),float(c))
  913. #ifndef XY_SKEW_FACTOR
  914. constexpr float XY_SKEW_FACTOR = (
  915. #if defined(XY_DIAG_AC) && defined(XY_DIAG_BD) && defined(XY_SIDE_AD)
  916. _SKEW_FACTOR(XY_DIAG_AC, XY_DIAG_BD, XY_SIDE_AD)
  917. #else
  918. 0.0
  919. #endif
  920. );
  921. #endif
  922. #ifndef XZ_SKEW_FACTOR
  923. #if defined(XY_SIDE_AD) && !defined(XZ_SIDE_AD)
  924. #define XZ_SIDE_AD XY_SIDE_AD
  925. #endif
  926. constexpr float XZ_SKEW_FACTOR = (
  927. #if defined(XZ_DIAG_AC) && defined(XZ_DIAG_BD) && defined(XZ_SIDE_AD)
  928. _SKEW_FACTOR(XZ_DIAG_AC, XZ_DIAG_BD, XZ_SIDE_AD)
  929. #else
  930. 0.0
  931. #endif
  932. );
  933. #endif
  934. #ifndef YZ_SKEW_FACTOR
  935. constexpr float YZ_SKEW_FACTOR = (
  936. #if defined(YZ_DIAG_AC) && defined(YZ_DIAG_BD) && defined(YZ_SIDE_AD)
  937. _SKEW_FACTOR(YZ_DIAG_AC, YZ_DIAG_BD, YZ_SIDE_AD)
  938. #else
  939. 0.0
  940. #endif
  941. );
  942. #endif
  943. #endif // SKEW_CORRECTION
  944. /**
  945. * Set granular options based on the specific type of leveling
  946. */
  947. #define UBL_SEGMENTED (ENABLED(AUTO_BED_LEVELING_UBL) && (ENABLED(DELTA)))
  948. #define ABL_PLANAR (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_3POINT))
  949. #define ABL_GRID (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR))
  950. #define OLDSCHOOL_ABL (ABL_PLANAR || ABL_GRID)
  951. #define HAS_ABL (OLDSCHOOL_ABL || ENABLED(AUTO_BED_LEVELING_UBL))
  952. #define HAS_LEVELING (HAS_ABL || ENABLED(MESH_BED_LEVELING))
  953. #define HAS_AUTOLEVEL (HAS_ABL && DISABLED(PROBE_MANUALLY))
  954. #define HAS_MESH (ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(MESH_BED_LEVELING))
  955. #define PLANNER_LEVELING (OLDSCHOOL_ABL || ENABLED(MESH_BED_LEVELING) || UBL_SEGMENTED || ENABLED(SKEW_CORRECTION))
  956. #define HAS_PROBING_PROCEDURE (HAS_ABL || ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST))
  957. #define HAS_UBL_AND_CURVES (ENABLED(AUTO_BED_LEVELING_UBL) && !PLANNER_LEVELING && (ENABLED(ARC_SUPPORT) || ENABLED(BEZIER_CURVE_SUPPORT)))
  958. #if ENABLED(AUTO_BED_LEVELING_UBL)
  959. #undef LCD_BED_LEVELING
  960. #endif
  961. /**
  962. * Heater & Fan Pausing
  963. */
  964. #if FAN_COUNT == 0
  965. #undef PROBING_FANS_OFF
  966. #endif
  967. #define QUIET_PROBING (HAS_BED_PROBE && (ENABLED(PROBING_HEATERS_OFF) || ENABLED(PROBING_FANS_OFF) || DELAY_BEFORE_PROBING > 0))
  968. #define HEATER_IDLE_HANDLER (ENABLED(ADVANCED_PAUSE_FEATURE) || ENABLED(PROBING_HEATERS_OFF))
  969. #if ENABLED(ADVANCED_PAUSE_FEATURE) && !defined(FILAMENT_CHANGE_SLOW_LOAD_LENGTH)
  970. #define FILAMENT_CHANGE_SLOW_LOAD_LENGTH 0
  971. #endif
  972. /**
  973. * Only constrain Z on DELTA / SCARA machines
  974. */
  975. #if IS_KINEMATIC
  976. #undef MIN_SOFTWARE_ENDSTOP_X
  977. #undef MIN_SOFTWARE_ENDSTOP_Y
  978. #undef MAX_SOFTWARE_ENDSTOP_X
  979. #undef MAX_SOFTWARE_ENDSTOP_Y
  980. #endif
  981. /**
  982. * Bed Probing rectangular bounds
  983. * These can be further constrained in code for Delta and SCARA
  984. */
  985. #ifndef MIN_PROBE_EDGE
  986. #define MIN_PROBE_EDGE 0
  987. #endif
  988. #if ENABLED(DELTA)
  989. /**
  990. * Delta radius/rod trimmers/angle trimmers
  991. */
  992. #define _PROBE_RADIUS (DELTA_PRINTABLE_RADIUS - (MIN_PROBE_EDGE))
  993. #ifndef DELTA_CALIBRATION_RADIUS
  994. #ifdef X_PROBE_OFFSET_FROM_EXTRUDER
  995. #define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - MAX3(abs(X_PROBE_OFFSET_FROM_EXTRUDER), abs(Y_PROBE_OFFSET_FROM_EXTRUDER), abs(MIN_PROBE_EDGE)))
  996. #else
  997. #define DELTA_CALIBRATION_RADIUS _PROBE_RADIUS
  998. #endif
  999. #endif
  1000. #ifndef DELTA_ENDSTOP_ADJ
  1001. #define DELTA_ENDSTOP_ADJ { 0, 0, 0 }
  1002. #endif
  1003. #ifndef DELTA_TOWER_ANGLE_TRIM
  1004. #define DELTA_TOWER_ANGLE_TRIM {0, 0, 0}
  1005. #endif
  1006. #ifndef DELTA_RADIUS_TRIM_TOWER
  1007. #define DELTA_RADIUS_TRIM_TOWER {0, 0, 0}
  1008. #endif
  1009. #ifndef DELTA_DIAGONAL_ROD_TRIM_TOWER
  1010. #define DELTA_DIAGONAL_ROD_TRIM_TOWER {0, 0, 0}
  1011. #endif
  1012. // Probing points may be verified at compile time within the radius
  1013. // using static_assert(HYPOT2(X2-X1,Y2-Y1)<=sq(DELTA_PRINTABLE_RADIUS),"bad probe point!")
  1014. // so that may be added to SanityCheck.h in the future.
  1015. #define _MIN_PROBE_X (X_CENTER - (_PROBE_RADIUS))
  1016. #define _MIN_PROBE_Y (Y_CENTER - (_PROBE_RADIUS))
  1017. #define _MAX_PROBE_X (X_CENTER + _PROBE_RADIUS)
  1018. #define _MAX_PROBE_Y (Y_CENTER + _PROBE_RADIUS)
  1019. #elif IS_SCARA
  1020. #define SCARA_PRINTABLE_RADIUS (SCARA_LINKAGE_1 + SCARA_LINKAGE_2)
  1021. #define _PROBE_RADIUS (SCARA_PRINTABLE_RADIUS - (MIN_PROBE_EDGE))
  1022. #define _MIN_PROBE_X (X_CENTER - (SCARA_PRINTABLE_RADIUS) + MIN_PROBE_EDGE)
  1023. #define _MIN_PROBE_Y (Y_CENTER - (SCARA_PRINTABLE_RADIUS) + MIN_PROBE_EDGE)
  1024. #define _MAX_PROBE_X (X_CENTER + SCARA_PRINTABLE_RADIUS - (MIN_PROBE_EDGE))
  1025. #define _MAX_PROBE_Y (Y_CENTER + SCARA_PRINTABLE_RADIUS - (MIN_PROBE_EDGE))
  1026. #else
  1027. // Boundaries for Cartesian probing based on bed limits
  1028. #define _MIN_PROBE_X (max(X_MIN_BED + MIN_PROBE_EDGE, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
  1029. #define _MIN_PROBE_Y (max(Y_MIN_BED + MIN_PROBE_EDGE, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
  1030. #define _MAX_PROBE_X (min(X_MAX_BED - (MIN_PROBE_EDGE), X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
  1031. #define _MAX_PROBE_Y (min(Y_MAX_BED - (MIN_PROBE_EDGE), Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
  1032. #endif
  1033. #if ENABLED(SEGMENT_LEVELED_MOVES) && !defined(LEVELED_SEGMENT_LENGTH)
  1034. #define LEVELED_SEGMENT_LENGTH 5
  1035. #endif
  1036. // These may be overridden in Configuration.h if a smaller area is desired
  1037. #ifndef MIN_PROBE_X
  1038. #define MIN_PROBE_X _MIN_PROBE_X
  1039. #endif
  1040. #ifndef MIN_PROBE_Y
  1041. #define MIN_PROBE_Y _MIN_PROBE_Y
  1042. #endif
  1043. #ifndef MAX_PROBE_X
  1044. #define MAX_PROBE_X _MAX_PROBE_X
  1045. #endif
  1046. #ifndef MAX_PROBE_Y
  1047. #define MAX_PROBE_Y _MAX_PROBE_Y
  1048. #endif
  1049. /**
  1050. * Default mesh area is an area with an inset margin on the print area.
  1051. */
  1052. #if ENABLED(MESH_BED_LEVELING) || ENABLED(AUTO_BED_LEVELING_UBL)
  1053. #if IS_KINEMATIC
  1054. // Probing points may be verified at compile time within the radius
  1055. // using static_assert(HYPOT2(X2-X1,Y2-Y1)<=sq(DELTA_PRINTABLE_RADIUS),"bad probe point!")
  1056. // so that may be added to SanityCheck.h in the future.
  1057. #define _MESH_MIN_X (X_MIN_BED + MESH_INSET)
  1058. #define _MESH_MIN_Y (Y_MIN_BED + MESH_INSET)
  1059. #define _MESH_MAX_X (X_MAX_BED - (MESH_INSET))
  1060. #define _MESH_MAX_Y (Y_MAX_BED - (MESH_INSET))
  1061. #else
  1062. // Boundaries for Cartesian probing based on set limits
  1063. #if ENABLED(AUTO_BED_LEVELING_UBL)
  1064. #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
  1065. #define _MESH_MIN_Y (max(Y_MIN_BED + MESH_INSET, Y_MIN_POS)) // need *_PROBE_OFFSET_FROM_EXTRUDER in the mesh dimensions
  1066. #define _MESH_MAX_X (min(X_MAX_BED - (MESH_INSET), X_MAX_POS))
  1067. #define _MESH_MAX_Y (min(Y_MAX_BED - (MESH_INSET), Y_MAX_POS))
  1068. #else
  1069. #define _MESH_MIN_X (max(X_MIN_BED + MESH_INSET, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
  1070. #define _MESH_MIN_Y (max(Y_MIN_BED + MESH_INSET, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
  1071. #define _MESH_MAX_X (min(X_MAX_BED - (MESH_INSET), X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
  1072. #define _MESH_MAX_Y (min(Y_MAX_BED - (MESH_INSET), Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
  1073. #endif
  1074. #endif
  1075. // These may be overridden in Configuration.h if a smaller area is desired
  1076. #ifndef MESH_MIN_X
  1077. #define MESH_MIN_X _MESH_MIN_X
  1078. #endif
  1079. #ifndef MESH_MIN_Y
  1080. #define MESH_MIN_Y _MESH_MIN_Y
  1081. #endif
  1082. #ifndef MESH_MAX_X
  1083. #define MESH_MAX_X _MESH_MAX_X
  1084. #endif
  1085. #ifndef MESH_MAX_Y
  1086. #define MESH_MAX_Y _MESH_MAX_Y
  1087. #endif
  1088. #endif // MESH_BED_LEVELING || AUTO_BED_LEVELING_UBL
  1089. #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(AUTO_BED_LEVELING_3POINT)
  1090. #if IS_KINEMATIC
  1091. #define SIN0 0.0
  1092. #define SIN120 0.866025
  1093. #define SIN240 -0.866025
  1094. #define COS0 1.0
  1095. #define COS120 -0.5
  1096. #define COS240 -0.5
  1097. #ifndef PROBE_PT_1_X
  1098. #define PROBE_PT_1_X (X_CENTER + (_PROBE_RADIUS) * COS0)
  1099. #endif
  1100. #ifndef PROBE_PT_1_Y
  1101. #define PROBE_PT_1_Y (Y_CENTER + (_PROBE_RADIUS) * SIN0)
  1102. #endif
  1103. #ifndef PROBE_PT_2_X
  1104. #define PROBE_PT_2_X (X_CENTER + (_PROBE_RADIUS) * COS120)
  1105. #endif
  1106. #ifndef PROBE_PT_2_Y
  1107. #define PROBE_PT_2_Y (Y_CENTER + (_PROBE_RADIUS) * SIN120)
  1108. #endif
  1109. #ifndef PROBE_PT_3_X
  1110. #define PROBE_PT_3_X (X_CENTER + (_PROBE_RADIUS) * COS240)
  1111. #endif
  1112. #ifndef PROBE_PT_3_Y
  1113. #define PROBE_PT_3_Y (Y_CENTER + (_PROBE_RADIUS) * SIN240)
  1114. #endif
  1115. #else
  1116. #ifndef PROBE_PT_1_X
  1117. #define PROBE_PT_1_X MIN_PROBE_X
  1118. #endif
  1119. #ifndef PROBE_PT_1_Y
  1120. #define PROBE_PT_1_Y MIN_PROBE_Y
  1121. #endif
  1122. #ifndef PROBE_PT_2_X
  1123. #define PROBE_PT_2_X MAX_PROBE_X
  1124. #endif
  1125. #ifndef PROBE_PT_2_Y
  1126. #define PROBE_PT_2_Y MIN_PROBE_Y
  1127. #endif
  1128. #ifndef PROBE_PT_3_X
  1129. #define PROBE_PT_3_X X_CENTER
  1130. #endif
  1131. #ifndef PROBE_PT_3_Y
  1132. #define PROBE_PT_3_Y MAX_PROBE_Y
  1133. #endif
  1134. #endif
  1135. #endif
  1136. #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
  1137. #ifndef LEFT_PROBE_BED_POSITION
  1138. #define LEFT_PROBE_BED_POSITION MIN_PROBE_X
  1139. #endif
  1140. #ifndef RIGHT_PROBE_BED_POSITION
  1141. #define RIGHT_PROBE_BED_POSITION MAX_PROBE_X
  1142. #endif
  1143. #ifndef FRONT_PROBE_BED_POSITION
  1144. #define FRONT_PROBE_BED_POSITION MIN_PROBE_Y
  1145. #endif
  1146. #ifndef BACK_PROBE_BED_POSITION
  1147. #define BACK_PROBE_BED_POSITION MAX_PROBE_Y
  1148. #endif
  1149. #endif
  1150. /**
  1151. * Buzzer/Speaker
  1152. */
  1153. #if ENABLED(LCD_USE_I2C_BUZZER)
  1154. #ifndef LCD_FEEDBACK_FREQUENCY_HZ
  1155. #define LCD_FEEDBACK_FREQUENCY_HZ 1000
  1156. #endif
  1157. #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
  1158. #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100
  1159. #endif
  1160. #else
  1161. #ifndef LCD_FEEDBACK_FREQUENCY_HZ
  1162. #define LCD_FEEDBACK_FREQUENCY_HZ 5000
  1163. #endif
  1164. #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
  1165. #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2
  1166. #endif
  1167. #endif
  1168. /**
  1169. * VIKI2, miniVIKI, AZSMZ_12864, and MKS_12864OLED_SSD1306 require DOGLCD_SCK and DOGLCD_MOSI to be defined.
  1170. */
  1171. #if ENABLED(VIKI2) || ENABLED(miniVIKI) || ENABLED(AZSMZ_12864) || ENABLED(MKS_12864OLED_SSD1306)
  1172. #ifndef DOGLCD_SCK
  1173. #define DOGLCD_SCK SCK_PIN
  1174. #endif
  1175. #ifndef DOGLCD_MOSI
  1176. #define DOGLCD_MOSI MOSI_PIN
  1177. #endif
  1178. #endif
  1179. /**
  1180. * Z_HOMING_HEIGHT / Z_CLEARANCE_BETWEEN_PROBES
  1181. */
  1182. #ifndef Z_HOMING_HEIGHT
  1183. #ifndef Z_CLEARANCE_BETWEEN_PROBES
  1184. #define Z_HOMING_HEIGHT 0
  1185. #else
  1186. #define Z_HOMING_HEIGHT Z_CLEARANCE_BETWEEN_PROBES
  1187. #endif
  1188. #endif
  1189. #ifndef Z_CLEARANCE_BETWEEN_PROBES
  1190. #define Z_CLEARANCE_BETWEEN_PROBES Z_HOMING_HEIGHT
  1191. #endif
  1192. #if Z_CLEARANCE_BETWEEN_PROBES > Z_HOMING_HEIGHT
  1193. #define MANUAL_PROBE_HEIGHT Z_CLEARANCE_BETWEEN_PROBES
  1194. #else
  1195. #define MANUAL_PROBE_HEIGHT Z_HOMING_HEIGHT
  1196. #endif
  1197. #ifndef __SAM3X8E__ //todo: hal: broken hal encapsulation
  1198. #undef UI_VOLTAGE_LEVEL
  1199. #undef RADDS_DISPLAY
  1200. #undef MOTOR_CURRENT
  1201. #endif
  1202. // Updated G92 behavior shifts the workspace
  1203. #define HAS_POSITION_SHIFT DISABLED(NO_WORKSPACE_OFFSETS)
  1204. // The home offset also shifts the coordinate space
  1205. #define HAS_HOME_OFFSET (DISABLED(NO_WORKSPACE_OFFSETS) && DISABLED(DELTA))
  1206. // Either offset yields extra calculations on all moves
  1207. #define HAS_WORKSPACE_OFFSET (HAS_POSITION_SHIFT || HAS_HOME_OFFSET)
  1208. // M206 doesn't apply to DELTA
  1209. #define HAS_M206_COMMAND (HAS_HOME_OFFSET && DISABLED(DELTA))
  1210. // LCD timeout to status screen default is 15s
  1211. #ifndef LCD_TIMEOUT_TO_STATUS
  1212. #define LCD_TIMEOUT_TO_STATUS 15000
  1213. #endif
  1214. // Shorthand
  1215. #define GRID_MAX_POINTS ((GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y))
  1216. // Add commands that need sub-codes to this list
  1217. #define USE_GCODE_SUBCODES ENABLED(G38_PROBE_TARGET) || ENABLED(CNC_COORDINATE_SYSTEMS) || ENABLED(POWER_LOSS_RECOVERY)
  1218. // Parking Extruder
  1219. #if ENABLED(PARKING_EXTRUDER)
  1220. #ifndef PARKING_EXTRUDER_GRAB_DISTANCE
  1221. #define PARKING_EXTRUDER_GRAB_DISTANCE 0
  1222. #endif
  1223. #ifndef PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE
  1224. #define PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE HIGH
  1225. #endif
  1226. #endif
  1227. // Use float instead of double. Needs profiling.
  1228. #if defined(ARDUINO_ARCH_SAM) && ENABLED(DELTA_FAST_SQRT)
  1229. #undef ATAN2
  1230. #undef FABS
  1231. #undef POW
  1232. #undef SQRT
  1233. #undef CEIL
  1234. #undef FLOOR
  1235. #undef LROUND
  1236. #undef FMOD
  1237. #define ATAN2(y, x) atan2f(y, x)
  1238. #define POW(x, y) powf(x, y)
  1239. #define SQRT(x) sqrtf(x)
  1240. #define CEIL(x) ceilf(x)
  1241. #define FLOOR(x) floorf(x)
  1242. #define LROUND(x) lroundf(x)
  1243. #define FMOD(x, y) fmodf(x, y)
  1244. #endif
  1245. // Number of VFAT entries used. Each entry has 13 UTF-16 characters
  1246. #if ENABLED(SCROLL_LONG_FILENAMES)
  1247. #define MAX_VFAT_ENTRIES (5)
  1248. #else
  1249. #define MAX_VFAT_ENTRIES (2)
  1250. #endif
  1251. // Set defaults for unspecified LED user colors
  1252. #if ENABLED(LED_CONTROL_MENU)
  1253. #ifndef LED_USER_PRESET_RED
  1254. #define LED_USER_PRESET_RED 255
  1255. #endif
  1256. #ifndef LED_USER_PRESET_GREEN
  1257. #define LED_USER_PRESET_GREEN 255
  1258. #endif
  1259. #ifndef LED_USER_PRESET_BLUE
  1260. #define LED_USER_PRESET_BLUE 255
  1261. #endif
  1262. #ifndef LED_USER_PRESET_WHITE
  1263. #define LED_USER_PRESET_WHITE 0
  1264. #endif
  1265. #ifndef LED_USER_PRESET_BRIGHTNESS
  1266. #ifdef NEOPIXEL_BRIGHTNESS
  1267. #define LED_USER_PRESET_BRIGHTNESS NEOPIXEL_BRIGHTNESS
  1268. #else
  1269. #define LED_USER_PRESET_BRIGHTNESS 255
  1270. #endif
  1271. #endif
  1272. #endif
  1273. // Nozzle park
  1274. #if ENABLED(NOZZLE_PARK_FEATURE) && ENABLED(DELTA)
  1275. #undef NOZZLE_PARK_Z_FEEDRATE
  1276. #define NOZZLE_PARK_Z_FEEDRATE NOZZLE_PARK_XY_FEEDRATE
  1277. #endif
  1278. // Force SDCARD_SORT_ALPHA to be enabled for Graphical LCD on LPC1768
  1279. // because of a bug in the shared SPI implementation. (See #8122)
  1280. #if defined(TARGET_LPC1768) && ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
  1281. #define SDCARD_SORT_ALPHA // Keeps one directory level in RAM. Changing
  1282. // directory levels still glitches the screen,
  1283. // but the following LCD update cleans it up.
  1284. #undef SDSORT_LIMIT
  1285. #undef SDSORT_USES_RAM
  1286. #undef SDSORT_USES_STACK
  1287. #undef SDSORT_CACHE_NAMES
  1288. #define SDSORT_LIMIT 64
  1289. #define SDSORT_USES_RAM true
  1290. #define SDSORT_USES_STACK false
  1291. #define SDSORT_CACHE_NAMES true
  1292. #ifndef FOLDER_SORTING
  1293. #define FOLDER_SORTING -1
  1294. #endif
  1295. #ifndef SDSORT_GCODE
  1296. #define SDSORT_GCODE false
  1297. #endif
  1298. #ifndef SDSORT_DYNAMIC_RAM
  1299. #define SDSORT_DYNAMIC_RAM false
  1300. #endif
  1301. #ifndef SDSORT_CACHE_VFATS
  1302. #define SDSORT_CACHE_VFATS 2
  1303. #endif
  1304. #endif
  1305. // needs to be here so that we catch the above changes to our defines
  1306. #if ENABLED(SDCARD_SORT_ALPHA)
  1307. #define HAS_FOLDER_SORTING (FOLDER_SORTING || ENABLED(SDSORT_GCODE))
  1308. #endif
  1309. // If platform requires early initialization of watchdog to properly boot
  1310. #define EARLY_WATCHDOG (ENABLED(USE_WATCHDOG) && defined(ARDUINO_ARCH_SAM))
  1311. #if ENABLED(G29_RETRY_AND_RECOVER)
  1312. #define USE_EXECUTE_COMMANDS_IMMEDIATE
  1313. #endif
  1314. //
  1315. // Estimate the amount of time the ISR will take to execute
  1316. //
  1317. #ifdef CPU_32_BIT
  1318. // The base ISR takes 792 cycles
  1319. #define ISR_BASE_CYCLES 792UL
  1320. // Linear advance base time is 64 cycles
  1321. #if ENABLED(LIN_ADVANCE)
  1322. #define ISR_LA_BASE_CYCLES 64UL
  1323. #else
  1324. #define ISR_LA_BASE_CYCLES 0UL
  1325. #endif
  1326. // S curve interpolation adds 40 cycles
  1327. #if ENABLED(S_CURVE_ACCELERATION)
  1328. #define ISR_S_CURVE_CYCLES 40UL
  1329. #else
  1330. #define ISR_S_CURVE_CYCLES 0UL
  1331. #endif
  1332. // Stepper Loop base cycles
  1333. #define ISR_LOOP_BASE_CYCLES 4UL
  1334. // And each stepper takes 16 cycles
  1335. #define ISR_STEPPER_CYCLES 16UL
  1336. #else
  1337. // The base ISR takes 752 cycles
  1338. #define ISR_BASE_CYCLES 752UL
  1339. // Linear advance base time is 32 cycles
  1340. #if ENABLED(LIN_ADVANCE)
  1341. #define ISR_LA_BASE_CYCLES 32UL
  1342. #else
  1343. #define ISR_LA_BASE_CYCLES 0UL
  1344. #endif
  1345. // S curve interpolation adds 160 cycles
  1346. #if ENABLED(S_CURVE_ACCELERATION)
  1347. #define ISR_S_CURVE_CYCLES 160UL
  1348. #else
  1349. #define ISR_S_CURVE_CYCLES 0UL
  1350. #endif
  1351. // Stepper Loop base cycles
  1352. #define ISR_LOOP_BASE_CYCLES 32UL
  1353. // And each stepper takes 88 cycles
  1354. #define ISR_STEPPER_CYCLES 88UL
  1355. #endif
  1356. // For each stepper, we add its time
  1357. #ifdef HAS_X_STEP
  1358. #define ISR_X_STEPPER_CYCLES ISR_STEPPER_CYCLES
  1359. #else
  1360. #define ISR_X_STEPPER_CYCLES 0UL
  1361. #endif
  1362. // For each stepper, we add its time
  1363. #ifdef HAS_Y_STEP
  1364. #define ISR_Y_STEPPER_CYCLES ISR_STEPPER_CYCLES
  1365. #else
  1366. #define ISR_Y_STEPPER_CYCLES 0UL
  1367. #endif
  1368. // For each stepper, we add its time
  1369. #ifdef HAS_Z_STEP
  1370. #define ISR_Z_STEPPER_CYCLES ISR_STEPPER_CYCLES
  1371. #else
  1372. #define ISR_Z_STEPPER_CYCLES 0UL
  1373. #endif
  1374. // E is always interpolated, even for mixing extruders
  1375. #define ISR_E_STEPPER_CYCLES ISR_STEPPER_CYCLES
  1376. // If linear advance is disabled, then the loop also handles them
  1377. #if DISABLED(LIN_ADVANCE) && ENABLED(MIXING_EXTRUDER)
  1378. #define ISR_MIXING_STEPPER_CYCLES ((MIXING_STEPPERS) * ISR_STEPPER_CYCLES)
  1379. #else
  1380. #define ISR_MIXING_STEPPER_CYCLES 0UL
  1381. #endif
  1382. // And the total minimum loop time is, without including the base
  1383. #define MIN_ISR_LOOP_CYCLES (ISR_X_STEPPER_CYCLES + ISR_Y_STEPPER_CYCLES + ISR_Z_STEPPER_CYCLES + ISR_E_STEPPER_CYCLES + ISR_MIXING_STEPPER_CYCLES)
  1384. // But the user could be enforcing a minimum time, so the loop time is
  1385. #define ISR_LOOP_CYCLES (ISR_LOOP_BASE_CYCLES + ((MINIMUM_STEPPER_PULSE*2UL) > MIN_ISR_LOOP_CYCLES ? (MINIMUM_STEPPER_PULSE*2UL) : MIN_ISR_LOOP_CYCLES))
  1386. // If linear advance is enabled, then it is handled separately
  1387. #if ENABLED(LIN_ADVANCE)
  1388. // Estimate the minimum LA loop time
  1389. #if ENABLED(MIXING_EXTRUDER)
  1390. #define MIN_ISR_LA_LOOP_CYCLES ((MIXING_STEPPERS) * (ISR_STEPPER_CYCLES))
  1391. #else
  1392. #define MIN_ISR_LA_LOOP_CYCLES ISR_STEPPER_CYCLES
  1393. #endif
  1394. // And the real loop time
  1395. #define ISR_LA_LOOP_CYCLES ((MINIMUM_STEPPER_PULSE*2UL) > MIN_ISR_LA_LOOP_CYCLES ? (MINIMUM_STEPPER_PULSE*2UL) : MIN_ISR_LA_LOOP_CYCLES)
  1396. #else
  1397. #define ISR_LA_LOOP_CYCLES 0UL
  1398. #endif
  1399. // Now estimate the total ISR execution time in cycles given a step per ISR multiplier
  1400. #define ISR_EXECUTION_CYCLES(rate) (((ISR_BASE_CYCLES + ISR_S_CURVE_CYCLES + (ISR_LOOP_CYCLES * rate) + ISR_LA_BASE_CYCLES + ISR_LA_LOOP_CYCLES)) / rate)
  1401. // The maximum allowable stepping frequency when doing x128-x1 stepping (in Hz)
  1402. #define MAX_128X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(128))
  1403. #define MAX_64X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(64))
  1404. #define MAX_32X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(32))
  1405. #define MAX_16X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(16))
  1406. #define MAX_8X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(8))
  1407. #define MAX_4X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(4))
  1408. #define MAX_2X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(2))
  1409. #define MAX_1X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(1))
  1410. // The minimum allowable frequency for step smoothing will be 1/10 of the maximum nominal frequency (in Hz)
  1411. #define MIN_STEP_ISR_FREQUENCY MAX_1X_STEP_ISR_FREQUENCY
  1412. // Disable multiple steps per ISR
  1413. //#define DISABLE_MULTI_STEPPING
  1414. #endif // CONDITIONALS_POST_H