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

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