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

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