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.

configuration_store.cpp 100KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * configuration_store.cpp
  24. *
  25. * Settings and EEPROM storage
  26. *
  27. * IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
  28. * in the functions below, also increment the version number. This makes sure that
  29. * the default values are used whenever there is a change to the data, to prevent
  30. * wrong data being written to the variables.
  31. *
  32. * ALSO: Variables in the Store and Retrieve sections must be in the same order.
  33. * If a feature is disabled, some data must still be written that, when read,
  34. * either sets a Sane Default, or results in No Change to the existing value.
  35. *
  36. */
  37. // Change EEPROM version if the structure changes
  38. #define EEPROM_VERSION "V74"
  39. #define EEPROM_OFFSET 100
  40. // Check the integrity of data offsets.
  41. // Can be disabled for production build.
  42. //#define DEBUG_EEPROM_READWRITE
  43. #include "configuration_store.h"
  44. #include "endstops.h"
  45. #include "planner.h"
  46. #include "stepper.h"
  47. #include "temperature.h"
  48. #include "../lcd/ultralcd.h"
  49. #include "../core/language.h"
  50. #include "../libs/vector_3.h" // for matrix_3x3
  51. #include "../gcode/gcode.h"
  52. #include "../MarlinCore.h"
  53. #if EITHER(EEPROM_SETTINGS, SD_FIRMWARE_UPDATE)
  54. #include "../HAL/shared/persistent_store_api.h"
  55. #endif
  56. #include "probe.h"
  57. #if HAS_LEVELING
  58. #include "../feature/bedlevel/bedlevel.h"
  59. #endif
  60. #if ENABLED(EXTENSIBLE_UI)
  61. #include "../lcd/extensible_ui/ui_api.h"
  62. #endif
  63. #if HAS_SERVOS
  64. #include "servo.h"
  65. #endif
  66. #if HAS_SERVOS && HAS_SERVO_ANGLES
  67. #define EEPROM_NUM_SERVOS NUM_SERVOS
  68. #else
  69. #define EEPROM_NUM_SERVOS NUM_SERVO_PLUGS
  70. #endif
  71. #include "../feature/fwretract.h"
  72. #if ENABLED(POWER_LOSS_RECOVERY)
  73. #include "../feature/power_loss_recovery.h"
  74. #endif
  75. #include "../feature/pause.h"
  76. #if ENABLED(BACKLASH_COMPENSATION)
  77. #include "../feature/backlash.h"
  78. #endif
  79. #if HAS_FILAMENT_SENSOR
  80. #include "../feature/runout.h"
  81. #endif
  82. #if ENABLED(EXTRA_LIN_ADVANCE_K)
  83. extern float saved_extruder_advance_K[EXTRUDERS];
  84. #endif
  85. #if EXTRUDERS > 1
  86. #include "tool_change.h"
  87. void M217_report(const bool eeprom);
  88. #endif
  89. #if ENABLED(BLTOUCH)
  90. #include "../feature/bltouch.h"
  91. #endif
  92. #if HAS_TRINAMIC
  93. #include "stepper/indirection.h"
  94. #include "../feature/tmc_util.h"
  95. #endif
  96. #pragma pack(push, 1) // No padding between variables
  97. typedef struct { uint16_t X, Y, Z, X2, Y2, Z2, Z3, E0, E1, E2, E3, E4, E5; } tmc_stepper_current_t;
  98. typedef struct { uint32_t X, Y, Z, X2, Y2, Z2, Z3, E0, E1, E2, E3, E4, E5; } tmc_hybrid_threshold_t;
  99. typedef struct { int16_t X, Y, Z, X2; } tmc_sgt_t;
  100. typedef struct { bool X, Y, Z, X2, Y2, Z2, Z3, E0, E1, E2, E3, E4, E5; } tmc_stealth_enabled_t;
  101. // Limit an index to an array size
  102. #define ALIM(I,ARR) _MIN(I, COUNT(ARR) - 1)
  103. // Defaults for reset / fill in on load
  104. static const uint32_t _DMA[] PROGMEM = DEFAULT_MAX_ACCELERATION;
  105. static const float _DASU[] PROGMEM = DEFAULT_AXIS_STEPS_PER_UNIT;
  106. static const feedRate_t _DMF[] PROGMEM = DEFAULT_MAX_FEEDRATE;
  107. extern const char SP_X_STR[], SP_Y_STR[], SP_Z_STR[], SP_E_STR[];
  108. /**
  109. * Current EEPROM Layout
  110. *
  111. * Keep this data structure up to date so
  112. * EEPROM size is known at compile time!
  113. */
  114. typedef struct SettingsDataStruct {
  115. char version[4]; // Vnn\0
  116. uint16_t crc; // Data Checksum
  117. //
  118. // DISTINCT_E_FACTORS
  119. //
  120. uint8_t esteppers; // XYZE_N - XYZ
  121. planner_settings_t planner_settings;
  122. xyze_float_t planner_max_jerk; // M205 XYZE planner.max_jerk
  123. float planner_junction_deviation_mm; // M205 J planner.junction_deviation_mm
  124. xyz_pos_t home_offset; // M206 XYZ / M665 TPZ
  125. #if HAS_HOTEND_OFFSET
  126. xyz_pos_t hotend_offset[HOTENDS - 1]; // M218 XYZ
  127. #endif
  128. //
  129. // FILAMENT_RUNOUT_SENSOR
  130. //
  131. bool runout_sensor_enabled; // M412 S
  132. float runout_distance_mm; // M412 D
  133. //
  134. // ENABLE_LEVELING_FADE_HEIGHT
  135. //
  136. float planner_z_fade_height; // M420 Zn planner.z_fade_height
  137. //
  138. // MESH_BED_LEVELING
  139. //
  140. float mbl_z_offset; // mbl.z_offset
  141. uint8_t mesh_num_x, mesh_num_y; // GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y
  142. #if ENABLED(MESH_BED_LEVELING)
  143. float mbl_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; // mbl.z_values
  144. #else
  145. float mbl_z_values[3][3];
  146. #endif
  147. //
  148. // HAS_BED_PROBE
  149. //
  150. xyz_pos_t probe_offset;
  151. //
  152. // ABL_PLANAR
  153. //
  154. matrix_3x3 planner_bed_level_matrix; // planner.bed_level_matrix
  155. //
  156. // AUTO_BED_LEVELING_BILINEAR
  157. //
  158. uint8_t grid_max_x, grid_max_y; // GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y
  159. xy_pos_t bilinear_grid_spacing, bilinear_start; // G29 L F
  160. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  161. bed_mesh_t z_values; // G29
  162. #else
  163. float z_values[3][3];
  164. #endif
  165. //
  166. // AUTO_BED_LEVELING_UBL
  167. //
  168. bool planner_leveling_active; // M420 S planner.leveling_active
  169. int8_t ubl_storage_slot; // ubl.storage_slot
  170. //
  171. // SERVO_ANGLES
  172. //
  173. uint16_t servo_angles[EEPROM_NUM_SERVOS][2]; // M281 P L U
  174. //
  175. // BLTOUCH
  176. //
  177. bool bltouch_last_written_mode;
  178. //
  179. // DELTA / [XYZ]_DUAL_ENDSTOPS
  180. //
  181. #if ENABLED(DELTA)
  182. float delta_height; // M666 H
  183. abc_float_t delta_endstop_adj; // M666 XYZ
  184. float delta_radius, // M665 R
  185. delta_diagonal_rod, // M665 L
  186. delta_segments_per_second; // M665 S
  187. abc_float_t delta_tower_angle_trim; // M665 XYZ
  188. #elif EITHER(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
  189. float x2_endstop_adj, // M666 X
  190. y2_endstop_adj, // M666 Y
  191. z2_endstop_adj, // M666 Z (S2)
  192. z3_endstop_adj; // M666 Z (S3)
  193. #endif
  194. //
  195. // ULTIPANEL
  196. //
  197. int16_t ui_preheat_hotend_temp[2], // M145 S0 H
  198. ui_preheat_bed_temp[2]; // M145 S0 B
  199. uint8_t ui_preheat_fan_speed[2]; // M145 S0 F
  200. //
  201. // PIDTEMP
  202. //
  203. PIDCF_t hotendPID[HOTENDS]; // M301 En PIDCF / M303 En U
  204. int16_t lpq_len; // M301 L
  205. //
  206. // PIDTEMPBED
  207. //
  208. PID_t bedPID; // M304 PID / M303 E-1 U
  209. //
  210. // User-defined Thermistors
  211. //
  212. #if HAS_USER_THERMISTORS
  213. user_thermistor_t user_thermistor[USER_THERMISTORS]; // M305 P0 R4700 T100000 B3950
  214. #endif
  215. //
  216. // HAS_LCD_CONTRAST
  217. //
  218. int16_t lcd_contrast; // M250 C
  219. //
  220. // POWER_LOSS_RECOVERY
  221. //
  222. bool recovery_enabled; // M413 S
  223. //
  224. // FWRETRACT
  225. //
  226. fwretract_settings_t fwretract_settings; // M207 S F Z W, M208 S F W R
  227. bool autoretract_enabled; // M209 S
  228. //
  229. // !NO_VOLUMETRIC
  230. //
  231. bool parser_volumetric_enabled; // M200 D parser.volumetric_enabled
  232. float planner_filament_size[EXTRUDERS]; // M200 T D planner.filament_size[]
  233. //
  234. // HAS_TRINAMIC
  235. //
  236. tmc_stepper_current_t tmc_stepper_current; // M906 X Y Z X2 Y2 Z2 Z3 E0 E1 E2 E3 E4 E5
  237. tmc_hybrid_threshold_t tmc_hybrid_threshold; // M913 X Y Z X2 Y2 Z2 Z3 E0 E1 E2 E3 E4 E5
  238. tmc_sgt_t tmc_sgt; // M914 X Y Z X2
  239. tmc_stealth_enabled_t tmc_stealth_enabled; // M569 X Y Z X2 Y2 Z2 Z3 E0 E1 E2 E3 E4 E5
  240. //
  241. // LIN_ADVANCE
  242. //
  243. float planner_extruder_advance_K[EXTRUDERS]; // M900 K planner.extruder_advance_K
  244. //
  245. // HAS_MOTOR_CURRENT_PWM
  246. //
  247. uint32_t motor_current_setting[3]; // M907 X Z E
  248. //
  249. // CNC_COORDINATE_SYSTEMS
  250. //
  251. xyz_pos_t coordinate_system[MAX_COORDINATE_SYSTEMS]; // G54-G59.3
  252. //
  253. // SKEW_CORRECTION
  254. //
  255. skew_factor_t planner_skew_factor; // M852 I J K planner.skew_factor
  256. //
  257. // ADVANCED_PAUSE_FEATURE
  258. //
  259. #if EXTRUDERS
  260. fil_change_settings_t fc_settings[EXTRUDERS]; // M603 T U L
  261. #endif
  262. //
  263. // Tool-change settings
  264. //
  265. #if EXTRUDERS > 1
  266. toolchange_settings_t toolchange_settings; // M217 S P R
  267. #endif
  268. //
  269. // BACKLASH_COMPENSATION
  270. //
  271. xyz_float_t backlash_distance_mm; // M425 X Y Z
  272. uint8_t backlash_correction; // M425 F
  273. float backlash_smoothing_mm; // M425 S
  274. //
  275. // EXTENSIBLE_UI
  276. //
  277. #if ENABLED(EXTENSIBLE_UI)
  278. // This is a significant hardware change; don't reserve space when not present
  279. uint8_t extui_data[ExtUI::eeprom_data_size];
  280. #endif
  281. } SettingsData;
  282. //static_assert(sizeof(SettingsData) <= E2END + 1, "EEPROM too small to contain SettingsData!");
  283. MarlinSettings settings;
  284. uint16_t MarlinSettings::datasize() { return sizeof(SettingsData); }
  285. /**
  286. * Post-process after Retrieve or Reset
  287. */
  288. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  289. float new_z_fade_height;
  290. #endif
  291. void MarlinSettings::postprocess() {
  292. xyze_pos_t oldpos = current_position;
  293. // steps per s2 needs to be updated to agree with units per s2
  294. planner.reset_acceleration_rates();
  295. // Make sure delta kinematics are updated before refreshing the
  296. // planner position so the stepper counts will be set correctly.
  297. #if ENABLED(DELTA)
  298. recalc_delta_settings();
  299. #endif
  300. #if ENABLED(PIDTEMP)
  301. thermalManager.updatePID();
  302. #endif
  303. #if DISABLED(NO_VOLUMETRICS)
  304. planner.calculate_volumetric_multipliers();
  305. #elif EXTRUDERS
  306. for (uint8_t i = COUNT(planner.e_factor); i--;)
  307. planner.refresh_e_factor(i);
  308. #endif
  309. // Software endstops depend on home_offset
  310. LOOP_XYZ(i) {
  311. update_workspace_offset((AxisEnum)i);
  312. update_software_endstops((AxisEnum)i);
  313. }
  314. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  315. set_z_fade_height(new_z_fade_height, false); // false = no report
  316. #endif
  317. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  318. refresh_bed_level();
  319. #endif
  320. #if HAS_MOTOR_CURRENT_PWM
  321. stepper.refresh_motor_power();
  322. #endif
  323. #if ENABLED(FWRETRACT)
  324. fwretract.refresh_autoretract();
  325. #endif
  326. #if HAS_LINEAR_E_JERK
  327. planner.recalculate_max_e_jerk();
  328. #endif
  329. // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm
  330. // and init stepper.count[], planner.position[] with current_position
  331. planner.refresh_positioning();
  332. // Various factors can change the current position
  333. if (oldpos != current_position)
  334. report_current_position();
  335. }
  336. #if BOTH(PRINTCOUNTER, EEPROM_SETTINGS)
  337. #include "printcounter.h"
  338. static_assert(
  339. !WITHIN(STATS_EEPROM_ADDRESS, EEPROM_OFFSET, EEPROM_OFFSET + sizeof(SettingsData)) &&
  340. !WITHIN(STATS_EEPROM_ADDRESS + sizeof(printStatistics), EEPROM_OFFSET, EEPROM_OFFSET + sizeof(SettingsData)),
  341. "STATS_EEPROM_ADDRESS collides with EEPROM settings storage."
  342. );
  343. #endif
  344. #if ENABLED(SD_FIRMWARE_UPDATE)
  345. #if ENABLED(EEPROM_SETTINGS)
  346. static_assert(
  347. !WITHIN(SD_FIRMWARE_UPDATE_EEPROM_ADDR, EEPROM_OFFSET, EEPROM_OFFSET + sizeof(SettingsData)),
  348. "SD_FIRMWARE_UPDATE_EEPROM_ADDR collides with EEPROM settings storage."
  349. );
  350. #endif
  351. bool MarlinSettings::sd_update_status() {
  352. uint8_t val;
  353. persistentStore.read_data(SD_FIRMWARE_UPDATE_EEPROM_ADDR, &val);
  354. return (val == SD_FIRMWARE_UPDATE_ACTIVE_VALUE);
  355. }
  356. bool MarlinSettings::set_sd_update_status(const bool enable) {
  357. if (enable != sd_update_status())
  358. persistentStore.write_data(
  359. SD_FIRMWARE_UPDATE_EEPROM_ADDR,
  360. enable ? SD_FIRMWARE_UPDATE_ACTIVE_VALUE : SD_FIRMWARE_UPDATE_INACTIVE_VALUE
  361. );
  362. return true;
  363. }
  364. #endif // SD_FIRMWARE_UPDATE
  365. #ifdef ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE
  366. static_assert(
  367. EEPROM_OFFSET + sizeof(SettingsData) < ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE,
  368. "ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE is insufficient to capture all EEPROM data."
  369. );
  370. #endif
  371. #define DEBUG_OUT ENABLED(EEPROM_CHITCHAT)
  372. #include "../core/debug_out.h"
  373. #if ENABLED(EEPROM_SETTINGS)
  374. #define EEPROM_START() if (!persistentStore.access_start()) { SERIAL_ECHO_MSG("No EEPROM."); return false; } \
  375. int eeprom_index = EEPROM_OFFSET
  376. #define EEPROM_FINISH() persistentStore.access_finish()
  377. #define EEPROM_SKIP(VAR) (eeprom_index += sizeof(VAR))
  378. #define EEPROM_WRITE(VAR) do{ persistentStore.write_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR), &working_crc); }while(0)
  379. #define EEPROM_READ(VAR) do{ persistentStore.read_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR), &working_crc, !validating); }while(0)
  380. #define EEPROM_READ_ALWAYS(VAR) do{ persistentStore.read_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR), &working_crc); }while(0)
  381. #define EEPROM_ASSERT(TST,ERR) do{ if (!(TST)) { SERIAL_ERROR_MSG(ERR); eeprom_error = true; } }while(0)
  382. #if ENABLED(DEBUG_EEPROM_READWRITE)
  383. #define _FIELD_TEST(FIELD) \
  384. EEPROM_ASSERT( \
  385. eeprom_error || eeprom_index == offsetof(SettingsData, FIELD) + EEPROM_OFFSET, \
  386. "Field " STRINGIFY(FIELD) " mismatch." \
  387. )
  388. #else
  389. #define _FIELD_TEST(FIELD) NOOP
  390. #endif
  391. const char version[4] = EEPROM_VERSION;
  392. bool MarlinSettings::eeprom_error, MarlinSettings::validating;
  393. bool MarlinSettings::size_error(const uint16_t size) {
  394. if (size != datasize()) {
  395. DEBUG_ERROR_MSG("EEPROM datasize error.");
  396. return true;
  397. }
  398. return false;
  399. }
  400. /**
  401. * M500 - Store Configuration
  402. */
  403. bool MarlinSettings::save() {
  404. float dummy = 0;
  405. char ver[4] = "ERR";
  406. uint16_t working_crc = 0;
  407. EEPROM_START();
  408. eeprom_error = false;
  409. #if ENABLED(FLASH_EEPROM_EMULATION)
  410. EEPROM_SKIP(ver); // Flash doesn't allow rewriting without erase
  411. #else
  412. EEPROM_WRITE(ver); // invalidate data first
  413. #endif
  414. EEPROM_SKIP(working_crc); // Skip the checksum slot
  415. working_crc = 0; // clear before first "real data"
  416. _FIELD_TEST(esteppers);
  417. const uint8_t esteppers = COUNT(planner.settings.axis_steps_per_mm) - XYZ;
  418. EEPROM_WRITE(esteppers);
  419. //
  420. // Planner Motion
  421. //
  422. {
  423. EEPROM_WRITE(planner.settings);
  424. #if HAS_CLASSIC_JERK
  425. EEPROM_WRITE(planner.max_jerk);
  426. #if HAS_LINEAR_E_JERK
  427. dummy = float(DEFAULT_EJERK);
  428. EEPROM_WRITE(dummy);
  429. #endif
  430. #else
  431. const xyze_pos_t planner_max_jerk = { 10, 10, 0.4, float(DEFAULT_EJERK) };
  432. EEPROM_WRITE(planner_max_jerk);
  433. #endif
  434. #if DISABLED(CLASSIC_JERK)
  435. EEPROM_WRITE(planner.junction_deviation_mm);
  436. #else
  437. dummy = 0.02f;
  438. EEPROM_WRITE(dummy);
  439. #endif
  440. }
  441. //
  442. // Home Offset
  443. //
  444. {
  445. _FIELD_TEST(home_offset);
  446. #if HAS_SCARA_OFFSET
  447. EEPROM_WRITE(scara_home_offset);
  448. #else
  449. #if !HAS_HOME_OFFSET
  450. const xyz_pos_t home_offset{0};
  451. #endif
  452. EEPROM_WRITE(home_offset);
  453. #endif
  454. #if HAS_HOTEND_OFFSET
  455. // Skip hotend 0 which must be 0
  456. for (uint8_t e = 1; e < HOTENDS; e++)
  457. EEPROM_WRITE(hotend_offset[e]);
  458. #endif
  459. }
  460. //
  461. // Filament Runout Sensor
  462. //
  463. {
  464. #if HAS_FILAMENT_SENSOR
  465. const bool &runout_sensor_enabled = runout.enabled;
  466. #else
  467. const bool runout_sensor_enabled = true;
  468. #endif
  469. #if HAS_FILAMENT_SENSOR && defined(FILAMENT_RUNOUT_DISTANCE_MM)
  470. const float &runout_distance_mm = runout.runout_distance();
  471. #else
  472. const float runout_distance_mm = 0;
  473. #endif
  474. _FIELD_TEST(runout_sensor_enabled);
  475. EEPROM_WRITE(runout_sensor_enabled);
  476. EEPROM_WRITE(runout_distance_mm);
  477. }
  478. //
  479. // Global Leveling
  480. //
  481. {
  482. const float zfh = (
  483. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  484. planner.z_fade_height
  485. #else
  486. 10.0
  487. #endif
  488. );
  489. EEPROM_WRITE(zfh);
  490. }
  491. //
  492. // Mesh Bed Leveling
  493. //
  494. {
  495. #if ENABLED(MESH_BED_LEVELING)
  496. // Compile time test that sizeof(mbl.z_values) is as expected
  497. static_assert(
  498. sizeof(mbl.z_values) == (GRID_MAX_POINTS) * sizeof(mbl.z_values[0][0]),
  499. "MBL Z array is the wrong size."
  500. );
  501. const uint8_t mesh_num_x = GRID_MAX_POINTS_X, mesh_num_y = GRID_MAX_POINTS_Y;
  502. EEPROM_WRITE(mbl.z_offset);
  503. EEPROM_WRITE(mesh_num_x);
  504. EEPROM_WRITE(mesh_num_y);
  505. EEPROM_WRITE(mbl.z_values);
  506. #else // For disabled MBL write a default mesh
  507. dummy = 0;
  508. const uint8_t mesh_num_x = 3, mesh_num_y = 3;
  509. EEPROM_WRITE(dummy); // z_offset
  510. EEPROM_WRITE(mesh_num_x);
  511. EEPROM_WRITE(mesh_num_y);
  512. for (uint8_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_WRITE(dummy);
  513. #endif
  514. }
  515. //
  516. // Probe XYZ Offsets
  517. //
  518. {
  519. _FIELD_TEST(probe_offset);
  520. EEPROM_WRITE(probe_offset);
  521. }
  522. //
  523. // Planar Bed Leveling matrix
  524. //
  525. {
  526. #if ABL_PLANAR
  527. EEPROM_WRITE(planner.bed_level_matrix);
  528. #else
  529. dummy = 0;
  530. for (uint8_t q = 9; q--;) EEPROM_WRITE(dummy);
  531. #endif
  532. }
  533. //
  534. // Bilinear Auto Bed Leveling
  535. //
  536. {
  537. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  538. // Compile time test that sizeof(z_values) is as expected
  539. static_assert(
  540. sizeof(z_values) == (GRID_MAX_POINTS) * sizeof(z_values[0][0]),
  541. "Bilinear Z array is the wrong size."
  542. );
  543. const uint8_t grid_max_x = GRID_MAX_POINTS_X, grid_max_y = GRID_MAX_POINTS_Y;
  544. EEPROM_WRITE(grid_max_x); // 1 byte
  545. EEPROM_WRITE(grid_max_y); // 1 byte
  546. EEPROM_WRITE(bilinear_grid_spacing); // 2 ints
  547. EEPROM_WRITE(bilinear_start); // 2 ints
  548. EEPROM_WRITE(z_values); // 9-256 floats
  549. #else
  550. // For disabled Bilinear Grid write an empty 3x3 grid
  551. const uint8_t grid_max_x = 3, grid_max_y = 3;
  552. const xy_pos_t bilinear_start{0}, bilinear_grid_spacing{0};
  553. dummy = 0;
  554. EEPROM_WRITE(grid_max_x);
  555. EEPROM_WRITE(grid_max_y);
  556. EEPROM_WRITE(bilinear_grid_spacing);
  557. EEPROM_WRITE(bilinear_start);
  558. for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_WRITE(dummy);
  559. #endif
  560. }
  561. //
  562. // Unified Bed Leveling
  563. //
  564. {
  565. _FIELD_TEST(planner_leveling_active);
  566. #if ENABLED(AUTO_BED_LEVELING_UBL)
  567. EEPROM_WRITE(planner.leveling_active);
  568. EEPROM_WRITE(ubl.storage_slot);
  569. #else
  570. const bool ubl_active = false;
  571. const int8_t storage_slot = -1;
  572. EEPROM_WRITE(ubl_active);
  573. EEPROM_WRITE(storage_slot);
  574. #endif // AUTO_BED_LEVELING_UBL
  575. }
  576. //
  577. // Servo Angles
  578. //
  579. {
  580. _FIELD_TEST(servo_angles);
  581. #if !HAS_SERVO_ANGLES
  582. uint16_t servo_angles[EEPROM_NUM_SERVOS][2] = { { 0, 0 } };
  583. #endif
  584. EEPROM_WRITE(servo_angles);
  585. }
  586. //
  587. // BLTOUCH
  588. //
  589. {
  590. _FIELD_TEST(bltouch_last_written_mode);
  591. #if ENABLED(BLTOUCH)
  592. const bool &bltouch_last_written_mode = bltouch.last_written_mode;
  593. #else
  594. constexpr bool bltouch_last_written_mode = false;
  595. #endif
  596. EEPROM_WRITE(bltouch_last_written_mode);
  597. }
  598. //
  599. // DELTA Geometry or Dual Endstops offsets
  600. //
  601. {
  602. #if ENABLED(DELTA)
  603. _FIELD_TEST(delta_height);
  604. EEPROM_WRITE(delta_height); // 1 float
  605. EEPROM_WRITE(delta_endstop_adj); // 3 floats
  606. EEPROM_WRITE(delta_radius); // 1 float
  607. EEPROM_WRITE(delta_diagonal_rod); // 1 float
  608. EEPROM_WRITE(delta_segments_per_second); // 1 float
  609. EEPROM_WRITE(delta_tower_angle_trim); // 3 floats
  610. #elif EITHER(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
  611. _FIELD_TEST(x2_endstop_adj);
  612. // Write dual endstops in X, Y, Z order. Unused = 0.0
  613. dummy = 0;
  614. #if ENABLED(X_DUAL_ENDSTOPS)
  615. EEPROM_WRITE(endstops.x2_endstop_adj); // 1 float
  616. #else
  617. EEPROM_WRITE(dummy);
  618. #endif
  619. #if ENABLED(Y_DUAL_ENDSTOPS)
  620. EEPROM_WRITE(endstops.y2_endstop_adj); // 1 float
  621. #else
  622. EEPROM_WRITE(dummy);
  623. #endif
  624. #if Z_MULTI_ENDSTOPS
  625. EEPROM_WRITE(endstops.z2_endstop_adj); // 1 float
  626. #else
  627. EEPROM_WRITE(dummy);
  628. #endif
  629. #if ENABLED(Z_TRIPLE_ENDSTOPS)
  630. EEPROM_WRITE(endstops.z3_endstop_adj); // 1 float
  631. #else
  632. EEPROM_WRITE(dummy);
  633. #endif
  634. #endif
  635. }
  636. //
  637. // LCD Preheat settings
  638. //
  639. {
  640. _FIELD_TEST(ui_preheat_hotend_temp);
  641. #if HOTENDS && HAS_LCD_MENU
  642. const int16_t (&ui_preheat_hotend_temp)[2] = ui.preheat_hotend_temp,
  643. (&ui_preheat_bed_temp)[2] = ui.preheat_bed_temp;
  644. const uint8_t (&ui_preheat_fan_speed)[2] = ui.preheat_fan_speed;
  645. #else
  646. constexpr int16_t ui_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
  647. ui_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED };
  648. constexpr uint8_t ui_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
  649. #endif
  650. EEPROM_WRITE(ui_preheat_hotend_temp);
  651. EEPROM_WRITE(ui_preheat_bed_temp);
  652. EEPROM_WRITE(ui_preheat_fan_speed);
  653. }
  654. //
  655. // PIDTEMP
  656. //
  657. {
  658. _FIELD_TEST(hotendPID);
  659. HOTEND_LOOP() {
  660. PIDCF_t pidcf = {
  661. #if DISABLED(PIDTEMP)
  662. DUMMY_PID_VALUE, DUMMY_PID_VALUE, DUMMY_PID_VALUE,
  663. DUMMY_PID_VALUE, DUMMY_PID_VALUE
  664. #else
  665. PID_PARAM(Kp, e),
  666. unscalePID_i(PID_PARAM(Ki, e)),
  667. unscalePID_d(PID_PARAM(Kd, e)),
  668. PID_PARAM(Kc, e),
  669. PID_PARAM(Kf, e)
  670. #endif
  671. };
  672. EEPROM_WRITE(pidcf);
  673. }
  674. _FIELD_TEST(lpq_len);
  675. #if ENABLED(PID_EXTRUSION_SCALING)
  676. EEPROM_WRITE(thermalManager.lpq_len);
  677. #else
  678. const int16_t lpq_len = 20;
  679. EEPROM_WRITE(lpq_len);
  680. #endif
  681. }
  682. //
  683. // PIDTEMPBED
  684. //
  685. {
  686. _FIELD_TEST(bedPID);
  687. const PID_t bed_pid = {
  688. #if DISABLED(PIDTEMPBED)
  689. DUMMY_PID_VALUE, DUMMY_PID_VALUE, DUMMY_PID_VALUE
  690. #else
  691. // Store the unscaled PID values
  692. thermalManager.temp_bed.pid.Kp,
  693. unscalePID_i(thermalManager.temp_bed.pid.Ki),
  694. unscalePID_d(thermalManager.temp_bed.pid.Kd)
  695. #endif
  696. };
  697. EEPROM_WRITE(bed_pid);
  698. }
  699. //
  700. // User-defined Thermistors
  701. //
  702. #if HAS_USER_THERMISTORS
  703. {
  704. _FIELD_TEST(user_thermistor);
  705. EEPROM_WRITE(thermalManager.user_thermistor);
  706. }
  707. #endif
  708. //
  709. // LCD Contrast
  710. //
  711. {
  712. _FIELD_TEST(lcd_contrast);
  713. const int16_t lcd_contrast =
  714. #if HAS_LCD_CONTRAST
  715. ui.contrast
  716. #elif defined(DEFAULT_LCD_CONTRAST)
  717. DEFAULT_LCD_CONTRAST
  718. #else
  719. 127
  720. #endif
  721. ;
  722. EEPROM_WRITE(lcd_contrast);
  723. }
  724. //
  725. // Power-Loss Recovery
  726. //
  727. {
  728. _FIELD_TEST(recovery_enabled);
  729. const bool recovery_enabled =
  730. #if ENABLED(POWER_LOSS_RECOVERY)
  731. recovery.enabled
  732. #else
  733. true
  734. #endif
  735. ;
  736. EEPROM_WRITE(recovery_enabled);
  737. }
  738. //
  739. // Firmware Retraction
  740. //
  741. {
  742. _FIELD_TEST(fwretract_settings);
  743. #if ENABLED(FWRETRACT)
  744. EEPROM_WRITE(fwretract.settings);
  745. #else
  746. const fwretract_settings_t autoretract_defaults = { 3, 45, 0, 0, 0, 13, 0, 8 };
  747. EEPROM_WRITE(autoretract_defaults);
  748. #endif
  749. #if BOTH(FWRETRACT, FWRETRACT_AUTORETRACT)
  750. EEPROM_WRITE(fwretract.autoretract_enabled);
  751. #else
  752. const bool autoretract_enabled = false;
  753. EEPROM_WRITE(autoretract_enabled);
  754. #endif
  755. }
  756. //
  757. // Volumetric & Filament Size
  758. //
  759. {
  760. _FIELD_TEST(parser_volumetric_enabled);
  761. #if DISABLED(NO_VOLUMETRICS)
  762. EEPROM_WRITE(parser.volumetric_enabled);
  763. EEPROM_WRITE(planner.filament_size);
  764. #else
  765. const bool volumetric_enabled = false;
  766. dummy = DEFAULT_NOMINAL_FILAMENT_DIA;
  767. EEPROM_WRITE(volumetric_enabled);
  768. for (uint8_t q = EXTRUDERS; q--;) EEPROM_WRITE(dummy);
  769. #endif
  770. }
  771. //
  772. // TMC Configuration
  773. //
  774. {
  775. _FIELD_TEST(tmc_stepper_current);
  776. tmc_stepper_current_t tmc_stepper_current = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  777. #if HAS_TRINAMIC
  778. #if AXIS_IS_TMC(X)
  779. tmc_stepper_current.X = stepperX.getMilliamps();
  780. #endif
  781. #if AXIS_IS_TMC(Y)
  782. tmc_stepper_current.Y = stepperY.getMilliamps();
  783. #endif
  784. #if AXIS_IS_TMC(Z)
  785. tmc_stepper_current.Z = stepperZ.getMilliamps();
  786. #endif
  787. #if AXIS_IS_TMC(X2)
  788. tmc_stepper_current.X2 = stepperX2.getMilliamps();
  789. #endif
  790. #if AXIS_IS_TMC(Y2)
  791. tmc_stepper_current.Y2 = stepperY2.getMilliamps();
  792. #endif
  793. #if AXIS_IS_TMC(Z2)
  794. tmc_stepper_current.Z2 = stepperZ2.getMilliamps();
  795. #endif
  796. #if AXIS_IS_TMC(Z3)
  797. tmc_stepper_current.Z3 = stepperZ3.getMilliamps();
  798. #endif
  799. #if MAX_EXTRUDERS
  800. #if AXIS_IS_TMC(E0)
  801. tmc_stepper_current.E0 = stepperE0.getMilliamps();
  802. #endif
  803. #if MAX_EXTRUDERS > 1
  804. #if AXIS_IS_TMC(E1)
  805. tmc_stepper_current.E1 = stepperE1.getMilliamps();
  806. #endif
  807. #if MAX_EXTRUDERS > 2
  808. #if AXIS_IS_TMC(E2)
  809. tmc_stepper_current.E2 = stepperE2.getMilliamps();
  810. #endif
  811. #if MAX_EXTRUDERS > 3
  812. #if AXIS_IS_TMC(E3)
  813. tmc_stepper_current.E3 = stepperE3.getMilliamps();
  814. #endif
  815. #if MAX_EXTRUDERS > 4
  816. #if AXIS_IS_TMC(E4)
  817. tmc_stepper_current.E4 = stepperE4.getMilliamps();
  818. #endif
  819. #if MAX_EXTRUDERS > 5
  820. #if AXIS_IS_TMC(E5)
  821. tmc_stepper_current.E5 = stepperE5.getMilliamps();
  822. #endif
  823. #endif // MAX_EXTRUDERS > 5
  824. #endif // MAX_EXTRUDERS > 4
  825. #endif // MAX_EXTRUDERS > 3
  826. #endif // MAX_EXTRUDERS > 2
  827. #endif // MAX_EXTRUDERS > 1
  828. #endif // MAX_EXTRUDERS
  829. #endif
  830. EEPROM_WRITE(tmc_stepper_current);
  831. }
  832. //
  833. // TMC Hybrid Threshold, and placeholder values
  834. //
  835. {
  836. _FIELD_TEST(tmc_hybrid_threshold);
  837. #if ENABLED(HYBRID_THRESHOLD)
  838. tmc_hybrid_threshold_t tmc_hybrid_threshold = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  839. #if AXIS_HAS_STEALTHCHOP(X)
  840. tmc_hybrid_threshold.X = stepperX.get_pwm_thrs();
  841. #endif
  842. #if AXIS_HAS_STEALTHCHOP(Y)
  843. tmc_hybrid_threshold.Y = stepperY.get_pwm_thrs();
  844. #endif
  845. #if AXIS_HAS_STEALTHCHOP(Z)
  846. tmc_hybrid_threshold.Z = stepperZ.get_pwm_thrs();
  847. #endif
  848. #if AXIS_HAS_STEALTHCHOP(X2)
  849. tmc_hybrid_threshold.X2 = stepperX2.get_pwm_thrs();
  850. #endif
  851. #if AXIS_HAS_STEALTHCHOP(Y2)
  852. tmc_hybrid_threshold.Y2 = stepperY2.get_pwm_thrs();
  853. #endif
  854. #if AXIS_HAS_STEALTHCHOP(Z2)
  855. tmc_hybrid_threshold.Z2 = stepperZ2.get_pwm_thrs();
  856. #endif
  857. #if AXIS_HAS_STEALTHCHOP(Z3)
  858. tmc_hybrid_threshold.Z3 = stepperZ3.get_pwm_thrs();
  859. #endif
  860. #if MAX_EXTRUDERS
  861. #if AXIS_HAS_STEALTHCHOP(E0)
  862. tmc_hybrid_threshold.E0 = stepperE0.get_pwm_thrs();
  863. #endif
  864. #if MAX_EXTRUDERS > 1
  865. #if AXIS_HAS_STEALTHCHOP(E1)
  866. tmc_hybrid_threshold.E1 = stepperE1.get_pwm_thrs();
  867. #endif
  868. #if MAX_EXTRUDERS > 2
  869. #if AXIS_HAS_STEALTHCHOP(E2)
  870. tmc_hybrid_threshold.E2 = stepperE2.get_pwm_thrs();
  871. #endif
  872. #if MAX_EXTRUDERS > 3
  873. #if AXIS_HAS_STEALTHCHOP(E3)
  874. tmc_hybrid_threshold.E3 = stepperE3.get_pwm_thrs();
  875. #endif
  876. #if MAX_EXTRUDERS > 4
  877. #if AXIS_HAS_STEALTHCHOP(E4)
  878. tmc_hybrid_threshold.E4 = stepperE4.get_pwm_thrs();
  879. #endif
  880. #if MAX_EXTRUDERS > 5
  881. #if AXIS_HAS_STEALTHCHOP(E5)
  882. tmc_hybrid_threshold.E5 = stepperE5.get_pwm_thrs();
  883. #endif
  884. #endif // MAX_EXTRUDERS > 5
  885. #endif // MAX_EXTRUDERS > 4
  886. #endif // MAX_EXTRUDERS > 3
  887. #endif // MAX_EXTRUDERS > 2
  888. #endif // MAX_EXTRUDERS > 1
  889. #endif // MAX_EXTRUDERS
  890. #else
  891. const tmc_hybrid_threshold_t tmc_hybrid_threshold = {
  892. .X = 100, .Y = 100, .Z = 3,
  893. .X2 = 100, .Y2 = 100, .Z2 = 3, .Z3 = 3,
  894. .E0 = 30, .E1 = 30, .E2 = 30,
  895. .E3 = 30, .E4 = 30, .E5 = 30
  896. };
  897. #endif
  898. EEPROM_WRITE(tmc_hybrid_threshold);
  899. }
  900. //
  901. // TMC StallGuard threshold
  902. //
  903. {
  904. tmc_sgt_t tmc_sgt{0};
  905. #if USE_SENSORLESS
  906. #if X_SENSORLESS
  907. tmc_sgt.X = stepperX.homing_threshold();
  908. #endif
  909. #if X2_SENSORLESS
  910. tmc_sgt.X2 = stepperX2.homing_threshold();
  911. #endif
  912. #if Y_SENSORLESS
  913. tmc_sgt.Y = stepperY.homing_threshold();
  914. #endif
  915. #if Z_SENSORLESS
  916. tmc_sgt.Z = stepperZ.homing_threshold();
  917. #endif
  918. #endif
  919. EEPROM_WRITE(tmc_sgt);
  920. }
  921. //
  922. // TMC stepping mode
  923. //
  924. {
  925. _FIELD_TEST(tmc_stealth_enabled);
  926. tmc_stealth_enabled_t tmc_stealth_enabled = { false, false, false, false, false, false, false, false, false, false, false, false, false };
  927. #if HAS_STEALTHCHOP
  928. #if AXIS_HAS_STEALTHCHOP(X)
  929. tmc_stealth_enabled.X = stepperX.get_stealthChop_status();
  930. #endif
  931. #if AXIS_HAS_STEALTHCHOP(Y)
  932. tmc_stealth_enabled.Y = stepperY.get_stealthChop_status();
  933. #endif
  934. #if AXIS_HAS_STEALTHCHOP(Z)
  935. tmc_stealth_enabled.Z = stepperZ.get_stealthChop_status();
  936. #endif
  937. #if AXIS_HAS_STEALTHCHOP(X2)
  938. tmc_stealth_enabled.X2 = stepperX2.get_stealthChop_status();
  939. #endif
  940. #if AXIS_HAS_STEALTHCHOP(Y2)
  941. tmc_stealth_enabled.Y2 = stepperY2.get_stealthChop_status();
  942. #endif
  943. #if AXIS_HAS_STEALTHCHOP(Z2)
  944. tmc_stealth_enabled.Z2 = stepperZ2.get_stealthChop_status();
  945. #endif
  946. #if AXIS_HAS_STEALTHCHOP(Z3)
  947. tmc_stealth_enabled.Z3 = stepperZ3.get_stealthChop_status();
  948. #endif
  949. #if MAX_EXTRUDERS
  950. #if AXIS_HAS_STEALTHCHOP(E0)
  951. tmc_stealth_enabled.E0 = stepperE0.get_stealthChop_status();
  952. #endif
  953. #if MAX_EXTRUDERS > 1
  954. #if AXIS_HAS_STEALTHCHOP(E1)
  955. tmc_stealth_enabled.E1 = stepperE1.get_stealthChop_status();
  956. #endif
  957. #if MAX_EXTRUDERS > 2
  958. #if AXIS_HAS_STEALTHCHOP(E2)
  959. tmc_stealth_enabled.E2 = stepperE2.get_stealthChop_status();
  960. #endif
  961. #if MAX_EXTRUDERS > 3
  962. #if AXIS_HAS_STEALTHCHOP(E3)
  963. tmc_stealth_enabled.E3 = stepperE3.get_stealthChop_status();
  964. #endif
  965. #if MAX_EXTRUDERS > 4
  966. #if AXIS_HAS_STEALTHCHOP(E4)
  967. tmc_stealth_enabled.E4 = stepperE4.get_stealthChop_status();
  968. #endif
  969. #if MAX_EXTRUDERS > 5
  970. #if AXIS_HAS_STEALTHCHOP(E5)
  971. tmc_stealth_enabled.E5 = stepperE5.get_stealthChop_status();
  972. #endif
  973. #endif // MAX_EXTRUDERS > 5
  974. #endif // MAX_EXTRUDERS > 4
  975. #endif // MAX_EXTRUDERS > 3
  976. #endif // MAX_EXTRUDERS > 2
  977. #endif // MAX_EXTRUDERS > 1
  978. #endif // MAX_EXTRUDERS
  979. #endif
  980. EEPROM_WRITE(tmc_stealth_enabled);
  981. }
  982. //
  983. // Linear Advance
  984. //
  985. {
  986. _FIELD_TEST(planner_extruder_advance_K);
  987. #if ENABLED(LIN_ADVANCE)
  988. EEPROM_WRITE(planner.extruder_advance_K);
  989. #else
  990. dummy = 0;
  991. for (uint8_t q = _MAX(EXTRUDERS, 1); q--;) EEPROM_WRITE(dummy);
  992. #endif
  993. }
  994. //
  995. // Motor Current PWM
  996. //
  997. {
  998. _FIELD_TEST(motor_current_setting);
  999. #if HAS_MOTOR_CURRENT_PWM
  1000. EEPROM_WRITE(stepper.motor_current_setting);
  1001. #else
  1002. const xyz_ulong_t no_current{0};
  1003. EEPROM_WRITE(no_current);
  1004. #endif
  1005. }
  1006. //
  1007. // CNC Coordinate Systems
  1008. //
  1009. _FIELD_TEST(coordinate_system);
  1010. #if ENABLED(CNC_COORDINATE_SYSTEMS)
  1011. EEPROM_WRITE(gcode.coordinate_system);
  1012. #else
  1013. const xyz_pos_t coordinate_system[MAX_COORDINATE_SYSTEMS] = { { 0 } };
  1014. EEPROM_WRITE(coordinate_system);
  1015. #endif
  1016. //
  1017. // Skew correction factors
  1018. //
  1019. _FIELD_TEST(planner_skew_factor);
  1020. EEPROM_WRITE(planner.skew_factor);
  1021. //
  1022. // Advanced Pause filament load & unload lengths
  1023. //
  1024. #if EXTRUDERS
  1025. {
  1026. #if DISABLED(ADVANCED_PAUSE_FEATURE)
  1027. const fil_change_settings_t fc_settings[EXTRUDERS] = { 0, 0 };
  1028. #endif
  1029. _FIELD_TEST(fc_settings);
  1030. EEPROM_WRITE(fc_settings);
  1031. }
  1032. #endif
  1033. //
  1034. // Multiple Extruders
  1035. //
  1036. #if EXTRUDERS > 1
  1037. _FIELD_TEST(toolchange_settings);
  1038. EEPROM_WRITE(toolchange_settings);
  1039. #endif
  1040. //
  1041. // Backlash Compensation
  1042. //
  1043. {
  1044. #if ENABLED(BACKLASH_GCODE)
  1045. const xyz_float_t &backlash_distance_mm = backlash.distance_mm;
  1046. const uint8_t &backlash_correction = backlash.correction;
  1047. #else
  1048. const xyz_float_t backlash_distance_mm{0};
  1049. const uint8_t backlash_correction = 0;
  1050. #endif
  1051. #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM)
  1052. const float &backlash_smoothing_mm = backlash.smoothing_mm;
  1053. #else
  1054. const float backlash_smoothing_mm = 3;
  1055. #endif
  1056. _FIELD_TEST(backlash_distance_mm);
  1057. EEPROM_WRITE(backlash_distance_mm);
  1058. EEPROM_WRITE(backlash_correction);
  1059. EEPROM_WRITE(backlash_smoothing_mm);
  1060. }
  1061. //
  1062. // Extensible UI User Data
  1063. //
  1064. #if ENABLED(EXTENSIBLE_UI)
  1065. {
  1066. char extui_data[ExtUI::eeprom_data_size] = { 0 };
  1067. ExtUI::onStoreSettings(extui_data);
  1068. _FIELD_TEST(extui_data);
  1069. EEPROM_WRITE(extui_data);
  1070. }
  1071. #endif
  1072. //
  1073. // Validate CRC and Data Size
  1074. //
  1075. if (!eeprom_error) {
  1076. const uint16_t eeprom_size = eeprom_index - (EEPROM_OFFSET),
  1077. final_crc = working_crc;
  1078. // Write the EEPROM header
  1079. eeprom_index = EEPROM_OFFSET;
  1080. EEPROM_WRITE(version);
  1081. EEPROM_WRITE(final_crc);
  1082. // Report storage size
  1083. DEBUG_ECHO_START();
  1084. DEBUG_ECHOLNPAIR("Settings Stored (", eeprom_size, " bytes; crc ", (uint32_t)final_crc, ")");
  1085. eeprom_error |= size_error(eeprom_size);
  1086. }
  1087. EEPROM_FINISH();
  1088. //
  1089. // UBL Mesh
  1090. //
  1091. #if ENABLED(UBL_SAVE_ACTIVE_ON_M500)
  1092. if (ubl.storage_slot >= 0)
  1093. store_mesh(ubl.storage_slot);
  1094. #endif
  1095. #if ENABLED(EXTENSIBLE_UI)
  1096. ExtUI::onConfigurationStoreWritten(!eeprom_error);
  1097. #endif
  1098. return !eeprom_error;
  1099. }
  1100. /**
  1101. * M501 - Retrieve Configuration
  1102. */
  1103. bool MarlinSettings::_load() {
  1104. uint16_t working_crc = 0;
  1105. EEPROM_START();
  1106. char stored_ver[4];
  1107. EEPROM_READ_ALWAYS(stored_ver);
  1108. uint16_t stored_crc;
  1109. EEPROM_READ_ALWAYS(stored_crc);
  1110. // Version has to match or defaults are used
  1111. if (strncmp(version, stored_ver, 3) != 0) {
  1112. if (stored_ver[3] != '\0') {
  1113. stored_ver[0] = '?';
  1114. stored_ver[1] = '\0';
  1115. }
  1116. DEBUG_ECHO_START();
  1117. DEBUG_ECHOLNPAIR("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")");
  1118. eeprom_error = true;
  1119. }
  1120. else {
  1121. float dummy = 0;
  1122. working_crc = 0; // Init to 0. Accumulated by EEPROM_READ
  1123. _FIELD_TEST(esteppers);
  1124. // Number of esteppers may change
  1125. uint8_t esteppers;
  1126. EEPROM_READ_ALWAYS(esteppers);
  1127. //
  1128. // Planner Motion
  1129. //
  1130. {
  1131. // Get only the number of E stepper parameters previously stored
  1132. // Any steppers added later are set to their defaults
  1133. uint32_t tmp1[XYZ + esteppers];
  1134. float tmp2[XYZ + esteppers];
  1135. feedRate_t tmp3[XYZ + esteppers];
  1136. EEPROM_READ(tmp1); // max_acceleration_mm_per_s2
  1137. EEPROM_READ(planner.settings.min_segment_time_us);
  1138. EEPROM_READ(tmp2); // axis_steps_per_mm
  1139. EEPROM_READ(tmp3); // max_feedrate_mm_s
  1140. if (!validating) LOOP_XYZE_N(i) {
  1141. const bool in = (i < esteppers + XYZ);
  1142. planner.settings.max_acceleration_mm_per_s2[i] = in ? tmp1[i] : pgm_read_dword(&_DMA[ALIM(i, _DMA)]);
  1143. planner.settings.axis_steps_per_mm[i] = in ? tmp2[i] : pgm_read_float(&_DASU[ALIM(i, _DASU)]);
  1144. planner.settings.max_feedrate_mm_s[i] = in ? tmp3[i] : pgm_read_float(&_DMF[ALIM(i, _DMF)]);
  1145. }
  1146. EEPROM_READ(planner.settings.acceleration);
  1147. EEPROM_READ(planner.settings.retract_acceleration);
  1148. EEPROM_READ(planner.settings.travel_acceleration);
  1149. EEPROM_READ(planner.settings.min_feedrate_mm_s);
  1150. EEPROM_READ(planner.settings.min_travel_feedrate_mm_s);
  1151. #if HAS_CLASSIC_JERK
  1152. EEPROM_READ(planner.max_jerk);
  1153. #if HAS_LINEAR_E_JERK
  1154. EEPROM_READ(dummy);
  1155. #endif
  1156. #else
  1157. for (uint8_t q = 4; q--;) EEPROM_READ(dummy);
  1158. #endif
  1159. #if DISABLED(CLASSIC_JERK)
  1160. EEPROM_READ(planner.junction_deviation_mm);
  1161. #else
  1162. EEPROM_READ(dummy);
  1163. #endif
  1164. }
  1165. //
  1166. // Home Offset (M206 / M665)
  1167. //
  1168. {
  1169. _FIELD_TEST(home_offset);
  1170. #if HAS_SCARA_OFFSET
  1171. EEPROM_READ(scara_home_offset);
  1172. #else
  1173. #if !HAS_HOME_OFFSET
  1174. xyz_pos_t home_offset;
  1175. #endif
  1176. EEPROM_READ(home_offset);
  1177. #endif
  1178. }
  1179. //
  1180. // Hotend Offsets, if any
  1181. //
  1182. {
  1183. #if HAS_HOTEND_OFFSET
  1184. // Skip hotend 0 which must be 0
  1185. for (uint8_t e = 1; e < HOTENDS; e++)
  1186. EEPROM_READ(hotend_offset[e]);
  1187. #endif
  1188. }
  1189. //
  1190. // Filament Runout Sensor
  1191. //
  1192. {
  1193. #if HAS_FILAMENT_SENSOR
  1194. bool &runout_sensor_enabled = runout.enabled;
  1195. #else
  1196. bool runout_sensor_enabled;
  1197. #endif
  1198. _FIELD_TEST(runout_sensor_enabled);
  1199. EEPROM_READ(runout_sensor_enabled);
  1200. float runout_distance_mm;
  1201. EEPROM_READ(runout_distance_mm);
  1202. #if HAS_FILAMENT_SENSOR && defined(FILAMENT_RUNOUT_DISTANCE_MM)
  1203. if (!validating) runout.set_runout_distance(runout_distance_mm);
  1204. #endif
  1205. }
  1206. //
  1207. // Global Leveling
  1208. //
  1209. {
  1210. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  1211. EEPROM_READ(new_z_fade_height);
  1212. #else
  1213. EEPROM_READ(dummy);
  1214. #endif
  1215. }
  1216. //
  1217. // Mesh (Manual) Bed Leveling
  1218. //
  1219. {
  1220. uint8_t mesh_num_x, mesh_num_y;
  1221. EEPROM_READ(dummy);
  1222. EEPROM_READ_ALWAYS(mesh_num_x);
  1223. EEPROM_READ_ALWAYS(mesh_num_y);
  1224. #if ENABLED(MESH_BED_LEVELING)
  1225. if (!validating) mbl.z_offset = dummy;
  1226. if (mesh_num_x == GRID_MAX_POINTS_X && mesh_num_y == GRID_MAX_POINTS_Y) {
  1227. // EEPROM data fits the current mesh
  1228. EEPROM_READ(mbl.z_values);
  1229. }
  1230. else {
  1231. // EEPROM data is stale
  1232. if (!validating) mbl.reset();
  1233. for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
  1234. }
  1235. #else
  1236. // MBL is disabled - skip the stored data
  1237. for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
  1238. #endif // MESH_BED_LEVELING
  1239. }
  1240. //
  1241. // Probe Z Offset
  1242. //
  1243. {
  1244. _FIELD_TEST(probe_offset);
  1245. #if HAS_BED_PROBE
  1246. xyz_pos_t &zpo = probe_offset;
  1247. #else
  1248. xyz_pos_t zpo;
  1249. #endif
  1250. EEPROM_READ(zpo);
  1251. }
  1252. //
  1253. // Planar Bed Leveling matrix
  1254. //
  1255. {
  1256. #if ABL_PLANAR
  1257. EEPROM_READ(planner.bed_level_matrix);
  1258. #else
  1259. for (uint8_t q = 9; q--;) EEPROM_READ(dummy);
  1260. #endif
  1261. }
  1262. //
  1263. // Bilinear Auto Bed Leveling
  1264. //
  1265. {
  1266. uint8_t grid_max_x, grid_max_y;
  1267. EEPROM_READ_ALWAYS(grid_max_x); // 1 byte
  1268. EEPROM_READ_ALWAYS(grid_max_y); // 1 byte
  1269. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  1270. if (grid_max_x == GRID_MAX_POINTS_X && grid_max_y == GRID_MAX_POINTS_Y) {
  1271. if (!validating) set_bed_leveling_enabled(false);
  1272. EEPROM_READ(bilinear_grid_spacing); // 2 ints
  1273. EEPROM_READ(bilinear_start); // 2 ints
  1274. EEPROM_READ(z_values); // 9 to 256 floats
  1275. }
  1276. else // EEPROM data is stale
  1277. #endif // AUTO_BED_LEVELING_BILINEAR
  1278. {
  1279. // Skip past disabled (or stale) Bilinear Grid data
  1280. xy_pos_t bgs, bs;
  1281. EEPROM_READ(bgs);
  1282. EEPROM_READ(bs);
  1283. for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummy);
  1284. }
  1285. }
  1286. //
  1287. // Unified Bed Leveling active state
  1288. //
  1289. {
  1290. _FIELD_TEST(planner_leveling_active);
  1291. #if ENABLED(AUTO_BED_LEVELING_UBL)
  1292. EEPROM_READ(planner.leveling_active);
  1293. EEPROM_READ(ubl.storage_slot);
  1294. #else
  1295. bool planner_leveling_active;
  1296. uint8_t ubl_storage_slot;
  1297. EEPROM_READ(planner_leveling_active);
  1298. EEPROM_READ(ubl_storage_slot);
  1299. #endif
  1300. }
  1301. //
  1302. // SERVO_ANGLES
  1303. //
  1304. {
  1305. _FIELD_TEST(servo_angles);
  1306. #if ENABLED(EDITABLE_SERVO_ANGLES)
  1307. uint16_t (&servo_angles_arr)[EEPROM_NUM_SERVOS][2] = servo_angles;
  1308. #else
  1309. uint16_t servo_angles_arr[EEPROM_NUM_SERVOS][2];
  1310. #endif
  1311. EEPROM_READ(servo_angles_arr);
  1312. }
  1313. //
  1314. // BLTOUCH
  1315. //
  1316. {
  1317. _FIELD_TEST(bltouch_last_written_mode);
  1318. #if ENABLED(BLTOUCH)
  1319. bool &bltouch_last_written_mode = bltouch.last_written_mode;
  1320. #else
  1321. bool bltouch_last_written_mode;
  1322. #endif
  1323. EEPROM_READ(bltouch_last_written_mode);
  1324. }
  1325. //
  1326. // DELTA Geometry or Dual Endstops offsets
  1327. //
  1328. {
  1329. #if ENABLED(DELTA)
  1330. _FIELD_TEST(delta_height);
  1331. EEPROM_READ(delta_height); // 1 float
  1332. EEPROM_READ(delta_endstop_adj); // 3 floats
  1333. EEPROM_READ(delta_radius); // 1 float
  1334. EEPROM_READ(delta_diagonal_rod); // 1 float
  1335. EEPROM_READ(delta_segments_per_second); // 1 float
  1336. EEPROM_READ(delta_tower_angle_trim); // 3 floats
  1337. #elif EITHER(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
  1338. _FIELD_TEST(x2_endstop_adj);
  1339. #if ENABLED(X_DUAL_ENDSTOPS)
  1340. EEPROM_READ(endstops.x2_endstop_adj); // 1 float
  1341. #else
  1342. EEPROM_READ(dummy);
  1343. #endif
  1344. #if ENABLED(Y_DUAL_ENDSTOPS)
  1345. EEPROM_READ(endstops.y2_endstop_adj); // 1 float
  1346. #else
  1347. EEPROM_READ(dummy);
  1348. #endif
  1349. #if Z_MULTI_ENDSTOPS
  1350. EEPROM_READ(endstops.z2_endstop_adj); // 1 float
  1351. #else
  1352. EEPROM_READ(dummy);
  1353. #endif
  1354. #if ENABLED(Z_TRIPLE_ENDSTOPS)
  1355. EEPROM_READ(endstops.z3_endstop_adj); // 1 float
  1356. #else
  1357. EEPROM_READ(dummy);
  1358. #endif
  1359. #endif
  1360. }
  1361. //
  1362. // LCD Preheat settings
  1363. //
  1364. {
  1365. _FIELD_TEST(ui_preheat_hotend_temp);
  1366. #if HOTENDS && HAS_LCD_MENU
  1367. int16_t (&ui_preheat_hotend_temp)[2] = ui.preheat_hotend_temp,
  1368. (&ui_preheat_bed_temp)[2] = ui.preheat_bed_temp;
  1369. uint8_t (&ui_preheat_fan_speed)[2] = ui.preheat_fan_speed;
  1370. #else
  1371. int16_t ui_preheat_hotend_temp[2], ui_preheat_bed_temp[2];
  1372. uint8_t ui_preheat_fan_speed[2];
  1373. #endif
  1374. EEPROM_READ(ui_preheat_hotend_temp); // 2 floats
  1375. EEPROM_READ(ui_preheat_bed_temp); // 2 floats
  1376. EEPROM_READ(ui_preheat_fan_speed); // 2 floats
  1377. }
  1378. //
  1379. // Hotend PID
  1380. //
  1381. {
  1382. HOTEND_LOOP() {
  1383. PIDCF_t pidcf;
  1384. EEPROM_READ(pidcf);
  1385. #if ENABLED(PIDTEMP)
  1386. if (!validating && pidcf.Kp != DUMMY_PID_VALUE) {
  1387. // Scale PID values since EEPROM values are unscaled
  1388. PID_PARAM(Kp, e) = pidcf.Kp;
  1389. PID_PARAM(Ki, e) = scalePID_i(pidcf.Ki);
  1390. PID_PARAM(Kd, e) = scalePID_d(pidcf.Kd);
  1391. #if ENABLED(PID_EXTRUSION_SCALING)
  1392. PID_PARAM(Kc, e) = pidcf.Kc;
  1393. #endif
  1394. #if ENABLED(PID_FAN_SCALING)
  1395. PID_PARAM(Kf, e) = pidcf.Kf;
  1396. #endif
  1397. }
  1398. #endif
  1399. }
  1400. }
  1401. //
  1402. // PID Extrusion Scaling
  1403. //
  1404. {
  1405. _FIELD_TEST(lpq_len);
  1406. #if ENABLED(PID_EXTRUSION_SCALING)
  1407. EEPROM_READ(thermalManager.lpq_len);
  1408. #else
  1409. int16_t lpq_len;
  1410. EEPROM_READ(lpq_len);
  1411. #endif
  1412. }
  1413. //
  1414. // Heated Bed PID
  1415. //
  1416. {
  1417. PID_t pid;
  1418. EEPROM_READ(pid);
  1419. #if ENABLED(PIDTEMPBED)
  1420. if (!validating && pid.Kp != DUMMY_PID_VALUE) {
  1421. // Scale PID values since EEPROM values are unscaled
  1422. thermalManager.temp_bed.pid.Kp = pid.Kp;
  1423. thermalManager.temp_bed.pid.Ki = scalePID_i(pid.Ki);
  1424. thermalManager.temp_bed.pid.Kd = scalePID_d(pid.Kd);
  1425. }
  1426. #endif
  1427. }
  1428. //
  1429. // User-defined Thermistors
  1430. //
  1431. #if HAS_USER_THERMISTORS
  1432. {
  1433. _FIELD_TEST(user_thermistor);
  1434. EEPROM_READ(thermalManager.user_thermistor);
  1435. }
  1436. #endif
  1437. //
  1438. // LCD Contrast
  1439. //
  1440. {
  1441. _FIELD_TEST(lcd_contrast);
  1442. int16_t lcd_contrast;
  1443. EEPROM_READ(lcd_contrast);
  1444. #if HAS_LCD_CONTRAST
  1445. ui.set_contrast(lcd_contrast);
  1446. #endif
  1447. }
  1448. //
  1449. // Power-Loss Recovery
  1450. //
  1451. {
  1452. _FIELD_TEST(recovery_enabled);
  1453. #if ENABLED(POWER_LOSS_RECOVERY)
  1454. EEPROM_READ(recovery.enabled);
  1455. #else
  1456. bool recovery_enabled;
  1457. EEPROM_READ(recovery_enabled);
  1458. #endif
  1459. }
  1460. //
  1461. // Firmware Retraction
  1462. //
  1463. {
  1464. _FIELD_TEST(fwretract_settings);
  1465. #if ENABLED(FWRETRACT)
  1466. EEPROM_READ(fwretract.settings);
  1467. #else
  1468. fwretract_settings_t fwretract_settings;
  1469. EEPROM_READ(fwretract_settings);
  1470. #endif
  1471. #if BOTH(FWRETRACT, FWRETRACT_AUTORETRACT)
  1472. EEPROM_READ(fwretract.autoretract_enabled);
  1473. #else
  1474. bool autoretract_enabled;
  1475. EEPROM_READ(autoretract_enabled);
  1476. #endif
  1477. }
  1478. //
  1479. // Volumetric & Filament Size
  1480. //
  1481. {
  1482. struct {
  1483. bool volumetric_enabled;
  1484. float filament_size[EXTRUDERS];
  1485. } storage;
  1486. _FIELD_TEST(parser_volumetric_enabled);
  1487. EEPROM_READ(storage);
  1488. #if DISABLED(NO_VOLUMETRICS)
  1489. if (!validating) {
  1490. parser.volumetric_enabled = storage.volumetric_enabled;
  1491. COPY(planner.filament_size, storage.filament_size);
  1492. }
  1493. #endif
  1494. }
  1495. //
  1496. // TMC Stepper Settings
  1497. //
  1498. if (!validating) reset_stepper_drivers();
  1499. // TMC Stepper Current
  1500. {
  1501. _FIELD_TEST(tmc_stepper_current);
  1502. tmc_stepper_current_t currents;
  1503. EEPROM_READ(currents);
  1504. #if HAS_TRINAMIC
  1505. #define SET_CURR(Q) stepper##Q.rms_current(currents.Q ? currents.Q : Q##_CURRENT)
  1506. if (!validating) {
  1507. #if AXIS_IS_TMC(X)
  1508. SET_CURR(X);
  1509. #endif
  1510. #if AXIS_IS_TMC(Y)
  1511. SET_CURR(Y);
  1512. #endif
  1513. #if AXIS_IS_TMC(Z)
  1514. SET_CURR(Z);
  1515. #endif
  1516. #if AXIS_IS_TMC(X2)
  1517. SET_CURR(X2);
  1518. #endif
  1519. #if AXIS_IS_TMC(Y2)
  1520. SET_CURR(Y2);
  1521. #endif
  1522. #if AXIS_IS_TMC(Z2)
  1523. SET_CURR(Z2);
  1524. #endif
  1525. #if AXIS_IS_TMC(Z3)
  1526. SET_CURR(Z3);
  1527. #endif
  1528. #if AXIS_IS_TMC(E0)
  1529. SET_CURR(E0);
  1530. #endif
  1531. #if AXIS_IS_TMC(E1)
  1532. SET_CURR(E1);
  1533. #endif
  1534. #if AXIS_IS_TMC(E2)
  1535. SET_CURR(E2);
  1536. #endif
  1537. #if AXIS_IS_TMC(E3)
  1538. SET_CURR(E3);
  1539. #endif
  1540. #if AXIS_IS_TMC(E4)
  1541. SET_CURR(E4);
  1542. #endif
  1543. #if AXIS_IS_TMC(E5)
  1544. SET_CURR(E5);
  1545. #endif
  1546. }
  1547. #endif
  1548. }
  1549. // TMC Hybrid Threshold
  1550. {
  1551. tmc_hybrid_threshold_t tmc_hybrid_threshold;
  1552. _FIELD_TEST(tmc_hybrid_threshold);
  1553. EEPROM_READ(tmc_hybrid_threshold);
  1554. #if ENABLED(HYBRID_THRESHOLD)
  1555. if (!validating) {
  1556. #if AXIS_HAS_STEALTHCHOP(X)
  1557. stepperX.set_pwm_thrs(tmc_hybrid_threshold.X);
  1558. #endif
  1559. #if AXIS_HAS_STEALTHCHOP(Y)
  1560. stepperY.set_pwm_thrs(tmc_hybrid_threshold.Y);
  1561. #endif
  1562. #if AXIS_HAS_STEALTHCHOP(Z)
  1563. stepperZ.set_pwm_thrs(tmc_hybrid_threshold.Z);
  1564. #endif
  1565. #if AXIS_HAS_STEALTHCHOP(X2)
  1566. stepperX2.set_pwm_thrs(tmc_hybrid_threshold.X2);
  1567. #endif
  1568. #if AXIS_HAS_STEALTHCHOP(Y2)
  1569. stepperY2.set_pwm_thrs(tmc_hybrid_threshold.Y2);
  1570. #endif
  1571. #if AXIS_HAS_STEALTHCHOP(Z2)
  1572. stepperZ2.set_pwm_thrs(tmc_hybrid_threshold.Z2);
  1573. #endif
  1574. #if AXIS_HAS_STEALTHCHOP(Z3)
  1575. stepperZ3.set_pwm_thrs(tmc_hybrid_threshold.Z3);
  1576. #endif
  1577. #if AXIS_HAS_STEALTHCHOP(E0)
  1578. stepperE0.set_pwm_thrs(tmc_hybrid_threshold.E0);
  1579. #endif
  1580. #if AXIS_HAS_STEALTHCHOP(E1)
  1581. stepperE1.set_pwm_thrs(tmc_hybrid_threshold.E1);
  1582. #endif
  1583. #if AXIS_HAS_STEALTHCHOP(E2)
  1584. stepperE2.set_pwm_thrs(tmc_hybrid_threshold.E2);
  1585. #endif
  1586. #if AXIS_HAS_STEALTHCHOP(E3)
  1587. stepperE3.set_pwm_thrs(tmc_hybrid_threshold.E3);
  1588. #endif
  1589. #if AXIS_HAS_STEALTHCHOP(E4)
  1590. stepperE4.set_pwm_thrs(tmc_hybrid_threshold.E4);
  1591. #endif
  1592. #if AXIS_HAS_STEALTHCHOP(E5)
  1593. stepperE5.set_pwm_thrs(tmc_hybrid_threshold.E5);
  1594. #endif
  1595. }
  1596. #endif
  1597. }
  1598. //
  1599. // TMC StallGuard threshold.
  1600. // X and X2 use the same value
  1601. // Y and Y2 use the same value
  1602. // Z, Z2 and Z3 use the same value
  1603. //
  1604. {
  1605. tmc_sgt_t tmc_sgt;
  1606. _FIELD_TEST(tmc_sgt);
  1607. EEPROM_READ(tmc_sgt);
  1608. #if USE_SENSORLESS
  1609. if (!validating) {
  1610. #ifdef X_STALL_SENSITIVITY
  1611. #if AXIS_HAS_STALLGUARD(X)
  1612. stepperX.homing_threshold(tmc_sgt.X);
  1613. #endif
  1614. #if AXIS_HAS_STALLGUARD(X2) && !X2_SENSORLESS
  1615. stepperX2.homing_threshold(tmc_sgt.X);
  1616. #endif
  1617. #endif
  1618. #if X2_SENSORLESS
  1619. stepperX2.homing_threshold(tmc_sgt.X2);
  1620. #endif
  1621. #ifdef Y_STALL_SENSITIVITY
  1622. #if AXIS_HAS_STALLGUARD(Y)
  1623. stepperY.homing_threshold(tmc_sgt.Y);
  1624. #endif
  1625. #if AXIS_HAS_STALLGUARD(Y2)
  1626. stepperY2.homing_threshold(tmc_sgt.Y);
  1627. #endif
  1628. #endif
  1629. #ifdef Z_STALL_SENSITIVITY
  1630. #if AXIS_HAS_STALLGUARD(Z)
  1631. stepperZ.homing_threshold(tmc_sgt.Z);
  1632. #endif
  1633. #if AXIS_HAS_STALLGUARD(Z2)
  1634. stepperZ2.homing_threshold(tmc_sgt.Z);
  1635. #endif
  1636. #if AXIS_HAS_STALLGUARD(Z3)
  1637. stepperZ3.homing_threshold(tmc_sgt.Z);
  1638. #endif
  1639. #endif
  1640. }
  1641. #endif
  1642. }
  1643. // TMC stepping mode
  1644. {
  1645. _FIELD_TEST(tmc_stealth_enabled);
  1646. tmc_stealth_enabled_t tmc_stealth_enabled;
  1647. EEPROM_READ(tmc_stealth_enabled);
  1648. #if HAS_TRINAMIC
  1649. #define SET_STEPPING_MODE(ST) stepper##ST.stored.stealthChop_enabled = tmc_stealth_enabled.ST; stepper##ST.refresh_stepping_mode();
  1650. if (!validating) {
  1651. #if AXIS_HAS_STEALTHCHOP(X)
  1652. SET_STEPPING_MODE(X);
  1653. #endif
  1654. #if AXIS_HAS_STEALTHCHOP(Y)
  1655. SET_STEPPING_MODE(Y);
  1656. #endif
  1657. #if AXIS_HAS_STEALTHCHOP(Z)
  1658. SET_STEPPING_MODE(Z);
  1659. #endif
  1660. #if AXIS_HAS_STEALTHCHOP(X2)
  1661. SET_STEPPING_MODE(X2);
  1662. #endif
  1663. #if AXIS_HAS_STEALTHCHOP(Y2)
  1664. SET_STEPPING_MODE(Y2);
  1665. #endif
  1666. #if AXIS_HAS_STEALTHCHOP(Z2)
  1667. SET_STEPPING_MODE(Z2);
  1668. #endif
  1669. #if AXIS_HAS_STEALTHCHOP(Z3)
  1670. SET_STEPPING_MODE(Z3);
  1671. #endif
  1672. #if AXIS_HAS_STEALTHCHOP(E0)
  1673. SET_STEPPING_MODE(E0);
  1674. #endif
  1675. #if AXIS_HAS_STEALTHCHOP(E1)
  1676. SET_STEPPING_MODE(E1);
  1677. #endif
  1678. #if AXIS_HAS_STEALTHCHOP(E2)
  1679. SET_STEPPING_MODE(E2);
  1680. #endif
  1681. #if AXIS_HAS_STEALTHCHOP(E3)
  1682. SET_STEPPING_MODE(E3);
  1683. #endif
  1684. #if AXIS_HAS_STEALTHCHOP(E4)
  1685. SET_STEPPING_MODE(E4);
  1686. #endif
  1687. #if AXIS_HAS_STEALTHCHOP(E5)
  1688. SET_STEPPING_MODE(E5);
  1689. #endif
  1690. }
  1691. #endif
  1692. }
  1693. //
  1694. // Linear Advance
  1695. //
  1696. {
  1697. float extruder_advance_K[_MAX(EXTRUDERS, 1)];
  1698. _FIELD_TEST(planner_extruder_advance_K);
  1699. EEPROM_READ(extruder_advance_K);
  1700. #if ENABLED(LIN_ADVANCE)
  1701. if (!validating)
  1702. COPY(planner.extruder_advance_K, extruder_advance_K);
  1703. #endif
  1704. }
  1705. //
  1706. // Motor Current PWM
  1707. //
  1708. {
  1709. uint32_t motor_current_setting[3];
  1710. _FIELD_TEST(motor_current_setting);
  1711. EEPROM_READ(motor_current_setting);
  1712. #if HAS_MOTOR_CURRENT_PWM
  1713. if (!validating)
  1714. COPY(stepper.motor_current_setting, motor_current_setting);
  1715. #endif
  1716. }
  1717. //
  1718. // CNC Coordinate System
  1719. //
  1720. {
  1721. _FIELD_TEST(coordinate_system);
  1722. #if ENABLED(CNC_COORDINATE_SYSTEMS)
  1723. if (!validating) (void)gcode.select_coordinate_system(-1); // Go back to machine space
  1724. EEPROM_READ(gcode.coordinate_system);
  1725. #else
  1726. xyz_pos_t coordinate_system[MAX_COORDINATE_SYSTEMS];
  1727. EEPROM_READ(coordinate_system);
  1728. #endif
  1729. }
  1730. //
  1731. // Skew correction factors
  1732. //
  1733. {
  1734. skew_factor_t skew_factor;
  1735. _FIELD_TEST(planner_skew_factor);
  1736. EEPROM_READ(skew_factor);
  1737. #if ENABLED(SKEW_CORRECTION_GCODE)
  1738. if (!validating) {
  1739. planner.skew_factor.xy = skew_factor.xy;
  1740. #if ENABLED(SKEW_CORRECTION_FOR_Z)
  1741. planner.skew_factor.xz = skew_factor.xz;
  1742. planner.skew_factor.yz = skew_factor.yz;
  1743. #endif
  1744. }
  1745. #endif
  1746. }
  1747. //
  1748. // Advanced Pause filament load & unload lengths
  1749. //
  1750. #if EXTRUDERS
  1751. {
  1752. #if DISABLED(ADVANCED_PAUSE_FEATURE)
  1753. fil_change_settings_t fc_settings[EXTRUDERS];
  1754. #endif
  1755. _FIELD_TEST(fc_settings);
  1756. EEPROM_READ(fc_settings);
  1757. }
  1758. #endif
  1759. //
  1760. // Tool-change settings
  1761. //
  1762. #if EXTRUDERS > 1
  1763. _FIELD_TEST(toolchange_settings);
  1764. EEPROM_READ(toolchange_settings);
  1765. #endif
  1766. //
  1767. // Backlash Compensation
  1768. //
  1769. {
  1770. #if ENABLED(BACKLASH_GCODE)
  1771. xyz_float_t &backlash_distance_mm = backlash.distance_mm;
  1772. uint8_t &backlash_correction = backlash.correction;
  1773. #else
  1774. float backlash_distance_mm[XYZ];
  1775. uint8_t backlash_correction;
  1776. #endif
  1777. #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM)
  1778. float &backlash_smoothing_mm = backlash.smoothing_mm;
  1779. #else
  1780. float backlash_smoothing_mm;
  1781. #endif
  1782. _FIELD_TEST(backlash_distance_mm);
  1783. EEPROM_READ(backlash_distance_mm);
  1784. EEPROM_READ(backlash_correction);
  1785. EEPROM_READ(backlash_smoothing_mm);
  1786. }
  1787. //
  1788. // Extensible UI User Data
  1789. //
  1790. #if ENABLED(EXTENSIBLE_UI)
  1791. // This is a significant hardware change; don't reserve EEPROM space when not present
  1792. {
  1793. const char extui_data[ExtUI::eeprom_data_size] = { 0 };
  1794. _FIELD_TEST(extui_data);
  1795. EEPROM_READ(extui_data);
  1796. if (!validating) ExtUI::onLoadSettings(extui_data);
  1797. }
  1798. #endif
  1799. eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET));
  1800. if (eeprom_error) {
  1801. DEBUG_ECHO_START();
  1802. DEBUG_ECHOLNPAIR("Index: ", int(eeprom_index - (EEPROM_OFFSET)), " Size: ", datasize());
  1803. }
  1804. else if (working_crc != stored_crc) {
  1805. eeprom_error = true;
  1806. DEBUG_ERROR_START();
  1807. DEBUG_ECHOLNPAIR("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!");
  1808. }
  1809. else if (!validating) {
  1810. DEBUG_ECHO_START();
  1811. DEBUG_ECHO(version);
  1812. DEBUG_ECHOLNPAIR(" stored settings retrieved (", eeprom_index - (EEPROM_OFFSET), " bytes; crc ", (uint32_t)working_crc, ")");
  1813. }
  1814. if (!validating && !eeprom_error) postprocess();
  1815. #if ENABLED(AUTO_BED_LEVELING_UBL)
  1816. if (!validating) {
  1817. ubl.report_state();
  1818. if (!ubl.sanity_check()) {
  1819. SERIAL_EOL();
  1820. #if ENABLED(EEPROM_CHITCHAT)
  1821. ubl.echo_name();
  1822. DEBUG_ECHOLNPGM(" initialized.\n");
  1823. #endif
  1824. }
  1825. else {
  1826. eeprom_error = true;
  1827. #if ENABLED(EEPROM_CHITCHAT)
  1828. DEBUG_ECHOPGM("?Can't enable ");
  1829. ubl.echo_name();
  1830. DEBUG_ECHOLNPGM(".");
  1831. #endif
  1832. ubl.reset();
  1833. }
  1834. if (ubl.storage_slot >= 0) {
  1835. load_mesh(ubl.storage_slot);
  1836. DEBUG_ECHOLNPAIR("Mesh ", ubl.storage_slot, " loaded from storage.");
  1837. }
  1838. else {
  1839. ubl.reset();
  1840. DEBUG_ECHOLNPGM("UBL reset");
  1841. }
  1842. }
  1843. #endif
  1844. }
  1845. #if ENABLED(EEPROM_CHITCHAT) && DISABLED(DISABLE_M503)
  1846. if (!validating) report();
  1847. #endif
  1848. EEPROM_FINISH();
  1849. return !eeprom_error;
  1850. }
  1851. #ifdef ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE
  1852. extern bool restoreEEPROM();
  1853. #endif
  1854. bool MarlinSettings::validate() {
  1855. validating = true;
  1856. #ifdef ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE
  1857. bool success = _load();
  1858. if (!success && restoreEEPROM()) {
  1859. SERIAL_ECHOLNPGM("Recovered backup EEPROM settings from SPI Flash");
  1860. success = _load();
  1861. }
  1862. #else
  1863. const bool success = _load();
  1864. #endif
  1865. validating = false;
  1866. return success;
  1867. }
  1868. bool MarlinSettings::load() {
  1869. if (validate()) {
  1870. const bool success = _load();
  1871. #if ENABLED(EXTENSIBLE_UI)
  1872. ExtUI::onConfigurationStoreRead(success);
  1873. #endif
  1874. return success;
  1875. }
  1876. reset();
  1877. #if ENABLED(EEPROM_AUTO_INIT)
  1878. (void)save();
  1879. SERIAL_ECHO_MSG("EEPROM Initialized");
  1880. #endif
  1881. return false;
  1882. }
  1883. #if ENABLED(AUTO_BED_LEVELING_UBL)
  1884. inline void ubl_invalid_slot(const int s) {
  1885. #if ENABLED(EEPROM_CHITCHAT)
  1886. DEBUG_ECHOLNPGM("?Invalid slot.");
  1887. DEBUG_ECHO(s);
  1888. DEBUG_ECHOLNPGM(" mesh slots available.");
  1889. #else
  1890. UNUSED(s);
  1891. #endif
  1892. }
  1893. const uint16_t MarlinSettings::meshes_end = persistentStore.capacity() - 129; // 128 (+1 because of the change to capacity rather than last valid address)
  1894. // is a placeholder for the size of the MAT; the MAT will always
  1895. // live at the very end of the eeprom
  1896. uint16_t MarlinSettings::meshes_start_index() {
  1897. return (datasize() + EEPROM_OFFSET + 32) & 0xFFF8; // Pad the end of configuration data so it can float up
  1898. // or down a little bit without disrupting the mesh data
  1899. }
  1900. uint16_t MarlinSettings::calc_num_meshes() {
  1901. return (meshes_end - meshes_start_index()) / sizeof(ubl.z_values);
  1902. }
  1903. int MarlinSettings::mesh_slot_offset(const int8_t slot) {
  1904. return meshes_end - (slot + 1) * sizeof(ubl.z_values);
  1905. }
  1906. void MarlinSettings::store_mesh(const int8_t slot) {
  1907. #if ENABLED(AUTO_BED_LEVELING_UBL)
  1908. const int16_t a = calc_num_meshes();
  1909. if (!WITHIN(slot, 0, a - 1)) {
  1910. ubl_invalid_slot(a);
  1911. DEBUG_ECHOLNPAIR("E2END=", persistentStore.capacity() - 1, " meshes_end=", meshes_end, " slot=", slot);
  1912. DEBUG_EOL();
  1913. return;
  1914. }
  1915. int pos = mesh_slot_offset(slot);
  1916. uint16_t crc = 0;
  1917. // Write crc to MAT along with other data, or just tack on to the beginning or end
  1918. persistentStore.access_start();
  1919. const bool status = persistentStore.write_data(pos, (uint8_t *)&ubl.z_values, sizeof(ubl.z_values), &crc);
  1920. persistentStore.access_finish();
  1921. if (status) SERIAL_ECHOLNPGM("?Unable to save mesh data.");
  1922. else DEBUG_ECHOLNPAIR("Mesh saved in slot ", slot);
  1923. #else
  1924. // Other mesh types
  1925. #endif
  1926. }
  1927. void MarlinSettings::load_mesh(const int8_t slot, void * const into/*=nullptr*/) {
  1928. #if ENABLED(AUTO_BED_LEVELING_UBL)
  1929. const int16_t a = settings.calc_num_meshes();
  1930. if (!WITHIN(slot, 0, a - 1)) {
  1931. ubl_invalid_slot(a);
  1932. return;
  1933. }
  1934. int pos = mesh_slot_offset(slot);
  1935. uint16_t crc = 0;
  1936. uint8_t * const dest = into ? (uint8_t*)into : (uint8_t*)&ubl.z_values;
  1937. persistentStore.access_start();
  1938. const uint16_t status = persistentStore.read_data(pos, dest, sizeof(ubl.z_values), &crc);
  1939. persistentStore.access_finish();
  1940. if (status) SERIAL_ECHOLNPGM("?Unable to load mesh data.");
  1941. else DEBUG_ECHOLNPAIR("Mesh loaded from slot ", slot);
  1942. EEPROM_FINISH();
  1943. #else
  1944. // Other mesh types
  1945. #endif
  1946. }
  1947. //void MarlinSettings::delete_mesh() { return; }
  1948. //void MarlinSettings::defrag_meshes() { return; }
  1949. #endif // AUTO_BED_LEVELING_UBL
  1950. #else // !EEPROM_SETTINGS
  1951. bool MarlinSettings::save() {
  1952. DEBUG_ERROR_MSG("EEPROM disabled");
  1953. return false;
  1954. }
  1955. #endif // !EEPROM_SETTINGS
  1956. /**
  1957. * M502 - Reset Configuration
  1958. */
  1959. void MarlinSettings::reset() {
  1960. LOOP_XYZE_N(i) {
  1961. planner.settings.max_acceleration_mm_per_s2[i] = pgm_read_dword(&_DMA[ALIM(i, _DMA)]);
  1962. planner.settings.axis_steps_per_mm[i] = pgm_read_float(&_DASU[ALIM(i, _DASU)]);
  1963. planner.settings.max_feedrate_mm_s[i] = pgm_read_float(&_DMF[ALIM(i, _DMF)]);
  1964. }
  1965. planner.settings.min_segment_time_us = DEFAULT_MINSEGMENTTIME;
  1966. planner.settings.acceleration = DEFAULT_ACCELERATION;
  1967. planner.settings.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
  1968. planner.settings.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
  1969. planner.settings.min_feedrate_mm_s = feedRate_t(DEFAULT_MINIMUMFEEDRATE);
  1970. planner.settings.min_travel_feedrate_mm_s = feedRate_t(DEFAULT_MINTRAVELFEEDRATE);
  1971. #if HAS_CLASSIC_JERK
  1972. #ifndef DEFAULT_XJERK
  1973. #define DEFAULT_XJERK 0
  1974. #endif
  1975. #ifndef DEFAULT_YJERK
  1976. #define DEFAULT_YJERK 0
  1977. #endif
  1978. #ifndef DEFAULT_ZJERK
  1979. #define DEFAULT_ZJERK 0
  1980. #endif
  1981. planner.max_jerk.set(DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK);
  1982. #if HAS_CLASSIC_E_JERK
  1983. planner.max_jerk.e = DEFAULT_EJERK;
  1984. #endif
  1985. #endif
  1986. #if DISABLED(CLASSIC_JERK)
  1987. planner.junction_deviation_mm = float(JUNCTION_DEVIATION_MM);
  1988. #endif
  1989. #if HAS_SCARA_OFFSET
  1990. scara_home_offset.reset();
  1991. #elif HAS_HOME_OFFSET
  1992. home_offset.reset();
  1993. #endif
  1994. #if HAS_HOTEND_OFFSET
  1995. reset_hotend_offsets();
  1996. #endif
  1997. //
  1998. // Filament Runout Sensor
  1999. //
  2000. #if HAS_FILAMENT_SENSOR
  2001. runout.enabled = true;
  2002. runout.reset();
  2003. #ifdef FILAMENT_RUNOUT_DISTANCE_MM
  2004. runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM);
  2005. #endif
  2006. #endif
  2007. //
  2008. // Tool-change Settings
  2009. //
  2010. #if EXTRUDERS > 1
  2011. #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
  2012. toolchange_settings.swap_length = TOOLCHANGE_FIL_SWAP_LENGTH;
  2013. toolchange_settings.extra_prime = TOOLCHANGE_FIL_EXTRA_PRIME;
  2014. toolchange_settings.prime_speed = TOOLCHANGE_FIL_SWAP_PRIME_SPEED;
  2015. toolchange_settings.retract_speed = TOOLCHANGE_FIL_SWAP_RETRACT_SPEED;
  2016. #endif
  2017. #if ENABLED(TOOLCHANGE_PARK)
  2018. constexpr xyz_pos_t tpxy = TOOLCHANGE_PARK_XY;
  2019. toolchange_settings.change_point = tpxy;
  2020. #endif
  2021. toolchange_settings.z_raise = TOOLCHANGE_ZRAISE;
  2022. #endif
  2023. #if ENABLED(BACKLASH_GCODE)
  2024. backlash.correction = (BACKLASH_CORRECTION) * 255;
  2025. constexpr xyz_float_t tmp = BACKLASH_DISTANCE_MM;
  2026. backlash.distance_mm = tmp;
  2027. #ifdef BACKLASH_SMOOTHING_MM
  2028. backlash.smoothing_mm = BACKLASH_SMOOTHING_MM;
  2029. #endif
  2030. #endif
  2031. #if ENABLED(EXTENSIBLE_UI)
  2032. ExtUI::onFactoryReset();
  2033. #endif
  2034. //
  2035. // Magnetic Parking Extruder
  2036. //
  2037. #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
  2038. mpe_settings_init();
  2039. #endif
  2040. //
  2041. // Global Leveling
  2042. //
  2043. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  2044. new_z_fade_height = 0.0;
  2045. #endif
  2046. #if HAS_LEVELING
  2047. reset_bed_level();
  2048. #endif
  2049. #if HAS_BED_PROBE
  2050. constexpr float dpo[] = NOZZLE_TO_PROBE_OFFSET;
  2051. static_assert(COUNT(dpo) == 3, "NOZZLE_TO_PROBE_OFFSET must contain offsets for X, Y, and Z.");
  2052. #if HAS_PROBE_XY_OFFSET
  2053. LOOP_XYZ(a) probe_offset[a] = dpo[a];
  2054. #else
  2055. probe_offset.x = probe_offset.y = 0;
  2056. probe_offset.z = dpo[Z_AXIS];
  2057. #endif
  2058. #endif
  2059. //
  2060. // Servo Angles
  2061. //
  2062. #if ENABLED(EDITABLE_SERVO_ANGLES)
  2063. COPY(servo_angles, base_servo_angles);
  2064. #endif
  2065. //
  2066. // BLTOUCH
  2067. //
  2068. //#if ENABLED(BLTOUCH)
  2069. // bltouch.last_written_mode;
  2070. //#endif
  2071. //
  2072. // Endstop Adjustments
  2073. //
  2074. #if ENABLED(DELTA)
  2075. const abc_float_t adj = DELTA_ENDSTOP_ADJ, dta = DELTA_TOWER_ANGLE_TRIM;
  2076. delta_height = DELTA_HEIGHT;
  2077. delta_endstop_adj = adj;
  2078. delta_radius = DELTA_RADIUS;
  2079. delta_diagonal_rod = DELTA_DIAGONAL_ROD;
  2080. delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
  2081. delta_tower_angle_trim = dta;
  2082. #elif EITHER(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
  2083. #if ENABLED(X_DUAL_ENDSTOPS)
  2084. endstops.x2_endstop_adj = (
  2085. #ifdef X_DUAL_ENDSTOPS_ADJUSTMENT
  2086. X_DUAL_ENDSTOPS_ADJUSTMENT
  2087. #else
  2088. 0
  2089. #endif
  2090. );
  2091. #endif
  2092. #if ENABLED(Y_DUAL_ENDSTOPS)
  2093. endstops.y2_endstop_adj = (
  2094. #ifdef Y_DUAL_ENDSTOPS_ADJUSTMENT
  2095. Y_DUAL_ENDSTOPS_ADJUSTMENT
  2096. #else
  2097. 0
  2098. #endif
  2099. );
  2100. #endif
  2101. #if ENABLED(Z_DUAL_ENDSTOPS)
  2102. endstops.z2_endstop_adj = (
  2103. #ifdef Z_DUAL_ENDSTOPS_ADJUSTMENT
  2104. Z_DUAL_ENDSTOPS_ADJUSTMENT
  2105. #else
  2106. 0
  2107. #endif
  2108. );
  2109. #elif ENABLED(Z_TRIPLE_ENDSTOPS)
  2110. endstops.z2_endstop_adj = (
  2111. #ifdef Z_TRIPLE_ENDSTOPS_ADJUSTMENT2
  2112. Z_TRIPLE_ENDSTOPS_ADJUSTMENT2
  2113. #else
  2114. 0
  2115. #endif
  2116. );
  2117. endstops.z3_endstop_adj = (
  2118. #ifdef Z_TRIPLE_ENDSTOPS_ADJUSTMENT3
  2119. Z_TRIPLE_ENDSTOPS_ADJUSTMENT3
  2120. #else
  2121. 0
  2122. #endif
  2123. );
  2124. #endif
  2125. #endif
  2126. //
  2127. // Preheat parameters
  2128. //
  2129. #if HOTENDS && HAS_LCD_MENU
  2130. ui.preheat_hotend_temp[0] = PREHEAT_1_TEMP_HOTEND;
  2131. ui.preheat_hotend_temp[1] = PREHEAT_2_TEMP_HOTEND;
  2132. ui.preheat_bed_temp[0] = PREHEAT_1_TEMP_BED;
  2133. ui.preheat_bed_temp[1] = PREHEAT_2_TEMP_BED;
  2134. ui.preheat_fan_speed[0] = PREHEAT_1_FAN_SPEED;
  2135. ui.preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
  2136. #endif
  2137. //
  2138. // Hotend PID
  2139. //
  2140. #if ENABLED(PIDTEMP)
  2141. HOTEND_LOOP() {
  2142. PID_PARAM(Kp, e) = float(DEFAULT_Kp);
  2143. PID_PARAM(Ki, e) = scalePID_i(DEFAULT_Ki);
  2144. PID_PARAM(Kd, e) = scalePID_d(DEFAULT_Kd);
  2145. #if ENABLED(PID_EXTRUSION_SCALING)
  2146. PID_PARAM(Kc, e) = DEFAULT_Kc;
  2147. #endif
  2148. #if ENABLED(PID_FAN_SCALING)
  2149. PID_PARAM(Kf, e) = DEFAULT_Kf;
  2150. #endif
  2151. }
  2152. #endif
  2153. //
  2154. // PID Extrusion Scaling
  2155. //
  2156. #if ENABLED(PID_EXTRUSION_SCALING)
  2157. thermalManager.lpq_len = 20; // Default last-position-queue size
  2158. #endif
  2159. //
  2160. // Heated Bed PID
  2161. //
  2162. #if ENABLED(PIDTEMPBED)
  2163. thermalManager.temp_bed.pid.Kp = DEFAULT_bedKp;
  2164. thermalManager.temp_bed.pid.Ki = scalePID_i(DEFAULT_bedKi);
  2165. thermalManager.temp_bed.pid.Kd = scalePID_d(DEFAULT_bedKd);
  2166. #endif
  2167. //
  2168. // User-Defined Thermistors
  2169. //
  2170. #if HAS_USER_THERMISTORS
  2171. thermalManager.reset_user_thermistors();
  2172. #endif
  2173. //
  2174. // LCD Contrast
  2175. //
  2176. #if HAS_LCD_CONTRAST
  2177. ui.set_contrast(DEFAULT_LCD_CONTRAST);
  2178. #endif
  2179. //
  2180. // Power-Loss Recovery
  2181. //
  2182. #if ENABLED(POWER_LOSS_RECOVERY)
  2183. recovery.enable(true);
  2184. #endif
  2185. //
  2186. // Firmware Retraction
  2187. //
  2188. #if ENABLED(FWRETRACT)
  2189. fwretract.reset();
  2190. #endif
  2191. //
  2192. // Volumetric & Filament Size
  2193. //
  2194. #if DISABLED(NO_VOLUMETRICS)
  2195. parser.volumetric_enabled =
  2196. #if ENABLED(VOLUMETRIC_DEFAULT_ON)
  2197. true
  2198. #else
  2199. false
  2200. #endif
  2201. ;
  2202. for (uint8_t q = 0; q < COUNT(planner.filament_size); q++)
  2203. planner.filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
  2204. #endif
  2205. endstops.enable_globally(
  2206. #if ENABLED(ENDSTOPS_ALWAYS_ON_DEFAULT)
  2207. true
  2208. #else
  2209. false
  2210. #endif
  2211. );
  2212. reset_stepper_drivers();
  2213. //
  2214. // Linear Advance
  2215. //
  2216. #if ENABLED(LIN_ADVANCE)
  2217. LOOP_L_N(i, EXTRUDERS) {
  2218. planner.extruder_advance_K[i] = LIN_ADVANCE_K;
  2219. #if ENABLED(EXTRA_LIN_ADVANCE_K)
  2220. saved_extruder_advance_K[i] = LIN_ADVANCE_K;
  2221. #endif
  2222. }
  2223. #endif
  2224. //
  2225. // Motor Current PWM
  2226. //
  2227. #if HAS_MOTOR_CURRENT_PWM
  2228. constexpr uint32_t tmp_motor_current_setting[3] = PWM_MOTOR_CURRENT;
  2229. for (uint8_t q = 3; q--;)
  2230. stepper.digipot_current(q, (stepper.motor_current_setting[q] = tmp_motor_current_setting[q]));
  2231. #endif
  2232. //
  2233. // CNC Coordinate System
  2234. //
  2235. #if ENABLED(CNC_COORDINATE_SYSTEMS)
  2236. (void)gcode.select_coordinate_system(-1); // Go back to machine space
  2237. #endif
  2238. //
  2239. // Skew Correction
  2240. //
  2241. #if ENABLED(SKEW_CORRECTION_GCODE)
  2242. planner.skew_factor.xy = XY_SKEW_FACTOR;
  2243. #if ENABLED(SKEW_CORRECTION_FOR_Z)
  2244. planner.skew_factor.xz = XZ_SKEW_FACTOR;
  2245. planner.skew_factor.yz = YZ_SKEW_FACTOR;
  2246. #endif
  2247. #endif
  2248. //
  2249. // Advanced Pause filament load & unload lengths
  2250. //
  2251. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  2252. for (uint8_t e = 0; e < EXTRUDERS; e++) {
  2253. fc_settings[e].unload_length = FILAMENT_CHANGE_UNLOAD_LENGTH;
  2254. fc_settings[e].load_length = FILAMENT_CHANGE_FAST_LOAD_LENGTH;
  2255. }
  2256. #endif
  2257. postprocess();
  2258. DEBUG_ECHO_START();
  2259. DEBUG_ECHOLNPGM("Hardcoded Default Settings Loaded");
  2260. #if ENABLED(EXTENSIBLE_UI)
  2261. ExtUI::onFactoryReset();
  2262. #endif
  2263. }
  2264. #if DISABLED(DISABLE_M503)
  2265. #define CONFIG_ECHO_START() do{ if (!forReplay) SERIAL_ECHO_START(); }while(0)
  2266. #define CONFIG_ECHO_MSG(STR) do{ CONFIG_ECHO_START(); SERIAL_ECHOLNPGM(STR); }while(0)
  2267. #define CONFIG_ECHO_HEADING(STR) do{ if (!forReplay) { CONFIG_ECHO_START(); SERIAL_ECHOLNPGM(STR); } }while(0)
  2268. #if HAS_TRINAMIC
  2269. inline void say_M906(const bool forReplay) { CONFIG_ECHO_START(); SERIAL_ECHOPGM(" M906"); }
  2270. #if HAS_STEALTHCHOP
  2271. void say_M569(const bool forReplay, const char * const etc=nullptr, const bool newLine = false) {
  2272. CONFIG_ECHO_START();
  2273. SERIAL_ECHOPGM(" M569 S1");
  2274. if (etc) {
  2275. SERIAL_CHAR(' ');
  2276. serialprintPGM(etc);
  2277. }
  2278. if (newLine) SERIAL_EOL();
  2279. }
  2280. #endif
  2281. #if ENABLED(HYBRID_THRESHOLD)
  2282. inline void say_M913(const bool forReplay) { CONFIG_ECHO_START(); SERIAL_ECHOPGM(" M913"); }
  2283. #endif
  2284. #if USE_SENSORLESS
  2285. inline void say_M914() { SERIAL_ECHOPGM(" M914"); }
  2286. #endif
  2287. #endif
  2288. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  2289. inline void say_M603(const bool forReplay) { CONFIG_ECHO_START(); SERIAL_ECHOPGM(" M603 "); }
  2290. #endif
  2291. inline void say_units(const bool colon) {
  2292. serialprintPGM(
  2293. #if ENABLED(INCH_MODE_SUPPORT)
  2294. parser.linear_unit_factor != 1.0 ? PSTR(" (in)") :
  2295. #endif
  2296. PSTR(" (mm)")
  2297. );
  2298. if (colon) SERIAL_ECHOLNPGM(":");
  2299. }
  2300. void report_M92(const bool echo=true, const int8_t e=-1);
  2301. /**
  2302. * M503 - Report current settings in RAM
  2303. *
  2304. * Unless specifically disabled, M503 is available even without EEPROM
  2305. */
  2306. void MarlinSettings::report(const bool forReplay) {
  2307. /**
  2308. * Announce current units, in case inches are being displayed
  2309. */
  2310. CONFIG_ECHO_START();
  2311. #if ENABLED(INCH_MODE_SUPPORT)
  2312. SERIAL_ECHOPGM(" G2");
  2313. SERIAL_CHAR(parser.linear_unit_factor == 1.0 ? '1' : '0');
  2314. SERIAL_ECHOPGM(" ;");
  2315. say_units(false);
  2316. #else
  2317. SERIAL_ECHOPGM(" G21 ; Units in mm");
  2318. say_units(false);
  2319. #endif
  2320. SERIAL_EOL();
  2321. #if HAS_LCD_MENU
  2322. // Temperature units - for Ultipanel temperature options
  2323. CONFIG_ECHO_START();
  2324. #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
  2325. SERIAL_ECHOPGM(" M149 ");
  2326. SERIAL_CHAR(parser.temp_units_code());
  2327. SERIAL_ECHOPGM(" ; Units in ");
  2328. serialprintPGM(parser.temp_units_name());
  2329. #else
  2330. SERIAL_ECHOLNPGM(" M149 C ; Units in Celsius");
  2331. #endif
  2332. #endif
  2333. SERIAL_EOL();
  2334. #if DISABLED(NO_VOLUMETRICS)
  2335. /**
  2336. * Volumetric extrusion M200
  2337. */
  2338. if (!forReplay) {
  2339. CONFIG_ECHO_START();
  2340. SERIAL_ECHOPGM("Filament settings:");
  2341. if (parser.volumetric_enabled)
  2342. SERIAL_EOL();
  2343. else
  2344. SERIAL_ECHOLNPGM(" Disabled");
  2345. }
  2346. CONFIG_ECHO_START();
  2347. SERIAL_ECHOLNPAIR(" M200 D", LINEAR_UNIT(planner.filament_size[0]));
  2348. #if EXTRUDERS > 1
  2349. CONFIG_ECHO_START();
  2350. SERIAL_ECHOLNPAIR(" M200 T1 D", LINEAR_UNIT(planner.filament_size[1]));
  2351. #if EXTRUDERS > 2
  2352. CONFIG_ECHO_START();
  2353. SERIAL_ECHOLNPAIR(" M200 T2 D", LINEAR_UNIT(planner.filament_size[2]));
  2354. #if EXTRUDERS > 3
  2355. CONFIG_ECHO_START();
  2356. SERIAL_ECHOLNPAIR(" M200 T3 D", LINEAR_UNIT(planner.filament_size[3]));
  2357. #if EXTRUDERS > 4
  2358. CONFIG_ECHO_START();
  2359. SERIAL_ECHOLNPAIR(" M200 T4 D", LINEAR_UNIT(planner.filament_size[4]));
  2360. #if EXTRUDERS > 5
  2361. CONFIG_ECHO_START();
  2362. SERIAL_ECHOLNPAIR(" M200 T5 D", LINEAR_UNIT(planner.filament_size[5]));
  2363. #endif // EXTRUDERS > 5
  2364. #endif // EXTRUDERS > 4
  2365. #endif // EXTRUDERS > 3
  2366. #endif // EXTRUDERS > 2
  2367. #endif // EXTRUDERS > 1
  2368. if (!parser.volumetric_enabled)
  2369. CONFIG_ECHO_MSG(" M200 D0");
  2370. #endif // !NO_VOLUMETRICS
  2371. CONFIG_ECHO_HEADING("Steps per unit:");
  2372. report_M92(!forReplay);
  2373. CONFIG_ECHO_HEADING("Maximum feedrates (units/s):");
  2374. CONFIG_ECHO_START();
  2375. SERIAL_ECHOLNPAIR_P(
  2376. PSTR(" M203 X"), LINEAR_UNIT(planner.settings.max_feedrate_mm_s[X_AXIS])
  2377. , SP_Y_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Y_AXIS])
  2378. , SP_Z_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Z_AXIS])
  2379. #if DISABLED(DISTINCT_E_FACTORS)
  2380. , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS])
  2381. #endif
  2382. );
  2383. #if ENABLED(DISTINCT_E_FACTORS)
  2384. CONFIG_ECHO_START();
  2385. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  2386. SERIAL_ECHOLNPAIR_P(
  2387. PSTR(" M203 T"), (int)i
  2388. , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS_N(i)])
  2389. );
  2390. }
  2391. #endif
  2392. CONFIG_ECHO_HEADING("Maximum Acceleration (units/s2):");
  2393. CONFIG_ECHO_START();
  2394. SERIAL_ECHOLNPAIR_P(
  2395. PSTR(" M201 X"), LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[X_AXIS])
  2396. , SP_Y_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Y_AXIS])
  2397. , SP_Z_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Z_AXIS])
  2398. #if DISABLED(DISTINCT_E_FACTORS)
  2399. , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_acceleration_mm_per_s2[E_AXIS])
  2400. #endif
  2401. );
  2402. #if ENABLED(DISTINCT_E_FACTORS)
  2403. CONFIG_ECHO_START();
  2404. for (uint8_t i = 0; i < E_STEPPERS; i++)
  2405. SERIAL_ECHOLNPAIR_P(
  2406. PSTR(" M201 T"), (int)i
  2407. , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(i)])
  2408. );
  2409. #endif
  2410. CONFIG_ECHO_HEADING("Acceleration (units/s2): P<print_accel> R<retract_accel> T<travel_accel>");
  2411. CONFIG_ECHO_START();
  2412. SERIAL_ECHOLNPAIR(
  2413. " M204 P", LINEAR_UNIT(planner.settings.acceleration)
  2414. , " R", LINEAR_UNIT(planner.settings.retract_acceleration)
  2415. , " T", LINEAR_UNIT(planner.settings.travel_acceleration)
  2416. );
  2417. if (!forReplay) {
  2418. CONFIG_ECHO_START();
  2419. SERIAL_ECHOPGM("Advanced: B<min_segment_time_us> S<min_feedrate> T<min_travel_feedrate>");
  2420. #if DISABLED(CLASSIC_JERK)
  2421. SERIAL_ECHOPGM(" J<junc_dev>");
  2422. #endif
  2423. #if HAS_CLASSIC_JERK
  2424. SERIAL_ECHOPGM(" X<max_x_jerk> Y<max_y_jerk> Z<max_z_jerk>");
  2425. #if HAS_CLASSIC_E_JERK
  2426. SERIAL_ECHOPGM(" E<max_e_jerk>");
  2427. #endif
  2428. #endif
  2429. SERIAL_EOL();
  2430. }
  2431. CONFIG_ECHO_START();
  2432. SERIAL_ECHOLNPAIR_P(
  2433. PSTR(" M205 B"), LINEAR_UNIT(planner.settings.min_segment_time_us)
  2434. , PSTR(" S"), LINEAR_UNIT(planner.settings.min_feedrate_mm_s)
  2435. , PSTR(" T"), LINEAR_UNIT(planner.settings.min_travel_feedrate_mm_s)
  2436. #if DISABLED(CLASSIC_JERK)
  2437. , PSTR(" J"), LINEAR_UNIT(planner.junction_deviation_mm)
  2438. #endif
  2439. #if HAS_CLASSIC_JERK
  2440. , SP_X_STR, LINEAR_UNIT(planner.max_jerk.x)
  2441. , SP_Y_STR, LINEAR_UNIT(planner.max_jerk.y)
  2442. , SP_Z_STR, LINEAR_UNIT(planner.max_jerk.z)
  2443. #if HAS_CLASSIC_E_JERK
  2444. , SP_E_STR, LINEAR_UNIT(planner.max_jerk.e)
  2445. #endif
  2446. #endif
  2447. );
  2448. #if HAS_M206_COMMAND
  2449. CONFIG_ECHO_HEADING("Home offset:");
  2450. CONFIG_ECHO_START();
  2451. SERIAL_ECHOLNPAIR_P(
  2452. #if IS_CARTESIAN
  2453. PSTR(" M206 X"), LINEAR_UNIT(home_offset.x)
  2454. , SP_Y_STR, LINEAR_UNIT(home_offset.y)
  2455. , SP_Z_STR
  2456. #else
  2457. PSTR(" M206 Z")
  2458. #endif
  2459. , LINEAR_UNIT(home_offset.z)
  2460. );
  2461. #endif
  2462. #if HAS_HOTEND_OFFSET
  2463. CONFIG_ECHO_HEADING("Hotend offsets:");
  2464. CONFIG_ECHO_START();
  2465. for (uint8_t e = 1; e < HOTENDS; e++) {
  2466. SERIAL_ECHOPAIR_P(
  2467. PSTR(" M218 T"), (int)e,
  2468. SP_X_STR, LINEAR_UNIT(hotend_offset[e].x),
  2469. SP_Y_STR, LINEAR_UNIT(hotend_offset[e].y)
  2470. );
  2471. SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(hotend_offset[e].z), 3);
  2472. }
  2473. #endif
  2474. /**
  2475. * Bed Leveling
  2476. */
  2477. #if HAS_LEVELING
  2478. #if ENABLED(MESH_BED_LEVELING)
  2479. CONFIG_ECHO_HEADING("Mesh Bed Leveling:");
  2480. #elif ENABLED(AUTO_BED_LEVELING_UBL)
  2481. if (!forReplay) {
  2482. CONFIG_ECHO_START();
  2483. ubl.echo_name();
  2484. SERIAL_ECHOLNPGM(":");
  2485. }
  2486. #elif HAS_ABL_OR_UBL
  2487. CONFIG_ECHO_HEADING("Auto Bed Leveling:");
  2488. #endif
  2489. CONFIG_ECHO_START();
  2490. SERIAL_ECHOLNPAIR_P(
  2491. PSTR(" M420 S"), planner.leveling_active ? 1 : 0
  2492. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  2493. , SP_Z_STR, LINEAR_UNIT(planner.z_fade_height)
  2494. #endif
  2495. );
  2496. #if ENABLED(MESH_BED_LEVELING)
  2497. if (leveling_is_valid()) {
  2498. for (uint8_t py = 0; py < GRID_MAX_POINTS_Y; py++) {
  2499. for (uint8_t px = 0; px < GRID_MAX_POINTS_X; px++) {
  2500. CONFIG_ECHO_START();
  2501. SERIAL_ECHOPAIR_P(PSTR(" G29 S3 I"), (int)px, PSTR(" J"), (int)py);
  2502. SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(mbl.z_values[px][py]), 5);
  2503. }
  2504. }
  2505. CONFIG_ECHO_START();
  2506. SERIAL_ECHOLNPAIR_F_P(PSTR(" G29 S4 Z"), LINEAR_UNIT(mbl.z_offset), 5);
  2507. }
  2508. #elif ENABLED(AUTO_BED_LEVELING_UBL)
  2509. if (!forReplay) {
  2510. SERIAL_EOL();
  2511. ubl.report_state();
  2512. SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.storage_slot);
  2513. SERIAL_ECHOLNPAIR("EEPROM can hold ", calc_num_meshes(), " meshes.\n");
  2514. }
  2515. //ubl.report_current_mesh(); // This is too verbose for large meshes. A better (more terse)
  2516. // solution needs to be found.
  2517. #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
  2518. if (leveling_is_valid()) {
  2519. for (uint8_t py = 0; py < GRID_MAX_POINTS_Y; py++) {
  2520. for (uint8_t px = 0; px < GRID_MAX_POINTS_X; px++) {
  2521. CONFIG_ECHO_START();
  2522. SERIAL_ECHOPAIR(" G29 W I", (int)px, " J", (int)py);
  2523. SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(z_values[px][py]), 5);
  2524. }
  2525. }
  2526. }
  2527. #endif
  2528. #endif // HAS_LEVELING
  2529. #if ENABLED(EDITABLE_SERVO_ANGLES)
  2530. CONFIG_ECHO_HEADING("Servo Angles:");
  2531. for (uint8_t i = 0; i < NUM_SERVOS; i++) {
  2532. switch (i) {
  2533. #if ENABLED(SWITCHING_EXTRUDER)
  2534. case SWITCHING_EXTRUDER_SERVO_NR:
  2535. #if EXTRUDERS > 3
  2536. case SWITCHING_EXTRUDER_E23_SERVO_NR:
  2537. #endif
  2538. #elif ENABLED(SWITCHING_NOZZLE)
  2539. case SWITCHING_NOZZLE_SERVO_NR:
  2540. #elif (ENABLED(BLTOUCH) && defined(BLTOUCH_ANGLES)) || (defined(Z_SERVO_ANGLES) && defined(Z_PROBE_SERVO_NR))
  2541. case Z_PROBE_SERVO_NR:
  2542. #endif
  2543. CONFIG_ECHO_START();
  2544. SERIAL_ECHOLNPAIR(" M281 P", int(i), " L", servo_angles[i][0], " U", servo_angles[i][1]);
  2545. default: break;
  2546. }
  2547. }
  2548. #endif // EDITABLE_SERVO_ANGLES
  2549. #if HAS_SCARA_OFFSET
  2550. CONFIG_ECHO_HEADING("SCARA settings: S<seg-per-sec> P<theta-psi-offset> T<theta-offset>");
  2551. CONFIG_ECHO_START();
  2552. SERIAL_ECHOLNPAIR_P(
  2553. PSTR(" M665 S"), delta_segments_per_second
  2554. , PSTR(" P"), scara_home_offset.a
  2555. , PSTR(" T"), scara_home_offset.b
  2556. , SP_Z_STR, LINEAR_UNIT(scara_home_offset.z)
  2557. );
  2558. #elif ENABLED(DELTA)
  2559. CONFIG_ECHO_HEADING("Endstop adjustment:");
  2560. CONFIG_ECHO_START();
  2561. SERIAL_ECHOLNPAIR_P(
  2562. PSTR(" M666 X"), LINEAR_UNIT(delta_endstop_adj.a)
  2563. , SP_Y_STR, LINEAR_UNIT(delta_endstop_adj.b)
  2564. , SP_Z_STR, LINEAR_UNIT(delta_endstop_adj.c)
  2565. );
  2566. CONFIG_ECHO_HEADING("Delta settings: L<diagonal_rod> R<radius> H<height> S<segments_per_s> XYZ<tower angle corrections>");
  2567. CONFIG_ECHO_START();
  2568. SERIAL_ECHOLNPAIR_P(
  2569. PSTR(" M665 L"), LINEAR_UNIT(delta_diagonal_rod)
  2570. , PSTR(" R"), LINEAR_UNIT(delta_radius)
  2571. , PSTR(" H"), LINEAR_UNIT(delta_height)
  2572. , PSTR(" S"), delta_segments_per_second
  2573. , SP_X_STR, LINEAR_UNIT(delta_tower_angle_trim.a)
  2574. , SP_Y_STR, LINEAR_UNIT(delta_tower_angle_trim.b)
  2575. , SP_Z_STR, LINEAR_UNIT(delta_tower_angle_trim.c)
  2576. );
  2577. #elif EITHER(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
  2578. CONFIG_ECHO_HEADING("Endstop adjustment:");
  2579. CONFIG_ECHO_START();
  2580. SERIAL_ECHOPGM(" M666");
  2581. #if ENABLED(X_DUAL_ENDSTOPS)
  2582. SERIAL_ECHOPAIR_P(SP_X_STR, LINEAR_UNIT(endstops.x2_endstop_adj));
  2583. #endif
  2584. #if ENABLED(Y_DUAL_ENDSTOPS)
  2585. SERIAL_ECHOPAIR_P(SP_Y_STR, LINEAR_UNIT(endstops.y2_endstop_adj));
  2586. #endif
  2587. #if ENABLED(Z_TRIPLE_ENDSTOPS)
  2588. SERIAL_ECHOLNPAIR("S1 Z", LINEAR_UNIT(endstops.z2_endstop_adj));
  2589. CONFIG_ECHO_START();
  2590. SERIAL_ECHOPAIR(" M666 S2 Z", LINEAR_UNIT(endstops.z3_endstop_adj));
  2591. #elif ENABLED(Z_DUAL_ENDSTOPS)
  2592. SERIAL_ECHOPAIR_P(SP_Z_STR, LINEAR_UNIT(endstops.z2_endstop_adj));
  2593. #endif
  2594. SERIAL_EOL();
  2595. #endif // [XYZ]_DUAL_ENDSTOPS
  2596. #if HOTENDS && HAS_LCD_MENU
  2597. CONFIG_ECHO_HEADING("Material heatup parameters:");
  2598. for (uint8_t i = 0; i < COUNT(ui.preheat_hotend_temp); i++) {
  2599. CONFIG_ECHO_START();
  2600. SERIAL_ECHOLNPAIR(
  2601. " M145 S", (int)i
  2602. , " H", TEMP_UNIT(ui.preheat_hotend_temp[i])
  2603. , " B", TEMP_UNIT(ui.preheat_bed_temp[i])
  2604. , " F", int(ui.preheat_fan_speed[i])
  2605. );
  2606. }
  2607. #endif
  2608. #if HAS_PID_HEATING
  2609. CONFIG_ECHO_HEADING("PID settings:");
  2610. #if ENABLED(PIDTEMP)
  2611. HOTEND_LOOP() {
  2612. CONFIG_ECHO_START();
  2613. SERIAL_ECHOPAIR_P(
  2614. #if HOTENDS > 1 && ENABLED(PID_PARAMS_PER_HOTEND)
  2615. PSTR(" M301 E"), e,
  2616. PSTR(" P")
  2617. #else
  2618. PSTR(" M301 P")
  2619. #endif
  2620. , PID_PARAM(Kp, e)
  2621. , PSTR(" I"), unscalePID_i(PID_PARAM(Ki, e))
  2622. , PSTR(" D"), unscalePID_d(PID_PARAM(Kd, e))
  2623. );
  2624. #if ENABLED(PID_EXTRUSION_SCALING)
  2625. SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, e));
  2626. if (e == 0) SERIAL_ECHOPAIR(" L", thermalManager.lpq_len);
  2627. #endif
  2628. #if ENABLED(PID_FAN_SCALING)
  2629. SERIAL_ECHOPAIR(" F", PID_PARAM(Kf, e));
  2630. #endif
  2631. SERIAL_EOL();
  2632. }
  2633. #endif // PIDTEMP
  2634. #if ENABLED(PIDTEMPBED)
  2635. CONFIG_ECHO_START();
  2636. SERIAL_ECHOLNPAIR(
  2637. " M304 P", thermalManager.temp_bed.pid.Kp
  2638. , " I", unscalePID_i(thermalManager.temp_bed.pid.Ki)
  2639. , " D", unscalePID_d(thermalManager.temp_bed.pid.Kd)
  2640. );
  2641. #endif
  2642. #endif // PIDTEMP || PIDTEMPBED
  2643. #if HAS_USER_THERMISTORS
  2644. CONFIG_ECHO_HEADING("User thermistors:");
  2645. for (uint8_t i = 0; i < USER_THERMISTORS; i++)
  2646. thermalManager.log_user_thermistor(i, true);
  2647. #endif
  2648. #if HAS_LCD_CONTRAST
  2649. CONFIG_ECHO_HEADING("LCD Contrast:");
  2650. CONFIG_ECHO_START();
  2651. SERIAL_ECHOLNPAIR(" M250 C", ui.contrast);
  2652. #endif
  2653. #if ENABLED(POWER_LOSS_RECOVERY)
  2654. CONFIG_ECHO_HEADING("Power-Loss Recovery:");
  2655. CONFIG_ECHO_START();
  2656. SERIAL_ECHOLNPAIR(" M413 S", int(recovery.enabled));
  2657. #endif
  2658. #if ENABLED(FWRETRACT)
  2659. CONFIG_ECHO_HEADING("Retract: S<length> F<units/m> Z<lift>");
  2660. CONFIG_ECHO_START();
  2661. SERIAL_ECHOLNPAIR_P(
  2662. PSTR(" M207 S"), LINEAR_UNIT(fwretract.settings.retract_length)
  2663. , PSTR(" W"), LINEAR_UNIT(fwretract.settings.swap_retract_length)
  2664. , PSTR(" F"), LINEAR_UNIT(MMS_TO_MMM(fwretract.settings.retract_feedrate_mm_s))
  2665. , SP_Z_STR, LINEAR_UNIT(fwretract.settings.retract_zraise)
  2666. );
  2667. CONFIG_ECHO_HEADING("Recover: S<length> F<units/m>");
  2668. CONFIG_ECHO_START();
  2669. SERIAL_ECHOLNPAIR(
  2670. " M208 S", LINEAR_UNIT(fwretract.settings.retract_recover_extra)
  2671. , " W", LINEAR_UNIT(fwretract.settings.swap_retract_recover_extra)
  2672. , " F", LINEAR_UNIT(MMS_TO_MMM(fwretract.settings.retract_recover_feedrate_mm_s))
  2673. );
  2674. #if ENABLED(FWRETRACT_AUTORETRACT)
  2675. CONFIG_ECHO_HEADING("Auto-Retract: S=0 to disable, 1 to interpret E-only moves as retract/recover");
  2676. CONFIG_ECHO_START();
  2677. SERIAL_ECHOLNPAIR(" M209 S", fwretract.autoretract_enabled ? 1 : 0);
  2678. #endif // FWRETRACT_AUTORETRACT
  2679. #endif // FWRETRACT
  2680. /**
  2681. * Probe Offset
  2682. */
  2683. #if HAS_BED_PROBE
  2684. if (!forReplay) {
  2685. CONFIG_ECHO_START();
  2686. SERIAL_ECHOPGM("Z-Probe Offset");
  2687. say_units(true);
  2688. }
  2689. CONFIG_ECHO_START();
  2690. SERIAL_ECHOLNPAIR_P(
  2691. #if HAS_PROBE_XY_OFFSET
  2692. PSTR(" M851 X"), LINEAR_UNIT(probe_offset_xy.x),
  2693. SP_Y_STR, LINEAR_UNIT(probe_offset_xy.y),
  2694. SP_Z_STR
  2695. #else
  2696. PSTR(" M851 X0 Y0 Z")
  2697. #endif
  2698. , LINEAR_UNIT(probe_offset.z)
  2699. );
  2700. #endif
  2701. /**
  2702. * Bed Skew Correction
  2703. */
  2704. #if ENABLED(SKEW_CORRECTION_GCODE)
  2705. CONFIG_ECHO_HEADING("Skew Factor: ");
  2706. CONFIG_ECHO_START();
  2707. #if ENABLED(SKEW_CORRECTION_FOR_Z)
  2708. SERIAL_ECHOPAIR_F(" M852 I", LINEAR_UNIT(planner.skew_factor.xy), 6);
  2709. SERIAL_ECHOPAIR_F(" J", LINEAR_UNIT(planner.skew_factor.xz), 6);
  2710. SERIAL_ECHOLNPAIR_F(" K", LINEAR_UNIT(planner.skew_factor.yz), 6);
  2711. #else
  2712. SERIAL_ECHOLNPAIR_F(" M852 S", LINEAR_UNIT(planner.skew_factor.xy), 6);
  2713. #endif
  2714. #endif
  2715. #if HAS_TRINAMIC
  2716. /**
  2717. * TMC stepper driver current
  2718. */
  2719. CONFIG_ECHO_HEADING("Stepper driver current:");
  2720. #if AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z)
  2721. say_M906(forReplay);
  2722. #if AXIS_IS_TMC(X)
  2723. SERIAL_ECHOPAIR_P(SP_X_STR, stepperX.getMilliamps());
  2724. #endif
  2725. #if AXIS_IS_TMC(Y)
  2726. SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY.getMilliamps());
  2727. #endif
  2728. #if AXIS_IS_TMC(Z)
  2729. SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ.getMilliamps());
  2730. #endif
  2731. SERIAL_EOL();
  2732. #endif
  2733. #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2)
  2734. say_M906(forReplay);
  2735. SERIAL_ECHOPGM(" I1");
  2736. #if AXIS_IS_TMC(X2)
  2737. SERIAL_ECHOPAIR_P(SP_X_STR, stepperX2.getMilliamps());
  2738. #endif
  2739. #if AXIS_IS_TMC(Y2)
  2740. SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY2.getMilliamps());
  2741. #endif
  2742. #if AXIS_IS_TMC(Z2)
  2743. SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ2.getMilliamps());
  2744. #endif
  2745. SERIAL_EOL();
  2746. #endif
  2747. #if AXIS_IS_TMC(Z3)
  2748. say_M906(forReplay);
  2749. SERIAL_ECHOLNPAIR(" I2 Z", stepperZ3.getMilliamps());
  2750. #endif
  2751. #if AXIS_IS_TMC(E0)
  2752. say_M906(forReplay);
  2753. SERIAL_ECHOLNPAIR(" T0 E", stepperE0.getMilliamps());
  2754. #endif
  2755. #if AXIS_IS_TMC(E1)
  2756. say_M906(forReplay);
  2757. SERIAL_ECHOLNPAIR(" T1 E", stepperE1.getMilliamps());
  2758. #endif
  2759. #if AXIS_IS_TMC(E2)
  2760. say_M906(forReplay);
  2761. SERIAL_ECHOLNPAIR(" T2 E", stepperE2.getMilliamps());
  2762. #endif
  2763. #if AXIS_IS_TMC(E3)
  2764. say_M906(forReplay);
  2765. SERIAL_ECHOLNPAIR(" T3 E", stepperE3.getMilliamps());
  2766. #endif
  2767. #if AXIS_IS_TMC(E4)
  2768. say_M906(forReplay);
  2769. SERIAL_ECHOLNPAIR(" T4 E", stepperE4.getMilliamps());
  2770. #endif
  2771. #if AXIS_IS_TMC(E5)
  2772. say_M906(forReplay);
  2773. SERIAL_ECHOLNPAIR(" T5 E", stepperE5.getMilliamps());
  2774. #endif
  2775. SERIAL_EOL();
  2776. /**
  2777. * TMC Hybrid Threshold
  2778. */
  2779. #if ENABLED(HYBRID_THRESHOLD)
  2780. CONFIG_ECHO_HEADING("Hybrid Threshold:");
  2781. #if AXIS_HAS_STEALTHCHOP(X) || AXIS_HAS_STEALTHCHOP(Y) || AXIS_HAS_STEALTHCHOP(Z)
  2782. say_M913(forReplay);
  2783. #endif
  2784. #if AXIS_HAS_STEALTHCHOP(X)
  2785. SERIAL_ECHOPAIR_P(SP_X_STR, stepperX.get_pwm_thrs());
  2786. #endif
  2787. #if AXIS_HAS_STEALTHCHOP(Y)
  2788. SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY.get_pwm_thrs());
  2789. #endif
  2790. #if AXIS_HAS_STEALTHCHOP(Z)
  2791. SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ.get_pwm_thrs());
  2792. #endif
  2793. #if AXIS_HAS_STEALTHCHOP(X) || AXIS_HAS_STEALTHCHOP(Y) || AXIS_HAS_STEALTHCHOP(Z)
  2794. SERIAL_EOL();
  2795. #endif
  2796. #if AXIS_HAS_STEALTHCHOP(X2) || AXIS_HAS_STEALTHCHOP(Y2) || AXIS_HAS_STEALTHCHOP(Z2)
  2797. say_M913(forReplay);
  2798. SERIAL_ECHOPGM(" I1");
  2799. #endif
  2800. #if AXIS_HAS_STEALTHCHOP(X2)
  2801. SERIAL_ECHOPAIR_P(SP_X_STR, stepperX2.get_pwm_thrs());
  2802. #endif
  2803. #if AXIS_HAS_STEALTHCHOP(Y2)
  2804. SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY2.get_pwm_thrs());
  2805. #endif
  2806. #if AXIS_HAS_STEALTHCHOP(Z2)
  2807. SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ2.get_pwm_thrs());
  2808. #endif
  2809. #if AXIS_HAS_STEALTHCHOP(X2) || AXIS_HAS_STEALTHCHOP(Y2) || AXIS_HAS_STEALTHCHOP(Z2)
  2810. SERIAL_EOL();
  2811. #endif
  2812. #if AXIS_HAS_STEALTHCHOP(Z3)
  2813. say_M913(forReplay);
  2814. SERIAL_ECHOLNPAIR(" I2 Z", stepperZ3.get_pwm_thrs());
  2815. #endif
  2816. #if AXIS_HAS_STEALTHCHOP(E0)
  2817. say_M913(forReplay);
  2818. SERIAL_ECHOLNPAIR(" T0 E", stepperE0.get_pwm_thrs());
  2819. #endif
  2820. #if AXIS_HAS_STEALTHCHOP(E1)
  2821. say_M913(forReplay);
  2822. SERIAL_ECHOLNPAIR(" T1 E", stepperE1.get_pwm_thrs());
  2823. #endif
  2824. #if AXIS_HAS_STEALTHCHOP(E2)
  2825. say_M913(forReplay);
  2826. SERIAL_ECHOLNPAIR(" T2 E", stepperE2.get_pwm_thrs());
  2827. #endif
  2828. #if AXIS_HAS_STEALTHCHOP(E3)
  2829. say_M913(forReplay);
  2830. SERIAL_ECHOLNPAIR(" T3 E", stepperE3.get_pwm_thrs());
  2831. #endif
  2832. #if AXIS_HAS_STEALTHCHOP(E4)
  2833. say_M913(forReplay);
  2834. SERIAL_ECHOLNPAIR(" T4 E", stepperE4.get_pwm_thrs());
  2835. #endif
  2836. #if AXIS_HAS_STEALTHCHOP(E5)
  2837. say_M913(forReplay);
  2838. SERIAL_ECHOLNPAIR(" T5 E", stepperE5.get_pwm_thrs());
  2839. #endif
  2840. SERIAL_EOL();
  2841. #endif // HYBRID_THRESHOLD
  2842. /**
  2843. * TMC Sensorless homing thresholds
  2844. */
  2845. #if USE_SENSORLESS
  2846. CONFIG_ECHO_HEADING("StallGuard threshold:");
  2847. #if X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS
  2848. CONFIG_ECHO_START();
  2849. say_M914();
  2850. #if X_SENSORLESS
  2851. SERIAL_ECHOPAIR_P(SP_X_STR, stepperX.homing_threshold());
  2852. #endif
  2853. #if Y_SENSORLESS
  2854. SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY.homing_threshold());
  2855. #endif
  2856. #if Z_SENSORLESS
  2857. SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ.homing_threshold());
  2858. #endif
  2859. SERIAL_EOL();
  2860. #endif
  2861. #if X2_SENSORLESS || Y2_SENSORLESS || Z2_SENSORLESS
  2862. CONFIG_ECHO_START();
  2863. say_M914();
  2864. SERIAL_ECHOPGM(" I1");
  2865. #if X2_SENSORLESS
  2866. SERIAL_ECHOPAIR_P(SP_X_STR, stepperX2.homing_threshold());
  2867. #endif
  2868. #if Y2_SENSORLESS
  2869. SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY2.homing_threshold());
  2870. #endif
  2871. #if Z2_SENSORLESS
  2872. SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ2.homing_threshold());
  2873. #endif
  2874. SERIAL_EOL();
  2875. #endif
  2876. #if Z3_SENSORLESS
  2877. CONFIG_ECHO_START();
  2878. say_M914();
  2879. SERIAL_ECHOLNPAIR(" I2 Z", stepperZ3.homing_threshold());
  2880. #endif
  2881. #endif // USE_SENSORLESS
  2882. /**
  2883. * TMC stepping mode
  2884. */
  2885. #if HAS_STEALTHCHOP
  2886. CONFIG_ECHO_HEADING("Driver stepping mode:");
  2887. #if AXIS_HAS_STEALTHCHOP(X)
  2888. const bool chop_x = stepperX.get_stealthChop_status();
  2889. #else
  2890. constexpr bool chop_x = false;
  2891. #endif
  2892. #if AXIS_HAS_STEALTHCHOP(Y)
  2893. const bool chop_y = stepperY.get_stealthChop_status();
  2894. #else
  2895. constexpr bool chop_y = false;
  2896. #endif
  2897. #if AXIS_HAS_STEALTHCHOP(Z)
  2898. const bool chop_z = stepperZ.get_stealthChop_status();
  2899. #else
  2900. constexpr bool chop_z = false;
  2901. #endif
  2902. if (chop_x || chop_y || chop_z) {
  2903. say_M569(forReplay);
  2904. if (chop_x) SERIAL_ECHO_P(SP_X_STR);
  2905. if (chop_y) SERIAL_ECHO_P(SP_Y_STR);
  2906. if (chop_z) SERIAL_ECHO_P(SP_Z_STR);
  2907. SERIAL_EOL();
  2908. }
  2909. #if AXIS_HAS_STEALTHCHOP(X2)
  2910. const bool chop_x2 = stepperX2.get_stealthChop_status();
  2911. #else
  2912. constexpr bool chop_x2 = false;
  2913. #endif
  2914. #if AXIS_HAS_STEALTHCHOP(Y2)
  2915. const bool chop_y2 = stepperY2.get_stealthChop_status();
  2916. #else
  2917. constexpr bool chop_y2 = false;
  2918. #endif
  2919. #if AXIS_HAS_STEALTHCHOP(Z2)
  2920. const bool chop_z2 = stepperZ2.get_stealthChop_status();
  2921. #else
  2922. constexpr bool chop_z2 = false;
  2923. #endif
  2924. if (chop_x2 || chop_y2 || chop_z2) {
  2925. say_M569(forReplay, PSTR("I1"));
  2926. if (chop_x2) SERIAL_ECHO_P(SP_X_STR);
  2927. if (chop_y2) SERIAL_ECHO_P(SP_Y_STR);
  2928. if (chop_z2) SERIAL_ECHO_P(SP_Z_STR);
  2929. SERIAL_EOL();
  2930. }
  2931. #if AXIS_HAS_STEALTHCHOP(Z3)
  2932. if (stepperZ3.get_stealthChop_status()) { say_M569(forReplay, PSTR("I2 Z"), true); }
  2933. #endif
  2934. #if AXIS_HAS_STEALTHCHOP(E0)
  2935. if (stepperE0.get_stealthChop_status()) { say_M569(forReplay, PSTR("T0 E"), true); }
  2936. #endif
  2937. #if AXIS_HAS_STEALTHCHOP(E1)
  2938. if (stepperE1.get_stealthChop_status()) { say_M569(forReplay, PSTR("T1 E"), true); }
  2939. #endif
  2940. #if AXIS_HAS_STEALTHCHOP(E2)
  2941. if (stepperE2.get_stealthChop_status()) { say_M569(forReplay, PSTR("T2 E"), true); }
  2942. #endif
  2943. #if AXIS_HAS_STEALTHCHOP(E3)
  2944. if (stepperE3.get_stealthChop_status()) { say_M569(forReplay, PSTR("T3 E"), true); }
  2945. #endif
  2946. #if AXIS_HAS_STEALTHCHOP(E4)
  2947. if (stepperE4.get_stealthChop_status()) { say_M569(forReplay, PSTR("T4 E"), true); }
  2948. #endif
  2949. #if AXIS_HAS_STEALTHCHOP(E5)
  2950. if (stepperE5.get_stealthChop_status()) { say_M569(forReplay, PSTR("T5 E"), true); }
  2951. #endif
  2952. #endif // HAS_STEALTHCHOP
  2953. #endif // HAS_TRINAMIC
  2954. /**
  2955. * Linear Advance
  2956. */
  2957. #if ENABLED(LIN_ADVANCE)
  2958. CONFIG_ECHO_HEADING("Linear Advance:");
  2959. CONFIG_ECHO_START();
  2960. #if EXTRUDERS < 2
  2961. SERIAL_ECHOLNPAIR(" M900 K", planner.extruder_advance_K[0]);
  2962. #else
  2963. LOOP_L_N(i, EXTRUDERS)
  2964. SERIAL_ECHOLNPAIR(" M900 T", int(i), " K", planner.extruder_advance_K[i]);
  2965. #endif
  2966. #endif
  2967. #if HAS_MOTOR_CURRENT_PWM
  2968. CONFIG_ECHO_HEADING("Stepper motor currents:");
  2969. CONFIG_ECHO_START();
  2970. SERIAL_ECHOLNPAIR_P(
  2971. PSTR(" M907 X"), stepper.motor_current_setting[0]
  2972. , SP_Z_STR, stepper.motor_current_setting[1]
  2973. , SP_E_STR, stepper.motor_current_setting[2]
  2974. );
  2975. #endif
  2976. /**
  2977. * Advanced Pause filament load & unload lengths
  2978. */
  2979. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  2980. CONFIG_ECHO_HEADING("Filament load/unload lengths:");
  2981. #if EXTRUDERS == 1
  2982. say_M603(forReplay);
  2983. SERIAL_ECHOLNPAIR("L", LINEAR_UNIT(fc_settings[0].load_length), " U", LINEAR_UNIT(fc_settings[0].unload_length));
  2984. #else
  2985. #define _ECHO_603(N) do{ say_M603(forReplay); SERIAL_ECHOLNPAIR("T" STRINGIFY(N) " L", LINEAR_UNIT(fc_settings[N].load_length), " U", LINEAR_UNIT(fc_settings[N].unload_length)); }while(0)
  2986. _ECHO_603(0);
  2987. _ECHO_603(1);
  2988. #if EXTRUDERS > 2
  2989. _ECHO_603(2);
  2990. #if EXTRUDERS > 3
  2991. _ECHO_603(3);
  2992. #if EXTRUDERS > 4
  2993. _ECHO_603(4);
  2994. #if EXTRUDERS > 5
  2995. _ECHO_603(5);
  2996. #endif // EXTRUDERS > 5
  2997. #endif // EXTRUDERS > 4
  2998. #endif // EXTRUDERS > 3
  2999. #endif // EXTRUDERS > 2
  3000. #endif // EXTRUDERS == 1
  3001. #endif // ADVANCED_PAUSE_FEATURE
  3002. #if EXTRUDERS > 1
  3003. CONFIG_ECHO_HEADING("Tool-changing:");
  3004. CONFIG_ECHO_START();
  3005. M217_report(true);
  3006. #endif
  3007. #if ENABLED(BACKLASH_GCODE)
  3008. CONFIG_ECHO_HEADING("Backlash compensation:");
  3009. CONFIG_ECHO_START();
  3010. SERIAL_ECHOLNPAIR_P(
  3011. PSTR(" M425 F"), backlash.get_correction()
  3012. , SP_X_STR, LINEAR_UNIT(backlash.distance_mm.x)
  3013. , SP_Y_STR, LINEAR_UNIT(backlash.distance_mm.y)
  3014. , SP_Z_STR, LINEAR_UNIT(backlash.distance_mm.z)
  3015. #ifdef BACKLASH_SMOOTHING_MM
  3016. , PSTR(" S"), LINEAR_UNIT(backlash.smoothing_mm)
  3017. #endif
  3018. );
  3019. #endif
  3020. #if HAS_FILAMENT_SENSOR
  3021. CONFIG_ECHO_HEADING("Filament runout sensor:");
  3022. CONFIG_ECHO_START();
  3023. SERIAL_ECHOLNPAIR(
  3024. " M412 S", int(runout.enabled)
  3025. #ifdef FILAMENT_RUNOUT_DISTANCE_MM
  3026. , " D", LINEAR_UNIT(runout.runout_distance())
  3027. #endif
  3028. );
  3029. #endif
  3030. }
  3031. #endif // !DISABLE_M503
  3032. #pragma pack(pop)