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

Conditionals_post.h 106KB

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