Conditionals_post.h 92 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /**
  24. * Conditionals_post.h
  25. * Internal defines that depend on Configurations and Pins but are not user-editable.
  26. */
  27. #ifdef GITHUB_ACTIONS
  28. // Extras for CI testing
  29. #endif
  30. // Arduino IDE with Teensy Additions
  31. #ifdef TEENSYDUINO
  32. #undef max
  33. #define max(a,b) ((a)>(b)?(a):(b))
  34. #undef min
  35. #define min(a,b) ((a)<(b)?(a):(b))
  36. #undef NOT_A_PIN // Override Teensyduino legacy CapSense define work-around
  37. #define NOT_A_PIN 0 // For PINS_DEBUGGING
  38. #endif
  39. // ADC
  40. #ifdef BOARD_ADC_VREF_MV
  41. #define ADC_VREF_MV BOARD_ADC_VREF_MV
  42. #else
  43. #define ADC_VREF_MV HAL_ADC_VREF_MV
  44. #endif
  45. // Determine which type of 'EEPROM' is in use
  46. #if ENABLED(EEPROM_SETTINGS)
  47. // EEPROM type may be defined by compile flags, configs, HALs, or pins
  48. // Set additional flags to let HALs choose in their Conditionals_post.h
  49. #if ANY(FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION, SDCARD_EEPROM_EMULATION, QSPI_EEPROM)
  50. #define USE_EMULATED_EEPROM 1
  51. #elif ANY(I2C_EEPROM, SPI_EEPROM)
  52. #define USE_WIRED_EEPROM 1
  53. #elif ENABLED(IIC_BL24CXX_EEPROM)
  54. // nothing
  55. #else
  56. #define USE_FALLBACK_EEPROM 1
  57. #endif
  58. #else
  59. #undef I2C_EEPROM
  60. #undef SPI_EEPROM
  61. #undef QSPI_EEPROM
  62. #undef SDCARD_EEPROM_EMULATION
  63. #undef SRAM_EEPROM_EMULATION
  64. #undef FLASH_EEPROM_EMULATION
  65. #undef IIC_BL24CXX_EEPROM
  66. #endif
  67. #if DISABLED(IIC_BL24CXX_EEPROM)
  68. #undef OTA_FIRMWARE_UPDATE
  69. #endif
  70. /**
  71. * Axis lengths and center
  72. */
  73. #if HAS_I_AXIS && !defined(AXIS4_NAME)
  74. #define AXIS4_NAME 'A'
  75. #endif
  76. #if HAS_J_AXIS && !defined(AXIS5_NAME)
  77. #define AXIS5_NAME 'B'
  78. #endif
  79. #if HAS_K_AXIS && !defined(AXIS6_NAME)
  80. #define AXIS6_NAME 'C'
  81. #endif
  82. #if HAS_U_AXIS && !defined(AXIS7_NAME)
  83. #define AXIS7_NAME 'U'
  84. #endif
  85. #if HAS_V_AXIS && !defined(AXIS8_NAME)
  86. #define AXIS8_NAME 'V'
  87. #endif
  88. #if HAS_W_AXIS && !defined(AXIS9_NAME)
  89. #define AXIS9_NAME 'W'
  90. #endif
  91. #if HAS_X_AXIS
  92. #define X_MAX_LENGTH (X_MAX_POS - (X_MIN_POS))
  93. #endif
  94. #if HAS_Y_AXIS
  95. #define Y_MAX_LENGTH (Y_MAX_POS - (Y_MIN_POS))
  96. #endif
  97. #if HAS_Z_AXIS
  98. #define Z_MAX_LENGTH (Z_MAX_POS - (Z_MIN_POS))
  99. #else
  100. #undef CONTROLLER_FAN_USE_Z_ONLY
  101. #endif
  102. #if HAS_I_AXIS
  103. #define I_MAX_LENGTH (I_MAX_POS - (I_MIN_POS))
  104. #endif
  105. #if HAS_J_AXIS
  106. #define J_MAX_LENGTH (J_MAX_POS - (J_MIN_POS))
  107. #endif
  108. #if HAS_K_AXIS
  109. #define K_MAX_LENGTH (K_MAX_POS - (K_MIN_POS))
  110. #endif
  111. #if HAS_U_AXIS
  112. #define U_MAX_LENGTH (U_MAX_POS - (U_MIN_POS))
  113. #endif
  114. #if HAS_V_AXIS
  115. #define V_MAX_LENGTH (V_MAX_POS - (V_MIN_POS))
  116. #endif
  117. #if HAS_W_AXIS
  118. #define W_MAX_LENGTH (W_MAX_POS - (W_MIN_POS))
  119. #endif
  120. // Defined only if the sanity-check is bypassed
  121. #if HAS_X_AXIS && !defined(X_BED_SIZE)
  122. #define X_BED_SIZE X_MAX_LENGTH
  123. #endif
  124. #if HAS_Y_AXIS && !defined(Y_BED_SIZE)
  125. #define Y_BED_SIZE Y_MAX_LENGTH
  126. #endif
  127. #if HAS_I_AXIS && !defined(I_BED_SIZE)
  128. #define I_BED_SIZE I_MAX_LENGTH
  129. #endif
  130. #if HAS_J_AXIS && !defined(J_BED_SIZE)
  131. #define J_BED_SIZE J_MAX_LENGTH
  132. #endif
  133. #if HAS_K_AXIS && !defined(K_BED_SIZE)
  134. #define K_BED_SIZE K_MAX_LENGTH
  135. #endif
  136. #if HAS_U_AXIS && !defined(U_BED_SIZE)
  137. #define U_BED_SIZE U_MAX_LENGTH
  138. #endif
  139. #if HAS_V_AXIS && !defined(V_BED_SIZE)
  140. #define V_BED_SIZE V_MAX_LENGTH
  141. #endif
  142. #if HAS_W_AXIS && !defined(W_BED_SIZE)
  143. #define W_BED_SIZE W_MAX_LENGTH
  144. #endif
  145. // Require 0,0 bed center for Delta, SCARA, and Polargraph
  146. #if IS_KINEMATIC
  147. #define BED_CENTER_AT_0_0
  148. #endif
  149. // Define center values for future use
  150. #if HAS_X_AXIS
  151. #define _X_HALF_BED ((X_BED_SIZE) / 2)
  152. #endif
  153. #if HAS_Y_AXIS
  154. #define _Y_HALF_BED ((Y_BED_SIZE) / 2)
  155. #endif
  156. #if HAS_I_AXIS
  157. #define _I_HALF_IMAX ((I_BED_SIZE) / 2)
  158. #endif
  159. #if HAS_J_AXIS
  160. #define _J_HALF_JMAX ((J_BED_SIZE) / 2)
  161. #endif
  162. #if HAS_K_AXIS
  163. #define _K_HALF_KMAX ((K_BED_SIZE) / 2)
  164. #endif
  165. #if HAS_U_AXIS
  166. #define _U_HALF_UMAX ((U_BED_SIZE) / 2)
  167. #endif
  168. #if HAS_V_AXIS
  169. #define _V_HALF_VMAX ((V_BED_SIZE) / 2)
  170. #endif
  171. #if HAS_W_AXIS
  172. #define _W_HALF_WMAX ((W_BED_SIZE) / 2)
  173. #endif
  174. #if HAS_X_AXIS
  175. #define X_CENTER TERN(BED_CENTER_AT_0_0, 0, _X_HALF_BED)
  176. #endif
  177. #if HAS_Y_AXIS
  178. #define Y_CENTER TERN(BED_CENTER_AT_0_0, 0, _Y_HALF_BED)
  179. #define XY_CENTER { X_CENTER, Y_CENTER }
  180. #endif
  181. #if HAS_I_AXIS
  182. #define I_CENTER _I_HALF_BED
  183. #endif
  184. #if HAS_J_AXIS
  185. #define J_CENTER _J_HALF_BED
  186. #endif
  187. #if HAS_K_AXIS
  188. #define K_CENTER _K_HALF_BED
  189. #endif
  190. #if HAS_U_AXIS
  191. #define U_CENTER _U_HALF_BED
  192. #endif
  193. #if HAS_V_AXIS
  194. #define V_CENTER _V_HALF_BED
  195. #endif
  196. #if HAS_W_AXIS
  197. #define W_CENTER _W_HALF_BED
  198. #endif
  199. // Get the linear boundaries of the bed
  200. #if HAS_X_AXIS
  201. #define X_MIN_BED (X_CENTER - _X_HALF_BED)
  202. #define X_MAX_BED (X_MIN_BED + X_BED_SIZE)
  203. #endif
  204. #if HAS_Y_AXIS
  205. #define Y_MIN_BED (Y_CENTER - _Y_HALF_BED)
  206. #define Y_MAX_BED (Y_MIN_BED + Y_BED_SIZE)
  207. #endif
  208. #if HAS_I_AXIS
  209. #define I_MINIM (I_CENTER - _I_HALF_BED_SIZE)
  210. #define I_MAXIM (I_MINIM + I_BED_SIZE)
  211. #endif
  212. #if HAS_J_AXIS
  213. #define J_MINIM (J_CENTER - _J_HALF_BED_SIZE)
  214. #define J_MAXIM (J_MINIM + J_BED_SIZE)
  215. #endif
  216. #if HAS_K_AXIS
  217. #define K_MINIM (K_CENTER - _K_HALF_BED_SIZE)
  218. #define K_MAXIM (K_MINIM + K_BED_SIZE)
  219. #endif
  220. #if HAS_U_AXIS
  221. #define U_MINIM (U_CENTER - _U_HALF_BED_SIZE)
  222. #define U_MAXIM (U_MINIM + U_BED_SIZE)
  223. #endif
  224. #if HAS_V_AXIS
  225. #define V_MINIM (V_CENTER - _V_HALF_BED_SIZE)
  226. #define V_MAXIM (V_MINIM + V_BED_SIZE)
  227. #endif
  228. #if HAS_W_AXIS
  229. #define W_MINIM (W_CENTER - _W_HALF_BED_SIZE)
  230. #define W_MAXIM (W_MINIM + W_BED_SIZE)
  231. #endif
  232. /**
  233. * Dual X Carriage
  234. */
  235. #if ENABLED(DUAL_X_CARRIAGE)
  236. #ifndef X1_MIN_POS
  237. #define X1_MIN_POS X_MIN_POS
  238. #endif
  239. #ifndef X1_MAX_POS
  240. #define X1_MAX_POS X_BED_SIZE
  241. #endif
  242. #endif
  243. // Calibration codes only for non-core axes
  244. #if ANY(BACKLASH_GCODE, CALIBRATION_GCODE)
  245. #if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX)
  246. #define CAN_CALIBRATE(A,B) TERN0(HAS_##A##_AXIS, (_AXIS(A) == B))
  247. #else
  248. #define CAN_CALIBRATE(A,B) ENABLED(HAS_##A##_AXIS)
  249. #endif
  250. #define AXIS_CAN_CALIBRATE(A) CAN_CALIBRATE(A,NORMAL_AXIS)
  251. #else
  252. #define AXIS_CAN_CALIBRATE(A) false
  253. #endif
  254. /**
  255. * No adjustable bed on non-cartesians
  256. */
  257. #if IS_KINEMATIC
  258. #undef LCD_BED_TRAMMING
  259. #undef SLOWDOWN
  260. #endif
  261. /**
  262. * SCARA cannot use SLOWDOWN and requires QUICKHOME
  263. * Printable radius assumes joints can fully extend
  264. */
  265. #if IS_SCARA
  266. #if ENABLED(AXEL_TPARA)
  267. #define PRINTABLE_RADIUS (TPARA_LINKAGE_1 + TPARA_LINKAGE_2)
  268. #else
  269. #define QUICK_HOME
  270. #define PRINTABLE_RADIUS (SCARA_LINKAGE_1 + SCARA_LINKAGE_2)
  271. #endif
  272. #endif
  273. /**
  274. * Set the home position based on settings or manual overrides
  275. */
  276. #if HAS_X_AXIS
  277. #ifdef MANUAL_X_HOME_POS
  278. #define X_HOME_POS MANUAL_X_HOME_POS
  279. #else
  280. #define X_END_POS TERN(X_HOME_TO_MIN, X_MIN_POS, X_MAX_POS)
  281. #if ENABLED(BED_CENTER_AT_0_0)
  282. #define X_HOME_POS TERN(DELTA, 0, X_END_POS)
  283. #else
  284. #define X_HOME_POS TERN(DELTA, X_MIN_POS + (X_BED_SIZE) * 0.5, X_END_POS)
  285. #endif
  286. #endif
  287. #endif
  288. #if HAS_Y_AXIS
  289. #ifdef MANUAL_Y_HOME_POS
  290. #define Y_HOME_POS MANUAL_Y_HOME_POS
  291. #else
  292. #define Y_END_POS TERN(Y_HOME_TO_MIN, Y_MIN_POS, Y_MAX_POS)
  293. #if ENABLED(BED_CENTER_AT_0_0)
  294. #define Y_HOME_POS TERN(DELTA, 0, Y_END_POS)
  295. #else
  296. #define Y_HOME_POS TERN(DELTA, Y_MIN_POS + (Y_BED_SIZE) * 0.5, Y_END_POS)
  297. #endif
  298. #endif
  299. #endif
  300. #ifdef MANUAL_Z_HOME_POS
  301. #define Z_HOME_POS MANUAL_Z_HOME_POS
  302. #else
  303. #define Z_HOME_POS TERN(Z_HOME_TO_MIN, Z_MIN_POS, Z_MAX_POS)
  304. #endif
  305. #if HAS_I_AXIS
  306. #ifdef MANUAL_I_HOME_POS
  307. #define I_HOME_POS MANUAL_I_HOME_POS
  308. #else
  309. #define I_HOME_POS TERN(I_HOME_TO_MIN, I_MIN_POS, I_MAX_POS)
  310. #endif
  311. #endif
  312. #if HAS_J_AXIS
  313. #ifdef MANUAL_J_HOME_POS
  314. #define J_HOME_POS MANUAL_J_HOME_POS
  315. #else
  316. #define J_HOME_POS TERN(J_HOME_TO_MIN, J_MIN_POS, J_MAX_POS)
  317. #endif
  318. #endif
  319. #if HAS_K_AXIS
  320. #ifdef MANUAL_K_HOME_POS
  321. #define K_HOME_POS MANUAL_K_HOME_POS
  322. #else
  323. #define K_HOME_POS TERN(K_HOME_TO_MIN, K_MIN_POS, K_MAX_POS)
  324. #endif
  325. #endif
  326. #if HAS_U_AXIS
  327. #ifdef MANUAL_U_HOME_POS
  328. #define U_HOME_POS MANUAL_U_HOME_POS
  329. #else
  330. #define U_HOME_POS TERN(U_HOME_TO_MIN, U_MIN_POS, U_MAX_POS)
  331. #endif
  332. #endif
  333. #if HAS_V_AXIS
  334. #ifdef MANUAL_V_HOME_POS
  335. #define V_HOME_POS MANUAL_V_HOME_POS
  336. #else
  337. #define V_HOME_POS TERN(V_HOME_TO_MIN, V_MIN_POS, V_MAX_POS)
  338. #endif
  339. #endif
  340. #if HAS_W_AXIS
  341. #ifdef MANUAL_W_HOME_POS
  342. #define W_HOME_POS MANUAL_W_HOME_POS
  343. #else
  344. #define W_HOME_POS TERN(W_HOME_TO_MIN, W_MIN_POS, W_MAX_POS)
  345. #endif
  346. #endif
  347. /**
  348. * If DELTA_HEIGHT isn't defined use the old setting
  349. */
  350. #if ENABLED(DELTA) && !defined(DELTA_HEIGHT)
  351. #define DELTA_HEIGHT Z_HOME_POS
  352. #endif
  353. /**
  354. * Z Sled Probe requires Z_SAFE_HOMING
  355. */
  356. #if ENABLED(Z_PROBE_SLED)
  357. #define Z_SAFE_HOMING
  358. #endif
  359. /**
  360. * DELTA should ignore Z_SAFE_HOMING and SLOWDOWN
  361. */
  362. #if ENABLED(DELTA)
  363. #undef Z_SAFE_HOMING
  364. #endif
  365. #ifndef MESH_INSET
  366. #define MESH_INSET 0
  367. #endif
  368. /**
  369. * Safe Homing Options
  370. */
  371. #if ENABLED(Z_SAFE_HOMING)
  372. #if ENABLED(AUTO_BED_LEVELING_UBL)
  373. // Home close to center so grid points have z heights very close to 0
  374. #define _SAFE_POINT(A) (((GRID_MAX_POINTS_##A) / 2) * (A##_BED_SIZE - 2 * (MESH_INSET)) / (GRID_MAX_POINTS_##A - 1) + MESH_INSET)
  375. #else
  376. #define _SAFE_POINT(A) A##_CENTER
  377. #endif
  378. #ifndef Z_SAFE_HOMING_X_POINT
  379. #define Z_SAFE_HOMING_X_POINT _SAFE_POINT(X)
  380. #endif
  381. #ifndef Z_SAFE_HOMING_Y_POINT
  382. #define Z_SAFE_HOMING_Y_POINT _SAFE_POINT(Y)
  383. #endif
  384. #endif
  385. #ifdef GRID_MAX_POINTS_X
  386. #define GRID_MAX_CELLS_X (GRID_MAX_POINTS_X - 1)
  387. #define GRID_MAX_CELLS_Y (GRID_MAX_POINTS_Y - 1)
  388. #endif
  389. /**
  390. * Host keep alive
  391. */
  392. #ifndef DEFAULT_KEEPALIVE_INTERVAL
  393. #define DEFAULT_KEEPALIVE_INTERVAL 2
  394. #endif
  395. /**
  396. * Provide a MAX_AUTORETRACT for older configs
  397. */
  398. #if ENABLED(FWRETRACT) && !defined(MAX_AUTORETRACT)
  399. #define MAX_AUTORETRACT 99
  400. #endif
  401. /**
  402. * Provide a DEFAULT_VOLUMETRIC_EXTRUDER_LIMIT in case NO_VOLUMETRICS is enabled
  403. */
  404. #ifndef DEFAULT_VOLUMETRIC_EXTRUDER_LIMIT
  405. #define DEFAULT_VOLUMETRIC_EXTRUDER_LIMIT 0.00
  406. #endif
  407. /**
  408. * LCD Contrast for Graphical Displays
  409. */
  410. #if ENABLED(CARTESIO_UI)
  411. #define _LCD_CONTRAST_MIN 60
  412. #define _LCD_CONTRAST_INIT 90
  413. #define _LCD_CONTRAST_MAX 140
  414. #elif ENABLED(miniVIKI)
  415. #define _LCD_CONTRAST_MIN 75
  416. #define _LCD_CONTRAST_INIT 95
  417. #define _LCD_CONTRAST_MAX 115
  418. #elif ENABLED(VIKI2)
  419. #define _LCD_CONTRAST_INIT 140
  420. #elif ENABLED(WYH_L12864)
  421. #define _LCD_CONTRAST_INIT 190
  422. #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
  423. #define _LCD_CONTRAST_MIN 90
  424. #define _LCD_CONTRAST_INIT 110
  425. #define _LCD_CONTRAST_MAX 130
  426. #elif ENABLED(AZSMZ_12864)
  427. #define _LCD_CONTRAST_MIN 120
  428. #define _LCD_CONTRAST_INIT 190
  429. #elif ANY(MKS_LCD12864A, MKS_LCD12864B)
  430. #define _LCD_CONTRAST_MIN 120
  431. #define _LCD_CONTRAST_INIT 205
  432. #elif ANY(MKS_MINI_12864, ENDER2_STOCKDISPLAY)
  433. #define _LCD_CONTRAST_MIN 120
  434. #define _LCD_CONTRAST_INIT 195
  435. #elif ENABLED(FYSETC_MINI_12864_2_1)
  436. #define _LCD_CONTRAST_MIN 230
  437. #define _LCD_CONTRAST_INIT 255
  438. #elif ENABLED(FYSETC_MINI_12864)
  439. #define _LCD_CONTRAST_MIN 180
  440. #define _LCD_CONTRAST_INIT 220
  441. #elif ENABLED(ULTI_CONTROLLER)
  442. #define _LCD_CONTRAST_INIT 127
  443. #define _LCD_CONTRAST_MAX 254
  444. #elif ENABLED(MAKRPANEL)
  445. #define _LCD_CONTRAST_INIT 17
  446. #elif ENABLED(MINIPANEL)
  447. #define _LCD_CONTRAST_INIT 150
  448. #elif ENABLED(ZONESTAR_12864OLED)
  449. #define _LCD_CONTRAST_MIN 64
  450. #define _LCD_CONTRAST_INIT 128
  451. #elif ENABLED(EMOTION_TECH_LCD)
  452. #define _LCD_CONTRAST_INIT 140
  453. #elif IS_TFTGLCD_PANEL
  454. #define _LCD_CONTRAST_INIT 250
  455. #endif
  456. #ifdef _LCD_CONTRAST_INIT
  457. #define HAS_LCD_CONTRAST 1
  458. #ifndef LCD_CONTRAST_MIN
  459. #ifdef _LCD_CONTRAST_MIN
  460. #define LCD_CONTRAST_MIN _LCD_CONTRAST_MIN
  461. #else
  462. #define LCD_CONTRAST_MIN 0
  463. #endif
  464. #endif
  465. #ifndef LCD_CONTRAST_INIT
  466. #define LCD_CONTRAST_INIT _LCD_CONTRAST_INIT
  467. #endif
  468. #ifndef LCD_CONTRAST_MAX
  469. #ifdef _LCD_CONTRAST_MAX
  470. #define LCD_CONTRAST_MAX _LCD_CONTRAST_MAX
  471. #elif _LCD_CONTRAST_INIT > 63
  472. #define LCD_CONTRAST_MAX 255
  473. #else
  474. #define LCD_CONTRAST_MAX 63 // ST7567 6-bits contrast
  475. #endif
  476. #endif
  477. #ifndef LCD_CONTRAST_DEFAULT
  478. #define LCD_CONTRAST_DEFAULT LCD_CONTRAST_INIT
  479. #endif
  480. #endif
  481. /**
  482. * Override the SD_DETECT_STATE set in Configuration_adv.h
  483. * and enable sharing of onboard SD host drives (all platforms but AGCM4)
  484. */
  485. #if HAS_MEDIA
  486. #if HAS_SD_HOST_DRIVE && SD_CONNECTION_IS(ONBOARD) && DISABLED(KEEP_SD_DETECT)
  487. //
  488. // The external SD card is not used. Hardware SPI is used to access the card.
  489. // When sharing the SD card with a PC we want the menu options to
  490. // mount/unmount the card and refresh it. So we disable card detect.
  491. //
  492. #undef SD_DETECT_PIN
  493. #define HAS_SHARED_MEDIA 1
  494. #endif
  495. // Extender cable doesn't support SD_DETECT_PIN
  496. #if ENABLED(NO_SD_DETECT)
  497. #undef SD_DETECT_PIN
  498. #endif
  499. // Not onboard or custom cable
  500. #if SD_CONNECTION_IS(LCD) || !defined(SDCARD_CONNECTION)
  501. #define SD_CONNECTION_TYPICAL 1
  502. #endif
  503. // Set SD_DETECT_STATE based on hardware if not overridden
  504. #if PIN_EXISTS(SD_DETECT)
  505. #define HAS_SD_DETECT 1
  506. #ifndef SD_DETECT_STATE
  507. #if ALL(SD_CONNECTION_TYPICAL, HAS_MARLINUI_MENU, ELB_FULL_GRAPHIC_CONTROLLER)
  508. #define SD_DETECT_STATE HIGH
  509. #else
  510. #define SD_DETECT_STATE LOW
  511. #endif
  512. #endif
  513. #endif
  514. #if DISABLED(USB_FLASH_DRIVE_SUPPORT) || ALL(MULTI_VOLUME, VOLUME_SD_ONBOARD)
  515. #if ENABLED(ONBOARD_SDIO)
  516. #define NEED_SD2CARD_SDIO 1
  517. #else
  518. #define NEED_SD2CARD_SPI 1
  519. #endif
  520. #endif
  521. #if HAS_SD_DETECT && NONE(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI, EXTENSIBLE_UI, HAS_DWIN_E3V2, HAS_U8GLIB_I2C_OLED)
  522. #define REINIT_NOISY_LCD 1 // Have the LCD re-init on SD insertion
  523. #endif
  524. #endif // HAS_MEDIA
  525. /**
  526. * Power Supply
  527. */
  528. #ifndef PSU_NAME
  529. #if DISABLED(PSU_CONTROL)
  530. #define PSU_NAME "Generic" // No control
  531. #elif PSU_ACTIVE_STATE
  532. #define PSU_NAME "XBox" // X-Box 360 (203W)
  533. #else
  534. #define PSU_NAME "ATX" // ATX style
  535. #endif
  536. #endif
  537. #if ENABLED(PSU_CONTROL)
  538. #ifndef PSU_POWERUP_DELAY
  539. #define PSU_POWERUP_DELAY 250
  540. #endif
  541. #ifndef POWER_OFF_DELAY
  542. #define POWER_OFF_DELAY 0
  543. #endif
  544. #endif
  545. /**
  546. * Temp Sensor defines; set up pins as needed.
  547. */
  548. // Usurp a sensor to do redundant readings
  549. #if TEMP_SENSOR_REDUNDANT
  550. #ifndef TEMP_SENSOR_REDUNDANT_SOURCE
  551. #define TEMP_SENSOR_REDUNDANT_SOURCE E1
  552. #endif
  553. #ifndef TEMP_SENSOR_REDUNDANT_TARGET
  554. #define TEMP_SENSOR_REDUNDANT_TARGET E0
  555. #endif
  556. #if !PIN_EXISTS(TEMP_REDUNDANT)
  557. #ifndef TEMP_SENSOR_REDUNDANT_MAX_DIFF
  558. #define TEMP_SENSOR_REDUNDANT_MAX_DIFF 10
  559. #endif
  560. #if REDUNDANT_TEMP_MATCH(SOURCE, BOARD)
  561. #if !PIN_EXISTS(TEMP_BOARD)
  562. #error "TEMP_SENSOR_REDUNDANT_SOURCE set to BOARD requires TEMP_BOARD_PIN."
  563. #else
  564. #define TEMP_REDUNDANT_PIN TEMP_BOARD_PIN
  565. #endif
  566. #elif REDUNDANT_TEMP_MATCH(SOURCE, COOLER)
  567. #if !PIN_EXISTS(TEMP_COOLER)
  568. #error "TEMP_SENSOR_REDUNDANT_SOURCE set to COOLER requires TEMP_COOLER_PIN."
  569. #else
  570. #define TEMP_REDUNDANT_PIN TEMP_COOLER_PIN
  571. #endif
  572. #elif REDUNDANT_TEMP_MATCH(SOURCE, PROBE)
  573. #if !PIN_EXISTS(TEMP_PROBE)
  574. #error "TEMP_SENSOR_REDUNDANT_SOURCE set to PROBE requires TEMP_PROBE_PIN."
  575. #else
  576. #define TEMP_REDUNDANT_PIN TEMP_PROBE_PIN
  577. #endif
  578. #elif REDUNDANT_TEMP_MATCH(SOURCE, CHAMBER)
  579. #if !PIN_EXISTS(TEMP_CHAMBER)
  580. #error "TEMP_SENSOR_REDUNDANT_SOURCE set to CHAMBER requires TEMP_CHAMBER_PIN."
  581. #else
  582. #define TEMP_REDUNDANT_PIN TEMP_CHAMBER_PIN
  583. #endif
  584. #elif REDUNDANT_TEMP_MATCH(SOURCE, BED)
  585. #if !PIN_EXISTS(TEMP_BED)
  586. #error "TEMP_SENSOR_REDUNDANT_SOURCE set to BED requires TEMP_BED_PIN."
  587. #else
  588. #define TEMP_REDUNDANT_PIN TEMP_BED_PIN
  589. #endif
  590. #elif REDUNDANT_TEMP_MATCH(SOURCE, E0)
  591. #if !PIN_EXISTS(TEMP_0)
  592. #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E0 requires TEMP_0_PIN."
  593. #else
  594. #define TEMP_REDUNDANT_PIN TEMP_0_PIN
  595. #endif
  596. #elif REDUNDANT_TEMP_MATCH(SOURCE, E1)
  597. #if !PIN_EXISTS(TEMP_1)
  598. #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E1 requires TEMP_1_PIN."
  599. #else
  600. #define TEMP_REDUNDANT_PIN TEMP_1_PIN
  601. #endif
  602. #elif REDUNDANT_TEMP_MATCH(SOURCE, E2)
  603. #if !PIN_EXISTS(TEMP_2)
  604. #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E2 requires TEMP_2_PIN."
  605. #else
  606. #define TEMP_REDUNDANT_PIN TEMP_2_PIN
  607. #endif
  608. #elif REDUNDANT_TEMP_MATCH(SOURCE, E3)
  609. #if !PIN_EXISTS(TEMP_3)
  610. #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E3 requires TEMP_3_PIN."
  611. #else
  612. #define TEMP_REDUNDANT_PIN TEMP_3_PIN
  613. #endif
  614. #elif REDUNDANT_TEMP_MATCH(SOURCE, E4)
  615. #if !PIN_EXISTS(TEMP_4)
  616. #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E4 requires TEMP_4_PIN."
  617. #else
  618. #define TEMP_REDUNDANT_PIN TEMP_4_PIN
  619. #endif
  620. #elif REDUNDANT_TEMP_MATCH(SOURCE, E5)
  621. #if !PIN_EXISTS(TEMP_5)
  622. #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E5 requires TEMP_5_PIN."
  623. #else
  624. #define TEMP_REDUNDANT_PIN TEMP_5_PIN
  625. #endif
  626. #elif REDUNDANT_TEMP_MATCH(SOURCE, E6)
  627. #if !PIN_EXISTS(TEMP_6)
  628. #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E6 requires TEMP_6_PIN."
  629. #else
  630. #define TEMP_REDUNDANT_PIN TEMP_6_PIN
  631. #endif
  632. #elif REDUNDANT_TEMP_MATCH(SOURCE, E7)
  633. #if !PIN_EXISTS(TEMP_7)
  634. #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E7 requires TEMP_7_PIN."
  635. #else
  636. #define TEMP_REDUNDANT_PIN TEMP_7_PIN
  637. #endif
  638. #endif
  639. #endif
  640. #endif
  641. /**
  642. * Compatibility layer for MAX (SPI) temp boards
  643. */
  644. #define TEMP_SENSOR_IS_ANY_MAX_TC(n) (TEMP_SENSOR_IS_MAX_TC(n) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E##n)))
  645. #if HAS_MAX_TC
  646. // Software SPI - enable if MISO/SCK are defined.
  647. #if TEMP_SENSOR_IS_ANY_MAX_TC(0) && DISABLED(TEMP_SENSOR_0_FORCE_HW_SPI) && PINS_EXIST(TEMP_0_MISO, TEMP_0_SCK)
  648. #if TEMP_SENSOR_0_IS_MAX31865 && !PIN_EXISTS(TEMP_0_MOSI)
  649. #error "TEMP_SENSOR_0 MAX31865 requires TEMP_0_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_0_FORCE_HW_SPI."
  650. #else
  651. #define TEMP_SENSOR_0_HAS_SPI_PINS 1
  652. #endif
  653. #endif
  654. #if TEMP_SENSOR_IS_ANY_MAX_TC(1) && DISABLED(TEMP_SENSOR_1_FORCE_HW_SPI) && PINS_EXIST(TEMP_1_MISO, TEMP_1_SCK)
  655. #if TEMP_SENSOR_1_IS_MAX31865 && !PIN_EXISTS(TEMP_1_MOSI)
  656. #error "TEMP_SENSOR_1 MAX31865 requires TEMP_1_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_1_FORCE_HW_SPI."
  657. #else
  658. #define TEMP_SENSOR_1_HAS_SPI_PINS 1
  659. #endif
  660. #endif
  661. #if TEMP_SENSOR_IS_ANY_MAX_TC(2) && DISABLED(TEMP_SENSOR_2_FORCE_HW_SPI) && PINS_EXIST(TEMP_2_MISO, TEMP_2_SCK)
  662. #if TEMP_SENSOR_2_IS_MAX31865 && !PIN_EXISTS(TEMP_2_MOSI)
  663. #error "TEMP_SENSOR_2 MAX31865 requires TEMP_2_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_2_FORCE_HW_SPI."
  664. #else
  665. #define TEMP_SENSOR_2_HAS_SPI_PINS 1
  666. #endif
  667. #endif
  668. #if (TEMP_SENSOR_IS_MAX_TC(BED)) && DISABLED(TEMP_SENSOR_BED_FORCE_HW_SPI) && PINS_EXIST(TEMP_BED_MISO, TEMP_BED_SCK)
  669. #if TEMP_SENSOR_BED_IS_MAX31865 && !PIN_EXISTS(TEMP_BED_MOSI)
  670. #error "TEMP_SENSOR_BED MAX31865 requires TEMP_BED_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_BED_FORCE_HW_SPI."
  671. #else
  672. #define TEMP_SENSOR_BED_HAS_SPI_PINS 1
  673. #endif
  674. #endif
  675. //
  676. // User-defined thermocouple libraries
  677. //
  678. // Add LIB_MAX6675 / LIB_MAX31855 / LIB_MAX31865 to the build_flags
  679. // to select a USER library for MAX6675, MAX31855, MAX31865
  680. //
  681. #if ALL(HAS_MAX6675, LIB_MAX6675)
  682. #define USE_LIB_MAX6675 1
  683. #endif
  684. #if ALL(HAS_MAX31855, LIB_MAX31855)
  685. #define USE_ADAFRUIT_MAX31855 1
  686. #endif
  687. #if ALL(HAS_MAX31865, LIB_MAX31865)
  688. #define USE_ADAFRUIT_MAX31865 1
  689. #elif HAS_MAX31865
  690. #define LIB_INTERNAL_MAX31865 1
  691. #endif
  692. #endif // HAS_MAX_TC
  693. /**
  694. * X_DUAL_ENDSTOPS endstop reassignment
  695. */
  696. #if ENABLED(X_DUAL_ENDSTOPS)
  697. #if X_HOME_TO_MAX
  698. #ifndef X2_MAX_ENDSTOP_HIT_STATE
  699. #if PIN_EXISTS(X2_STOP)
  700. #if X2_STOP_PIN == X_MIN_PIN
  701. #define X2_MAX_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
  702. #elif X2_STOP_PIN == X_MAX_PIN
  703. #define X2_MAX_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
  704. #elif X2_STOP_PIN == Y_MIN_PIN
  705. #define X2_MAX_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
  706. #elif X2_STOP_PIN == Y_MAX_PIN
  707. #define X2_MAX_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
  708. #elif X2_STOP_PIN == Z_MIN_PIN
  709. #define X2_MAX_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
  710. #elif X2_STOP_PIN == Z_MAX_PIN
  711. #define X2_MAX_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
  712. #endif
  713. #endif
  714. #endif
  715. #if !PIN_EXISTS(X2_MAX)
  716. #undef X2_MAX_PIN
  717. #if PIN_EXISTS(X2_STOP)
  718. #define X2_MAX_PIN X2_STOP_PIN
  719. #endif
  720. #endif
  721. #else
  722. #ifndef X2_MIN_ENDSTOP_HIT_STATE
  723. #if PIN_EXISTS(X2_STOP)
  724. #if X2_STOP_PIN == X_MIN_PIN
  725. #define X2_MIN_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
  726. #elif X2_STOP_PIN == X_MAX_PIN
  727. #define X2_MIN_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
  728. #elif X2_STOP_PIN == Y_MIN_PIN
  729. #define X2_MIN_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
  730. #elif X2_STOP_PIN == Y_MAX_PIN
  731. #define X2_MIN_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
  732. #elif X2_STOP_PIN == Z_MIN_PIN
  733. #define X2_MIN_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
  734. #elif X2_STOP_PIN == Z_MAX_PIN
  735. #define X2_MIN_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
  736. #endif
  737. #endif
  738. #endif
  739. #if !PIN_EXISTS(X2_MIN)
  740. #undef X2_MIN_PIN
  741. #if PIN_EXISTS(X2_STOP)
  742. #define X2_MIN_PIN X2_STOP_PIN
  743. #endif
  744. #endif
  745. #endif
  746. #ifndef X2_MAX_ENDSTOP_HIT_STATE
  747. #define X2_MAX_ENDSTOP_HIT_STATE HIGH
  748. #endif
  749. #ifndef X2_MIN_ENDSTOP_HIT_STATE
  750. #define X2_MIN_ENDSTOP_HIT_STATE HIGH
  751. #endif
  752. #endif
  753. /**
  754. * Y_DUAL_ENDSTOPS endstop reassignment
  755. */
  756. #if ENABLED(Y_DUAL_ENDSTOPS)
  757. #if Y_HOME_TO_MAX
  758. #ifndef Y2_MAX_ENDSTOP_HIT_STATE
  759. #if PIN_EXISTS(Y2_STOP)
  760. #if Y2_STOP_PIN == X_MIN_PIN
  761. #define Y2_MAX_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
  762. #elif Y2_STOP_PIN == X_MAX_PIN
  763. #define Y2_MAX_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
  764. #elif Y2_STOP_PIN == Y_MIN_PIN
  765. #define Y2_MAX_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
  766. #elif Y2_STOP_PIN == Y_MAX_PIN
  767. #define Y2_MAX_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
  768. #elif Y2_STOP_PIN == Z_MIN_PIN
  769. #define Y2_MAX_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
  770. #elif Y2_STOP_PIN == Z_MAX_PIN
  771. #define Y2_MAX_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
  772. #endif
  773. #endif
  774. #endif
  775. #if !PIN_EXISTS(Y2_MAX)
  776. #undef Y2_MAX_PIN
  777. #if PIN_EXISTS(Y2_STOP)
  778. #define Y2_MAX_PIN Y2_STOP_PIN
  779. #endif
  780. #endif
  781. #else
  782. #ifndef Y2_MIN_ENDSTOP_HIT_STATE
  783. #if PIN_EXISTS(Y2_STOP)
  784. #if Y2_STOP_PIN == X_MIN_PIN
  785. #define Y2_MIN_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
  786. #elif Y2_STOP_PIN == X_MAX_PIN
  787. #define Y2_MIN_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
  788. #elif Y2_STOP_PIN == Y_MIN_PIN
  789. #define Y2_MIN_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
  790. #elif Y2_STOP_PIN == Y_MAX_PIN
  791. #define Y2_MIN_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
  792. #elif Y2_STOP_PIN == Z_MIN_PIN
  793. #define Y2_MIN_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
  794. #elif Y2_STOP_PIN == Z_MAX_PIN
  795. #define Y2_MIN_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
  796. #endif
  797. #endif
  798. #endif
  799. #if !PIN_EXISTS(Y2_MIN)
  800. #undef Y2_MIN_PIN
  801. #if PIN_EXISTS(Y2_STOP)
  802. #define Y2_MIN_PIN Y2_STOP_PIN
  803. #endif
  804. #endif
  805. #endif
  806. #ifndef Y2_MAX_ENDSTOP_HIT_STATE
  807. #define Y2_MAX_ENDSTOP_HIT_STATE HIGH
  808. #endif
  809. #ifndef Y2_MIN_ENDSTOP_HIT_STATE
  810. #define Y2_MIN_ENDSTOP_HIT_STATE HIGH
  811. #endif
  812. #endif
  813. /**
  814. * Z_MULTI_ENDSTOPS endstop reassignment
  815. */
  816. #if ENABLED(Z_MULTI_ENDSTOPS)
  817. #if Z_HOME_TO_MAX
  818. #ifndef Z2_MAX_ENDSTOP_HIT_STATE
  819. #if PIN_EXISTS(Z2_STOP)
  820. #if Z2_STOP_PIN == X_MIN_PIN
  821. #define Z2_MAX_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
  822. #elif Z2_STOP_PIN == X_MAX_PIN
  823. #define Z2_MAX_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
  824. #elif Z2_STOP_PIN == Y_MIN_PIN
  825. #define Z2_MAX_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
  826. #elif Z2_STOP_PIN == Y_MAX_PIN
  827. #define Z2_MAX_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
  828. #elif Z2_STOP_PIN == Z_MIN_PIN
  829. #define Z2_MAX_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
  830. #elif Z2_STOP_PIN == Z_MAX_PIN
  831. #define Z2_MAX_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
  832. #endif
  833. #endif
  834. #endif
  835. #if !PIN_EXISTS(Z2_MAX)
  836. #undef Z2_MAX_PIN
  837. #if PIN_EXISTS(Z2_STOP)
  838. #define Z2_MAX_PIN Z2_STOP_PIN
  839. #endif
  840. #endif
  841. #else
  842. #ifndef Z2_MIN_ENDSTOP_HIT_STATE
  843. #if PIN_EXISTS(Z2_STOP)
  844. #if Z2_STOP_PIN == X_MIN_PIN
  845. #define Z2_MIN_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
  846. #elif Z2_STOP_PIN == X_MAX_PIN
  847. #define Z2_MIN_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
  848. #elif Z2_STOP_PIN == Y_MIN_PIN
  849. #define Z2_MIN_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
  850. #elif Z2_STOP_PIN == Y_MAX_PIN
  851. #define Z2_MIN_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
  852. #elif Z2_STOP_PIN == Z_MIN_PIN
  853. #define Z2_MIN_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
  854. #elif Z2_STOP_PIN == Z_MAX_PIN
  855. #define Z2_MIN_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
  856. #endif
  857. #endif
  858. #endif
  859. #if !PIN_EXISTS(Z2_MIN)
  860. #undef Z2_MIN_PIN
  861. #if PIN_EXISTS(Z2_STOP)
  862. #define Z2_MIN_PIN Z2_STOP_PIN
  863. #endif
  864. #endif
  865. #endif
  866. #ifndef Z2_MAX_ENDSTOP_HIT_STATE
  867. #define Z2_MAX_ENDSTOP_HIT_STATE HIGH
  868. #endif
  869. #ifndef Z2_MIN_ENDSTOP_HIT_STATE
  870. #define Z2_MIN_ENDSTOP_HIT_STATE HIGH
  871. #endif
  872. #if NUM_Z_STEPPERS >= 3
  873. #if Z_HOME_TO_MAX
  874. #ifndef Z3_MAX_ENDSTOP_HIT_STATE
  875. #if PIN_EXISTS(Z3_STOP)
  876. #if Z3_STOP_PIN == X_MIN_PIN
  877. #define Z3_MAX_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
  878. #elif Z3_STOP_PIN == X_MAX_PIN
  879. #define Z3_MAX_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
  880. #elif Z3_STOP_PIN == Y_MIN_PIN
  881. #define Z3_MAX_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
  882. #elif Z3_STOP_PIN == Y_MAX_PIN
  883. #define Z3_MAX_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
  884. #elif Z3_STOP_PIN == Z_MIN_PIN
  885. #define Z3_MAX_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
  886. #elif Z3_STOP_PIN == Z_MAX_PIN
  887. #define Z3_MAX_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
  888. #endif
  889. #endif
  890. #endif
  891. #if !PIN_EXISTS(Z3_MAX)
  892. #undef Z3_MAX_PIN
  893. #if PIN_EXISTS(Z3_STOP)
  894. #define Z3_MAX_PIN Z3_STOP_PIN
  895. #endif
  896. #endif
  897. #else
  898. #ifndef Z3_MIN_ENDSTOP_HIT_STATE
  899. #if PIN_EXISTS(Z3_STOP)
  900. #if Z3_STOP_PIN == X_MIN_PIN
  901. #define Z3_MIN_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
  902. #elif Z3_STOP_PIN == X_MAX_PIN
  903. #define Z3_MIN_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
  904. #elif Z3_STOP_PIN == Y_MIN_PIN
  905. #define Z3_MIN_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
  906. #elif Z3_STOP_PIN == Y_MAX_PIN
  907. #define Z3_MIN_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
  908. #elif Z3_STOP_PIN == Z_MIN_PIN
  909. #define Z3_MIN_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
  910. #elif Z3_STOP_PIN == Z_MAX_PIN
  911. #define Z3_MIN_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
  912. #endif
  913. #endif
  914. #endif
  915. #if !PIN_EXISTS(Z3_MIN)
  916. #undef Z3_MIN_PIN
  917. #if PIN_EXISTS(Z3_STOP)
  918. #define Z3_MIN_PIN Z3_STOP_PIN
  919. #endif
  920. #endif
  921. #endif
  922. #ifndef Z3_MAX_ENDSTOP_HIT_STATE
  923. #define Z3_MAX_ENDSTOP_HIT_STATE HIGH
  924. #endif
  925. #ifndef Z3_MIN_ENDSTOP_HIT_STATE
  926. #define Z3_MIN_ENDSTOP_HIT_STATE HIGH
  927. #endif
  928. #endif
  929. #if NUM_Z_STEPPERS >= 4
  930. #if Z_HOME_TO_MAX
  931. #ifndef Z4_MAX_ENDSTOP_HIT_STATE
  932. #if PIN_EXISTS(Z4_STOP)
  933. #if Z4_STOP_PIN == X_MIN_PIN
  934. #define Z4_MAX_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
  935. #elif Z4_STOP_PIN == X_MAX_PIN
  936. #define Z4_MAX_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
  937. #elif Z4_STOP_PIN == Y_MIN_PIN
  938. #define Z4_MAX_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
  939. #elif Z4_STOP_PIN == Y_MAX_PIN
  940. #define Z4_MAX_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
  941. #elif Z4_STOP_PIN == Z_MIN_PIN
  942. #define Z4_MAX_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
  943. #elif Z4_STOP_PIN == Z_MAX_PIN
  944. #define Z4_MAX_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
  945. #endif
  946. #endif
  947. #endif
  948. #if !PIN_EXISTS(Z4_MAX)
  949. #undef Z4_MAX_PIN
  950. #if PIN_EXISTS(Z4_STOP)
  951. #define Z4_MAX_PIN Z4_STOP_PIN
  952. #endif
  953. #endif
  954. #else
  955. #ifndef Z4_MIN_ENDSTOP_HIT_STATE
  956. #if PIN_EXISTS(Z4_STOP)
  957. #if Z4_STOP_PIN == X_MIN_PIN
  958. #define Z4_MIN_ENDSTOP_HIT_STATE X_MIN_ENDSTOP_HIT_STATE
  959. #elif Z4_STOP_PIN == X_MAX_PIN
  960. #define Z4_MIN_ENDSTOP_HIT_STATE X_MAX_ENDSTOP_HIT_STATE
  961. #elif Z4_STOP_PIN == Y_MIN_PIN
  962. #define Z4_MIN_ENDSTOP_HIT_STATE Y_MIN_ENDSTOP_HIT_STATE
  963. #elif Z4_STOP_PIN == Y_MAX_PIN
  964. #define Z4_MIN_ENDSTOP_HIT_STATE Y_MAX_ENDSTOP_HIT_STATE
  965. #elif Z4_STOP_PIN == Z_MIN_PIN
  966. #define Z4_MIN_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
  967. #elif Z4_STOP_PIN == Z_MAX_PIN
  968. #define Z4_MIN_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
  969. #endif
  970. #endif
  971. #endif
  972. #if !PIN_EXISTS(Z4_MIN)
  973. #undef Z4_MIN_PIN
  974. #if PIN_EXISTS(Z4_STOP)
  975. #define Z4_MIN_PIN Z4_STOP_PIN
  976. #endif
  977. #endif
  978. #endif
  979. #ifndef Z4_MAX_ENDSTOP_HIT_STATE
  980. #define Z4_MAX_ENDSTOP_HIT_STATE HIGH
  981. #endif
  982. #ifndef Z4_MIN_ENDSTOP_HIT_STATE
  983. #define Z4_MIN_ENDSTOP_HIT_STATE HIGH
  984. #endif
  985. #endif
  986. #endif // Z_MULTI_ENDSTOPS
  987. /**
  988. * Shorthand for pin tests, used wherever needed
  989. */
  990. // Steppers
  991. #if HAS_X_AXIS
  992. #if PIN_EXISTS(X_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X))
  993. #define HAS_X_ENABLE 1
  994. #endif
  995. #if PIN_EXISTS(X_DIR)
  996. #define HAS_X_DIR 1
  997. #endif
  998. #if PIN_EXISTS(X_STEP)
  999. #define HAS_X_STEP 1
  1000. #endif
  1001. #if PIN_EXISTS(X_MS1)
  1002. #define HAS_X_MS_PINS 1
  1003. #endif
  1004. #if PIN_EXISTS(X2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X2))
  1005. #define HAS_X2_ENABLE 1
  1006. #endif
  1007. #if PIN_EXISTS(X2_DIR)
  1008. #define HAS_X2_DIR 1
  1009. #endif
  1010. #if PIN_EXISTS(X2_STEP)
  1011. #define HAS_X2_STEP 1
  1012. #endif
  1013. #if PIN_EXISTS(X2_MS1)
  1014. #define HAS_X2_MS_PINS 1
  1015. #endif
  1016. #endif
  1017. /**
  1018. * Set defaults for missing (newer) options
  1019. */
  1020. #if HAS_Y_AXIS
  1021. #if PIN_EXISTS(Y_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y))
  1022. #define HAS_Y_ENABLE 1
  1023. #endif
  1024. #if PIN_EXISTS(Y_DIR)
  1025. #define HAS_Y_DIR 1
  1026. #endif
  1027. #if PIN_EXISTS(Y_STEP)
  1028. #define HAS_Y_STEP 1
  1029. #endif
  1030. #if PIN_EXISTS(Y_MS1)
  1031. #define HAS_Y_MS_PINS 1
  1032. #endif
  1033. #if HAS_Y2_STEPPER
  1034. #if PIN_EXISTS(Y2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y2))
  1035. #define HAS_Y2_ENABLE 1
  1036. #endif
  1037. #if PIN_EXISTS(Y2_DIR)
  1038. #define HAS_Y2_DIR 1
  1039. #endif
  1040. #if PIN_EXISTS(Y2_STEP)
  1041. #define HAS_Y2_STEP 1
  1042. #endif
  1043. #if PIN_EXISTS(Y2_MS1)
  1044. #define HAS_Y2_MS_PINS 1
  1045. #endif
  1046. #endif
  1047. #endif
  1048. #if HAS_Z_AXIS
  1049. #if PIN_EXISTS(Z_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z))
  1050. #define HAS_Z_ENABLE 1
  1051. #endif
  1052. #if PIN_EXISTS(Z_DIR)
  1053. #define HAS_Z_DIR 1
  1054. #endif
  1055. #if PIN_EXISTS(Z_STEP)
  1056. #define HAS_Z_STEP 1
  1057. #endif
  1058. #if PIN_EXISTS(Z_MS1)
  1059. #define HAS_Z_MS_PINS 1
  1060. #endif
  1061. #endif
  1062. #if NUM_Z_STEPPERS >= 2
  1063. #if PIN_EXISTS(Z2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2))
  1064. #define HAS_Z2_ENABLE 1
  1065. #endif
  1066. #if PIN_EXISTS(Z2_DIR)
  1067. #define HAS_Z2_DIR 1
  1068. #endif
  1069. #if PIN_EXISTS(Z2_STEP)
  1070. #define HAS_Z2_STEP 1
  1071. #endif
  1072. #if PIN_EXISTS(Z2_MS1)
  1073. #define HAS_Z2_MS_PINS 1
  1074. #endif
  1075. #endif
  1076. #if NUM_Z_STEPPERS >= 3
  1077. #if PIN_EXISTS(Z3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3))
  1078. #define HAS_Z3_ENABLE 1
  1079. #endif
  1080. #if PIN_EXISTS(Z3_DIR)
  1081. #define HAS_Z3_DIR 1
  1082. #endif
  1083. #if PIN_EXISTS(Z3_STEP)
  1084. #define HAS_Z3_STEP 1
  1085. #endif
  1086. #if PIN_EXISTS(Z3_MS1)
  1087. #define HAS_Z3_MS_PINS 1
  1088. #endif
  1089. #endif
  1090. #if NUM_Z_STEPPERS >= 4
  1091. #if PIN_EXISTS(Z4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z4))
  1092. #define HAS_Z4_ENABLE 1
  1093. #endif
  1094. #if PIN_EXISTS(Z4_DIR)
  1095. #define HAS_Z4_DIR 1
  1096. #endif
  1097. #if PIN_EXISTS(Z4_STEP)
  1098. #define HAS_Z4_STEP 1
  1099. #endif
  1100. #if PIN_EXISTS(Z4_MS1)
  1101. #define HAS_Z4_MS_PINS 1
  1102. #endif
  1103. #endif
  1104. #if HAS_I_AXIS
  1105. #if PIN_EXISTS(I_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(I))
  1106. #define HAS_I_ENABLE 1
  1107. #endif
  1108. #if PIN_EXISTS(I_DIR)
  1109. #define HAS_I_DIR 1
  1110. #endif
  1111. #if PIN_EXISTS(I_STEP)
  1112. #define HAS_I_STEP 1
  1113. #endif
  1114. #if PIN_EXISTS(I_MS1)
  1115. #define HAS_I_MS_PINS 1
  1116. #endif
  1117. #endif
  1118. #if HAS_J_AXIS
  1119. #if PIN_EXISTS(J_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(J))
  1120. #define HAS_J_ENABLE 1
  1121. #endif
  1122. #if PIN_EXISTS(J_DIR)
  1123. #define HAS_J_DIR 1
  1124. #endif
  1125. #if PIN_EXISTS(J_STEP)
  1126. #define HAS_J_STEP 1
  1127. #endif
  1128. #if PIN_EXISTS(J_MS1)
  1129. #define HAS_J_MS_PINS 1
  1130. #endif
  1131. #endif
  1132. #if HAS_K_AXIS
  1133. #if PIN_EXISTS(K_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(K))
  1134. #define HAS_K_ENABLE 1
  1135. #endif
  1136. #if PIN_EXISTS(K_DIR)
  1137. #define HAS_K_DIR 1
  1138. #endif
  1139. #if PIN_EXISTS(K_STEP)
  1140. #define HAS_K_STEP 1
  1141. #endif
  1142. #if PIN_EXISTS(K_MS1)
  1143. #define HAS_K_MS_PINS 1
  1144. #endif
  1145. #endif
  1146. #if HAS_U_AXIS
  1147. #if PIN_EXISTS(U_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(U))
  1148. #define HAS_U_ENABLE 1
  1149. #endif
  1150. #if PIN_EXISTS(U_DIR)
  1151. #define HAS_U_DIR 1
  1152. #endif
  1153. #if PIN_EXISTS(U_STEP)
  1154. #define HAS_U_STEP 1
  1155. #endif
  1156. #if PIN_EXISTS(U_MS1)
  1157. #define HAS_U_MS_PINS 1
  1158. #endif
  1159. #endif
  1160. #if HAS_V_AXIS
  1161. #if PIN_EXISTS(V_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(V))
  1162. #define HAS_V_ENABLE 1
  1163. #endif
  1164. #if PIN_EXISTS(V_DIR)
  1165. #define HAS_V_DIR 1
  1166. #endif
  1167. #if PIN_EXISTS(V_STEP)
  1168. #define HAS_V_STEP 1
  1169. #endif
  1170. #if PIN_EXISTS(V_MS1)
  1171. #define HAS_V_MS_PINS 1
  1172. #endif
  1173. #endif
  1174. #if HAS_W_AXIS
  1175. #if PIN_EXISTS(W_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(W))
  1176. #define HAS_W_ENABLE 1
  1177. #endif
  1178. #if PIN_EXISTS(W_DIR)
  1179. #define HAS_W_DIR 1
  1180. #endif
  1181. #if PIN_EXISTS(W_STEP)
  1182. #define HAS_W_STEP 1
  1183. #endif
  1184. #if PIN_EXISTS(W_MS1)
  1185. #define HAS_W_MS_PINS 1
  1186. #endif
  1187. #endif
  1188. // Extruder steppers and solenoids
  1189. #if HAS_EXTRUDERS
  1190. #if PIN_EXISTS(E0_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0))
  1191. #define HAS_E0_ENABLE 1
  1192. #endif
  1193. #if PIN_EXISTS(E0_DIR)
  1194. #define HAS_E0_DIR 1
  1195. #endif
  1196. #if PIN_EXISTS(E0_STEP)
  1197. #define HAS_E0_STEP 1
  1198. #endif
  1199. #if PIN_EXISTS(E0_MS1)
  1200. #define HAS_E0_MS_PINS 1
  1201. #endif
  1202. #if E_STEPPERS > 1 || ENABLED(E_DUAL_STEPPER_DRIVERS)
  1203. #if PIN_EXISTS(E1_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1))
  1204. #define HAS_E1_ENABLE 1
  1205. #endif
  1206. #if PIN_EXISTS(E1_DIR)
  1207. #define HAS_E1_DIR 1
  1208. #endif
  1209. #if PIN_EXISTS(E1_STEP)
  1210. #define HAS_E1_STEP 1
  1211. #endif
  1212. #if PIN_EXISTS(E1_MS1)
  1213. #define HAS_E1_MS_PINS 1
  1214. #endif
  1215. #endif
  1216. #if E_STEPPERS > 2
  1217. #if PIN_EXISTS(E2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2))
  1218. #define HAS_E2_ENABLE 1
  1219. #endif
  1220. #if PIN_EXISTS(E2_DIR)
  1221. #define HAS_E2_DIR 1
  1222. #endif
  1223. #if PIN_EXISTS(E2_STEP)
  1224. #define HAS_E2_STEP 1
  1225. #endif
  1226. #if PIN_EXISTS(E2_MS1)
  1227. #define HAS_E2_MS_PINS 1
  1228. #endif
  1229. #endif
  1230. #if E_STEPPERS > 3
  1231. #if PIN_EXISTS(E3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3))
  1232. #define HAS_E3_ENABLE 1
  1233. #endif
  1234. #if PIN_EXISTS(E3_DIR)
  1235. #define HAS_E3_DIR 1
  1236. #endif
  1237. #if PIN_EXISTS(E3_STEP)
  1238. #define HAS_E3_STEP 1
  1239. #endif
  1240. #if PIN_EXISTS(E3_MS1)
  1241. #define HAS_E3_MS_PINS 1
  1242. #endif
  1243. #endif
  1244. #if E_STEPPERS > 4
  1245. #if PIN_EXISTS(E4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4))
  1246. #define HAS_E4_ENABLE 1
  1247. #endif
  1248. #if PIN_EXISTS(E4_DIR)
  1249. #define HAS_E4_DIR 1
  1250. #endif
  1251. #if PIN_EXISTS(E4_STEP)
  1252. #define HAS_E4_STEP 1
  1253. #endif
  1254. #if PIN_EXISTS(E4_MS1)
  1255. #define HAS_E4_MS_PINS 1
  1256. #endif
  1257. #endif
  1258. #if E_STEPPERS > 5
  1259. #if PIN_EXISTS(E5_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5))
  1260. #define HAS_E5_ENABLE 1
  1261. #endif
  1262. #if PIN_EXISTS(E5_DIR)
  1263. #define HAS_E5_DIR 1
  1264. #endif
  1265. #if PIN_EXISTS(E5_STEP)
  1266. #define HAS_E5_STEP 1
  1267. #endif
  1268. #if PIN_EXISTS(E5_MS1)
  1269. #define HAS_E5_MS_PINS 1
  1270. #endif
  1271. #endif
  1272. #if E_STEPPERS > 6
  1273. #if PIN_EXISTS(E6_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6))
  1274. #define HAS_E6_ENABLE 1
  1275. #endif
  1276. #if PIN_EXISTS(E6_DIR)
  1277. #define HAS_E6_DIR 1
  1278. #endif
  1279. #if PIN_EXISTS(E6_STEP)
  1280. #define HAS_E6_STEP 1
  1281. #endif
  1282. #if PIN_EXISTS(E6_MS1)
  1283. #define HAS_E6_MS_PINS 1
  1284. #endif
  1285. #endif
  1286. #if E_STEPPERS > 7
  1287. #if PIN_EXISTS(E7_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7))
  1288. #define HAS_E7_ENABLE 1
  1289. #endif
  1290. #if PIN_EXISTS(E7_DIR)
  1291. #define HAS_E7_DIR 1
  1292. #endif
  1293. #if PIN_EXISTS(E7_STEP)
  1294. #define HAS_E7_STEP 1
  1295. #endif
  1296. #if PIN_EXISTS(E7_MS1)
  1297. #define HAS_E7_MS_PINS 1
  1298. #endif
  1299. #endif
  1300. #endif // HAS_EXTRUDERS
  1301. /**
  1302. * Set solenoid flags if any features use solenoids
  1303. * - EXT_SOLENOID (M380, M381) to enable/disable the extruder solenoid
  1304. * - MANUAL_SOLENOID_CONTROL (M380, M381) to enable/disable solenoids by index
  1305. * - PARKING_EXTRUDER uses SOL0_PIN and SOL1_PIN
  1306. * - SOLENOID_PROBE uses SOL1_PIN
  1307. * - Z_PROBE_SLED uses SOL1_PIN, when defined (unless EXT_SOLENOID is enabled)
  1308. */
  1309. #if ANY(EXT_SOLENOID, MANUAL_SOLENOID_CONTROL, PARKING_EXTRUDER, SOLENOID_PROBE, Z_PROBE_SLED)
  1310. #if PIN_EXISTS(SOL0) && (ANY(MANUAL_SOLENOID_CONTROL, PARKING_EXTRUDER) || ALL(EXT_SOLENOID, HAS_EXTRUDERS))
  1311. #define HAS_SOLENOID_0 1
  1312. #endif
  1313. #if PIN_EXISTS(SOL1) && (ANY(MANUAL_SOLENOID_CONTROL, PARKING_EXTRUDER, SOLENOID_PROBE, Z_PROBE_SLED) || TERN0(EXT_SOLENOID, E_STEPPERS > 1))
  1314. #define HAS_SOLENOID_1 1
  1315. #endif
  1316. #if PIN_EXISTS(SOL2) && (ENABLED(MANUAL_SOLENOID_CONTROL) || TERN0(EXT_SOLENOID, E_STEPPERS > 2))
  1317. #define HAS_SOLENOID_2 2
  1318. #endif
  1319. #if PIN_EXISTS(SOL3) && (ENABLED(MANUAL_SOLENOID_CONTROL) || TERN0(EXT_SOLENOID, E_STEPPERS > 3))
  1320. #define HAS_SOLENOID_3 3
  1321. #endif
  1322. #if PIN_EXISTS(SOL4) && (ENABLED(MANUAL_SOLENOID_CONTROL) || TERN0(EXT_SOLENOID, E_STEPPERS > 4))
  1323. #define HAS_SOLENOID_4 4
  1324. #endif
  1325. #if PIN_EXISTS(SOL5) && (ENABLED(MANUAL_SOLENOID_CONTROL) || TERN0(EXT_SOLENOID, E_STEPPERS > 5))
  1326. #define HAS_SOLENOID_5 5
  1327. #endif
  1328. #if PIN_EXISTS(SOL6) && (ENABLED(MANUAL_SOLENOID_CONTROL) || TERN0(EXT_SOLENOID, E_STEPPERS > 6))
  1329. #define HAS_SOLENOID_6 6
  1330. #endif
  1331. #if PIN_EXISTS(SOL7) && (ENABLED(MANUAL_SOLENOID_CONTROL) || TERN0(EXT_SOLENOID, E_STEPPERS > 7))
  1332. #define HAS_SOLENOID_7 7
  1333. #endif
  1334. #endif
  1335. //
  1336. // Trinamic Stepper Drivers
  1337. //
  1338. #if HAS_TRINAMIC_CONFIG
  1339. #if ANY(STEALTHCHOP_E, STEALTHCHOP_XY, STEALTHCHOP_Z, STEALTHCHOP_I, STEALTHCHOP_J, STEALTHCHOP_K, STEALTHCHOP_U, STEALTHCHOP_V, STEALTHCHOP_W)
  1340. #define STEALTHCHOP_ENABLED 1
  1341. #endif
  1342. #if ANY(SENSORLESS_HOMING, SENSORLESS_PROBING)
  1343. #define USE_SENSORLESS 1
  1344. #endif
  1345. // Disable Z axis sensorless homing if a probe is used to home the Z axis
  1346. #if HOMING_Z_WITH_PROBE
  1347. #undef Z_STALL_SENSITIVITY
  1348. #undef Z2_STALL_SENSITIVITY
  1349. #undef Z3_STALL_SENSITIVITY
  1350. #undef Z4_STALL_SENSITIVITY
  1351. #endif
  1352. #if AXIS_IS_TMC(X)
  1353. #if defined(X_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(X)
  1354. #define X_SENSORLESS 1
  1355. #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(X)
  1356. #define X_SPI_SENSORLESS 1
  1357. #endif
  1358. #endif
  1359. #if AXIS_HAS_STEALTHCHOP(X)
  1360. #define X_HAS_STEALTHCHOP 1
  1361. #endif
  1362. #ifndef X_INTERPOLATE
  1363. #define X_INTERPOLATE INTERPOLATE
  1364. #endif
  1365. #ifndef X_HOLD_MULTIPLIER
  1366. #define X_HOLD_MULTIPLIER HOLD_MULTIPLIER
  1367. #endif
  1368. #ifndef X_SLAVE_ADDRESS
  1369. #define X_SLAVE_ADDRESS 0
  1370. #endif
  1371. #endif
  1372. #if AXIS_IS_TMC(X2)
  1373. #if defined(X2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(X2)
  1374. #define X2_SENSORLESS 1
  1375. #endif
  1376. #if AXIS_HAS_STEALTHCHOP(X2)
  1377. #define X2_HAS_STEALTHCHOP 1
  1378. #endif
  1379. #ifndef X2_INTERPOLATE
  1380. #define X2_INTERPOLATE X_INTERPOLATE
  1381. #endif
  1382. #ifndef X2_HOLD_MULTIPLIER
  1383. #define X2_HOLD_MULTIPLIER X_HOLD_MULTIPLIER
  1384. #endif
  1385. #ifndef X2_SLAVE_ADDRESS
  1386. #define X2_SLAVE_ADDRESS 0
  1387. #endif
  1388. #endif
  1389. #if AXIS_IS_TMC(Y)
  1390. #if defined(Y_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y)
  1391. #define Y_SENSORLESS 1
  1392. #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(Y)
  1393. #define Y_SPI_SENSORLESS 1
  1394. #endif
  1395. #endif
  1396. #if AXIS_HAS_STEALTHCHOP(Y)
  1397. #define Y_HAS_STEALTHCHOP 1
  1398. #endif
  1399. #ifndef Y_INTERPOLATE
  1400. #define Y_INTERPOLATE INTERPOLATE
  1401. #endif
  1402. #ifndef Y_HOLD_MULTIPLIER
  1403. #define Y_HOLD_MULTIPLIER HOLD_MULTIPLIER
  1404. #endif
  1405. #ifndef Y_SLAVE_ADDRESS
  1406. #define Y_SLAVE_ADDRESS 0
  1407. #endif
  1408. #endif
  1409. #if AXIS_IS_TMC(Y2)
  1410. #if defined(Y2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y2)
  1411. #define Y2_SENSORLESS 1
  1412. #endif
  1413. #if AXIS_HAS_STEALTHCHOP(Y2)
  1414. #define Y2_HAS_STEALTHCHOP 1
  1415. #endif
  1416. #ifndef Y2_INTERPOLATE
  1417. #define Y2_INTERPOLATE Y_INTERPOLATE
  1418. #endif
  1419. #ifndef Y2_HOLD_MULTIPLIER
  1420. #define Y2_HOLD_MULTIPLIER Y_HOLD_MULTIPLIER
  1421. #endif
  1422. #ifndef Y2_SLAVE_ADDRESS
  1423. #define Y2_SLAVE_ADDRESS 0
  1424. #endif
  1425. #endif
  1426. #if AXIS_IS_TMC(Z)
  1427. #if defined(Z_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z)
  1428. #define Z_SENSORLESS 1
  1429. #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(Z)
  1430. #define Z_SPI_SENSORLESS 1
  1431. #endif
  1432. #endif
  1433. #if AXIS_HAS_STEALTHCHOP(Z)
  1434. #define Z_HAS_STEALTHCHOP 1
  1435. #endif
  1436. #ifndef Z_INTERPOLATE
  1437. #define Z_INTERPOLATE INTERPOLATE
  1438. #endif
  1439. #ifndef Z_HOLD_MULTIPLIER
  1440. #define Z_HOLD_MULTIPLIER HOLD_MULTIPLIER
  1441. #endif
  1442. #ifndef Z_SLAVE_ADDRESS
  1443. #define Z_SLAVE_ADDRESS 0
  1444. #endif
  1445. #endif
  1446. #if NUM_Z_STEPPERS >= 2 && AXIS_IS_TMC(Z2)
  1447. #if defined(Z2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z2)
  1448. #define Z2_SENSORLESS 1
  1449. #endif
  1450. #if AXIS_HAS_STEALTHCHOP(Z2)
  1451. #define Z2_HAS_STEALTHCHOP 1
  1452. #endif
  1453. #ifndef Z2_INTERPOLATE
  1454. #define Z2_INTERPOLATE Z_INTERPOLATE
  1455. #endif
  1456. #ifndef Z2_HOLD_MULTIPLIER
  1457. #define Z2_HOLD_MULTIPLIER Z_HOLD_MULTIPLIER
  1458. #endif
  1459. #ifndef Z2_SLAVE_ADDRESS
  1460. #define Z2_SLAVE_ADDRESS 0
  1461. #endif
  1462. #endif
  1463. #if NUM_Z_STEPPERS >= 3 && AXIS_IS_TMC(Z3)
  1464. #if defined(Z3_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z3)
  1465. #define Z3_SENSORLESS 1
  1466. #endif
  1467. #if AXIS_HAS_STEALTHCHOP(Z3)
  1468. #define Z3_HAS_STEALTHCHOP 1
  1469. #endif
  1470. #ifndef Z3_INTERPOLATE
  1471. #define Z3_INTERPOLATE Z_INTERPOLATE
  1472. #endif
  1473. #ifndef Z3_HOLD_MULTIPLIER
  1474. #define Z3_HOLD_MULTIPLIER Z_HOLD_MULTIPLIER
  1475. #endif
  1476. #ifndef Z3_SLAVE_ADDRESS
  1477. #define Z3_SLAVE_ADDRESS 0
  1478. #endif
  1479. #endif
  1480. #if NUM_Z_STEPPERS >= 4 && AXIS_IS_TMC(Z4)
  1481. #if defined(Z4_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z4)
  1482. #define Z4_SENSORLESS 1
  1483. #endif
  1484. #if AXIS_HAS_STEALTHCHOP(Z4)
  1485. #define Z4_HAS_STEALTHCHOP 1
  1486. #endif
  1487. #ifndef Z4_INTERPOLATE
  1488. #define Z4_INTERPOLATE Z_INTERPOLATE
  1489. #endif
  1490. #ifndef Z4_HOLD_MULTIPLIER
  1491. #define Z4_HOLD_MULTIPLIER Z_HOLD_MULTIPLIER
  1492. #endif
  1493. #ifndef Z4_SLAVE_ADDRESS
  1494. #define Z4_SLAVE_ADDRESS 0
  1495. #endif
  1496. #endif
  1497. #if AXIS_IS_TMC(I)
  1498. #if defined(I_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(I)
  1499. #define I_SENSORLESS 1
  1500. #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(I)
  1501. #define I_SPI_SENSORLESS 1
  1502. #endif
  1503. #endif
  1504. #if AXIS_HAS_STEALTHCHOP(I)
  1505. #define I_HAS_STEALTHCHOP 1
  1506. #endif
  1507. #ifndef I_INTERPOLATE
  1508. #define I_INTERPOLATE INTERPOLATE
  1509. #endif
  1510. #ifndef I_HOLD_MULTIPLIER
  1511. #define I_HOLD_MULTIPLIER HOLD_MULTIPLIER
  1512. #endif
  1513. #ifndef I_SLAVE_ADDRESS
  1514. #define I_SLAVE_ADDRESS 0
  1515. #endif
  1516. #endif
  1517. #if AXIS_IS_TMC(J)
  1518. #if defined(J_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(J)
  1519. #define J_SENSORLESS 1
  1520. #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(J)
  1521. #define J_SPI_SENSORLESS 1
  1522. #endif
  1523. #endif
  1524. #if AXIS_HAS_STEALTHCHOP(J)
  1525. #define J_HAS_STEALTHCHOP 1
  1526. #endif
  1527. #ifndef J_INTERPOLATE
  1528. #define J_INTERPOLATE INTERPOLATE
  1529. #endif
  1530. #ifndef J_HOLD_MULTIPLIER
  1531. #define J_HOLD_MULTIPLIER HOLD_MULTIPLIER
  1532. #endif
  1533. #ifndef J_SLAVE_ADDRESS
  1534. #define J_SLAVE_ADDRESS 0
  1535. #endif
  1536. #endif
  1537. #if AXIS_IS_TMC(K)
  1538. #if defined(K_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(K)
  1539. #define K_SENSORLESS 1
  1540. #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(K)
  1541. #define K_SPI_SENSORLESS 1
  1542. #endif
  1543. #endif
  1544. #if AXIS_HAS_STEALTHCHOP(K)
  1545. #define K_HAS_STEALTHCHOP 1
  1546. #endif
  1547. #ifndef K_INTERPOLATE
  1548. #define K_INTERPOLATE INTERPOLATE
  1549. #endif
  1550. #ifndef K_HOLD_MULTIPLIER
  1551. #define K_HOLD_MULTIPLIER HOLD_MULTIPLIER
  1552. #endif
  1553. #ifndef K_SLAVE_ADDRESS
  1554. #define K_SLAVE_ADDRESS 0
  1555. #endif
  1556. #endif
  1557. #if AXIS_IS_TMC(U)
  1558. #if defined(U_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(U)
  1559. #define U_SENSORLESS 1
  1560. #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(U)
  1561. #define U_SPI_SENSORLESS 1
  1562. #endif
  1563. #endif
  1564. #if AXIS_HAS_STEALTHCHOP(U)
  1565. #define U_HAS_STEALTHCHOP 1
  1566. #endif
  1567. #ifndef U_INTERPOLATE
  1568. #define U_INTERPOLATE INTERPOLATE
  1569. #endif
  1570. #ifndef U_HOLD_MULTIPLIER
  1571. #define U_HOLD_MULTIPLIER HOLD_MULTIPLIER
  1572. #endif
  1573. #ifndef U_SLAVE_ADDRESS
  1574. #define U_SLAVE_ADDRESS 0
  1575. #endif
  1576. #endif
  1577. #if AXIS_IS_TMC(V)
  1578. #if defined(V_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(V)
  1579. #define V_SENSORLESS 1
  1580. #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(V)
  1581. #define V_SPI_SENSORLESS 1
  1582. #endif
  1583. #endif
  1584. #if AXIS_HAS_STEALTHCHOP(V)
  1585. #define V_HAS_STEALTHCHOP 1
  1586. #endif
  1587. #ifndef V_INTERPOLATE
  1588. #define V_INTERPOLATE INTERPOLATE
  1589. #endif
  1590. #ifndef V_HOLD_MULTIPLIER
  1591. #define V_HOLD_MULTIPLIER HOLD_MULTIPLIER
  1592. #endif
  1593. #ifndef V_SLAVE_ADDRESS
  1594. #define V_SLAVE_ADDRESS 0
  1595. #endif
  1596. #endif
  1597. #if AXIS_IS_TMC(W)
  1598. #if defined(W_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(W)
  1599. #define W_SENSORLESS 1
  1600. #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(W)
  1601. #define W_SPI_SENSORLESS 1
  1602. #endif
  1603. #endif
  1604. #if AXIS_HAS_STEALTHCHOP(W)
  1605. #define W_HAS_STEALTHCHOP 1
  1606. #endif
  1607. #ifndef W_INTERPOLATE
  1608. #define W_INTERPOLATE INTERPOLATE
  1609. #endif
  1610. #ifndef W_HOLD_MULTIPLIER
  1611. #define W_HOLD_MULTIPLIER HOLD_MULTIPLIER
  1612. #endif
  1613. #ifndef W_SLAVE_ADDRESS
  1614. #define W_SLAVE_ADDRESS 0
  1615. #endif
  1616. #endif
  1617. #if AXIS_IS_TMC(E0)
  1618. #if AXIS_HAS_STEALTHCHOP(E0)
  1619. #define E0_HAS_STEALTHCHOP 1
  1620. #endif
  1621. #ifndef E0_INTERPOLATE
  1622. #define E0_INTERPOLATE INTERPOLATE
  1623. #endif
  1624. #ifndef E0_HOLD_MULTIPLIER
  1625. #define E0_HOLD_MULTIPLIER HOLD_MULTIPLIER
  1626. #endif
  1627. #ifndef E0_SLAVE_ADDRESS
  1628. #define E0_SLAVE_ADDRESS 0
  1629. #endif
  1630. #endif
  1631. #if AXIS_IS_TMC(E1)
  1632. #if AXIS_HAS_STEALTHCHOP(E1)
  1633. #define E1_HAS_STEALTHCHOP 1
  1634. #endif
  1635. #ifndef E1_INTERPOLATE
  1636. #define E1_INTERPOLATE E0_INTERPOLATE
  1637. #endif
  1638. #ifndef E1_HOLD_MULTIPLIER
  1639. #define E1_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER
  1640. #endif
  1641. #ifndef E1_SLAVE_ADDRESS
  1642. #define E1_SLAVE_ADDRESS 0
  1643. #endif
  1644. #endif
  1645. #if AXIS_IS_TMC(E2)
  1646. #if AXIS_HAS_STEALTHCHOP(E2)
  1647. #define E2_HAS_STEALTHCHOP 1
  1648. #endif
  1649. #ifndef E2_INTERPOLATE
  1650. #define E2_INTERPOLATE E0_INTERPOLATE
  1651. #endif
  1652. #ifndef E2_HOLD_MULTIPLIER
  1653. #define E2_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER
  1654. #endif
  1655. #ifndef E2_SLAVE_ADDRESS
  1656. #define E2_SLAVE_ADDRESS 0
  1657. #endif
  1658. #endif
  1659. #if AXIS_IS_TMC(E3)
  1660. #if AXIS_HAS_STEALTHCHOP(E3)
  1661. #define E3_HAS_STEALTHCHOP 1
  1662. #endif
  1663. #ifndef E3_INTERPOLATE
  1664. #define E3_INTERPOLATE E0_INTERPOLATE
  1665. #endif
  1666. #ifndef E3_HOLD_MULTIPLIER
  1667. #define E3_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER
  1668. #endif
  1669. #ifndef E3_SLAVE_ADDRESS
  1670. #define E3_SLAVE_ADDRESS 0
  1671. #endif
  1672. #endif
  1673. #if AXIS_IS_TMC(E4)
  1674. #if AXIS_HAS_STEALTHCHOP(E4)
  1675. #define E4_HAS_STEALTHCHOP 1
  1676. #endif
  1677. #ifndef E4_INTERPOLATE
  1678. #define E4_INTERPOLATE E0_INTERPOLATE
  1679. #endif
  1680. #ifndef E4_HOLD_MULTIPLIER
  1681. #define E4_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER
  1682. #endif
  1683. #ifndef E4_SLAVE_ADDRESS
  1684. #define E4_SLAVE_ADDRESS 0
  1685. #endif
  1686. #endif
  1687. #if AXIS_IS_TMC(E5)
  1688. #if AXIS_HAS_STEALTHCHOP(E5)
  1689. #define E5_HAS_STEALTHCHOP 1
  1690. #endif
  1691. #ifndef E5_INTERPOLATE
  1692. #define E5_INTERPOLATE E0_INTERPOLATE
  1693. #endif
  1694. #ifndef E5_HOLD_MULTIPLIER
  1695. #define E5_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER
  1696. #endif
  1697. #ifndef E5_SLAVE_ADDRESS
  1698. #define E5_SLAVE_ADDRESS 0
  1699. #endif
  1700. #endif
  1701. #if AXIS_IS_TMC(E6)
  1702. #if AXIS_HAS_STEALTHCHOP(E6)
  1703. #define E6_HAS_STEALTHCHOP 1
  1704. #endif
  1705. #ifndef E6_INTERPOLATE
  1706. #define E6_INTERPOLATE E0_INTERPOLATE
  1707. #endif
  1708. #ifndef E6_HOLD_MULTIPLIER
  1709. #define E6_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER
  1710. #endif
  1711. #ifndef E6_SLAVE_ADDRESS
  1712. #define E6_SLAVE_ADDRESS 0
  1713. #endif
  1714. #endif
  1715. #if AXIS_IS_TMC(E7)
  1716. #if AXIS_HAS_STEALTHCHOP(E7)
  1717. #define E7_HAS_STEALTHCHOP 1
  1718. #endif
  1719. #ifndef E7_INTERPOLATE
  1720. #define E7_INTERPOLATE E0_INTERPOLATE
  1721. #endif
  1722. #ifndef E7_HOLD_MULTIPLIER
  1723. #define E7_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER
  1724. #endif
  1725. #ifndef E7_SLAVE_ADDRESS
  1726. #define E7_SLAVE_ADDRESS 0
  1727. #endif
  1728. #endif
  1729. #endif // HAS_TRINAMIC_CONFIG
  1730. #if ANY_AXIS_HAS(HW_SERIAL)
  1731. #define HAS_TMC_HW_SERIAL 1
  1732. #endif
  1733. #if ANY_AXIS_HAS(SW_SERIAL)
  1734. #define HAS_TMC_SW_SERIAL 1
  1735. #endif
  1736. #ifndef SERIAL_FLOAT_PRECISION
  1737. #define SERIAL_FLOAT_PRECISION 2
  1738. #endif
  1739. #if DISABLED(SENSORLESS_HOMING)
  1740. #undef SENSORLESS_BACKOFF_MM
  1741. #endif
  1742. //
  1743. // Set USING_HW_SERIALn flags for used Serial Ports
  1744. //
  1745. // Flag the indexed hardware serial ports in use
  1746. #define SERIAL_IN_USE(N) ( (defined(SERIAL_PORT) && N == SERIAL_PORT) \
  1747. || (defined(SERIAL_PORT_2) && N == SERIAL_PORT_2) \
  1748. || (defined(SERIAL_PORT_3) && N == SERIAL_PORT_3) \
  1749. || (defined(MMU2_SERIAL_PORT) && N == MMU2_SERIAL_PORT) \
  1750. || (defined(LCD_SERIAL_PORT) && N == LCD_SERIAL_PORT) \
  1751. || (defined(RS485_SERIAL_PORT) && N == RS485_SERIAL_PORT) )
  1752. // Flag the named hardware serial ports in use
  1753. #define TMC_UART_IS(A,N) (defined(A##_HARDWARE_SERIAL) && (CAT(HW_,A##_HARDWARE_SERIAL) == HW_Serial##N || CAT(HW_,A##_HARDWARE_SERIAL) == HW_MSerial##N))
  1754. #define ANY_SERIAL_IS(N) ( SERIAL_IN_USE(N) \
  1755. || TMC_UART_IS(X, N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \
  1756. || TMC_UART_IS(I, N) || TMC_UART_IS(J , N) || TMC_UART_IS(K , N) \
  1757. || TMC_UART_IS(U, N) || TMC_UART_IS(V , N) || TMC_UART_IS(W , N) \
  1758. || TMC_UART_IS(X2, N) || TMC_UART_IS(Y2, N) || TMC_UART_IS(Z2, N) || TMC_UART_IS(Z3, N) || TMC_UART_IS(Z4, N) \
  1759. || TMC_UART_IS(E0, N) || TMC_UART_IS(E1, N) || TMC_UART_IS(E2, N) || TMC_UART_IS(E3, N) || TMC_UART_IS(E4, N) )
  1760. #define HW_Serial 501
  1761. #define HW_Serial0 502
  1762. #define HW_Serial1 503
  1763. #define HW_Serial2 504
  1764. #define HW_Serial3 505
  1765. #define HW_Serial4 506
  1766. #define HW_Serial5 507
  1767. #define HW_Serial6 508
  1768. #define HW_MSerial0 509
  1769. #define HW_MSerial1 510
  1770. #define HW_MSerial2 511
  1771. #define HW_MSerial3 512
  1772. #define HW_MSerial4 513
  1773. #define HW_MSerial5 514
  1774. #define HW_MSerial6 515
  1775. #define HW_MSerial7 516
  1776. #define HW_MSerial8 517
  1777. #define HW_MSerial9 518
  1778. #define HW_MSerial10 519
  1779. #if SERIAL_IN_USE(-1)
  1780. #define USING_HW_SERIALUSB 1
  1781. #endif
  1782. #if ANY_SERIAL_IS(0)
  1783. #define USING_HW_SERIAL0 1
  1784. #endif
  1785. #if ANY_SERIAL_IS(1)
  1786. #define USING_HW_SERIAL1 1
  1787. #endif
  1788. #if ANY_SERIAL_IS(2)
  1789. #define USING_HW_SERIAL2 1
  1790. #endif
  1791. #if ANY_SERIAL_IS(3)
  1792. #define USING_HW_SERIAL3 1
  1793. #endif
  1794. #if ANY_SERIAL_IS(4)
  1795. #define USING_HW_SERIAL4 1
  1796. #endif
  1797. #if ANY_SERIAL_IS(5)
  1798. #define USING_HW_SERIAL5 1
  1799. #endif
  1800. #if ANY_SERIAL_IS(6)
  1801. #define USING_HW_SERIAL6 1
  1802. #endif
  1803. #if ANY_SERIAL_IS(7)
  1804. #define USING_HW_SERIAL7 1
  1805. #endif
  1806. #if ANY_SERIAL_IS(8)
  1807. #define USING_HW_SERIAL8 1
  1808. #endif
  1809. #if ANY_SERIAL_IS(9)
  1810. #define USING_HW_SERIAL9 1
  1811. #endif
  1812. #if ANY_SERIAL_IS(10)
  1813. #define USING_HW_SERIAL10 1
  1814. #endif
  1815. #undef HW_Serial
  1816. #undef HW_Serial0
  1817. #undef HW_Serial1
  1818. #undef HW_Serial2
  1819. #undef HW_Serial3
  1820. #undef HW_Serial4
  1821. #undef HW_Serial5
  1822. #undef HW_Serial6
  1823. #undef HW_MSerial0
  1824. #undef HW_MSerial1
  1825. #undef HW_MSerial2
  1826. #undef HW_MSerial3
  1827. #undef HW_MSerial4
  1828. #undef HW_MSerial5
  1829. #undef HW_MSerial6
  1830. #undef HW_MSerial7
  1831. #undef HW_MSerial8
  1832. #undef HW_MSerial9
  1833. #undef HW_MSerial10
  1834. #undef _SERIAL_ID
  1835. #undef _TMC_UART_IS
  1836. #undef TMC_UART_IS
  1837. #undef ANY_SERIAL_IS
  1838. #if defined(__AVR_ARCH__) && defined(TMC_SPI_MISO) && defined(TMC_SPI_MOSI) && defined(TMC_SPI_SCK)
  1839. // Check that the pins are the solitary supported SPI hardware pins of the (AVR) platform.
  1840. // Otherwise we are forced to enable software SPI.
  1841. #if TMC_SPI_MISO != MISO || TMC_SPI_MOSI != MOSI || TMC_SPI_SCK != SCK
  1842. #define TMC_USE_SW_SPI
  1843. #endif
  1844. #endif
  1845. // Clean up unused ESP_WIFI pins
  1846. #ifdef ESP_WIFI_MODULE_COM
  1847. #if !SERIAL_IN_USE(ESP_WIFI_MODULE_COM)
  1848. #undef ESP_WIFI_MODULE_COM
  1849. #undef ESP_WIFI_MODULE_BAUDRATE
  1850. #undef ESP_WIFI_MODULE_RESET_PIN
  1851. #undef ESP_WIFI_MODULE_ENABLE_PIN
  1852. #undef ESP_WIFI_MODULE_TXD_PIN
  1853. #undef ESP_WIFI_MODULE_RXD_PIN
  1854. #undef ESP_WIFI_MODULE_GPIO0_PIN
  1855. #undef ESP_WIFI_MODULE_GPIO2_PIN
  1856. #undef ESP_WIFI_MODULE_GPIO4_PIN
  1857. #endif
  1858. #endif
  1859. /**
  1860. * Endstop and probe flags
  1861. * - Set USE_(AXIS)_(MIN|MAX) flags for each used endstop that has a pin, including those for DIAG0 state.
  1862. * - Note: Dual X Carriage uses "X" and "X2" steppers, but X_MIN and X_MAX endstop states (i.e., not X2_MAX).
  1863. * - Set a HAS_(AXIS)_(MIN|MAX)_STATE flag for each endstop that has a state, including SPI Sensorless which don't use a pin.
  1864. * - Set a HAS_(AXIS)_STATE flag for each axis that has at least one state.
  1865. * - Consider (AXIS)_SAFETY_STOP for the case where the axis has a second endstop.
  1866. * Currently this must be distinct, but we can add a mechanism to use the same pin for sensorless
  1867. * or switches wired to the same pin, or for the single SPI stall state on the axis.
  1868. */
  1869. #define _ANY_STOP(A,N,M) ANY(A##_HOME_TO_##M, A##N##_SAFETY_STOP)
  1870. #define _USE_STOP(A,N,M,C) ((_ANY_STOP(A,N,M) || (C+0)) && PIN_EXISTS(A##N##_##M) && !A##_SPI_SENSORLESS)
  1871. #define _HAS_STATE(A,N,M) (USE_##A##N##_##M || (_ANY_STOP(A,N,M) && A##_SPI_SENSORLESS))
  1872. #if _USE_STOP(X,,MIN,)
  1873. #define USE_X_MIN 1
  1874. #endif
  1875. #if _USE_STOP(X,,MAX,ENABLED(DUAL_X_CARRIAGE))
  1876. #define USE_X_MAX 1
  1877. #endif
  1878. #if _HAS_STATE(X,,MIN)
  1879. #define HAS_X_MIN_STATE 1
  1880. #endif
  1881. #if _HAS_STATE(X,,MAX)
  1882. #define HAS_X_MAX_STATE 1
  1883. #endif
  1884. #if HAS_X_MIN_STATE || HAS_X_MAX_STATE
  1885. #define HAS_X_STATE 1
  1886. #endif
  1887. #if _USE_STOP(Y,,MIN,)
  1888. #define USE_Y_MIN 1
  1889. #endif
  1890. #if _USE_STOP(Y,,MAX,)
  1891. #define USE_Y_MAX 1
  1892. #endif
  1893. #if _HAS_STATE(Y,,MIN)
  1894. #define HAS_Y_MIN_STATE 1
  1895. #endif
  1896. #if _HAS_STATE(Y,,MAX)
  1897. #define HAS_Y_MAX_STATE 1
  1898. #endif
  1899. #if HAS_Y_MIN_STATE || HAS_Y_MAX_STATE
  1900. #define HAS_Y_STATE 1
  1901. #endif
  1902. #if _USE_STOP(Z,,MIN,ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)) && (DISABLED(USE_PROBE_FOR_Z_HOMING) || ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN))
  1903. #define USE_Z_MIN 1
  1904. #endif
  1905. #if _USE_STOP(Z,,MAX,)
  1906. #define USE_Z_MAX 1
  1907. #endif
  1908. #if _HAS_STATE(Z,,MIN)
  1909. #define HAS_Z_MIN_STATE 1
  1910. #endif
  1911. #if _HAS_STATE(Z,,MAX)
  1912. #define HAS_Z_MAX_STATE 1
  1913. #endif
  1914. #if HAS_Z_MIN_STATE || HAS_Z_MAX_STATE
  1915. #define HAS_Z_STATE 1
  1916. #endif
  1917. #if _USE_STOP(I,,MIN,)
  1918. #define USE_I_MIN 1
  1919. #endif
  1920. #if _USE_STOP(I,,MAX,)
  1921. #define USE_I_MAX 1
  1922. #endif
  1923. #if _HAS_STATE(I,,MIN)
  1924. #define HAS_I_MIN_STATE 1
  1925. #endif
  1926. #if _HAS_STATE(I,,MAX)
  1927. #define HAS_I_MAX_STATE 1
  1928. #endif
  1929. #if HAS_I_MIN_STATE || HAS_I_MAX_STATE
  1930. #define HAS_I_STATE 1
  1931. #endif
  1932. #if _USE_STOP(J,,MIN,)
  1933. #define USE_J_MIN 1
  1934. #endif
  1935. #if _USE_STOP(J,,MAX,)
  1936. #define USE_J_MAX 1
  1937. #endif
  1938. #if _HAS_STATE(J,,MIN)
  1939. #define HAS_J_MIN_STATE 1
  1940. #endif
  1941. #if _HAS_STATE(J,,MAX)
  1942. #define HAS_J_MAX_STATE 1
  1943. #endif
  1944. #if HAS_J_MIN_STATE || HAS_J_MAX_STATE
  1945. #define HAS_J_STATE 1
  1946. #endif
  1947. #if _USE_STOP(K,,MIN,)
  1948. #define USE_K_MIN 1
  1949. #endif
  1950. #if _USE_STOP(K,,MAX,)
  1951. #define USE_K_MAX 1
  1952. #endif
  1953. #if _HAS_STATE(K,,MIN)
  1954. #define HAS_K_MIN_STATE 1
  1955. #endif
  1956. #if _HAS_STATE(K,,MAX)
  1957. #define HAS_K_MAX_STATE 1
  1958. #endif
  1959. #if HAS_K_MIN_STATE || HAS_K_MAX_STATE
  1960. #define HAS_K_STATE 1
  1961. #endif
  1962. #if _USE_STOP(U,,MIN,)
  1963. #define USE_U_MIN 1
  1964. #endif
  1965. #if _USE_STOP(U,,MAX,)
  1966. #define USE_U_MAX 1
  1967. #endif
  1968. #if _HAS_STATE(U,,MIN)
  1969. #define HAS_U_MIN_STATE 1
  1970. #endif
  1971. #if _HAS_STATE(U,,MAX)
  1972. #define HAS_U_MAX_STATE 1
  1973. #endif
  1974. #if HAS_U_MIN_STATE || HAS_U_MAX_STATE
  1975. #define HAS_U_STATE 1
  1976. #endif
  1977. #if _USE_STOP(V,,MIN,)
  1978. #define USE_V_MIN 1
  1979. #endif
  1980. #if _USE_STOP(V,,MAX,)
  1981. #define USE_V_MAX 1
  1982. #endif
  1983. #if _HAS_STATE(V,,MIN)
  1984. #define HAS_V_MIN_STATE 1
  1985. #endif
  1986. #if _HAS_STATE(V,,MAX)
  1987. #define HAS_V_MAX_STATE 1
  1988. #endif
  1989. #if HAS_V_MIN_STATE || HAS_V_MAX_STATE
  1990. #define HAS_V_STATE 1
  1991. #endif
  1992. #if _USE_STOP(W,,MIN,)
  1993. #define USE_W_MIN 1
  1994. #endif
  1995. #if _USE_STOP(W,,MAX,)
  1996. #define USE_W_MAX 1
  1997. #endif
  1998. #if _HAS_STATE(W,,MIN)
  1999. #define HAS_W_MIN_STATE 1
  2000. #endif
  2001. #if _HAS_STATE(W,,MAX)
  2002. #define HAS_W_MAX_STATE 1
  2003. #endif
  2004. #if HAS_W_MIN_STATE || HAS_W_MAX_STATE
  2005. #define HAS_W_STATE 1
  2006. #endif
  2007. #if ENABLED(X_DUAL_ENDSTOPS)
  2008. #if _USE_STOP(X,2,MIN,)
  2009. #define USE_X2_MIN 1
  2010. #endif
  2011. #if _USE_STOP(X,2,MAX,)
  2012. #define USE_X2_MAX 1
  2013. #endif
  2014. #if _HAS_STATE(X,2,MIN) || HAS_X_MIN_STATE
  2015. #define HAS_X2_MIN_STATE 1
  2016. #endif
  2017. #if _HAS_STATE(X,2,MAX) || HAS_X_MAX_STATE
  2018. #define HAS_X2_MAX_STATE 1
  2019. #endif
  2020. #if HAS_X2_MIN_STATE || HAS_X2_MAX_STATE
  2021. #define HAS_X2_STATE 1
  2022. #endif
  2023. #endif
  2024. #if ENABLED(Y_DUAL_ENDSTOPS)
  2025. #if _USE_STOP(Y,2,MIN,)
  2026. #define USE_Y2_MIN 1
  2027. #endif
  2028. #if _USE_STOP(Y,2,MAX,)
  2029. #define USE_Y2_MAX 1
  2030. #endif
  2031. #if _HAS_STATE(Y,2,MIN) || HAS_Y_MIN_STATE
  2032. #define HAS_Y2_MIN_STATE 1
  2033. #endif
  2034. #if _HAS_STATE(Y,2,MAX) || HAS_Y_MAX_STATE
  2035. #define HAS_Y2_MAX_STATE 1
  2036. #endif
  2037. #if HAS_Y2_MIN_STATE || HAS_Y2_MAX_STATE
  2038. #define HAS_Y2_STATE 1
  2039. #endif
  2040. #endif
  2041. #if ENABLED(Z_MULTI_ENDSTOPS)
  2042. #if _USE_STOP(Z,2,MIN,)
  2043. #define USE_Z2_MIN 1
  2044. #endif
  2045. #if _USE_STOP(Z,2,MAX,)
  2046. #define USE_Z2_MAX 1
  2047. #endif
  2048. #if _HAS_STATE(Z,2,MIN) || HAS_Z_MIN_STATE
  2049. #define HAS_Z2_MIN_STATE 1
  2050. #endif
  2051. #if _HAS_STATE(Z,2,MAX) || HAS_Z_MAX_STATE
  2052. #define HAS_Z2_MAX_STATE 1
  2053. #endif
  2054. #if HAS_Z2_MIN_STATE || HAS_Z2_MAX_STATE
  2055. #define HAS_Z2_STATE 1
  2056. #endif
  2057. #if NUM_Z_STEPPERS >= 3
  2058. #if _USE_STOP(Z,3,MIN,)
  2059. #define USE_Z3_MIN 1
  2060. #endif
  2061. #if _USE_STOP(Z,3,MAX,)
  2062. #define USE_Z3_MAX 1
  2063. #endif
  2064. #if _HAS_STATE(Z,3,MIN) || HAS_Z_MIN_STATE
  2065. #define HAS_Z3_MIN_STATE 1
  2066. #endif
  2067. #if _HAS_STATE(Z,3,MAX) || HAS_Z_MAX_STATE
  2068. #define HAS_Z3_MAX_STATE 1
  2069. #endif
  2070. #if HAS_Z3_MIN_STATE || HAS_Z3_MAX_STATE
  2071. #define HAS_Z3_STATE 1
  2072. #endif
  2073. #endif
  2074. #if NUM_Z_STEPPERS >= 4
  2075. #if _USE_STOP(Z,4,MIN,)
  2076. #define USE_Z4_MIN 1
  2077. #endif
  2078. #if _USE_STOP(Z,4,MAX,)
  2079. #define USE_Z4_MAX 1
  2080. #endif
  2081. #if _HAS_STATE(Z,4,MIN) || HAS_Z_MIN_STATE
  2082. #define HAS_Z4_MIN_STATE 1
  2083. #endif
  2084. #if _HAS_STATE(Z,4,MAX) || HAS_Z_MAX_STATE
  2085. #define HAS_Z4_MAX_STATE 1
  2086. #endif
  2087. #if HAS_Z4_MIN_STATE || HAS_Z4_MAX_STATE
  2088. #define HAS_Z4_STATE 1
  2089. #endif
  2090. #endif
  2091. #endif
  2092. #if NEED_Z_MIN_PROBE_PIN && PIN_EXISTS(Z_MIN_PROBE)
  2093. #define USE_Z_MIN_PROBE 1
  2094. #endif
  2095. #if HAS_REAL_BED_PROBE
  2096. #define HAS_Z_PROBE_STATE 1
  2097. #endif
  2098. #if PIN_EXISTS(CALIBRATION)
  2099. #define USE_CALIBRATION 1
  2100. #define HAS_CALIBRATION_STATE 1
  2101. #endif
  2102. #undef _ANY_STOP
  2103. #undef _USE_STOP
  2104. #undef _HAS_STATE
  2105. /**
  2106. * Set ENDSTOPPULLUPS for active endstop switches
  2107. */
  2108. #if ENABLED(ENDSTOPPULLUPS)
  2109. #if USE_X_MIN
  2110. #define ENDSTOPPULLUP_XMIN
  2111. #endif
  2112. #if USE_X_MAX
  2113. #define ENDSTOPPULLUP_XMAX
  2114. #endif
  2115. #if USE_Y_MIN
  2116. #define ENDSTOPPULLUP_YMIN
  2117. #endif
  2118. #if USE_Y_MAX
  2119. #define ENDSTOPPULLUP_YMAX
  2120. #endif
  2121. #if USE_Z_MIN
  2122. #define ENDSTOPPULLUP_ZMIN
  2123. #endif
  2124. #if USE_Z_MAX
  2125. #define ENDSTOPPULLUP_ZMAX
  2126. #endif
  2127. #if USE_I_MIN
  2128. #define ENDSTOPPULLUP_IMIN
  2129. #endif
  2130. #if USE_I_MAX
  2131. #define ENDSTOPPULLUP_IMAX
  2132. #endif
  2133. #if USE_J_MIN
  2134. #define ENDSTOPPULLUP_JMIN
  2135. #endif
  2136. #if USE_J_MAX
  2137. #define ENDSTOPPULLUP_JMAX
  2138. #endif
  2139. #if USE_K_MIN
  2140. #define ENDSTOPPULLUP_KMIN
  2141. #endif
  2142. #if USE_K_MAX
  2143. #define ENDSTOPPULLUP_KMAX
  2144. #endif
  2145. #if USE_U_MIN
  2146. #define ENDSTOPPULLUP_UMIN
  2147. #endif
  2148. #if USE_U_MAX
  2149. #define ENDSTOPPULLUP_UMAX
  2150. #endif
  2151. #if USE_V_MIN
  2152. #define ENDSTOPPULLUP_VMIN
  2153. #endif
  2154. #if USE_V_MAX
  2155. #define ENDSTOPPULLUP_VMAX
  2156. #endif
  2157. #if USE_W_MIN
  2158. #define ENDSTOPPULLUP_WMIN
  2159. #endif
  2160. #if USE_W_MAX
  2161. #define ENDSTOPPULLUP_WMAX
  2162. #endif
  2163. #endif
  2164. /**
  2165. * Set ENDSTOPPULLDOWNS for active endstop switches
  2166. */
  2167. #if ENABLED(ENDSTOPPULLDOWNS)
  2168. #if USE_X_MIN
  2169. #define ENDSTOPPULLDOWN_XMIN
  2170. #endif
  2171. #if USE_X_MAX
  2172. #define ENDSTOPPULLDOWN_XMAX
  2173. #endif
  2174. #if USE_Y_MIN
  2175. #define ENDSTOPPULLDOWN_YMIN
  2176. #endif
  2177. #if USE_Y_MAX
  2178. #define ENDSTOPPULLDOWN_YMAX
  2179. #endif
  2180. #if USE_Z_MIN
  2181. #define ENDSTOPPULLDOWN_ZMIN
  2182. #endif
  2183. #if USE_Z_MAX
  2184. #define ENDSTOPPULLDOWN_ZMAX
  2185. #endif
  2186. #if USE_I_MIN
  2187. #define ENDSTOPPULLDOWN_IMIN
  2188. #endif
  2189. #if USE_I_MAX
  2190. #define ENDSTOPPULLDOWN_IMAX
  2191. #endif
  2192. #if USE_J_MIN
  2193. #define ENDSTOPPULLDOWN_JMIN
  2194. #endif
  2195. #if USE_J_MAX
  2196. #define ENDSTOPPULLDOWN_JMAX
  2197. #endif
  2198. #if USE_K_MIN
  2199. #define ENDSTOPPULLDOWN_KMIN
  2200. #endif
  2201. #if USE_K_MAX
  2202. #define ENDSTOPPULLDOWN_KMAX
  2203. #endif
  2204. #if USE_U_MIN
  2205. #define ENDSTOPPULLDOWN_UMIN
  2206. #endif
  2207. #if USE_U_MAX
  2208. #define ENDSTOPPULLDOWN_UMAX
  2209. #endif
  2210. #if USE_V_MIN
  2211. #define ENDSTOPPULLDOWN_VMIN
  2212. #endif
  2213. #if USE_V_MAX
  2214. #define ENDSTOPPULLDOWN_VMAX
  2215. #endif
  2216. #if USE_W_MIN
  2217. #define ENDSTOPPULLDOWN_WMIN
  2218. #endif
  2219. #if USE_W_MAX
  2220. #define ENDSTOPPULLDOWN_WMAX
  2221. #endif
  2222. #endif
  2223. //
  2224. // ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface)
  2225. //
  2226. #define HAS_ADC_TEST(P) (TEMP_SENSOR(P) && PIN_EXISTS(TEMP_##P) && !TEMP_SENSOR_IS_MAX_TC(P) && !TEMP_SENSOR_##P##_IS_DUMMY)
  2227. #if HOTENDS > 0 && HAS_ADC_TEST(0)
  2228. #define HAS_TEMP_ADC_0 1
  2229. #endif
  2230. #if HOTENDS > 1 && HAS_ADC_TEST(1)
  2231. #define HAS_TEMP_ADC_1 1
  2232. #endif
  2233. #if HOTENDS > 2 && HAS_ADC_TEST(2)
  2234. #define HAS_TEMP_ADC_2 1
  2235. #endif
  2236. #if HOTENDS > 3 && HAS_ADC_TEST(3)
  2237. #define HAS_TEMP_ADC_3 1
  2238. #endif
  2239. #if HOTENDS > 4 && HAS_ADC_TEST(4)
  2240. #define HAS_TEMP_ADC_4 1
  2241. #endif
  2242. #if HOTENDS > 5 && HAS_ADC_TEST(5)
  2243. #define HAS_TEMP_ADC_5 1
  2244. #endif
  2245. #if HOTENDS > 6 && HAS_ADC_TEST(6)
  2246. #define HAS_TEMP_ADC_6 1
  2247. #endif
  2248. #if HOTENDS > 7 && HAS_ADC_TEST(7)
  2249. #define HAS_TEMP_ADC_7 1
  2250. #endif
  2251. #if TEMP_SENSOR_BED
  2252. #define HAS_HEATED_BED 1
  2253. #if HAS_ADC_TEST(BED)
  2254. #define HAS_TEMP_ADC_BED 1
  2255. #endif
  2256. #endif
  2257. #if HAS_ADC_TEST(PROBE)
  2258. #define HAS_TEMP_ADC_PROBE 1
  2259. #endif
  2260. #if HAS_ADC_TEST(CHAMBER)
  2261. #define HAS_TEMP_ADC_CHAMBER 1
  2262. #endif
  2263. #if HAS_ADC_TEST(COOLER)
  2264. #define HAS_TEMP_ADC_COOLER 1
  2265. #endif
  2266. #if HAS_ADC_TEST(BOARD)
  2267. #define HAS_TEMP_ADC_BOARD 1
  2268. #endif
  2269. #if HAS_ADC_TEST(SOC)
  2270. #define HAS_TEMP_ADC_SOC 1
  2271. #endif
  2272. #if HAS_ADC_TEST(REDUNDANT)
  2273. #define HAS_TEMP_ADC_REDUNDANT 1
  2274. #endif
  2275. #define HAS_TEMP(N) (TEMP_SENSOR_IS_MAX_TC(N) || HAS_TEMP_ADC_##N || TEMP_SENSOR_##N##_IS_DUMMY)
  2276. #if HAS_HOTEND && HAS_TEMP(0)
  2277. #define HAS_TEMP_HOTEND 1
  2278. #endif
  2279. #if HAS_TEMP(BED)
  2280. #define HAS_TEMP_BED 1
  2281. #endif
  2282. #if HAS_TEMP(CHAMBER)
  2283. #define HAS_TEMP_CHAMBER 1
  2284. #endif
  2285. #if HAS_TEMP(PROBE)
  2286. #define HAS_TEMP_PROBE 1
  2287. #endif
  2288. #if HAS_TEMP(COOLER)
  2289. #define HAS_TEMP_COOLER 1
  2290. #endif
  2291. #if HAS_TEMP(BOARD)
  2292. #define HAS_TEMP_BOARD 1
  2293. #endif
  2294. #if HAS_TEMP(SOC)
  2295. #define HAS_TEMP_SOC 1
  2296. #endif
  2297. #if HAS_TEMP(REDUNDANT)
  2298. #define HAS_TEMP_REDUNDANT 1
  2299. #endif
  2300. #if ENABLED(JOYSTICK)
  2301. #if PIN_EXISTS(JOY_X)
  2302. #define HAS_JOY_ADC_X 1
  2303. #endif
  2304. #if PIN_EXISTS(JOY_Y)
  2305. #define HAS_JOY_ADC_Y 1
  2306. #endif
  2307. #if PIN_EXISTS(JOY_Z)
  2308. #define HAS_JOY_ADC_Z 1
  2309. #endif
  2310. #if PIN_EXISTS(JOY_EN)
  2311. #define HAS_JOY_ADC_EN 1
  2312. #endif
  2313. #endif
  2314. // Heaters
  2315. #if PIN_EXISTS(HEATER_0)
  2316. #define HAS_HEATER_0 1
  2317. #endif
  2318. #if PIN_EXISTS(HEATER_1)
  2319. #define HAS_HEATER_1 1
  2320. #endif
  2321. #if PIN_EXISTS(HEATER_2)
  2322. #define HAS_HEATER_2 1
  2323. #endif
  2324. #if PIN_EXISTS(HEATER_3)
  2325. #define HAS_HEATER_3 1
  2326. #endif
  2327. #if PIN_EXISTS(HEATER_4)
  2328. #define HAS_HEATER_4 1
  2329. #endif
  2330. #if PIN_EXISTS(HEATER_5)
  2331. #define HAS_HEATER_5 1
  2332. #endif
  2333. #if PIN_EXISTS(HEATER_6)
  2334. #define HAS_HEATER_6 1
  2335. #endif
  2336. #if PIN_EXISTS(HEATER_7)
  2337. #define HAS_HEATER_7 1
  2338. #endif
  2339. #if PIN_EXISTS(HEATER_BED)
  2340. #define HAS_HEATER_BED 1
  2341. #endif
  2342. #if PIN_EXISTS(HEATER_CHAMBER)
  2343. #define HAS_HEATER_CHAMBER 1
  2344. #endif
  2345. // Shorthand for common combinations
  2346. #if HAS_HEATED_BED
  2347. #ifndef BED_OVERSHOOT
  2348. #define BED_OVERSHOOT 10
  2349. #endif
  2350. #define BED_MAX_TARGET ((BED_MAXTEMP) - (BED_OVERSHOOT))
  2351. #else
  2352. #undef PIDTEMPBED
  2353. #undef PREHEAT_BEFORE_LEVELING
  2354. #endif
  2355. #if HAS_TEMP_COOLER && PIN_EXISTS(COOLER)
  2356. #define HAS_COOLER 1
  2357. #ifndef COOLER_OVERSHOOT
  2358. #define COOLER_OVERSHOOT 2
  2359. #endif
  2360. #define COOLER_MIN_TARGET ((COOLER_MINTEMP) + (COOLER_OVERSHOOT))
  2361. #define COOLER_MAX_TARGET ((COOLER_MAXTEMP) - (COOLER_OVERSHOOT))
  2362. #endif
  2363. #if HAS_TEMP_HOTEND || HAS_HEATED_BED || HAS_TEMP_CHAMBER || HAS_TEMP_PROBE || HAS_TEMP_COOLER || HAS_TEMP_BOARD || HAS_TEMP_SOC
  2364. #define HAS_TEMP_SENSOR 1
  2365. #endif
  2366. #if HAS_TEMP_CHAMBER && HAS_HEATER_CHAMBER
  2367. #define HAS_HEATED_CHAMBER 1
  2368. #ifndef CHAMBER_OVERSHOOT
  2369. #define CHAMBER_OVERSHOOT 10
  2370. #endif
  2371. #define CHAMBER_MAX_TARGET ((CHAMBER_MAXTEMP) - (CHAMBER_OVERSHOOT))
  2372. #else
  2373. #undef PIDTEMPCHAMBER
  2374. #endif
  2375. // PID heating
  2376. #if ANY(PIDTEMP, PIDTEMPBED, PIDTEMPCHAMBER)
  2377. #define HAS_PID_HEATING 1
  2378. #endif
  2379. // Thermal protection
  2380. #if !HAS_HEATED_BED
  2381. #undef THERMAL_PROTECTION_BED
  2382. #undef THERMAL_PROTECTION_BED_PERIOD
  2383. #endif
  2384. #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
  2385. #define WATCH_HOTENDS 1
  2386. #endif
  2387. #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
  2388. #define WATCH_BED 1
  2389. #endif
  2390. #if ALL(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) && WATCH_CHAMBER_TEMP_PERIOD > 0
  2391. #define WATCH_CHAMBER 1
  2392. #endif
  2393. #if ALL(HAS_COOLER, THERMAL_PROTECTION_COOLER) && WATCH_COOLER_TEMP_PERIOD > 0
  2394. #define WATCH_COOLER 1
  2395. #endif
  2396. #if NONE(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_CHAMBER, THERMAL_PROTECTION_BED, THERMAL_PROTECTION_COOLER)
  2397. #undef THERMAL_PROTECTION_VARIANCE_MONITOR
  2398. #endif
  2399. #if (ENABLED(THERMAL_PROTECTION_HOTENDS) || !EXTRUDERS) \
  2400. && (ENABLED(THERMAL_PROTECTION_BED) || !HAS_HEATED_BED) \
  2401. && (ENABLED(THERMAL_PROTECTION_CHAMBER) || !HAS_HEATED_CHAMBER) \
  2402. && (ENABLED(THERMAL_PROTECTION_COOLER) || !HAS_COOLER)
  2403. #define THERMALLY_SAFE 1
  2404. #endif
  2405. // Auto fans
  2406. #if HAS_HOTEND && PIN_EXISTS(E0_AUTO_FAN)
  2407. #define HAS_AUTO_FAN_0 1
  2408. #endif
  2409. #if HAS_MULTI_HOTEND && PIN_EXISTS(E1_AUTO_FAN)
  2410. #define HAS_AUTO_FAN_1 1
  2411. #endif
  2412. #if HOTENDS > 2 && PIN_EXISTS(E2_AUTO_FAN)
  2413. #define HAS_AUTO_FAN_2 1
  2414. #endif
  2415. #if HOTENDS > 3 && PIN_EXISTS(E3_AUTO_FAN)
  2416. #define HAS_AUTO_FAN_3 1
  2417. #endif
  2418. #if HOTENDS > 4 && PIN_EXISTS(E4_AUTO_FAN)
  2419. #define HAS_AUTO_FAN_4 1
  2420. #endif
  2421. #if HOTENDS > 5 && PIN_EXISTS(E5_AUTO_FAN)
  2422. #define HAS_AUTO_FAN_5 1
  2423. #endif
  2424. #if HOTENDS > 6 && PIN_EXISTS(E6_AUTO_FAN)
  2425. #define HAS_AUTO_FAN_6 1
  2426. #endif
  2427. #if HOTENDS > 7 && PIN_EXISTS(E7_AUTO_FAN)
  2428. #define HAS_AUTO_FAN_7 1
  2429. #endif
  2430. #if HAS_TEMP_CHAMBER && PIN_EXISTS(CHAMBER_AUTO_FAN)
  2431. #define HAS_AUTO_CHAMBER_FAN 1
  2432. #endif
  2433. #if HAS_TEMP_COOLER && PIN_EXISTS(COOLER_AUTO_FAN)
  2434. #define HAS_AUTO_COOLER_FAN 1
  2435. #endif
  2436. #if ANY(HAS_AUTO_FAN_0, HAS_AUTO_FAN_1, HAS_AUTO_FAN_2, HAS_AUTO_FAN_3, HAS_AUTO_FAN_4, HAS_AUTO_FAN_5, HAS_AUTO_FAN_6, HAS_AUTO_FAN_7, HAS_AUTO_CHAMBER_FAN, HAS_AUTO_COOLER_FAN)
  2437. #define HAS_AUTO_FAN 1
  2438. #define _FANOVERLAP(I,T) (T##_AUTO_FAN_PIN == E##I##_AUTO_FAN_PIN)
  2439. #if HAS_AUTO_CHAMBER_FAN
  2440. #define _CHFANOVERLAP(I) || _FANOVERLAP(I,CHAMBER)
  2441. #if (0 REPEAT(8, _CHFANOVERLAP))
  2442. #define AUTO_CHAMBER_IS_E 1
  2443. #endif
  2444. #undef _CHFANOVERLAP
  2445. #endif
  2446. #if HAS_AUTO_COOLER_FAN
  2447. #define _COFANOVERLAP(I) || _FANOVERLAP(I,COOLER)
  2448. #if (0 REPEAT(8, _COFANOVERLAP))
  2449. #define AUTO_COOLER_IS_E 1
  2450. #endif
  2451. #undef _COFANOVERLAP
  2452. #endif
  2453. #endif
  2454. // Fans check
  2455. #if HAS_HOTEND && PIN_EXISTS(E0_FAN_TACHO)
  2456. #define HAS_E0_FAN_TACHO 1
  2457. #endif
  2458. #if HOTENDS > 1 && PIN_EXISTS(E1_FAN_TACHO)
  2459. #define HAS_E1_FAN_TACHO 1
  2460. #endif
  2461. #if HOTENDS > 2 && PIN_EXISTS(E2_FAN_TACHO)
  2462. #define HAS_E2_FAN_TACHO 1
  2463. #endif
  2464. #if HOTENDS > 3 && PIN_EXISTS(E3_FAN_TACHO)
  2465. #define HAS_E3_FAN_TACHO 1
  2466. #endif
  2467. #if HOTENDS > 4 && PIN_EXISTS(E4_FAN_TACHO)
  2468. #define HAS_E4_FAN_TACHO 1
  2469. #endif
  2470. #if HOTENDS > 5 && PIN_EXISTS(E5_FAN_TACHO)
  2471. #define HAS_E5_FAN_TACHO 1
  2472. #endif
  2473. #if HOTENDS > 6 && PIN_EXISTS(E6_FAN_TACHO)
  2474. #define HAS_E6_FAN_TACHO 1
  2475. #endif
  2476. #if HOTENDS > 7 && PIN_EXISTS(E7_FAN_TACHO)
  2477. #define HAS_E7_FAN_TACHO 1
  2478. #endif
  2479. #if ANY(HAS_E0_FAN_TACHO, HAS_E1_FAN_TACHO, HAS_E2_FAN_TACHO, HAS_E3_FAN_TACHO, HAS_E4_FAN_TACHO, HAS_E5_FAN_TACHO, HAS_E6_FAN_TACHO, HAS_E7_FAN_TACHO)
  2480. #define HAS_FANCHECK 1
  2481. #if HAS_AUTO_FAN && EXTRUDER_AUTO_FAN_SPEED != 255 && DISABLED(FOURWIRES_FANS)
  2482. #define HAS_PWMFANCHECK 1
  2483. #endif
  2484. #endif
  2485. #if !HAS_TEMP_SENSOR
  2486. #undef AUTO_REPORT_TEMPERATURES
  2487. #endif
  2488. #if ANY(AUTO_REPORT_TEMPERATURES, AUTO_REPORT_SD_STATUS, AUTO_REPORT_POSITION, AUTO_REPORT_FANS)
  2489. #define HAS_AUTO_REPORTING 1
  2490. #endif
  2491. #if !HAS_AUTO_CHAMBER_FAN || AUTO_CHAMBER_IS_E
  2492. #undef AUTO_POWER_CHAMBER_FAN
  2493. #endif
  2494. #if !HAS_AUTO_COOLER_FAN || AUTO_COOLER_IS_E
  2495. #undef AUTO_POWER_COOLER_FAN
  2496. #endif
  2497. #if !HAS_CUTTER
  2498. #undef AUTO_POWER_SPINDLE_LASER
  2499. #endif
  2500. /**
  2501. * Controller Fan Settings
  2502. */
  2503. #if PIN_EXISTS(CONTROLLER_FAN)
  2504. #define HAS_CONTROLLER_FAN 1
  2505. #endif
  2506. #if HAS_CONTROLLER_FAN
  2507. #if ENABLED(CONTROLLER_FAN_USE_BOARD_TEMP)
  2508. #define HAS_CONTROLLER_FAN_BOARD_TEMP_TRIGGER 1
  2509. #ifndef CONTROLLER_FAN_TRIGGER_TEMP
  2510. #define CONTROLLER_FAN_TRIGGER_TEMP 30
  2511. #endif
  2512. #else
  2513. #undef CONTROLLER_FAN_TRIGGER_TEMP
  2514. #endif
  2515. #endif
  2516. /**
  2517. * Up to 12 PWM fans
  2518. */
  2519. #ifdef NUM_M106_FANS
  2520. #define MAX_FANS NUM_M106_FANS
  2521. #else
  2522. #define MAX_FANS 12 // Max supported fans
  2523. #endif
  2524. #define _IS_E_AUTO(N,F) (PIN_EXISTS(E##N##_AUTO_FAN) && E##N##_AUTO_FAN_PIN == FAN##F##_PIN)
  2525. #define _HAS_FAN(F) (F < MAX_FANS && PIN_EXISTS(FAN##F) \
  2526. && !(HAS_CONTROLLER_FAN && CONTROLLER_FAN_PIN == FAN##F##_PIN) \
  2527. && !_IS_E_AUTO(0,F) && !_IS_E_AUTO(1,F) \
  2528. && !_IS_E_AUTO(2,F) && !_IS_E_AUTO(3,F) \
  2529. && !_IS_E_AUTO(4,F) && !_IS_E_AUTO(5,F) \
  2530. && !_IS_E_AUTO(6,F) && !_IS_E_AUTO(7,F))
  2531. #if _HAS_FAN(0)
  2532. #define HAS_FAN0 1
  2533. #endif
  2534. #if _HAS_FAN(1)
  2535. #define HAS_FAN1 1
  2536. #endif
  2537. #if _HAS_FAN(2)
  2538. #define HAS_FAN2 1
  2539. #endif
  2540. #if _HAS_FAN(3)
  2541. #define HAS_FAN3 1
  2542. #endif
  2543. #if _HAS_FAN(4)
  2544. #define HAS_FAN4 1
  2545. #endif
  2546. #if _HAS_FAN(5)
  2547. #define HAS_FAN5 1
  2548. #endif
  2549. #if _HAS_FAN(6)
  2550. #define HAS_FAN6 1
  2551. #endif
  2552. #if _HAS_FAN(7)
  2553. #define HAS_FAN7 1
  2554. #endif
  2555. #if _HAS_FAN(8)
  2556. #define HAS_FAN8 1
  2557. #endif
  2558. #if _HAS_FAN(9)
  2559. #define HAS_FAN9 1
  2560. #endif
  2561. #if _HAS_FAN(10)
  2562. #define HAS_FAN10 1
  2563. #endif
  2564. #if _HAS_FAN(11)
  2565. #define HAS_FAN11 1
  2566. #endif
  2567. #undef _HAS_FAN
  2568. #undef _IS_E_AUTO
  2569. #if HAS_FAN11
  2570. #define FAN_COUNT 12
  2571. #elif HAS_FAN10
  2572. #define FAN_COUNT 11
  2573. #elif HAS_FAN9
  2574. #define FAN_COUNT 10
  2575. #elif HAS_FAN8
  2576. #define FAN_COUNT 9
  2577. #elif HAS_FAN7
  2578. #define FAN_COUNT 8
  2579. #elif HAS_FAN6
  2580. #define FAN_COUNT 7
  2581. #elif HAS_FAN5
  2582. #define FAN_COUNT 6
  2583. #elif HAS_FAN4
  2584. #define FAN_COUNT 5
  2585. #elif HAS_FAN3
  2586. #define FAN_COUNT 4
  2587. #elif HAS_FAN2
  2588. #define FAN_COUNT 3
  2589. #elif HAS_FAN1
  2590. #define FAN_COUNT 2
  2591. #elif HAS_FAN0
  2592. #define FAN_COUNT 1
  2593. #else
  2594. #define FAN_COUNT 0
  2595. #endif
  2596. #if FAN_COUNT > 0
  2597. #define HAS_FAN 1
  2598. #endif
  2599. #if PIN_EXISTS(FANMUX0)
  2600. #define HAS_FANMUX 1 // Part Cooling fan multipliexer
  2601. #endif
  2602. /**
  2603. * MIN/MAX fan PWM scaling
  2604. */
  2605. #if ANY(HAS_FAN, USE_CONTROLLER_FAN)
  2606. #ifndef FAN_OFF_PWM
  2607. #define FAN_OFF_PWM 0
  2608. #endif
  2609. #ifndef FAN_MIN_PWM
  2610. #if FAN_OFF_PWM > 0
  2611. #define FAN_MIN_PWM (FAN_OFF_PWM + 1)
  2612. #else
  2613. #define FAN_MIN_PWM 0
  2614. #endif
  2615. #endif
  2616. #ifndef FAN_MAX_PWM
  2617. #define FAN_MAX_PWM 255
  2618. #endif
  2619. #if FAN_MIN_PWM == 0 && FAN_MAX_PWM == 255
  2620. #define CALC_FAN_SPEED(f) (f ?: FAN_OFF_PWM)
  2621. #else
  2622. #define CALC_FAN_SPEED(f) (f ? map(f, 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : FAN_OFF_PWM)
  2623. #endif
  2624. #endif
  2625. // Fan Kickstart
  2626. #if FAN_KICKSTART_TIME && !defined(FAN_KICKSTART_POWER)
  2627. #define FAN_KICKSTART_POWER TERN(FAN_KICKSTART_LINEAR, 255, 180)
  2628. #endif
  2629. // Servos
  2630. #if NUM_SERVOS > 0
  2631. #define HAS_SERVOS 1
  2632. #if PIN_EXISTS(SERVO0)
  2633. #define HAS_SERVO_0 1
  2634. #endif
  2635. #if PIN_EXISTS(SERVO1) && NUM_SERVOS > 1
  2636. #define HAS_SERVO_1 1
  2637. #endif
  2638. #if PIN_EXISTS(SERVO2) && NUM_SERVOS > 2
  2639. #define HAS_SERVO_2 1
  2640. #endif
  2641. #if PIN_EXISTS(SERVO3) && NUM_SERVOS > 3
  2642. #define HAS_SERVO_3 1
  2643. #endif
  2644. #if PIN_EXISTS(SERVO4) && NUM_SERVOS > 4
  2645. #define HAS_SERVO_4 1
  2646. #endif
  2647. #if PIN_EXISTS(SERVO5) && NUM_SERVOS > 5
  2648. #define HAS_SERVO_5 1
  2649. #endif
  2650. #if defined(PAUSE_SERVO_OUTPUT) && defined(RESUME_SERVO_OUTPUT)
  2651. #define HAS_PAUSE_SERVO_OUTPUT 1
  2652. #endif
  2653. #else
  2654. #undef SERVO_DELAY
  2655. #undef DEACTIVATE_SERVOS_AFTER_MOVE
  2656. #undef EDITABLE_SERVO_ANGLES
  2657. #undef SERVO_DETACH_GCODE
  2658. #endif
  2659. // Sensors
  2660. #if PIN_EXISTS(FILWIDTH)
  2661. #define HAS_FILAMENT_WIDTH_SENSOR 1
  2662. #endif
  2663. // User Interface
  2664. #if ENABLED(FREEZE_FEATURE) && !PIN_EXISTS(FREEZE) && PIN_EXISTS(KILL)
  2665. #define FREEZE_PIN KILL_PIN
  2666. #elif PIN_EXISTS(KILL) && TERN1(FREEZE_FEATURE, KILL_PIN != FREEZE_PIN)
  2667. #define HAS_KILL 1
  2668. #endif
  2669. #if PIN_EXISTS(HOME)
  2670. #define HAS_HOME 1
  2671. #endif
  2672. #if PIN_EXISTS(SUICIDE)
  2673. #define HAS_SUICIDE 1
  2674. #endif
  2675. #if PIN_EXISTS(PHOTOGRAPH)
  2676. #define HAS_PHOTOGRAPH 1
  2677. #endif
  2678. // Digital control
  2679. #if PIN_EXISTS(STEPPER_RESET)
  2680. #define HAS_STEPPER_RESET 1
  2681. #endif
  2682. #if PIN_EXISTS(DIGIPOTSS)
  2683. #define HAS_MOTOR_CURRENT_SPI 1
  2684. #endif
  2685. #if ANY_PIN(MOTOR_CURRENT_PWM_E, MOTOR_CURRENT_PWM_E0, MOTOR_CURRENT_PWM_E1)
  2686. #define HAS_MOTOR_CURRENT_PWM_E 1
  2687. #endif
  2688. #if HAS_MOTOR_CURRENT_PWM_E || ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_Z, MOTOR_CURRENT_PWM_I, MOTOR_CURRENT_PWM_J, MOTOR_CURRENT_PWM_K, MOTOR_CURRENT_PWM_U, MOTOR_CURRENT_PWM_V, MOTOR_CURRENT_PWM_W)
  2689. #define HAS_MOTOR_CURRENT_PWM 1
  2690. #endif
  2691. #if ANY(HAS_Z_MS_PINS, HAS_Z2_MS_PINS, HAS_Z3_MS_PINS, HAS_Z4_MS_PINS)
  2692. #define HAS_SOME_Z_MS_PINS 1
  2693. #endif
  2694. #if ANY(HAS_E0_MS_PINS, HAS_E1_MS_PINS, HAS_E2_MS_PINS, HAS_E3_MS_PINS, HAS_E4_MS_PINS, HAS_E5_MS_PINS, HAS_E6_MS_PINS, HAS_E7_MS_PINS)
  2695. #define HAS_SOME_E_MS_PINS 1
  2696. #endif
  2697. #if ANY(HAS_X_MS_PINS, HAS_X2_MS_PINS, HAS_Y_MS_PINS, HAS_Y2_MS_PINS, HAS_SOME_Z_MS_PINS, HAS_I_MS_PINS, HAS_J_MS_PINS, HAS_K_MS_PINS, HAS_U_MS_PINS, HAS_V_MS_PINS, HAS_W_MS_PINS, HAS_SOME_E_MS_PINS)
  2698. #define HAS_MICROSTEPS 1
  2699. #endif
  2700. /**
  2701. * Helper Macros for heaters and extruder fan
  2702. */
  2703. #define WRITE_HEATER_0P(v) WRITE(HEATER_0_PIN, (v) ^ ENABLED(HEATER_0_INVERTING))
  2704. #if ANY(HAS_MULTI_HOTEND, HEATERS_PARALLEL)
  2705. #define WRITE_HEATER_1(v) WRITE(HEATER_1_PIN, (v) ^ ENABLED(HEATER_1_INVERTING))
  2706. #if HOTENDS > 2
  2707. #define WRITE_HEATER_2(v) WRITE(HEATER_2_PIN, (v) ^ ENABLED(HEATER_2_INVERTING))
  2708. #if HOTENDS > 3
  2709. #define WRITE_HEATER_3(v) WRITE(HEATER_3_PIN, (v) ^ ENABLED(HEATER_3_INVERTING))
  2710. #if HOTENDS > 4
  2711. #define WRITE_HEATER_4(v) WRITE(HEATER_4_PIN, (v) ^ ENABLED(HEATER_4_INVERTING))
  2712. #if HOTENDS > 5
  2713. #define WRITE_HEATER_5(v) WRITE(HEATER_5_PIN, (v) ^ ENABLED(HEATER_5_INVERTING))
  2714. #if HOTENDS > 6
  2715. #define WRITE_HEATER_6(v) WRITE(HEATER_6_PIN, (v) ^ ENABLED(HEATER_6_INVERTING))
  2716. #if HOTENDS > 7
  2717. #define WRITE_HEATER_7(v) WRITE(HEATER_7_PIN, (v) ^ ENABLED(HEATER_7_INVERTING))
  2718. #endif // HOTENDS > 7
  2719. #endif // HOTENDS > 6
  2720. #endif // HOTENDS > 5
  2721. #endif // HOTENDS > 4
  2722. #endif // HOTENDS > 3
  2723. #endif // HOTENDS > 2
  2724. #endif // HAS_MULTI_HOTEND || HEATERS_PARALLEL
  2725. #if ENABLED(HEATERS_PARALLEL)
  2726. #define WRITE_HEATER_0(v) { WRITE_HEATER_0P(v); WRITE_HEATER_1(v); }
  2727. #else
  2728. #define WRITE_HEATER_0(v) WRITE_HEATER_0P(v)
  2729. #endif
  2730. /**
  2731. * Heated bed requires settings
  2732. */
  2733. #if HAS_HEATED_BED
  2734. #ifndef MIN_BED_POWER
  2735. #define MIN_BED_POWER 0
  2736. #endif
  2737. #ifndef MAX_BED_POWER
  2738. #define MAX_BED_POWER 255
  2739. #endif
  2740. #define WRITE_HEATER_BED(v) WRITE(HEATER_BED_PIN, (v) ^ ENABLED(HEATER_BED_INVERTING))
  2741. #endif
  2742. /**
  2743. * Heated chamber requires settings
  2744. */
  2745. #if HAS_HEATED_CHAMBER
  2746. #ifndef MIN_CHAMBER_POWER
  2747. #define MIN_CHAMBER_POWER 0
  2748. #endif
  2749. #ifndef MAX_CHAMBER_POWER
  2750. #define MAX_CHAMBER_POWER 255
  2751. #endif
  2752. #define WRITE_HEATER_CHAMBER(v) WRITE(HEATER_CHAMBER_PIN, (v) ^ ENABLED(HEATER_CHAMBER_INVERTING))
  2753. #endif
  2754. /**
  2755. * Laser Cooling requires settings
  2756. */
  2757. #if HAS_COOLER
  2758. #ifndef MAX_COOLER_POWER
  2759. #define MAX_COOLER_POWER 255
  2760. #endif
  2761. #define WRITE_HEATER_COOLER(v) WRITE(COOLER_PIN, (v) ^ ENABLED(COOLER_INVERTING))
  2762. #endif
  2763. #if HAS_HOTEND || HAS_HEATED_BED || HAS_HEATED_CHAMBER || HAS_COOLER
  2764. #define HAS_TEMPERATURE 1
  2765. #endif
  2766. #if HAS_TEMPERATURE && ANY(HAS_MARLINUI_MENU, HAS_DWIN_E3V2, HAS_DGUS_LCD_CLASSIC)
  2767. #ifdef PREHEAT_10_LABEL
  2768. #define PREHEAT_COUNT 10
  2769. #elif defined(PREHEAT_9_LABEL)
  2770. #define PREHEAT_COUNT 9
  2771. #elif defined(PREHEAT_8_LABEL)
  2772. #define PREHEAT_COUNT 8
  2773. #elif defined(PREHEAT_7_LABEL)
  2774. #define PREHEAT_COUNT 7
  2775. #elif defined(PREHEAT_6_LABEL)
  2776. #define PREHEAT_COUNT 6
  2777. #elif defined(PREHEAT_5_LABEL)
  2778. #define PREHEAT_COUNT 5
  2779. #elif defined(PREHEAT_4_LABEL)
  2780. #define PREHEAT_COUNT 4
  2781. #elif defined(PREHEAT_3_LABEL)
  2782. #define PREHEAT_COUNT 3
  2783. #elif defined(PREHEAT_2_LABEL)
  2784. #define PREHEAT_COUNT 2
  2785. #elif defined(PREHEAT_1_LABEL)
  2786. #define PREHEAT_COUNT 1
  2787. #endif
  2788. #if PREHEAT_COUNT && ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN)
  2789. #define HAS_PREHEAT 1
  2790. #endif
  2791. #endif
  2792. #if !HAS_PREHEAT
  2793. #undef PREHEAT_SHORTCUT_MENU_ITEM
  2794. #undef DGUS_PREHEAT_UI
  2795. #endif
  2796. /**
  2797. * MIN/MAX case light PWM scaling
  2798. */
  2799. #if ENABLED(CASE_LIGHT_ENABLE)
  2800. #ifndef CASE_LIGHT_MAX_PWM
  2801. #define CASE_LIGHT_MAX_PWM 255
  2802. #elif !WITHIN(CASE_LIGHT_MAX_PWM, 1, 255)
  2803. #error "CASE_LIGHT_MAX_PWM must be a value from 1 to 255."
  2804. #endif
  2805. #endif
  2806. /**
  2807. * Bed Probe dependencies
  2808. */
  2809. #if ANY(MESH_BED_LEVELING, HAS_BED_PROBE)
  2810. #ifndef PROBE_OFFSET_ZMIN
  2811. #define PROBE_OFFSET_ZMIN -20
  2812. #endif
  2813. #ifndef PROBE_OFFSET_ZMAX
  2814. #define PROBE_OFFSET_ZMAX 20
  2815. #endif
  2816. #endif
  2817. #if HAS_BED_PROBE
  2818. #ifndef PROBE_OFFSET_XMIN
  2819. #define PROBE_OFFSET_XMIN -(X_BED_SIZE)
  2820. #endif
  2821. #ifndef PROBE_OFFSET_XMAX
  2822. #define PROBE_OFFSET_XMAX X_BED_SIZE
  2823. #endif
  2824. #ifndef PROBE_OFFSET_YMIN
  2825. #define PROBE_OFFSET_YMIN -(Y_BED_SIZE)
  2826. #endif
  2827. #ifndef PROBE_OFFSET_YMAX
  2828. #define PROBE_OFFSET_YMAX Y_BED_SIZE
  2829. #endif
  2830. #if ALL(ENDSTOPPULLUPS, USE_Z_MIN_PROBE)
  2831. #define ENDSTOPPULLUP_ZMIN_PROBE
  2832. #endif
  2833. #ifndef XY_PROBE_FEEDRATE
  2834. #define XY_PROBE_FEEDRATE ((homing_feedrate_mm_m.x + homing_feedrate_mm_m.y) / 2)
  2835. #endif
  2836. #ifndef NOZZLE_TO_PROBE_OFFSET
  2837. #define NOZZLE_TO_PROBE_OFFSET { 0, 0, 0 }
  2838. #endif
  2839. #endif
  2840. /**
  2841. * XYZ Bed Skew Correction
  2842. */
  2843. #if ENABLED(SKEW_CORRECTION)
  2844. #define SKEW_FACTOR_MIN -1
  2845. #define SKEW_FACTOR_MAX 1
  2846. #define _GET_SIDE(a,b,c) (SQRT(2*sq(a)+2*sq(b)-4*sq(c))*0.5)
  2847. #define _SKEW_SIDE(a,b,c) tan(M_PI*0.5-acos((sq(a)-sq(b)-sq(c))/(2*c*b)))
  2848. #define _SKEW_FACTOR(a,b,c) _SKEW_SIDE(float(a),_GET_SIDE(float(a),float(b),float(c)),float(c))
  2849. #ifndef XY_SKEW_FACTOR
  2850. #if defined(XY_DIAG_AC) && defined(XY_DIAG_BD) && defined(XY_SIDE_AD)
  2851. #define XY_SKEW_FACTOR _SKEW_FACTOR(XY_DIAG_AC, XY_DIAG_BD, XY_SIDE_AD)
  2852. #else
  2853. #define XY_SKEW_FACTOR 0.0
  2854. #endif
  2855. #endif
  2856. #ifndef XZ_SKEW_FACTOR
  2857. #if defined(XY_SIDE_AD) && !defined(XZ_SIDE_AD)
  2858. #define XZ_SIDE_AD XY_SIDE_AD
  2859. #endif
  2860. #if defined(XZ_DIAG_AC) && defined(XZ_DIAG_BD) && defined(XZ_SIDE_AD)
  2861. #define XZ_SKEW_FACTOR _SKEW_FACTOR(XZ_DIAG_AC, XZ_DIAG_BD, XZ_SIDE_AD)
  2862. #else
  2863. #define XZ_SKEW_FACTOR 0.0
  2864. #endif
  2865. #endif
  2866. #ifndef YZ_SKEW_FACTOR
  2867. #if defined(YZ_DIAG_AC) && defined(YZ_DIAG_BD) && defined(YZ_SIDE_AD)
  2868. #define YZ_SKEW_FACTOR _SKEW_FACTOR(YZ_DIAG_AC, YZ_DIAG_BD, YZ_SIDE_AD)
  2869. #else
  2870. #define YZ_SKEW_FACTOR 0.0
  2871. #endif
  2872. #endif
  2873. #endif // SKEW_CORRECTION
  2874. /**
  2875. * Heater, Fan, and Probe interactions
  2876. */
  2877. #if !HAS_FAN
  2878. #undef ADAPTIVE_FAN_SLOWING
  2879. #undef TEMP_TUNING_MAINTAIN_FAN
  2880. #endif
  2881. #if !ALL(HAS_BED_PROBE, HAS_FAN)
  2882. #undef PROBING_FANS_OFF
  2883. #endif
  2884. #if !ALL(HAS_BED_PROBE, HAS_EXTRUDERS)
  2885. #undef PROBING_ESTEPPERS_OFF
  2886. #elif ENABLED(PROBING_STEPPERS_OFF)
  2887. // PROBING_STEPPERS_OFF implies PROBING_ESTEPPERS_OFF, make sure it is defined
  2888. #define PROBING_ESTEPPERS_OFF
  2889. #endif
  2890. #if ANY(ADVANCED_PAUSE_FEATURE, PROBING_HEATERS_OFF)
  2891. #define HEATER_IDLE_HANDLER 1
  2892. #endif
  2893. #if HAS_BED_PROBE && (ANY(PROBING_HEATERS_OFF, PROBING_STEPPERS_OFF, PROBING_ESTEPPERS_OFF, PROBING_FANS_OFF) || DELAY_BEFORE_PROBING > 0)
  2894. #define HAS_QUIET_PROBING 1
  2895. #endif
  2896. /**
  2897. * Advanced Pause - Filament Change
  2898. */
  2899. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  2900. #if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_CREALITY_LCD_JYERSUI) || ALL(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT)
  2901. #define M600_PURGE_MORE_RESUMABLE 1 // UI provides some way to Purge More / Resume
  2902. #endif
  2903. #ifndef FILAMENT_CHANGE_SLOW_LOAD_LENGTH
  2904. #define FILAMENT_CHANGE_SLOW_LOAD_LENGTH 0
  2905. #endif
  2906. #endif
  2907. #if HAS_MULTI_EXTRUDER && !defined(TOOLCHANGE_FS_EXTRA_PRIME)
  2908. #define TOOLCHANGE_FS_EXTRA_PRIME 0
  2909. #endif
  2910. /**
  2911. * Only constrain Z on DELTA / SCARA machines
  2912. */
  2913. #if ENABLED(POLAR)
  2914. #undef MIN_SOFTWARE_ENDSTOP_Y
  2915. #undef MAX_SOFTWARE_ENDSTOP_Y
  2916. #elif IS_KINEMATIC
  2917. #undef MIN_SOFTWARE_ENDSTOP_X
  2918. #undef MIN_SOFTWARE_ENDSTOP_Y
  2919. #undef MAX_SOFTWARE_ENDSTOP_X
  2920. #undef MAX_SOFTWARE_ENDSTOP_Y
  2921. #endif
  2922. /**
  2923. * Bed Probing bounds
  2924. */
  2925. #if IS_KINEMATIC
  2926. #undef PROBING_MARGIN_LEFT
  2927. #undef PROBING_MARGIN_RIGHT
  2928. #undef PROBING_MARGIN_FRONT
  2929. #undef PROBING_MARGIN_BACK
  2930. #elif PROBING_MARGIN
  2931. #ifndef PROBING_MARGIN_LEFT
  2932. #define PROBING_MARGIN_LEFT PROBING_MARGIN
  2933. #endif
  2934. #ifndef PROBING_MARGIN_RIGHT
  2935. #define PROBING_MARGIN_RIGHT PROBING_MARGIN
  2936. #endif
  2937. #ifndef PROBING_MARGIN_FRONT
  2938. #define PROBING_MARGIN_FRONT PROBING_MARGIN
  2939. #endif
  2940. #ifndef PROBING_MARGIN_BACK
  2941. #define PROBING_MARGIN_BACK PROBING_MARGIN
  2942. #endif
  2943. #endif
  2944. #ifndef PROBING_MARGIN_LEFT
  2945. #define PROBING_MARGIN_LEFT 0
  2946. #endif
  2947. #ifndef PROBING_MARGIN_RIGHT
  2948. #define PROBING_MARGIN_RIGHT 0
  2949. #endif
  2950. #ifndef PROBING_MARGIN_FRONT
  2951. #define PROBING_MARGIN_FRONT 0
  2952. #endif
  2953. #ifndef PROBING_MARGIN_BACK
  2954. #define PROBING_MARGIN_BACK 0
  2955. #endif
  2956. #if ENABLED(DELTA)
  2957. /**
  2958. * Delta radius/rod trimmers/angle trimmers
  2959. */
  2960. #ifndef DELTA_ENDSTOP_ADJ
  2961. #define DELTA_ENDSTOP_ADJ { 0, 0, 0 }
  2962. #endif
  2963. #ifndef DELTA_TOWER_ANGLE_TRIM
  2964. #define DELTA_TOWER_ANGLE_TRIM { 0, 0, 0 }
  2965. #endif
  2966. #ifndef DELTA_RADIUS_TRIM_TOWER
  2967. #define DELTA_RADIUS_TRIM_TOWER { 0, 0, 0 }
  2968. #endif
  2969. #ifndef DELTA_DIAGONAL_ROD_TRIM_TOWER
  2970. #define DELTA_DIAGONAL_ROD_TRIM_TOWER { 0, 0, 0 }
  2971. #endif
  2972. #endif
  2973. #ifndef DEFAULT_LEVELING_FADE_HEIGHT
  2974. #define DEFAULT_LEVELING_FADE_HEIGHT 0.0
  2975. #endif
  2976. #if ENABLED(SEGMENT_LEVELED_MOVES) && !defined(LEVELED_SEGMENT_LENGTH)
  2977. #define LEVELED_SEGMENT_LENGTH 5
  2978. #endif
  2979. /**
  2980. * Default mesh area is an area with an inset margin on the print area.
  2981. */
  2982. #if ANY(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL)
  2983. #if IS_KINEMATIC
  2984. // Probing points may be verified at compile time within the radius
  2985. // using static_assert(HYPOT2(X2-X1,Y2-Y1)<=sq(PRINTABLE_RADIUS),"bad probe point!")
  2986. // so that may be added to SanityCheck.h in the future.
  2987. #define _MESH_MIN_X (X_MIN_BED + (MESH_INSET))
  2988. #define _MESH_MIN_Y (Y_MIN_BED + (MESH_INSET))
  2989. #define _MESH_MAX_X (X_MAX_BED - (MESH_INSET))
  2990. #define _MESH_MAX_Y (Y_MAX_BED - (MESH_INSET))
  2991. #else
  2992. // Boundaries for Cartesian probing based on set limits
  2993. #define _MESH_MIN_X (_MAX(X_MIN_BED + (MESH_INSET), X_MIN_POS)) // UBL is careful not to probe off the bed. It doesn't
  2994. #define _MESH_MIN_Y (_MAX(Y_MIN_BED + (MESH_INSET), Y_MIN_POS)) // need NOZZLE_TO_PROBE_OFFSET in the mesh dimensions.
  2995. #define _MESH_MAX_X (_MIN(X_MAX_BED - (MESH_INSET), X_MAX_POS))
  2996. #define _MESH_MAX_Y (_MIN(Y_MAX_BED - (MESH_INSET), Y_MAX_POS))
  2997. #endif
  2998. // These may be overridden in Configuration.h if a smaller area is desired
  2999. #ifndef MESH_MIN_X
  3000. #define MESH_MIN_X _MESH_MIN_X
  3001. #endif
  3002. #ifndef MESH_MIN_Y
  3003. #define MESH_MIN_Y _MESH_MIN_Y
  3004. #endif
  3005. #ifndef MESH_MAX_X
  3006. #define MESH_MAX_X _MESH_MAX_X
  3007. #endif
  3008. #ifndef MESH_MAX_Y
  3009. #define MESH_MAX_Y _MESH_MAX_Y
  3010. #endif
  3011. #else
  3012. #undef MESH_MIN_X
  3013. #undef MESH_MIN_Y
  3014. #undef MESH_MAX_X
  3015. #undef MESH_MAX_Y
  3016. #endif
  3017. #if NEEDS_THREE_PROBE_POINTS && defined(PROBE_PT_1)
  3018. #define HAS_FIXED_3POINT 1 // Points are defined for ABL/UBL. Else calculated in probe.get_three_points.
  3019. #endif
  3020. /**
  3021. * Buzzer/Speaker
  3022. */
  3023. #if PIN_EXISTS(BEEPER)
  3024. #define HAS_BEEPER 1
  3025. #endif
  3026. #if ANY(IS_TFTGLCD_PANEL, PCA9632_BUZZER, LCD_USE_I2C_BUZZER)
  3027. #define USE_MARLINUI_BUZZER 1
  3028. #endif
  3029. #if ANY(HAS_BEEPER, USE_MARLINUI_BUZZER)
  3030. #define HAS_SOUND 1
  3031. #endif
  3032. #if ENABLED(LCD_USE_I2C_BUZZER)
  3033. #ifndef LCD_FEEDBACK_FREQUENCY_HZ
  3034. #define LCD_FEEDBACK_FREQUENCY_HZ 1000
  3035. #endif
  3036. #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
  3037. #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100
  3038. #endif
  3039. #elif HAS_SOUND
  3040. #ifndef LCD_FEEDBACK_FREQUENCY_HZ
  3041. #define LCD_FEEDBACK_FREQUENCY_HZ 5000
  3042. #endif
  3043. #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
  3044. #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2
  3045. #endif
  3046. #endif
  3047. #if HAS_SOUND
  3048. #if LCD_FEEDBACK_FREQUENCY_DURATION_MS && LCD_FEEDBACK_FREQUENCY_HZ
  3049. #define HAS_CHIRP 1
  3050. #endif
  3051. #else
  3052. #undef SOUND_MENU_ITEM // No buzzer menu item without a buzzer
  3053. #undef SOUND_ON_DEFAULT
  3054. #endif
  3055. /**
  3056. * Z_CLEARANCE_FOR_HOMING / Z_CLEARANCE_BETWEEN_PROBES
  3057. */
  3058. #ifndef Z_CLEARANCE_FOR_HOMING
  3059. #ifdef Z_CLEARANCE_BETWEEN_PROBES
  3060. #define Z_CLEARANCE_FOR_HOMING Z_CLEARANCE_BETWEEN_PROBES
  3061. #else
  3062. #define Z_CLEARANCE_FOR_HOMING 0
  3063. #endif
  3064. #endif
  3065. #ifndef Z_CLEARANCE_BETWEEN_PROBES
  3066. #define Z_CLEARANCE_BETWEEN_PROBES Z_CLEARANCE_FOR_HOMING
  3067. #endif
  3068. #if PROBE_SELECTED
  3069. #if Z_CLEARANCE_BETWEEN_PROBES > Z_CLEARANCE_FOR_HOMING
  3070. #define Z_CLEARANCE_BETWEEN_MANUAL_PROBES Z_CLEARANCE_BETWEEN_PROBES
  3071. #else
  3072. #define Z_CLEARANCE_BETWEEN_MANUAL_PROBES Z_CLEARANCE_FOR_HOMING
  3073. #endif
  3074. #ifndef Z_CLEARANCE_MULTI_PROBE
  3075. #define Z_CLEARANCE_MULTI_PROBE Z_CLEARANCE_BETWEEN_PROBES
  3076. #endif
  3077. #if ENABLED(BLTOUCH) && !defined(BLTOUCH_DELAY)
  3078. #define BLTOUCH_DELAY 500
  3079. #endif
  3080. #endif
  3081. // Define a starting height for measuring manual probe points
  3082. #ifndef MANUAL_PROBE_START_Z
  3083. #if ANY(MESH_BED_LEVELING, PROBE_MANUALLY)
  3084. // Leave MANUAL_PROBE_START_Z undefined so the prior Z height will be used.
  3085. // Note: If Z_CLEARANCE_BETWEEN_MANUAL_PROBES is 0 there will be no raise between points
  3086. #elif ENABLED(AUTO_BED_LEVELING_UBL) && defined(Z_CLEARANCE_BETWEEN_PROBES)
  3087. #define MANUAL_PROBE_START_Z Z_CLEARANCE_BETWEEN_PROBES
  3088. #endif
  3089. #endif
  3090. #ifndef __SAM3X8E__ //todo: hal: broken hal encapsulation
  3091. #undef UI_VOLTAGE_LEVEL
  3092. #undef RADDS_DISPLAY
  3093. #undef MOTOR_CURRENT
  3094. #endif
  3095. // G92 shifts the workspace
  3096. #if DISABLED(NO_WORKSPACE_OFFSETS)
  3097. #define HAS_WORKSPACE_OFFSET 1
  3098. #endif
  3099. #if DISABLED(NO_HOME_OFFSETS)
  3100. #if IS_CARTESIAN
  3101. #define HAS_HOME_OFFSET 1 // M206 affects the Native Machine Space on G28
  3102. #elif IS_SCARA
  3103. #define HAS_SCARA_OFFSET 1 // The SCARA home offset applies only on G28
  3104. #endif
  3105. #endif
  3106. #if ANY(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE)
  3107. // LCD timeout to status screen default is 15s
  3108. #ifndef LCD_TIMEOUT_TO_STATUS
  3109. #define LCD_TIMEOUT_TO_STATUS 15000
  3110. #endif
  3111. #if LCD_TIMEOUT_TO_STATUS
  3112. #define HAS_SCREEN_TIMEOUT 1
  3113. #endif
  3114. #endif
  3115. // Add commands that need sub-codes to this list
  3116. #if ANY(G38_PROBE_TARGET, CNC_COORDINATE_SYSTEMS, POWER_LOSS_RECOVERY, HAS_ROTATIONAL_AXES)
  3117. #define USE_GCODE_SUBCODES 1
  3118. #endif
  3119. // Parking Extruder
  3120. #if ENABLED(PARKING_EXTRUDER)
  3121. #ifndef PARKING_EXTRUDER_GRAB_DISTANCE
  3122. #define PARKING_EXTRUDER_GRAB_DISTANCE 0
  3123. #endif
  3124. #ifndef PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE
  3125. #define PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE HIGH
  3126. #endif
  3127. #endif
  3128. // Touch Calibration
  3129. #if ANY(HAS_SPI_TFT, HAS_FSMC_TFT, HAS_LTDC_TFT)
  3130. #ifndef TOUCH_CALIBRATION_X
  3131. #define TOUCH_CALIBRATION_X 0
  3132. #endif
  3133. #ifndef TOUCH_CALIBRATION_Y
  3134. #define TOUCH_CALIBRATION_Y 0
  3135. #endif
  3136. #ifndef TOUCH_OFFSET_X
  3137. #define TOUCH_OFFSET_X 0
  3138. #endif
  3139. #ifndef TOUCH_OFFSET_Y
  3140. #define TOUCH_OFFSET_Y 0
  3141. #endif
  3142. #ifndef TOUCH_ORIENTATION
  3143. #define TOUCH_ORIENTATION TOUCH_LANDSCAPE
  3144. #endif
  3145. #endif
  3146. // Number of VFAT entries used. Each entry has 13 UTF-16 characters
  3147. #if ANY(SCROLL_LONG_FILENAMES, HAS_DWIN_E3V2, TFT_COLOR_UI)
  3148. #define VFAT_ENTRIES_LIMIT 5
  3149. #else
  3150. #define VFAT_ENTRIES_LIMIT 2
  3151. #endif
  3152. #define MAX_VFAT_ENTRIES 20 // by VFAT specs to fit LFN of length 255
  3153. // Nozzle park for Delta
  3154. #if ALL(NOZZLE_PARK_FEATURE, DELTA)
  3155. #undef NOZZLE_PARK_Z_FEEDRATE
  3156. #define NOZZLE_PARK_Z_FEEDRATE NOZZLE_PARK_XY_FEEDRATE
  3157. #endif
  3158. // Force SDCARD_SORT_ALPHA to be enabled for Graphical LCD on LPC1768
  3159. // on boards where SD card and LCD display share the same SPI bus
  3160. // because of a bug in the shared SPI implementation. (See #8122)
  3161. #if defined(TARGET_LPC1768) && IS_RRD_FG_SC && (SD_SCK_PIN == LCD_PINS_D4)
  3162. #define SDCARD_SORT_ALPHA // Keep one directory level in RAM. Changing directory levels
  3163. // may still glitch the screen, but LCD updates clean it up.
  3164. #if SDSORT_LIMIT > 64 || !SDSORT_USES_RAM || SDSORT_USES_STACK || !SDSORT_CACHE_NAMES
  3165. #undef SDSORT_LIMIT
  3166. #undef SDSORT_USES_RAM
  3167. #undef SDSORT_USES_STACK
  3168. #undef SDSORT_CACHE_NAMES
  3169. #define SDSORT_LIMIT 64
  3170. #define SDSORT_USES_RAM true
  3171. #define SDSORT_USES_STACK false
  3172. #define SDSORT_CACHE_NAMES true
  3173. #define SDSORT_CACHE_LPC1768_WARNING 1
  3174. #endif
  3175. #ifndef SDSORT_FOLDERS
  3176. #define SDSORT_FOLDERS -1
  3177. #endif
  3178. #ifndef SDSORT_GCODE
  3179. #define SDSORT_GCODE false
  3180. #endif
  3181. #ifndef SDSORT_DYNAMIC_RAM
  3182. #define SDSORT_DYNAMIC_RAM false
  3183. #endif
  3184. #ifndef SDSORT_CACHE_VFATS
  3185. #define SDSORT_CACHE_VFATS 2
  3186. #endif
  3187. #endif
  3188. // Fallback SPI Speed for SD
  3189. #if HAS_MEDIA && !defined(SD_SPI_SPEED)
  3190. #define SD_SPI_SPEED SPI_FULL_SPEED
  3191. #endif
  3192. #if HAS_WIRED_LCD
  3193. // Get LCD character width/height, which may be overridden by pins, configs, etc.
  3194. #ifndef LCD_WIDTH
  3195. #if HAS_MARLINUI_U8GLIB
  3196. #define LCD_WIDTH 21
  3197. #elif IS_DWIN_MARLINUI
  3198. // Defined by header
  3199. #else
  3200. #define LCD_WIDTH TERN(IS_ULTIPANEL, 20, 16)
  3201. #endif
  3202. #endif
  3203. #ifndef LCD_HEIGHT
  3204. #if HAS_MARLINUI_U8GLIB
  3205. #define LCD_HEIGHT 5
  3206. #elif IS_DWIN_MARLINUI
  3207. // Defined by header
  3208. #else
  3209. #define LCD_HEIGHT TERN(IS_ULTIPANEL, 4, 2)
  3210. #endif
  3211. #endif
  3212. // Prepare the LCD to show the bootscreen early in setup
  3213. #if ENABLED(SHOW_BOOTSCREEN) && ANY(HAS_LCD_CONTRAST, HAS_LCD_BRIGHTNESS)
  3214. #define HAS_EARLY_LCD_SETTINGS 1
  3215. #endif
  3216. #endif
  3217. #if BUTTONS_EXIST(EN1, EN2, ENC)
  3218. #define HAS_ROTARY_ENCODER 1
  3219. #endif
  3220. #if PIN_EXISTS(SAFE_POWER) && DISABLED(DISABLE_DRIVER_SAFE_POWER_PROTECT)
  3221. #define HAS_DRIVER_SAFE_POWER_PROTECT 1
  3222. #endif
  3223. #if ANY(ENDSTOPPULLDOWNS, ENDSTOPPULLDOWN_ZMIN_PROBE, \
  3224. ENDSTOPPULLDOWN_XMIN, ENDSTOPPULLDOWN_YMIN, ENDSTOPPULLDOWN_ZMIN, \
  3225. ENDSTOPPULLDOWN_IMIN, ENDSTOPPULLDOWN_JMIN, ENDSTOPPULLDOWN_KMIN, \
  3226. ENDSTOPPULLDOWN_XMAX, ENDSTOPPULLDOWN_YMAX, ENDSTOPPULLDOWN_ZMAX, \
  3227. ENDSTOPPULLDOWN_IMAX, ENDSTOPPULLDOWN_JMAX, ENDSTOPPULLDOWN_KMAX, \
  3228. POWER_LOSS_PULLDOWN, CALIBRATION_PIN_PULLDOWN, FIL_RUNOUT_PULLDOWN, \
  3229. FIL_RUNOUT1_PULLDOWN, FIL_RUNOUT2_PULLDOWN, FIL_RUNOUT3_PULLDOWN, FIL_RUNOUT4_PULLDOWN, \
  3230. FIL_RUNOUT5_PULLDOWN, FIL_RUNOUT6_PULLDOWN, FIL_RUNOUT7_PULLDOWN, FIL_RUNOUT8_PULLDOWN)
  3231. #define USING_PULLDOWNS 1
  3232. #endif
  3233. // Machine UUID can come from STM32 CPU Serial Number
  3234. #ifdef MACHINE_UUID
  3235. #undef HAS_STM32_UID
  3236. #elif !HAS_STM32_UID && defined(DEFAULT_MACHINE_UUID)
  3237. #define MACHINE_UUID DEFAULT_MACHINE_UUID
  3238. #endif
  3239. // Flag whether hex_print.cpp is needed
  3240. #if ANY(AUTO_BED_LEVELING_UBL, M100_FREE_MEMORY_WATCHER, DEBUG_GCODE_PARSER, TMC_DEBUG, MARLIN_DEV_MODE, DEBUG_CARDREADER, M20_TIMESTAMP_SUPPORT, HAS_STM32_UID)
  3241. #define NEED_HEX_PRINT 1
  3242. #endif