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.h 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  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.h
  24. * Defines that depend on configuration but are not editable.
  25. */
  26. #ifndef CONDITIONALS_H
  27. /**
  28. * Miscellaneous
  29. */
  30. #ifndef M_PI
  31. #define M_PI 3.1415926536
  32. #endif
  33. /**
  34. * This value is used by M109 when tying to calculate a ballpark safe margin
  35. * to prevent wait-forever situation.
  36. */
  37. #ifndef EXTRUDE_MINTEMP
  38. #define EXTRUDE_MINTEMP 170
  39. #endif
  40. #ifndef CONFIGURATION_LCD // Get the LCD defines which are needed first
  41. #define CONFIGURATION_LCD
  42. #if ENABLED(MAKRPANEL)
  43. #define DOGLCD
  44. #define DEFAULT_LCD_CONTRAST 17
  45. #define ULTIPANEL
  46. #define NEWPANEL
  47. #endif
  48. #if ENABLED(miniVIKI) || ENABLED(VIKI2) || ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
  49. #define ULTRA_LCD //general LCD support, also 16x2
  50. #define DOGLCD // Support for SPI LCD 128x64 (Controller ST7565R graphic Display Family)
  51. #define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
  52. #if ENABLED(miniVIKI)
  53. #define DEFAULT_LCD_CONTRAST 95
  54. #elif ENABLED(VIKI2)
  55. #define DEFAULT_LCD_CONTRAST 40
  56. #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
  57. #define DEFAULT_LCD_CONTRAST 110
  58. #define U8GLIB_LM6059_AF
  59. #define SD_DETECT_INVERTED
  60. #endif
  61. #define ENCODER_PULSES_PER_STEP 4
  62. #define ENCODER_STEPS_PER_MENU_ITEM 1
  63. #endif
  64. // Generic support for SSD1306 OLED based LCDs.
  65. #if ENABLED(U8GLIB_SSD1306)
  66. #define ULTRA_LCD //general LCD support, also 16x2
  67. #define DOGLCD // Support for I2C LCD 128x64 (Controller SSD1306 graphic Display Family)
  68. #endif
  69. #if ENABLED(PANEL_ONE)
  70. #define ULTIMAKERCONTROLLER
  71. #endif
  72. #if ENABLED(BQ_LCD_SMART_CONTROLLER)
  73. #define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
  74. #ifndef ENCODER_PULSES_PER_STEP
  75. #define ENCODER_PULSES_PER_STEP 4
  76. #endif
  77. #ifndef ENCODER_STEPS_PER_MENU_ITEM
  78. #define ENCODER_STEPS_PER_MENU_ITEM 1
  79. #endif
  80. #ifndef LONG_FILENAME_HOST_SUPPORT
  81. #define LONG_FILENAME_HOST_SUPPORT
  82. #endif
  83. #endif
  84. #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
  85. #define DOGLCD
  86. #define U8GLIB_ST7920
  87. #define REPRAP_DISCOUNT_SMART_CONTROLLER
  88. #endif
  89. #if ENABLED(ULTIMAKERCONTROLLER) || ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) || ENABLED(G3D_PANEL) || ENABLED(RIGIDBOT_PANEL)
  90. #define ULTIPANEL
  91. #define NEWPANEL
  92. #endif
  93. #if ENABLED(REPRAPWORLD_KEYPAD)
  94. #define ULTIPANEL
  95. #define NEWPANEL
  96. #endif
  97. #if ENABLED(RA_CONTROL_PANEL)
  98. #define LCD_I2C_TYPE_PCA8574
  99. #define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander
  100. #define ULTIPANEL
  101. #define NEWPANEL
  102. #endif
  103. #if ENABLED(MINIPANEL)
  104. #define DOGLCD
  105. #define ULTIPANEL
  106. #define NEWPANEL
  107. #define DEFAULT_LCD_CONTRAST 17
  108. #endif
  109. /**
  110. * I2C PANELS
  111. */
  112. #if ENABLED(LCD_I2C_SAINSMART_YWROBOT)
  113. // This uses the LiquidCrystal_I2C library ( https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home )
  114. // Make sure it is placed in the Arduino libraries directory.
  115. #define LCD_I2C_TYPE_PCF8575
  116. #define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander
  117. #define ULTIPANEL
  118. #define NEWPANEL
  119. #endif
  120. // PANELOLU2 LCD with status LEDs, separate encoder and click inputs
  121. #if ENABLED(LCD_I2C_PANELOLU2)
  122. #define LCD_I2C_TYPE_MCP23017
  123. #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
  124. #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD
  125. #ifndef ENCODER_PULSES_PER_STEP
  126. #define ENCODER_PULSES_PER_STEP 4
  127. #endif
  128. #ifndef ENCODER_STEPS_PER_MENU_ITEM
  129. #define ENCODER_STEPS_PER_MENU_ITEM 1
  130. #endif
  131. #if ENABLED(LCD_USE_I2C_BUZZER)
  132. #define LCD_FEEDBACK_FREQUENCY_HZ 1000
  133. #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100
  134. #endif
  135. #define ULTIPANEL
  136. #define NEWPANEL
  137. #endif
  138. // Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
  139. #if ENABLED(LCD_I2C_VIKI)
  140. // This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
  141. // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
  142. // Note: The pause/stop/resume LCD button pin should be connected to the Arduino
  143. // BTN_ENC pin (or set BTN_ENC to -1 if not used)
  144. #define LCD_I2C_TYPE_MCP23017
  145. #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
  146. #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD (requires LiquidTWI2 v1.2.3 or later)
  147. #define ULTIPANEL
  148. #define NEWPANEL
  149. #endif
  150. // Shift register panels
  151. // ---------------------
  152. // 2 wire Non-latching LCD SR from:
  153. // https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
  154. #if ENABLED(SAV_3DLCD)
  155. #define SR_LCD_2W_NL // Non latching 2 wire shift register
  156. #define ULTIPANEL
  157. #define NEWPANEL
  158. #endif
  159. #if ENABLED(DOGLCD) // Change number of lines to match the DOG graphic display
  160. #ifndef LCD_WIDTH
  161. #define LCD_WIDTH 22
  162. #endif
  163. #ifndef LCD_HEIGHT
  164. #define LCD_HEIGHT 5
  165. #endif
  166. #endif
  167. #if ENABLED(ULTIPANEL)
  168. #define NEWPANEL //enable this if you have a click-encoder panel
  169. #define ULTRA_LCD
  170. #ifndef LCD_WIDTH
  171. #define LCD_WIDTH 20
  172. #endif
  173. #ifndef LCD_HEIGHT
  174. #define LCD_HEIGHT 4
  175. #endif
  176. #else //no panel but just LCD
  177. #if ENABLED(ULTRA_LCD)
  178. #ifndef LCD_WIDTH
  179. #define LCD_WIDTH 16
  180. #endif
  181. #ifndef LCD_HEIGHT
  182. #define LCD_HEIGHT 2
  183. #endif
  184. #endif
  185. #endif
  186. #if ENABLED(DOGLCD)
  187. /* Custom characters defined in font dogm_font_data_Marlin_symbols.h / Marlin_symbols.fon */
  188. // \x00 intentionally skipped to avoid problems in strings
  189. #define LCD_STR_REFRESH "\x01"
  190. #define LCD_STR_FOLDER "\x02"
  191. #define LCD_STR_ARROW_RIGHT "\x03"
  192. #define LCD_STR_UPLEVEL "\x04"
  193. #define LCD_STR_CLOCK "\x05"
  194. #define LCD_STR_FEEDRATE "\x06"
  195. #define LCD_STR_BEDTEMP "\x07"
  196. #define LCD_STR_THERMOMETER "\x08"
  197. #define LCD_STR_DEGREE "\x09"
  198. #define LCD_STR_SPECIAL_MAX '\x09'
  199. // Maximum here is 0x1f because 0x20 is ' ' (space) and the normal charsets begin.
  200. // Better stay below 0x10 because DISPLAY_CHARSET_HD44780_WESTERN begins here.
  201. #else
  202. /* Custom characters defined in the first 8 characters of the LCD */
  203. #define LCD_STR_BEDTEMP "\x00" // Print only as a char. This will have 'unexpected' results when used in a string!
  204. #define LCD_STR_DEGREE "\x01"
  205. #define LCD_STR_THERMOMETER "\x02"
  206. #define LCD_STR_UPLEVEL "\x03"
  207. #define LCD_STR_REFRESH "\x04"
  208. #define LCD_STR_FOLDER "\x05"
  209. #define LCD_STR_FEEDRATE "\x06"
  210. #define LCD_STR_CLOCK "\x07"
  211. #define LCD_STR_ARROW_RIGHT ">" /* from the default character set */
  212. #endif
  213. /**
  214. * Default LCD contrast for dogm-like LCD displays
  215. */
  216. #if ENABLED(DOGLCD) && DISABLED(DEFAULT_LCD_CONTRAST)
  217. #define DEFAULT_LCD_CONTRAST 32
  218. #endif
  219. #if ENABLED(DOGLCD)
  220. #define HAS_LCD_CONTRAST
  221. #if ENABLED(U8GLIB_ST7920)
  222. #undef HAS_LCD_CONTRAST
  223. #endif
  224. #if ENABLED(U8GLIB_SSD1306)
  225. #undef HAS_LCD_CONTRAST
  226. #endif
  227. #endif
  228. #else // CONFIGURATION_LCD
  229. #define CONDITIONALS_H
  230. #include "pins.h"
  231. #ifndef USBCON
  232. #define HardwareSerial_h // trick to disable the standard HWserial
  233. #endif
  234. #include "Arduino.h"
  235. /**
  236. * Set ENDSTOPPULLUPS for unused endstop switches
  237. */
  238. #if ENABLED(ENDSTOPPULLUPS)
  239. #if ENABLED(USE_XMAX_PLUG)
  240. #define ENDSTOPPULLUP_XMAX
  241. #endif
  242. #if ENABLED(USE_YMAX_PLUG)
  243. #define ENDSTOPPULLUP_YMAX
  244. #endif
  245. #if ENABLED(USE_ZMAX_PLUG)
  246. #define ENDSTOPPULLUP_ZMAX
  247. #endif
  248. #if ENABLED(USE_XMIN_PLUG)
  249. #define ENDSTOPPULLUP_XMIN
  250. #endif
  251. #if ENABLED(USE_YMIN_PLUG)
  252. #define ENDSTOPPULLUP_YMIN
  253. #endif
  254. #if ENABLED(USE_ZMIN_PLUG)
  255. #define ENDSTOPPULLUP_ZMIN
  256. #endif
  257. #if DISABLED(DISABLE_Z_MIN_PROBE_ENDSTOP)
  258. #define ENDSTOPPULLUP_ZMIN_PROBE
  259. #endif
  260. #endif
  261. /**
  262. * Axis lengths
  263. */
  264. #define X_MAX_LENGTH (X_MAX_POS - (X_MIN_POS))
  265. #define Y_MAX_LENGTH (Y_MAX_POS - (Y_MIN_POS))
  266. #define Z_MAX_LENGTH (Z_MAX_POS - (Z_MIN_POS))
  267. /**
  268. * CoreXY and CoreXZ
  269. */
  270. #if ENABLED(COREXY)
  271. #define CORE_AXIS_2 B_AXIS
  272. #define CORE_AXIS_3 Z_AXIS
  273. #elif ENABLED(COREXZ)
  274. #define CORE_AXIS_2 C_AXIS
  275. #define CORE_AXIS_3 Y_AXIS
  276. #endif
  277. /**
  278. * SCARA
  279. */
  280. #if ENABLED(SCARA)
  281. #undef SLOWDOWN
  282. #define QUICK_HOME //SCARA needs Quickhome
  283. #endif
  284. /**
  285. * AUTOSET LOCATIONS OF LIMIT SWITCHES
  286. */
  287. #if ENABLED(MANUAL_HOME_POSITIONS) // Use manual limit switch locations
  288. #define X_HOME_POS MANUAL_X_HOME_POS
  289. #define Y_HOME_POS MANUAL_Y_HOME_POS
  290. #define Z_HOME_POS MANUAL_Z_HOME_POS
  291. #else //!MANUAL_HOME_POSITIONS – Use home switch positions based on homing direction and travel limits
  292. #if ENABLED(BED_CENTER_AT_0_0)
  293. #define X_HOME_POS (X_MAX_LENGTH) * (X_HOME_DIR) * 0.5
  294. #define Y_HOME_POS (Y_MAX_LENGTH) * (Y_HOME_DIR) * 0.5
  295. #else
  296. #define X_HOME_POS (X_HOME_DIR < 0 ? X_MIN_POS : X_MAX_POS)
  297. #define Y_HOME_POS (Y_HOME_DIR < 0 ? Y_MIN_POS : Y_MAX_POS)
  298. #endif
  299. #define Z_HOME_POS (Z_HOME_DIR < 0 ? Z_MIN_POS : Z_MAX_POS)
  300. #endif //!MANUAL_HOME_POSITIONS
  301. /**
  302. * Auto Bed Leveling
  303. */
  304. #if ENABLED(AUTO_BED_LEVELING_FEATURE)
  305. // Boundaries for probing based on set limits
  306. #define MIN_PROBE_X (max(X_MIN_POS, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
  307. #define MAX_PROBE_X (min(X_MAX_POS, X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
  308. #define MIN_PROBE_Y (max(Y_MIN_POS, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
  309. #define MAX_PROBE_Y (min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
  310. #endif
  311. #define HAS_Z_ENDSTOP_SERVO (defined(Z_ENDSTOP_SERVO_NR) && Z_ENDSTOP_SERVO_NR >= 0)
  312. #define SERVO_LEVELING (ENABLED(AUTO_BED_LEVELING_FEATURE) && HAS_Z_ENDSTOP_SERVO)
  313. /**
  314. * Sled Options
  315. */
  316. #if ENABLED(Z_PROBE_SLED)
  317. #define Z_SAFE_HOMING
  318. #endif
  319. /**
  320. * Enable MECHANICAL_PROBE for Z_PROBE_ALLEN_KEY, for older configs
  321. */
  322. #if ENABLED(Z_PROBE_ALLEN_KEY)
  323. #define MECHANICAL_PROBE
  324. #endif
  325. /**
  326. * Avoid double-negatives for enabling features
  327. */
  328. #if DISABLED(DISABLE_HOST_KEEPALIVE)
  329. #define HOST_KEEPALIVE_FEATURE
  330. #endif
  331. /**
  332. * MAX_STEP_FREQUENCY differs for TOSHIBA
  333. */
  334. #if ENABLED(CONFIG_STEPPERS_TOSHIBA)
  335. #define MAX_STEP_FREQUENCY 10000 // Max step frequency for Toshiba Stepper Controllers
  336. #else
  337. #define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step)
  338. #endif
  339. // MS1 MS2 Stepper Driver Microstepping mode table
  340. #define MICROSTEP1 LOW,LOW
  341. #define MICROSTEP2 HIGH,LOW
  342. #define MICROSTEP4 LOW,HIGH
  343. #define MICROSTEP8 HIGH,HIGH
  344. #define MICROSTEP16 HIGH,HIGH
  345. /**
  346. * Advance calculated values
  347. */
  348. #if ENABLED(ADVANCE)
  349. #define EXTRUSION_AREA (0.25 * (D_FILAMENT) * (D_FILAMENT) * M_PI)
  350. #define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS] / (EXTRUSION_AREA))
  351. #endif
  352. #if ENABLED(ULTIPANEL) && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER)
  353. #undef SD_DETECT_INVERTED
  354. #endif
  355. /**
  356. * Set defaults for missing (newer) options
  357. */
  358. #ifndef DISABLE_INACTIVE_X
  359. #define DISABLE_INACTIVE_X DISABLE_X
  360. #endif
  361. #ifndef DISABLE_INACTIVE_Y
  362. #define DISABLE_INACTIVE_Y DISABLE_Y
  363. #endif
  364. #ifndef DISABLE_INACTIVE_Z
  365. #define DISABLE_INACTIVE_Z DISABLE_Z
  366. #endif
  367. #ifndef DISABLE_INACTIVE_E
  368. #define DISABLE_INACTIVE_E DISABLE_E
  369. #endif
  370. // Power Signal Control Definitions
  371. // By default use ATX definition
  372. #ifndef POWER_SUPPLY
  373. #define POWER_SUPPLY 1
  374. #endif
  375. #if (POWER_SUPPLY == 1) // 1 = ATX
  376. #define PS_ON_AWAKE LOW
  377. #define PS_ON_ASLEEP HIGH
  378. #elif (POWER_SUPPLY == 2) // 2 = X-Box 360 203W
  379. #define PS_ON_AWAKE HIGH
  380. #define PS_ON_ASLEEP LOW
  381. #endif
  382. #define HAS_POWER_SWITCH (POWER_SUPPLY > 0 && PIN_EXISTS(PS_ON))
  383. /**
  384. * Temp Sensor defines
  385. */
  386. #if TEMP_SENSOR_0 == -3
  387. #define HEATER_0_USES_MAX6675
  388. #define MAX6675_IS_MAX31855
  389. #elif TEMP_SENSOR_0 == -2
  390. #define HEATER_0_USES_MAX6675
  391. #elif TEMP_SENSOR_0 == -1
  392. #define HEATER_0_USES_AD595
  393. #elif TEMP_SENSOR_0 == 0
  394. #undef HEATER_0_MINTEMP
  395. #undef HEATER_0_MAXTEMP
  396. #elif TEMP_SENSOR_0 > 0
  397. #define THERMISTORHEATER_0 TEMP_SENSOR_0
  398. #define HEATER_0_USES_THERMISTOR
  399. #endif
  400. #if TEMP_SENSOR_1 <= -2
  401. #error MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_1
  402. #elif TEMP_SENSOR_1 == -1
  403. #define HEATER_1_USES_AD595
  404. #elif TEMP_SENSOR_1 == 0
  405. #undef HEATER_1_MINTEMP
  406. #undef HEATER_1_MAXTEMP
  407. #elif TEMP_SENSOR_1 > 0
  408. #define THERMISTORHEATER_1 TEMP_SENSOR_1
  409. #define HEATER_1_USES_THERMISTOR
  410. #endif
  411. #if TEMP_SENSOR_2 <= -2
  412. #error MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_2
  413. #elif TEMP_SENSOR_2 == -1
  414. #define HEATER_2_USES_AD595
  415. #elif TEMP_SENSOR_2 == 0
  416. #undef HEATER_2_MINTEMP
  417. #undef HEATER_2_MAXTEMP
  418. #elif TEMP_SENSOR_2 > 0
  419. #define THERMISTORHEATER_2 TEMP_SENSOR_2
  420. #define HEATER_2_USES_THERMISTOR
  421. #endif
  422. #if TEMP_SENSOR_3 <= -2
  423. #error MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_3
  424. #elif TEMP_SENSOR_3 == -1
  425. #define HEATER_3_USES_AD595
  426. #elif TEMP_SENSOR_3 == 0
  427. #undef HEATER_3_MINTEMP
  428. #undef HEATER_3_MAXTEMP
  429. #elif TEMP_SENSOR_3 > 0
  430. #define THERMISTORHEATER_3 TEMP_SENSOR_3
  431. #define HEATER_3_USES_THERMISTOR
  432. #endif
  433. #if TEMP_SENSOR_BED <= -2
  434. #error MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_BED
  435. #elif TEMP_SENSOR_BED == -1
  436. #define BED_USES_AD595
  437. #elif TEMP_SENSOR_BED == 0
  438. #undef BED_MINTEMP
  439. #undef BED_MAXTEMP
  440. #elif TEMP_SENSOR_BED > 0
  441. #define THERMISTORBED TEMP_SENSOR_BED
  442. #define BED_USES_THERMISTOR
  443. #endif
  444. /**
  445. * ARRAY_BY_EXTRUDERS based on EXTRUDERS
  446. */
  447. #if EXTRUDERS > 3
  448. #define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1, v2, v3, v4 }
  449. #elif EXTRUDERS > 2
  450. #define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1, v2, v3 }
  451. #elif EXTRUDERS > 1
  452. #define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1, v2 }
  453. #else
  454. #define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1 }
  455. #endif
  456. #define ARRAY_BY_EXTRUDERS1(v1) ARRAY_BY_EXTRUDERS(v1, v1, v1, v1)
  457. /**
  458. * Z_DUAL_ENDSTOPS endstop reassignment
  459. */
  460. #if ENABLED(Z_DUAL_ENDSTOPS)
  461. #define _XMIN_ 100
  462. #define _YMIN_ 200
  463. #define _ZMIN_ 300
  464. #define _XMAX_ 101
  465. #define _YMAX_ 201
  466. #define _ZMAX_ 301
  467. const bool Z2_MAX_ENDSTOP_INVERTING =
  468. #if Z2_USE_ENDSTOP == _XMAX_
  469. X_MAX_ENDSTOP_INVERTING
  470. #define Z2_MAX_PIN X_MAX_PIN
  471. #undef USE_XMAX_PLUG
  472. #elif Z2_USE_ENDSTOP == _YMAX_
  473. Y_MAX_ENDSTOP_INVERTING
  474. #define Z2_MAX_PIN Y_MAX_PIN
  475. #undef USE_YMAX_PLUG
  476. #elif Z2_USE_ENDSTOP == _ZMAX_
  477. Z_MAX_ENDSTOP_INVERTING
  478. #define Z2_MAX_PIN Z_MAX_PIN
  479. #undef USE_ZMAX_PLUG
  480. #elif Z2_USE_ENDSTOP == _XMIN_
  481. X_MIN_ENDSTOP_INVERTING
  482. #define Z2_MAX_PIN X_MIN_PIN
  483. #undef USE_XMIN_PLUG
  484. #elif Z2_USE_ENDSTOP == _YMIN_
  485. Y_MIN_ENDSTOP_INVERTING
  486. #define Z2_MAX_PIN Y_MIN_PIN
  487. #undef USE_YMIN_PLUG
  488. #elif Z2_USE_ENDSTOP == _ZMIN_
  489. Z_MIN_ENDSTOP_INVERTING
  490. #define Z2_MAX_PIN Z_MIN_PIN
  491. #undef USE_ZMIN_PLUG
  492. #else
  493. 0
  494. #endif
  495. ;
  496. #endif
  497. /**
  498. * Shorthand for pin tests, used wherever needed
  499. */
  500. #define HAS_TEMP_0 (PIN_EXISTS(TEMP_0) && TEMP_SENSOR_0 != 0 && TEMP_SENSOR_0 > -2)
  501. #define HAS_TEMP_1 (PIN_EXISTS(TEMP_1) && TEMP_SENSOR_1 != 0 && TEMP_SENSOR_1 > -2)
  502. #define HAS_TEMP_2 (PIN_EXISTS(TEMP_2) && TEMP_SENSOR_2 != 0 && TEMP_SENSOR_2 > -2)
  503. #define HAS_TEMP_3 (PIN_EXISTS(TEMP_3) && TEMP_SENSOR_3 != 0 && TEMP_SENSOR_3 > -2)
  504. #define HAS_TEMP_BED (PIN_EXISTS(TEMP_BED) && TEMP_SENSOR_BED != 0 && TEMP_SENSOR_BED > -2)
  505. #define HAS_HEATER_0 (PIN_EXISTS(HEATER_0))
  506. #define HAS_HEATER_1 (PIN_EXISTS(HEATER_1))
  507. #define HAS_HEATER_2 (PIN_EXISTS(HEATER_2))
  508. #define HAS_HEATER_3 (PIN_EXISTS(HEATER_3))
  509. #define HAS_HEATER_BED (PIN_EXISTS(HEATER_BED))
  510. #define HAS_AUTO_FAN_0 (PIN_EXISTS(EXTRUDER_0_AUTO_FAN))
  511. #define HAS_AUTO_FAN_1 (PIN_EXISTS(EXTRUDER_1_AUTO_FAN))
  512. #define HAS_AUTO_FAN_2 (PIN_EXISTS(EXTRUDER_2_AUTO_FAN))
  513. #define HAS_AUTO_FAN_3 (PIN_EXISTS(EXTRUDER_3_AUTO_FAN))
  514. #define HAS_AUTO_FAN (HAS_AUTO_FAN_0 || HAS_AUTO_FAN_1 || HAS_AUTO_FAN_2 || HAS_AUTO_FAN_3)
  515. #define HAS_FAN0 (PIN_EXISTS(FAN))
  516. #define HAS_FAN1 (PIN_EXISTS(FAN1) && CONTROLLERFAN_PIN != FAN1_PIN && EXTRUDER_0_AUTO_FAN_PIN != FAN1_PIN && EXTRUDER_1_AUTO_FAN_PIN != FAN1_PIN && EXTRUDER_2_AUTO_FAN_PIN != FAN1_PIN)
  517. #define HAS_FAN2 (PIN_EXISTS(FAN2) && CONTROLLERFAN_PIN != FAN2_PIN && EXTRUDER_0_AUTO_FAN_PIN != FAN2_PIN && EXTRUDER_1_AUTO_FAN_PIN != FAN2_PIN && EXTRUDER_2_AUTO_FAN_PIN != FAN2_PIN)
  518. #define HAS_CONTROLLERFAN (PIN_EXISTS(CONTROLLERFAN))
  519. #define HAS_SERVOS (defined(NUM_SERVOS) && NUM_SERVOS > 0)
  520. #define HAS_SERVO_0 (PIN_EXISTS(SERVO0))
  521. #define HAS_SERVO_1 (PIN_EXISTS(SERVO1))
  522. #define HAS_SERVO_2 (PIN_EXISTS(SERVO2))
  523. #define HAS_SERVO_3 (PIN_EXISTS(SERVO3))
  524. #define HAS_FILAMENT_WIDTH_SENSOR (PIN_EXISTS(FILWIDTH))
  525. #define HAS_FILRUNOUT (PIN_EXISTS(FILRUNOUT))
  526. #define HAS_HOME (PIN_EXISTS(HOME))
  527. #define HAS_KILL (PIN_EXISTS(KILL))
  528. #define HAS_SUICIDE (PIN_EXISTS(SUICIDE))
  529. #define HAS_PHOTOGRAPH (PIN_EXISTS(PHOTOGRAPH))
  530. #define HAS_X_MIN (PIN_EXISTS(X_MIN))
  531. #define HAS_X_MAX (PIN_EXISTS(X_MAX))
  532. #define HAS_Y_MIN (PIN_EXISTS(Y_MIN))
  533. #define HAS_Y_MAX (PIN_EXISTS(Y_MAX))
  534. #define HAS_Z_MIN (PIN_EXISTS(Z_MIN))
  535. #define HAS_Z_MAX (PIN_EXISTS(Z_MAX))
  536. #define HAS_Z2_MIN (PIN_EXISTS(Z2_MIN))
  537. #define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX))
  538. #define HAS_Z_PROBE (PIN_EXISTS(Z_MIN_PROBE))
  539. #define HAS_SOLENOID_1 (PIN_EXISTS(SOL1))
  540. #define HAS_SOLENOID_2 (PIN_EXISTS(SOL2))
  541. #define HAS_SOLENOID_3 (PIN_EXISTS(SOL3))
  542. #define HAS_MICROSTEPS (PIN_EXISTS(X_MS1))
  543. #define HAS_MICROSTEPS_E0 (PIN_EXISTS(E0_MS1))
  544. #define HAS_MICROSTEPS_E1 (PIN_EXISTS(E1_MS1))
  545. #define HAS_MICROSTEPS_E2 (PIN_EXISTS(E2_MS1))
  546. #define HAS_STEPPER_RESET (PIN_EXISTS(STEPPER_RESET))
  547. #define HAS_X_ENABLE (PIN_EXISTS(X_ENABLE))
  548. #define HAS_X2_ENABLE (PIN_EXISTS(X2_ENABLE))
  549. #define HAS_Y_ENABLE (PIN_EXISTS(Y_ENABLE))
  550. #define HAS_Y2_ENABLE (PIN_EXISTS(Y2_ENABLE))
  551. #define HAS_Z_ENABLE (PIN_EXISTS(Z_ENABLE))
  552. #define HAS_Z2_ENABLE (PIN_EXISTS(Z2_ENABLE))
  553. #define HAS_E0_ENABLE (PIN_EXISTS(E0_ENABLE))
  554. #define HAS_E1_ENABLE (PIN_EXISTS(E1_ENABLE))
  555. #define HAS_E2_ENABLE (PIN_EXISTS(E2_ENABLE))
  556. #define HAS_E3_ENABLE (PIN_EXISTS(E3_ENABLE))
  557. #define HAS_E4_ENABLE (PIN_EXISTS(E4_ENABLE))
  558. #define HAS_X_DIR (PIN_EXISTS(X_DIR))
  559. #define HAS_X2_DIR (PIN_EXISTS(X2_DIR))
  560. #define HAS_Y_DIR (PIN_EXISTS(Y_DIR))
  561. #define HAS_Y2_DIR (PIN_EXISTS(Y2_DIR))
  562. #define HAS_Z_DIR (PIN_EXISTS(Z_DIR))
  563. #define HAS_Z2_DIR (PIN_EXISTS(Z2_DIR))
  564. #define HAS_E0_DIR (PIN_EXISTS(E0_DIR))
  565. #define HAS_E1_DIR (PIN_EXISTS(E1_DIR))
  566. #define HAS_E2_DIR (PIN_EXISTS(E2_DIR))
  567. #define HAS_E3_DIR (PIN_EXISTS(E3_DIR))
  568. #define HAS_E4_DIR (PIN_EXISTS(E4_DIR))
  569. #define HAS_X_STEP (PIN_EXISTS(X_STEP))
  570. #define HAS_X2_STEP (PIN_EXISTS(X2_STEP))
  571. #define HAS_Y_STEP (PIN_EXISTS(Y_STEP))
  572. #define HAS_Y2_STEP (PIN_EXISTS(Y2_STEP))
  573. #define HAS_Z_STEP (PIN_EXISTS(Z_STEP))
  574. #define HAS_Z2_STEP (PIN_EXISTS(Z2_STEP))
  575. #define HAS_E0_STEP (PIN_EXISTS(E0_STEP))
  576. #define HAS_E1_STEP (PIN_EXISTS(E1_STEP))
  577. #define HAS_E2_STEP (PIN_EXISTS(E2_STEP))
  578. #define HAS_E3_STEP (PIN_EXISTS(E3_STEP))
  579. #define HAS_E4_STEP (PIN_EXISTS(E4_STEP))
  580. #define HAS_MOTOR_CURRENT_PWM (PIN_EXISTS(MOTOR_CURRENT_PWM_XY) || PIN_EXISTS(MOTOR_CURRENT_PWM_Z) || PIN_EXISTS(MOTOR_CURRENT_PWM_E))
  581. #define HAS_TEMP_HOTEND (HAS_TEMP_0 || ENABLED(HEATER_0_USES_MAX6675))
  582. /**
  583. * Helper Macros for heaters and extruder fan
  584. */
  585. #define WRITE_HEATER_0P(v) WRITE(HEATER_0_PIN, v)
  586. #if EXTRUDERS > 1 || ENABLED(HEATERS_PARALLEL)
  587. #define WRITE_HEATER_1(v) WRITE(HEATER_1_PIN, v)
  588. #if EXTRUDERS > 2
  589. #define WRITE_HEATER_2(v) WRITE(HEATER_2_PIN, v)
  590. #if EXTRUDERS > 3
  591. #define WRITE_HEATER_3(v) WRITE(HEATER_3_PIN, v)
  592. #endif
  593. #endif
  594. #endif
  595. #if ENABLED(HEATERS_PARALLEL)
  596. #define WRITE_HEATER_0(v) { WRITE_HEATER_0P(v); WRITE_HEATER_1(v); }
  597. #else
  598. #define WRITE_HEATER_0(v) WRITE_HEATER_0P(v)
  599. #endif
  600. #if HAS_HEATER_BED
  601. #define WRITE_HEATER_BED(v) WRITE(HEATER_BED_PIN, v)
  602. #endif
  603. /**
  604. * Up to 3 PWM fans
  605. */
  606. #if HAS_FAN2
  607. #define FAN_COUNT 3
  608. #elif HAS_FAN1
  609. #define FAN_COUNT 2
  610. #elif HAS_FAN0
  611. #define FAN_COUNT 1
  612. #else
  613. #define FAN_COUNT 0
  614. #endif
  615. #if HAS_FAN0
  616. #define WRITE_FAN(v) WRITE(FAN_PIN, v)
  617. #define WRITE_FAN0(v) WRITE_FAN(v)
  618. #endif
  619. #if HAS_FAN1
  620. #define WRITE_FAN1(v) WRITE(FAN1_PIN, v)
  621. #endif
  622. #if HAS_FAN2
  623. #define WRITE_FAN2(v) WRITE(FAN2_PIN, v)
  624. #endif
  625. #define WRITE_FAN_N(n, v) WRITE_FAN##n(v)
  626. #define HAS_BUZZER (PIN_EXISTS(BEEPER) || defined(LCD_USE_I2C_BUZZER))
  627. #if HAS_SERVOS
  628. #ifndef X_ENDSTOP_SERVO_NR
  629. #define X_ENDSTOP_SERVO_NR -1
  630. #endif
  631. #ifndef Y_ENDSTOP_SERVO_NR
  632. #define Y_ENDSTOP_SERVO_NR -1
  633. #endif
  634. #ifndef Z_ENDSTOP_SERVO_NR
  635. #define Z_ENDSTOP_SERVO_NR -1
  636. #endif
  637. #if X_ENDSTOP_SERVO_NR >= 0 || Y_ENDSTOP_SERVO_NR >= 0 || HAS_Z_ENDSTOP_SERVO
  638. #define HAS_SERVO_ENDSTOPS true
  639. #define SERVO_ENDSTOP_IDS { X_ENDSTOP_SERVO_NR, Y_ENDSTOP_SERVO_NR, Z_ENDSTOP_SERVO_NR }
  640. #endif
  641. #endif
  642. #if ( (HAS_Z_MIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)) || HAS_Z_PROBE ) \
  643. && ( \
  644. ENABLED(FIX_MOUNTED_PROBE) \
  645. || ENABLED(MECHANICAL_PROBE) \
  646. || HAS_Z_ENDSTOP_SERVO \
  647. || ENABLED(Z_PROBE_ALLEN_KEY) \
  648. || ENABLED(Z_PROBE_SLED) \
  649. )
  650. #define HAS_Z_MIN_PROBE
  651. #endif
  652. #endif //CONFIGURATION_LCD
  653. #endif //CONDITIONALS_H