My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

configuration_store.cpp 99KB

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