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 36KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
  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. /**
  186. * Provide a MAX_AUTORETRACT for older configs
  187. */
  188. #if ENABLED(FWRETRACT) && !defined(MAX_AUTORETRACT)
  189. #define MAX_AUTORETRACT 99
  190. #endif
  191. /**
  192. * MAX_STEP_FREQUENCY differs for TOSHIBA
  193. */
  194. #if ENABLED(CONFIG_STEPPERS_TOSHIBA)
  195. #define MAX_STEP_FREQUENCY 10000 // Max step frequency for Toshiba Stepper Controllers
  196. #else
  197. #define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step)
  198. #endif
  199. // MS1 MS2 Stepper Driver Microstepping mode table
  200. #define MICROSTEP1 LOW,LOW
  201. #define MICROSTEP2 HIGH,LOW
  202. #define MICROSTEP4 LOW,HIGH
  203. #define MICROSTEP8 HIGH,HIGH
  204. #define MICROSTEP16 HIGH,HIGH
  205. /**
  206. * Override here because this is set in Configuration_adv.h
  207. */
  208. #if ENABLED(ULTIPANEL) && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER)
  209. #undef SD_DETECT_INVERTED
  210. #endif
  211. /**
  212. * Set defaults for missing (newer) options
  213. */
  214. #ifndef DISABLE_INACTIVE_X
  215. #define DISABLE_INACTIVE_X DISABLE_X
  216. #endif
  217. #ifndef DISABLE_INACTIVE_Y
  218. #define DISABLE_INACTIVE_Y DISABLE_Y
  219. #endif
  220. #ifndef DISABLE_INACTIVE_Z
  221. #define DISABLE_INACTIVE_Z DISABLE_Z
  222. #endif
  223. #ifndef DISABLE_INACTIVE_E
  224. #define DISABLE_INACTIVE_E DISABLE_E
  225. #endif
  226. // Power Signal Control Definitions
  227. // By default use ATX definition
  228. #ifndef POWER_SUPPLY
  229. #define POWER_SUPPLY 1
  230. #endif
  231. #if (POWER_SUPPLY == 1) // 1 = ATX
  232. #define PS_ON_AWAKE LOW
  233. #define PS_ON_ASLEEP HIGH
  234. #elif (POWER_SUPPLY == 2) // 2 = X-Box 360 203W
  235. #define PS_ON_AWAKE HIGH
  236. #define PS_ON_ASLEEP LOW
  237. #endif
  238. #define HAS_POWER_SWITCH (POWER_SUPPLY > 0 && PIN_EXISTS(PS_ON))
  239. /**
  240. * Temp Sensor defines
  241. */
  242. #if TEMP_SENSOR_0 == -3
  243. #define HEATER_0_USES_MAX6675
  244. #define MAX6675_IS_MAX31855
  245. #define MAX6675_TMIN -270
  246. #define MAX6675_TMAX 1800
  247. #elif TEMP_SENSOR_0 == -2
  248. #define HEATER_0_USES_MAX6675
  249. #define MAX6675_TMIN 0
  250. #define MAX6675_TMAX 1024
  251. #elif TEMP_SENSOR_0 == -1
  252. #define HEATER_0_USES_AD595
  253. #elif TEMP_SENSOR_0 == 0
  254. #undef HEATER_0_MINTEMP
  255. #undef HEATER_0_MAXTEMP
  256. #elif TEMP_SENSOR_0 > 0
  257. #define THERMISTORHEATER_0 TEMP_SENSOR_0
  258. #define HEATER_0_USES_THERMISTOR
  259. #endif
  260. #if TEMP_SENSOR_1 <= -2
  261. #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_1"
  262. #elif TEMP_SENSOR_1 == -1
  263. #define HEATER_1_USES_AD595
  264. #elif TEMP_SENSOR_1 == 0
  265. #undef HEATER_1_MINTEMP
  266. #undef HEATER_1_MAXTEMP
  267. #elif TEMP_SENSOR_1 > 0
  268. #define THERMISTORHEATER_1 TEMP_SENSOR_1
  269. #define HEATER_1_USES_THERMISTOR
  270. #endif
  271. #if TEMP_SENSOR_2 <= -2
  272. #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_2"
  273. #elif TEMP_SENSOR_2 == -1
  274. #define HEATER_2_USES_AD595
  275. #elif TEMP_SENSOR_2 == 0
  276. #undef HEATER_2_MINTEMP
  277. #undef HEATER_2_MAXTEMP
  278. #elif TEMP_SENSOR_2 > 0
  279. #define THERMISTORHEATER_2 TEMP_SENSOR_2
  280. #define HEATER_2_USES_THERMISTOR
  281. #endif
  282. #if TEMP_SENSOR_3 <= -2
  283. #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_3"
  284. #elif TEMP_SENSOR_3 == -1
  285. #define HEATER_3_USES_AD595
  286. #elif TEMP_SENSOR_3 == 0
  287. #undef HEATER_3_MINTEMP
  288. #undef HEATER_3_MAXTEMP
  289. #elif TEMP_SENSOR_3 > 0
  290. #define THERMISTORHEATER_3 TEMP_SENSOR_3
  291. #define HEATER_3_USES_THERMISTOR
  292. #endif
  293. #if TEMP_SENSOR_4 <= -2
  294. #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_4"
  295. #elif TEMP_SENSOR_4 == -1
  296. #define HEATER_4_USES_AD595
  297. #elif TEMP_SENSOR_4 == 0
  298. #undef HEATER_4_MINTEMP
  299. #undef HEATER_4_MAXTEMP
  300. #elif TEMP_SENSOR_4 > 0
  301. #define THERMISTORHEATER_4 TEMP_SENSOR_4
  302. #define HEATER_4_USES_THERMISTOR
  303. #endif
  304. #if TEMP_SENSOR_BED <= -2
  305. #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_BED"
  306. #elif TEMP_SENSOR_BED == -1
  307. #define BED_USES_AD595
  308. #elif TEMP_SENSOR_BED == 0
  309. #undef BED_MINTEMP
  310. #undef BED_MAXTEMP
  311. #elif TEMP_SENSOR_BED > 0
  312. #define THERMISTORBED TEMP_SENSOR_BED
  313. #define BED_USES_THERMISTOR
  314. #endif
  315. /**
  316. * Flags for PID handling
  317. */
  318. #define HAS_PID_HEATING (ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED))
  319. #define HAS_PID_FOR_BOTH (ENABLED(PIDTEMP) && ENABLED(PIDTEMPBED))
  320. /**
  321. * Default hotend offsets, if not defined
  322. */
  323. #if HOTENDS > 1
  324. #ifndef HOTEND_OFFSET_X
  325. #define HOTEND_OFFSET_X { 0 } // X offsets for each extruder
  326. #endif
  327. #ifndef HOTEND_OFFSET_Y
  328. #define HOTEND_OFFSET_Y { 0 } // Y offsets for each extruder
  329. #endif
  330. #if !defined(HOTEND_OFFSET_Z) && (ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_NOZZLE))
  331. #define HOTEND_OFFSET_Z { 0 }
  332. #endif
  333. #endif
  334. /**
  335. * ARRAY_BY_EXTRUDERS based on EXTRUDERS
  336. */
  337. #define ARRAY_BY_EXTRUDERS(...) ARRAY_N(EXTRUDERS, __VA_ARGS__)
  338. #define ARRAY_BY_EXTRUDERS1(v1) ARRAY_BY_EXTRUDERS(v1, v1, v1, v1, v1, v1)
  339. /**
  340. * ARRAY_BY_HOTENDS based on HOTENDS
  341. */
  342. #define ARRAY_BY_HOTENDS(...) ARRAY_N(HOTENDS, __VA_ARGS__)
  343. #define ARRAY_BY_HOTENDS1(v1) ARRAY_BY_HOTENDS(v1, v1, v1, v1, v1, v1)
  344. /**
  345. * X_DUAL_ENDSTOPS endstop reassignment
  346. */
  347. #if ENABLED(X_DUAL_ENDSTOPS)
  348. #if X_HOME_DIR > 0
  349. #if X2_USE_ENDSTOP == _XMIN_
  350. #define X2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
  351. #define X2_MAX_PIN X_MIN_PIN
  352. #elif X2_USE_ENDSTOP == _XMAX_
  353. #define X2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
  354. #define X2_MAX_PIN X_MAX_PIN
  355. #elif X2_USE_ENDSTOP == _YMIN_
  356. #define X2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
  357. #define X2_MAX_PIN Y_MIN_PIN
  358. #elif X2_USE_ENDSTOP == _YMAX_
  359. #define X2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
  360. #define X2_MAX_PIN Y_MAX_PIN
  361. #elif X2_USE_ENDSTOP == _ZMIN_
  362. #define X2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
  363. #define X2_MAX_PIN Z_MIN_PIN
  364. #elif X2_USE_ENDSTOP == _ZMAX_
  365. #define X2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
  366. #define X2_MAX_PIN Z_MAX_PIN
  367. #else
  368. #define X2_MAX_ENDSTOP_INVERTING false
  369. #endif
  370. #define X2_MIN_ENDSTOP_INVERTING false
  371. #else
  372. #if X2_USE_ENDSTOP == _XMIN_
  373. #define X2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
  374. #define X2_MIN_PIN X_MIN_PIN
  375. #elif X2_USE_ENDSTOP == _XMAX_
  376. #define X2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
  377. #define X2_MIN_PIN X_MAX_PIN
  378. #elif X2_USE_ENDSTOP == _YMIN_
  379. #define X2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
  380. #define X2_MIN_PIN Y_MIN_PIN
  381. #elif X2_USE_ENDSTOP == _YMAX_
  382. #define X2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
  383. #define X2_MIN_PIN Y_MAX_PIN
  384. #elif X2_USE_ENDSTOP == _ZMIN_
  385. #define X2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
  386. #define X2_MIN_PIN Z_MIN_PIN
  387. #elif X2_USE_ENDSTOP == _ZMAX_
  388. #define X2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
  389. #define X2_MIN_PIN Z_MAX_PIN
  390. #else
  391. #define X2_MIN_ENDSTOP_INVERTING false
  392. #endif
  393. #define X2_MAX_ENDSTOP_INVERTING false
  394. #endif
  395. #endif
  396. // Is an endstop plug used for the X2 endstop?
  397. #define IS_X2_ENDSTOP(A,M) (ENABLED(X_DUAL_ENDSTOPS) && X2_USE_ENDSTOP == _##A##M##_)
  398. /**
  399. * Y_DUAL_ENDSTOPS endstop reassignment
  400. */
  401. #if ENABLED(Y_DUAL_ENDSTOPS)
  402. #if Y_HOME_DIR > 0
  403. #if Y2_USE_ENDSTOP == _XMIN_
  404. #define Y2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
  405. #define Y2_MAX_PIN X_MIN_PIN
  406. #elif Y2_USE_ENDSTOP == _XMAX_
  407. #define Y2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
  408. #define Y2_MAX_PIN X_MAX_PIN
  409. #elif Y2_USE_ENDSTOP == _YMIN_
  410. #define Y2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
  411. #define Y2_MAX_PIN Y_MIN_PIN
  412. #elif Y2_USE_ENDSTOP == _YMAX_
  413. #define Y2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
  414. #define Y2_MAX_PIN Y_MAX_PIN
  415. #elif Y2_USE_ENDSTOP == _ZMIN_
  416. #define Y2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
  417. #define Y2_MAX_PIN Z_MIN_PIN
  418. #elif Y2_USE_ENDSTOP == _ZMAX_
  419. #define Y2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
  420. #define Y2_MAX_PIN Z_MAX_PIN
  421. #else
  422. #define Y2_MAX_ENDSTOP_INVERTING false
  423. #endif
  424. #define Y2_MIN_ENDSTOP_INVERTING false
  425. #else
  426. #if Y2_USE_ENDSTOP == _XMIN_
  427. #define Y2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
  428. #define Y2_MIN_PIN X_MIN_PIN
  429. #elif Y2_USE_ENDSTOP == _XMAX_
  430. #define Y2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
  431. #define Y2_MIN_PIN X_MAX_PIN
  432. #elif Y2_USE_ENDSTOP == _YMIN_
  433. #define Y2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
  434. #define Y2_MIN_PIN Y_MIN_PIN
  435. #elif Y2_USE_ENDSTOP == _YMAX_
  436. #define Y2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
  437. #define Y2_MIN_PIN Y_MAX_PIN
  438. #elif Y2_USE_ENDSTOP == _ZMIN_
  439. #define Y2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
  440. #define Y2_MIN_PIN Z_MIN_PIN
  441. #elif Y2_USE_ENDSTOP == _ZMAX_
  442. #define Y2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
  443. #define Y2_MIN_PIN Z_MAX_PIN
  444. #else
  445. #define Y2_MIN_ENDSTOP_INVERTING false
  446. #endif
  447. #define Y2_MAX_ENDSTOP_INVERTING false
  448. #endif
  449. #endif
  450. // Is an endstop plug used for the Y2 endstop or the bed probe?
  451. #define IS_Y2_ENDSTOP(A,M) (ENABLED(Y_DUAL_ENDSTOPS) && Y2_USE_ENDSTOP == _##A##M##_)
  452. /**
  453. * Z_DUAL_ENDSTOPS endstop reassignment
  454. */
  455. #if ENABLED(Z_DUAL_ENDSTOPS)
  456. #if Z_HOME_DIR > 0
  457. #if Z2_USE_ENDSTOP == _XMIN_
  458. #define Z2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
  459. #define Z2_MAX_PIN X_MIN_PIN
  460. #elif Z2_USE_ENDSTOP == _XMAX_
  461. #define Z2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
  462. #define Z2_MAX_PIN X_MAX_PIN
  463. #elif Z2_USE_ENDSTOP == _YMIN_
  464. #define Z2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
  465. #define Z2_MAX_PIN Y_MIN_PIN
  466. #elif Z2_USE_ENDSTOP == _YMAX_
  467. #define Z2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
  468. #define Z2_MAX_PIN Y_MAX_PIN
  469. #elif Z2_USE_ENDSTOP == _ZMIN_
  470. #define Z2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
  471. #define Z2_MAX_PIN Z_MIN_PIN
  472. #elif Z2_USE_ENDSTOP == _ZMAX_
  473. #define Z2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
  474. #define Z2_MAX_PIN Z_MAX_PIN
  475. #else
  476. #define Z2_MAX_ENDSTOP_INVERTING false
  477. #endif
  478. #define Z2_MIN_ENDSTOP_INVERTING false
  479. #else
  480. #if Z2_USE_ENDSTOP == _XMIN_
  481. #define Z2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
  482. #define Z2_MIN_PIN X_MIN_PIN
  483. #elif Z2_USE_ENDSTOP == _XMAX_
  484. #define Z2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
  485. #define Z2_MIN_PIN X_MAX_PIN
  486. #elif Z2_USE_ENDSTOP == _YMIN_
  487. #define Z2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
  488. #define Z2_MIN_PIN Y_MIN_PIN
  489. #elif Z2_USE_ENDSTOP == _YMAX_
  490. #define Z2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
  491. #define Z2_MIN_PIN Y_MAX_PIN
  492. #elif Z2_USE_ENDSTOP == _ZMIN_
  493. #define Z2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
  494. #define Z2_MIN_PIN Z_MIN_PIN
  495. #elif Z2_USE_ENDSTOP == _ZMAX_
  496. #define Z2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
  497. #define Z2_MIN_PIN Z_MAX_PIN
  498. #else
  499. #define Z2_MIN_ENDSTOP_INVERTING false
  500. #endif
  501. #define Z2_MAX_ENDSTOP_INVERTING false
  502. #endif
  503. #endif
  504. // Is an endstop plug used for the Z2 endstop or the bed probe?
  505. #define IS_Z2_OR_PROBE(A,M) ( \
  506. (ENABLED(Z_DUAL_ENDSTOPS) && Z2_USE_ENDSTOP == _##A##M##_) \
  507. || (ENABLED(Z_MIN_PROBE_ENDSTOP) && Z_MIN_PROBE_PIN == A##_##M##_PIN ) )
  508. /**
  509. * Set ENDSTOPPULLUPS for active endstop switches
  510. */
  511. #if ENABLED(ENDSTOPPULLUPS)
  512. #if ENABLED(USE_XMAX_PLUG)
  513. #define ENDSTOPPULLUP_XMAX
  514. #endif
  515. #if ENABLED(USE_YMAX_PLUG)
  516. #define ENDSTOPPULLUP_YMAX
  517. #endif
  518. #if ENABLED(USE_ZMAX_PLUG)
  519. #define ENDSTOPPULLUP_ZMAX
  520. #endif
  521. #if ENABLED(USE_XMIN_PLUG)
  522. #define ENDSTOPPULLUP_XMIN
  523. #endif
  524. #if ENABLED(USE_YMIN_PLUG)
  525. #define ENDSTOPPULLUP_YMIN
  526. #endif
  527. #if ENABLED(USE_ZMIN_PLUG)
  528. #define ENDSTOPPULLUP_ZMIN
  529. #endif
  530. #endif
  531. /**
  532. * Shorthand for pin tests, used wherever needed
  533. */
  534. // Steppers
  535. #define HAS_X_ENABLE (PIN_EXISTS(X_ENABLE))
  536. #define HAS_X_DIR (PIN_EXISTS(X_DIR))
  537. #define HAS_X_STEP (PIN_EXISTS(X_STEP))
  538. #define HAS_X_MICROSTEPS (PIN_EXISTS(X_MS1))
  539. #define HAS_X2_ENABLE (PIN_EXISTS(X2_ENABLE))
  540. #define HAS_X2_DIR (PIN_EXISTS(X2_DIR))
  541. #define HAS_X2_STEP (PIN_EXISTS(X2_STEP))
  542. #define HAS_Y_MICROSTEPS (PIN_EXISTS(Y_MS1))
  543. #define HAS_Y_ENABLE (PIN_EXISTS(Y_ENABLE))
  544. #define HAS_Y_DIR (PIN_EXISTS(Y_DIR))
  545. #define HAS_Y_STEP (PIN_EXISTS(Y_STEP))
  546. #define HAS_Z_MICROSTEPS (PIN_EXISTS(Z_MS1))
  547. #define HAS_Y2_ENABLE (PIN_EXISTS(Y2_ENABLE))
  548. #define HAS_Y2_DIR (PIN_EXISTS(Y2_DIR))
  549. #define HAS_Y2_STEP (PIN_EXISTS(Y2_STEP))
  550. #define HAS_Z_ENABLE (PIN_EXISTS(Z_ENABLE))
  551. #define HAS_Z_DIR (PIN_EXISTS(Z_DIR))
  552. #define HAS_Z_STEP (PIN_EXISTS(Z_STEP))
  553. #define HAS_Z2_ENABLE (PIN_EXISTS(Z2_ENABLE))
  554. #define HAS_Z2_DIR (PIN_EXISTS(Z2_DIR))
  555. #define HAS_Z2_STEP (PIN_EXISTS(Z2_STEP))
  556. // Extruder steppers and solenoids
  557. #define HAS_E0_ENABLE (PIN_EXISTS(E0_ENABLE))
  558. #define HAS_E0_DIR (PIN_EXISTS(E0_DIR))
  559. #define HAS_E0_STEP (PIN_EXISTS(E0_STEP))
  560. #define HAS_E0_MICROSTEPS (PIN_EXISTS(E0_MS1))
  561. #define HAS_SOLENOID_0 (PIN_EXISTS(SOL0))
  562. #define HAS_E1_ENABLE (PIN_EXISTS(E1_ENABLE))
  563. #define HAS_E1_DIR (PIN_EXISTS(E1_DIR))
  564. #define HAS_E1_STEP (PIN_EXISTS(E1_STEP))
  565. #define HAS_E1_MICROSTEPS (PIN_EXISTS(E1_MS1))
  566. #define HAS_SOLENOID_1 (PIN_EXISTS(SOL1))
  567. #define HAS_E2_ENABLE (PIN_EXISTS(E2_ENABLE))
  568. #define HAS_E2_DIR (PIN_EXISTS(E2_DIR))
  569. #define HAS_E2_STEP (PIN_EXISTS(E2_STEP))
  570. #define HAS_E2_MICROSTEPS (PIN_EXISTS(E2_MS1))
  571. #define HAS_SOLENOID_2 (PIN_EXISTS(SOL2))
  572. #define HAS_E3_ENABLE (PIN_EXISTS(E3_ENABLE))
  573. #define HAS_E3_DIR (PIN_EXISTS(E3_DIR))
  574. #define HAS_E3_STEP (PIN_EXISTS(E3_STEP))
  575. #define HAS_E3_MICROSTEPS (PIN_EXISTS(E3_MS1))
  576. #define HAS_SOLENOID_3 (PIN_EXISTS(SOL3))
  577. #define HAS_E4_ENABLE (PIN_EXISTS(E4_ENABLE))
  578. #define HAS_E4_DIR (PIN_EXISTS(E4_DIR))
  579. #define HAS_E4_STEP (PIN_EXISTS(E4_STEP))
  580. #define HAS_E4_MICROSTEPS (PIN_EXISTS(E4_MS1))
  581. #define HAS_SOLENOID_4 (PIN_EXISTS(SOL4))
  582. // Endstops and bed probe
  583. #define HAS_X_MIN (PIN_EXISTS(X_MIN) && !IS_X2_ENDSTOP(X,MIN) && !IS_Y2_ENDSTOP(X,MIN) && !IS_Z2_OR_PROBE(X,MIN))
  584. #define HAS_X_MAX (PIN_EXISTS(X_MAX) && !IS_X2_ENDSTOP(X,MAX) && !IS_Y2_ENDSTOP(X,MAX) && !IS_Z2_OR_PROBE(X,MAX))
  585. #define HAS_Y_MIN (PIN_EXISTS(Y_MIN) && !IS_X2_ENDSTOP(Y,MIN) && !IS_Y2_ENDSTOP(Y,MIN) && !IS_Z2_OR_PROBE(Y,MIN))
  586. #define HAS_Y_MAX (PIN_EXISTS(Y_MAX) && !IS_X2_ENDSTOP(Y,MAX) && !IS_Y2_ENDSTOP(Y,MAX) && !IS_Z2_OR_PROBE(Y,MAX))
  587. #define HAS_Z_MIN (PIN_EXISTS(Z_MIN) && !IS_X2_ENDSTOP(Z,MIN) && !IS_Y2_ENDSTOP(Z,MIN) && !IS_Z2_OR_PROBE(Z,MIN))
  588. #define HAS_Z_MAX (PIN_EXISTS(Z_MAX) && !IS_X2_ENDSTOP(Z,MAX) && !IS_Y2_ENDSTOP(Z,MAX) && !IS_Z2_OR_PROBE(Z,MAX))
  589. #define HAS_X2_MIN (PIN_EXISTS(X2_MIN))
  590. #define HAS_X2_MAX (PIN_EXISTS(X2_MAX))
  591. #define HAS_Y2_MIN (PIN_EXISTS(Y2_MIN))
  592. #define HAS_Y2_MAX (PIN_EXISTS(Y2_MAX))
  593. #define HAS_Z2_MIN (PIN_EXISTS(Z2_MIN))
  594. #define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX))
  595. #define HAS_Z_MIN_PROBE_PIN (PIN_EXISTS(Z_MIN_PROBE))
  596. // Thermistors
  597. #define HAS_TEMP_0 (PIN_EXISTS(TEMP_0) && TEMP_SENSOR_0 != 0 && TEMP_SENSOR_0 > -2)
  598. #define HAS_TEMP_1 (PIN_EXISTS(TEMP_1) && TEMP_SENSOR_1 != 0 && TEMP_SENSOR_1 > -2)
  599. #define HAS_TEMP_2 (PIN_EXISTS(TEMP_2) && TEMP_SENSOR_2 != 0 && TEMP_SENSOR_2 > -2)
  600. #define HAS_TEMP_3 (PIN_EXISTS(TEMP_3) && TEMP_SENSOR_3 != 0 && TEMP_SENSOR_3 > -2)
  601. #define HAS_TEMP_4 (PIN_EXISTS(TEMP_4) && TEMP_SENSOR_4 != 0 && TEMP_SENSOR_4 > -2)
  602. #define HAS_TEMP_HOTEND (HAS_TEMP_0 || ENABLED(HEATER_0_USES_MAX6675))
  603. #define HAS_TEMP_BED (PIN_EXISTS(TEMP_BED) && TEMP_SENSOR_BED != 0 && TEMP_SENSOR_BED > -2)
  604. // Heaters
  605. #define HAS_HEATER_0 (PIN_EXISTS(HEATER_0))
  606. #define HAS_HEATER_1 (PIN_EXISTS(HEATER_1))
  607. #define HAS_HEATER_2 (PIN_EXISTS(HEATER_2))
  608. #define HAS_HEATER_3 (PIN_EXISTS(HEATER_3))
  609. #define HAS_HEATER_4 (PIN_EXISTS(HEATER_4))
  610. #define HAS_HEATER_BED (PIN_EXISTS(HEATER_BED))
  611. // Thermal protection
  612. #define HAS_THERMALLY_PROTECTED_BED (ENABLED(THERMAL_PROTECTION_BED) && HAS_TEMP_BED && HAS_HEATER_BED)
  613. #define WATCH_HOTENDS (ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0)
  614. #define WATCH_THE_BED (HAS_THERMALLY_PROTECTED_BED && WATCH_BED_TEMP_PERIOD > 0)
  615. // Auto fans
  616. #define HAS_AUTO_FAN_0 (PIN_EXISTS(E0_AUTO_FAN))
  617. #define HAS_AUTO_FAN_1 (HOTENDS > 1 && PIN_EXISTS(E1_AUTO_FAN))
  618. #define HAS_AUTO_FAN_2 (HOTENDS > 2 && PIN_EXISTS(E2_AUTO_FAN))
  619. #define HAS_AUTO_FAN_3 (HOTENDS > 3 && PIN_EXISTS(E3_AUTO_FAN))
  620. #define HAS_AUTO_FAN_4 (HOTENDS > 4 && PIN_EXISTS(E4_AUTO_FAN))
  621. #define HAS_AUTO_FAN (HAS_AUTO_FAN_0 || HAS_AUTO_FAN_1 || HAS_AUTO_FAN_2 || HAS_AUTO_FAN_3)
  622. #define AUTO_1_IS_0 (E1_AUTO_FAN_PIN == E0_AUTO_FAN_PIN)
  623. #define AUTO_2_IS_0 (E2_AUTO_FAN_PIN == E0_AUTO_FAN_PIN)
  624. #define AUTO_2_IS_1 (E2_AUTO_FAN_PIN == E1_AUTO_FAN_PIN)
  625. #define AUTO_3_IS_0 (E3_AUTO_FAN_PIN == E0_AUTO_FAN_PIN)
  626. #define AUTO_3_IS_1 (E3_AUTO_FAN_PIN == E1_AUTO_FAN_PIN)
  627. #define AUTO_3_IS_2 (E3_AUTO_FAN_PIN == E2_AUTO_FAN_PIN)
  628. #define AUTO_4_IS_0 (E4_AUTO_FAN_PIN == E0_AUTO_FAN_PIN)
  629. #define AUTO_4_IS_1 (E4_AUTO_FAN_PIN == E1_AUTO_FAN_PIN)
  630. #define AUTO_4_IS_2 (E4_AUTO_FAN_PIN == E2_AUTO_FAN_PIN)
  631. #define AUTO_4_IS_3 (E4_AUTO_FAN_PIN == E3_AUTO_FAN_PIN)
  632. // Other fans
  633. #define HAS_FAN0 (PIN_EXISTS(FAN))
  634. #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)
  635. #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)
  636. #define HAS_CONTROLLER_FAN (PIN_EXISTS(CONTROLLER_FAN))
  637. // Servos
  638. #define HAS_SERVOS (defined(NUM_SERVOS) && NUM_SERVOS > 0)
  639. #define HAS_SERVO_0 (PIN_EXISTS(SERVO0))
  640. #define HAS_SERVO_1 (PIN_EXISTS(SERVO1))
  641. #define HAS_SERVO_2 (PIN_EXISTS(SERVO2))
  642. #define HAS_SERVO_3 (PIN_EXISTS(SERVO3))
  643. // Sensors
  644. #define HAS_FILAMENT_WIDTH_SENSOR (PIN_EXISTS(FILWIDTH))
  645. #define HAS_FIL_RUNOUT (PIN_EXISTS(FIL_RUNOUT))
  646. // User Interface
  647. #define HAS_HOME (PIN_EXISTS(HOME))
  648. #define HAS_KILL (PIN_EXISTS(KILL))
  649. #define HAS_SUICIDE (PIN_EXISTS(SUICIDE))
  650. #define HAS_PHOTOGRAPH (PIN_EXISTS(PHOTOGRAPH))
  651. #define HAS_BUZZER (PIN_EXISTS(BEEPER) || ENABLED(LCD_USE_I2C_BUZZER))
  652. #define HAS_CASE_LIGHT (PIN_EXISTS(CASE_LIGHT) && ENABLED(CASE_LIGHT_ENABLE))
  653. // Digital control
  654. #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)
  655. #define HAS_STEPPER_RESET (PIN_EXISTS(STEPPER_RESET))
  656. #define HAS_DIGIPOTSS (PIN_EXISTS(DIGIPOTSS))
  657. #define HAS_MOTOR_CURRENT_PWM (PIN_EXISTS(MOTOR_CURRENT_PWM_XY) || PIN_EXISTS(MOTOR_CURRENT_PWM_Z) || PIN_EXISTS(MOTOR_CURRENT_PWM_E))
  658. /**
  659. * This setting is also used by M109 when trying to calculate
  660. * a ballpark safe margin to prevent wait-forever situation.
  661. */
  662. #ifndef EXTRUDE_MINTEMP
  663. #define EXTRUDE_MINTEMP 170
  664. #endif
  665. /**
  666. * Helper Macros for heaters and extruder fan
  667. */
  668. #define WRITE_HEATER_0P(v) WRITE(HEATER_0_PIN, v)
  669. #if HOTENDS > 1 || ENABLED(HEATERS_PARALLEL)
  670. #define WRITE_HEATER_1(v) WRITE(HEATER_1_PIN, v)
  671. #if HOTENDS > 2
  672. #define WRITE_HEATER_2(v) WRITE(HEATER_2_PIN, v)
  673. #if HOTENDS > 3
  674. #define WRITE_HEATER_3(v) WRITE(HEATER_3_PIN, v)
  675. #if HOTENDS > 4
  676. #define WRITE_HEATER_4(v) WRITE(HEATER_4_PIN, v)
  677. #endif // HOTENDS > 4
  678. #endif // HOTENDS > 3
  679. #endif // HOTENDS > 2
  680. #endif // HOTENDS > 1
  681. #if ENABLED(HEATERS_PARALLEL)
  682. #define WRITE_HEATER_0(v) { WRITE_HEATER_0P(v); WRITE_HEATER_1(v); }
  683. #else
  684. #define WRITE_HEATER_0(v) WRITE_HEATER_0P(v)
  685. #endif
  686. /**
  687. * Heated bed requires settings
  688. */
  689. #if HAS_HEATER_BED
  690. #ifndef MAX_BED_POWER
  691. #define MAX_BED_POWER 255
  692. #endif
  693. #ifndef HEATER_BED_INVERTING
  694. #define HEATER_BED_INVERTING false
  695. #endif
  696. #define WRITE_HEATER_BED(v) WRITE(HEATER_BED_PIN, (v) ^ HEATER_BED_INVERTING)
  697. #endif
  698. /**
  699. * Up to 3 PWM fans
  700. */
  701. #if HAS_FAN2
  702. #define FAN_COUNT 3
  703. #elif HAS_FAN1
  704. #define FAN_COUNT 2
  705. #elif HAS_FAN0
  706. #define FAN_COUNT 1
  707. #else
  708. #define FAN_COUNT 0
  709. #endif
  710. #if HAS_FAN0
  711. #define WRITE_FAN(v) WRITE(FAN_PIN, v)
  712. #define WRITE_FAN0(v) WRITE_FAN(v)
  713. #endif
  714. #if HAS_FAN1
  715. #define WRITE_FAN1(v) WRITE(FAN1_PIN, v)
  716. #endif
  717. #if HAS_FAN2
  718. #define WRITE_FAN2(v) WRITE(FAN2_PIN, v)
  719. #endif
  720. #define WRITE_FAN_N(n, v) WRITE_FAN##n(v)
  721. /**
  722. * Part Cooling fan multipliexer
  723. */
  724. #define HAS_FANMUX PIN_EXISTS(FANMUX0)
  725. /**
  726. * Servos and probes
  727. */
  728. #if HAS_SERVOS
  729. #ifndef Z_ENDSTOP_SERVO_NR
  730. #define Z_ENDSTOP_SERVO_NR -1
  731. #endif
  732. #endif
  733. #define PROBE_PIN_CONFIGURED (HAS_Z_MIN_PROBE_PIN || (HAS_Z_MIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)))
  734. #define HAS_BED_PROBE (PROBE_SELECTED && PROBE_PIN_CONFIGURED && DISABLED(PROBE_MANUALLY))
  735. #if ENABLED(Z_PROBE_ALLEN_KEY)
  736. #define PROBE_IS_TRIGGERED_WHEN_STOWED_TEST
  737. #endif
  738. /**
  739. * Bed Probe dependencies
  740. */
  741. #if HAS_BED_PROBE
  742. #if ENABLED(ENDSTOPPULLUPS) && HAS_Z_MIN_PROBE_PIN
  743. #define ENDSTOPPULLUP_ZMIN_PROBE
  744. #endif
  745. #ifndef Z_PROBE_OFFSET_RANGE_MIN
  746. #define Z_PROBE_OFFSET_RANGE_MIN -20
  747. #endif
  748. #ifndef Z_PROBE_OFFSET_RANGE_MAX
  749. #define Z_PROBE_OFFSET_RANGE_MAX 20
  750. #endif
  751. #ifndef XY_PROBE_SPEED
  752. #ifdef HOMING_FEEDRATE_XY
  753. #define XY_PROBE_SPEED HOMING_FEEDRATE_XY
  754. #else
  755. #define XY_PROBE_SPEED 4000
  756. #endif
  757. #endif
  758. #if Z_CLEARANCE_BETWEEN_PROBES > Z_CLEARANCE_DEPLOY_PROBE
  759. #define _Z_CLEARANCE_DEPLOY_PROBE Z_CLEARANCE_BETWEEN_PROBES
  760. #else
  761. #define _Z_CLEARANCE_DEPLOY_PROBE Z_CLEARANCE_DEPLOY_PROBE
  762. #endif
  763. #else
  764. #undef X_PROBE_OFFSET_FROM_EXTRUDER
  765. #undef Y_PROBE_OFFSET_FROM_EXTRUDER
  766. #undef Z_PROBE_OFFSET_FROM_EXTRUDER
  767. #define X_PROBE_OFFSET_FROM_EXTRUDER 0
  768. #define Y_PROBE_OFFSET_FROM_EXTRUDER 0
  769. #define Z_PROBE_OFFSET_FROM_EXTRUDER 0
  770. #endif
  771. /**
  772. * Heater & Fan Pausing
  773. */
  774. #if FAN_COUNT == 0
  775. #undef PROBING_FANS_OFF
  776. #endif
  777. #define QUIET_PROBING (HAS_BED_PROBE && (ENABLED(PROBING_HEATERS_OFF) || ENABLED(PROBING_FANS_OFF) || DELAY_BEFORE_PROBING > 0))
  778. #define HEATER_IDLE_HANDLER (ENABLED(ADVANCED_PAUSE_FEATURE) || ENABLED(PROBING_HEATERS_OFF))
  779. /**
  780. * Only constrain Z on DELTA / SCARA machines
  781. */
  782. #if IS_KINEMATIC
  783. #undef MIN_SOFTWARE_ENDSTOP_X
  784. #undef MIN_SOFTWARE_ENDSTOP_Y
  785. #undef MAX_SOFTWARE_ENDSTOP_X
  786. #undef MAX_SOFTWARE_ENDSTOP_Y
  787. #endif
  788. /**
  789. * Delta radius/rod trimmers/angle trimmers
  790. */
  791. #if ENABLED(DELTA)
  792. #ifndef DELTA_PROBEABLE_RADIUS
  793. #define DELTA_PROBEABLE_RADIUS DELTA_PRINTABLE_RADIUS
  794. #endif
  795. #ifndef DELTA_CALIBRATION_RADIUS
  796. #define DELTA_CALIBRATION_RADIUS DELTA_PRINTABLE_RADIUS - 10
  797. #endif
  798. #ifndef DELTA_ENDSTOP_ADJ
  799. #define DELTA_ENDSTOP_ADJ { 0, 0, 0 }
  800. #endif
  801. #ifndef DELTA_TOWER_ANGLE_TRIM
  802. #define DELTA_TOWER_ANGLE_TRIM {0, 0, 0}
  803. #endif
  804. #ifndef DELTA_RADIUS_TRIM_TOWER
  805. #define DELTA_RADIUS_TRIM_TOWER {0, 0, 0}
  806. #endif
  807. #ifndef DELTA_DIAGONAL_ROD_TRIM_TOWER
  808. #define DELTA_DIAGONAL_ROD_TRIM_TOWER {0, 0, 0}
  809. #endif
  810. #endif
  811. /**
  812. * Set granular options based on the specific type of leveling
  813. */
  814. #define UBL_DELTA (ENABLED(AUTO_BED_LEVELING_UBL) && (ENABLED(DELTA) || ENABLED(UBL_GRANULAR_SEGMENTATION_FOR_CARTESIAN)))
  815. #define ABL_PLANAR (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_3POINT))
  816. #define ABL_GRID (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR))
  817. #define OLDSCHOOL_ABL (ABL_PLANAR || ABL_GRID)
  818. #define HAS_ABL (OLDSCHOOL_ABL || ENABLED(AUTO_BED_LEVELING_UBL))
  819. #define HAS_LEVELING (HAS_ABL || ENABLED(MESH_BED_LEVELING))
  820. #define HAS_AUTOLEVEL (HAS_ABL && DISABLED(PROBE_MANUALLY))
  821. #define HAS_MESH (ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(MESH_BED_LEVELING))
  822. #define PLANNER_LEVELING (OLDSCHOOL_ABL || ENABLED(MESH_BED_LEVELING) || UBL_DELTA)
  823. #define HAS_PROBING_PROCEDURE (HAS_ABL || ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST))
  824. #if HAS_PROBING_PROCEDURE
  825. #define PROBE_BED_WIDTH abs(RIGHT_PROBE_BED_POSITION - (LEFT_PROBE_BED_POSITION))
  826. #define PROBE_BED_HEIGHT abs(BACK_PROBE_BED_POSITION - (FRONT_PROBE_BED_POSITION))
  827. #endif
  828. /**
  829. * Bed Probing rectangular bounds
  830. * These can be further constrained in code for Delta and SCARA
  831. */
  832. #if ENABLED(DELTA)
  833. // Probing points may be verified at compile time within the radius
  834. // using static_assert(HYPOT2(X2-X1,Y2-Y1)<=sq(DELTA_PRINTABLE_RADIUS),"bad probe point!")
  835. // so that may be added to SanityCheck.h in the future.
  836. #define MIN_PROBE_X (X_CENTER - DELTA_PRINTABLE_RADIUS)
  837. #define MIN_PROBE_Y (Y_CENTER - DELTA_PRINTABLE_RADIUS)
  838. #define MAX_PROBE_X (X_CENTER + DELTA_PRINTABLE_RADIUS)
  839. #define MAX_PROBE_Y (Y_CENTER + DELTA_PRINTABLE_RADIUS)
  840. #elif IS_SCARA
  841. #define SCARA_PRINTABLE_RADIUS (SCARA_LINKAGE_1 + SCARA_LINKAGE_2)
  842. #define MIN_PROBE_X (X_CENTER - (SCARA_PRINTABLE_RADIUS))
  843. #define MIN_PROBE_Y (Y_CENTER - (SCARA_PRINTABLE_RADIUS))
  844. #define MAX_PROBE_X (X_CENTER + SCARA_PRINTABLE_RADIUS)
  845. #define MAX_PROBE_Y (Y_CENTER + SCARA_PRINTABLE_RADIUS)
  846. #else
  847. // Boundaries for Cartesian probing based on bed limits
  848. #define MIN_PROBE_X (max(X_MIN_BED, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
  849. #define MIN_PROBE_Y (max(Y_MIN_BED, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
  850. #define MAX_PROBE_X (min(X_MAX_BED, X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
  851. #define MAX_PROBE_Y (min(Y_MAX_BED, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
  852. #endif
  853. /**
  854. * Default mesh area is an area with an inset margin on the print area.
  855. */
  856. #if ENABLED(MESH_BED_LEVELING) || ENABLED(AUTO_BED_LEVELING_UBL)
  857. #if IS_KINEMATIC
  858. // Probing points may be verified at compile time within the radius
  859. // using static_assert(HYPOT2(X2-X1,Y2-Y1)<=sq(DELTA_PRINTABLE_RADIUS),"bad probe point!")
  860. // so that may be added to SanityCheck.h in the future.
  861. #define _MESH_MIN_X (MIN_PROBE_X + MESH_INSET)
  862. #define _MESH_MIN_Y (MIN_PROBE_Y + MESH_INSET)
  863. #define _MESH_MAX_X (MAX_PROBE_X - (MESH_INSET))
  864. #define _MESH_MAX_Y (MAX_PROBE_Y - (MESH_INSET))
  865. #else
  866. // Boundaries for Cartesian probing based on set limits
  867. #define _MESH_MIN_X (max(X_MIN_BED + MESH_INSET, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
  868. #define _MESH_MIN_Y (max(Y_MIN_BED + MESH_INSET, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
  869. #define _MESH_MAX_X (min(X_MAX_BED - (MESH_INSET), X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
  870. #define _MESH_MAX_Y (min(Y_MAX_BED - (MESH_INSET), Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
  871. #endif
  872. /**
  873. * These may be overridden in Configuration if a smaller area is wanted
  874. */
  875. #if ENABLED(MESH_BED_LEVELING) || ENABLED(AUTO_BED_LEVELING_UBL)
  876. #ifndef MESH_MIN_X
  877. #define MESH_MIN_X _MESH_MIN_X
  878. #endif
  879. #ifndef MESH_MIN_Y
  880. #define MESH_MIN_Y _MESH_MIN_Y
  881. #endif
  882. #ifndef MESH_MAX_X
  883. #define MESH_MAX_X _MESH_MAX_X
  884. #endif
  885. #ifndef MESH_MAX_Y
  886. #define MESH_MAX_Y _MESH_MAX_Y
  887. #endif
  888. #endif
  889. #endif // MESH_BED_LEVELING || AUTO_BED_LEVELING_UBL
  890. /**
  891. * Buzzer/Speaker
  892. */
  893. #if ENABLED(LCD_USE_I2C_BUZZER)
  894. #ifndef LCD_FEEDBACK_FREQUENCY_HZ
  895. #define LCD_FEEDBACK_FREQUENCY_HZ 1000
  896. #endif
  897. #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
  898. #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100
  899. #endif
  900. #else
  901. #ifndef LCD_FEEDBACK_FREQUENCY_HZ
  902. #define LCD_FEEDBACK_FREQUENCY_HZ 5000
  903. #endif
  904. #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
  905. #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2
  906. #endif
  907. #endif
  908. /**
  909. * VIKI2, miniVIKI, and AZSMZ_12864 require DOGLCD_SCK and DOGLCD_MOSI to be defined.
  910. */
  911. #if ENABLED(VIKI2) || ENABLED(miniVIKI) || ENABLED(AZSMZ_12864)
  912. #ifndef DOGLCD_SCK
  913. #define DOGLCD_SCK SCK_PIN
  914. #endif
  915. #ifndef DOGLCD_MOSI
  916. #define DOGLCD_MOSI MOSI_PIN
  917. #endif
  918. #endif
  919. /**
  920. * Z_HOMING_HEIGHT / Z_CLEARANCE_BETWEEN_PROBES
  921. */
  922. #ifndef Z_HOMING_HEIGHT
  923. #ifndef Z_CLEARANCE_BETWEEN_PROBES
  924. #define Z_HOMING_HEIGHT 0
  925. #else
  926. #define Z_HOMING_HEIGHT Z_CLEARANCE_BETWEEN_PROBES
  927. #endif
  928. #endif
  929. #ifndef Z_CLEARANCE_BETWEEN_PROBES
  930. #define Z_CLEARANCE_BETWEEN_PROBES Z_HOMING_HEIGHT
  931. #endif
  932. #if Z_CLEARANCE_BETWEEN_PROBES > Z_HOMING_HEIGHT
  933. #define MANUAL_PROBE_HEIGHT Z_CLEARANCE_BETWEEN_PROBES
  934. #else
  935. #define MANUAL_PROBE_HEIGHT Z_HOMING_HEIGHT
  936. #endif
  937. // Stepper pulse duration, in cycles
  938. #define STEP_PULSE_CYCLES ((MINIMUM_STEPPER_PULSE) * CYCLES_PER_MICROSECOND)
  939. #if ENABLED(SDCARD_SORT_ALPHA)
  940. #define HAS_FOLDER_SORTING (FOLDER_SORTING || ENABLED(SDSORT_GCODE))
  941. #endif
  942. // Updated G92 behavior shifts the workspace
  943. #define HAS_POSITION_SHIFT DISABLED(NO_WORKSPACE_OFFSETS)
  944. // The home offset also shifts the coordinate space
  945. #define HAS_HOME_OFFSET (DISABLED(NO_WORKSPACE_OFFSETS) && DISABLED(DELTA))
  946. // Either offset yields extra calculations on all moves
  947. #define HAS_WORKSPACE_OFFSET (HAS_POSITION_SHIFT || HAS_HOME_OFFSET)
  948. // M206 doesn't apply to DELTA
  949. #define HAS_M206_COMMAND (HAS_HOME_OFFSET && DISABLED(DELTA))
  950. // LCD timeout to status screen default is 15s
  951. #ifndef LCD_TIMEOUT_TO_STATUS
  952. #define LCD_TIMEOUT_TO_STATUS 15000
  953. #endif
  954. /**
  955. * DELTA_SEGMENT_MIN_LENGTH for UBL_DELTA
  956. */
  957. #if UBL_DELTA
  958. #ifndef DELTA_SEGMENT_MIN_LENGTH
  959. #if IS_SCARA
  960. #define DELTA_SEGMENT_MIN_LENGTH 0.25 // SCARA minimum segment size is 0.25mm
  961. #elif ENABLED(DELTA)
  962. #define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DELTA_SEGMENTS_PER_SECOND)
  963. #else // CARTESIAN
  964. #define DELTA_SEGMENT_MIN_LENGTH 1.00 // mm (similar to G2/G3 arc segmentation)
  965. #endif
  966. #endif
  967. #endif
  968. // Shorthand
  969. #define GRID_MAX_POINTS ((GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y))
  970. // Add commands that need sub-codes to this list
  971. #define USE_GCODE_SUBCODES ENABLED(G38_PROBE_TARGET) || ENABLED(CNC_COORDINATE_SYSTEMS)
  972. // Parking Extruder
  973. #if ENABLED(PARKING_EXTRUDER)
  974. #ifndef PARKING_EXTRUDER_GRAB_DISTANCE
  975. #define PARKING_EXTRUDER_GRAB_DISTANCE 0
  976. #endif
  977. #ifndef PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE
  978. #define PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE HIGH
  979. #endif
  980. #endif
  981. // Number of VFAT entries used. Each entry has 13 UTF-16 characters
  982. #if ENABLED(SCROLL_LONG_FILENAMES)
  983. #define MAX_VFAT_ENTRIES (5)
  984. #else
  985. #define MAX_VFAT_ENTRIES (2)
  986. #endif
  987. #endif // CONDITIONALS_POST_H