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

configuration_store.cpp 66KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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. #define EEPROM_VERSION "V47"
  38. // Change EEPROM version if these are changed:
  39. #define EEPROM_OFFSET 100
  40. /**
  41. * V47 EEPROM Layout:
  42. *
  43. * 100 Version (char x4)
  44. * 104 EEPROM CRC16 (uint16_t)
  45. *
  46. * 106 E_STEPPERS (uint8_t)
  47. * 107 M92 XYZE planner.axis_steps_per_mm (float x4 ... x8) + 64
  48. * 123 M203 XYZE planner.max_feedrate_mm_s (float x4 ... x8) + 64
  49. * 139 M201 XYZE planner.max_acceleration_mm_per_s2 (uint32_t x4 ... x8) + 64
  50. * 155 M204 P planner.acceleration (float)
  51. * 159 M204 R planner.retract_acceleration (float)
  52. * 163 M204 T planner.travel_acceleration (float)
  53. * 167 M205 S planner.min_feedrate_mm_s (float)
  54. * 171 M205 T planner.min_travel_feedrate_mm_s (float)
  55. * 175 M205 B planner.min_segment_time_us (ulong)
  56. * 179 M205 X planner.max_jerk[X_AXIS] (float)
  57. * 183 M205 Y planner.max_jerk[Y_AXIS] (float)
  58. * 187 M205 Z planner.max_jerk[Z_AXIS] (float)
  59. * 191 M205 E planner.max_jerk[E_AXIS] (float)
  60. * 195 M206 XYZ home_offset (float x3)
  61. * 207 M218 XYZ hotend_offset (float x3 per additional hotend) +16
  62. *
  63. * Global Leveling: 4 bytes
  64. * 219 z_fade_height (float)
  65. *
  66. * MESH_BED_LEVELING: 43 bytes
  67. * 223 M420 S planner.leveling_active (bool)
  68. * 224 mbl.z_offset (float)
  69. * 228 GRID_MAX_POINTS_X (uint8_t)
  70. * 229 GRID_MAX_POINTS_Y (uint8_t)
  71. * 230 G29 S3 XYZ z_values[][] (float x9, up to float x81) +288
  72. *
  73. * HAS_BED_PROBE: 4 bytes
  74. * 266 M851 zprobe_zoffset (float)
  75. *
  76. * ABL_PLANAR: 36 bytes
  77. * 270 planner.bed_level_matrix (matrix_3x3 = float x9)
  78. *
  79. * AUTO_BED_LEVELING_BILINEAR: 46 bytes
  80. * 306 GRID_MAX_POINTS_X (uint8_t)
  81. * 307 GRID_MAX_POINTS_Y (uint8_t)
  82. * 308 bilinear_grid_spacing (int x2)
  83. * 312 G29 L F bilinear_start (int x2)
  84. * 316 z_values[][] (float x9, up to float x256) +988
  85. *
  86. * AUTO_BED_LEVELING_UBL: 2 bytes
  87. * 352 G29 A planner.leveling_active (bool)
  88. * 353 G29 S ubl.storage_slot (int8_t)
  89. *
  90. * DELTA: 44 bytes
  91. * 354 M666 H delta_height (float)
  92. * 358 M666 XYZ delta_endstop_adj (float x3)
  93. * 370 M665 R delta_radius (float)
  94. * 374 M665 L delta_diagonal_rod (float)
  95. * 378 M665 S delta_segments_per_second (float)
  96. * 382 M665 B delta_calibration_radius (float)
  97. * 386 M665 X delta_tower_angle_trim[A] (float)
  98. * 390 M665 Y delta_tower_angle_trim[B] (float)
  99. * 394 M665 Z delta_tower_angle_trim[C] (float)
  100. *
  101. * [XYZ]_DUAL_ENDSTOPS: 12 bytes
  102. * 354 M666 X x_endstop_adj (float)
  103. * 358 M666 Y y_endstop_adj (float)
  104. * 362 M666 Z z_endstop_adj (float)
  105. *
  106. * ULTIPANEL: 6 bytes
  107. * 398 M145 S0 H lcd_preheat_hotend_temp (int x2)
  108. * 402 M145 S0 B lcd_preheat_bed_temp (int x2)
  109. * 406 M145 S0 F lcd_preheat_fan_speed (int x2)
  110. *
  111. * PIDTEMP: 82 bytes
  112. * 410 M301 E0 PIDC Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
  113. * 426 M301 E1 PIDC Kp[1], Ki[1], Kd[1], Kc[1] (float x4)
  114. * 442 M301 E2 PIDC Kp[2], Ki[2], Kd[2], Kc[2] (float x4)
  115. * 458 M301 E3 PIDC Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
  116. * 474 M301 E4 PIDC Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
  117. * 490 M301 L lpq_len (int)
  118. *
  119. * PIDTEMPBED: 12 bytes
  120. * 492 M304 PID bedKp, .bedKi, .bedKd (float x3)
  121. *
  122. * DOGLCD: 2 bytes
  123. * 504 M250 C lcd_contrast (uint16_t)
  124. *
  125. * FWRETRACT: 33 bytes
  126. * 506 M209 S autoretract_enabled (bool)
  127. * 507 M207 S retract_length (float)
  128. * 511 M207 F retract_feedrate_mm_s (float)
  129. * 515 M207 Z retract_zlift (float)
  130. * 519 M208 S retract_recover_length (float)
  131. * 523 M208 F retract_recover_feedrate_mm_s (float)
  132. * 527 M207 W swap_retract_length (float)
  133. * 531 M208 W swap_retract_recover_length (float)
  134. * 535 M208 R swap_retract_recover_feedrate_mm_s (float)
  135. *
  136. * Volumetric Extrusion: 21 bytes
  137. * 539 M200 D parser.volumetric_enabled (bool)
  138. * 540 M200 T D planner.filament_size (float x5) (T0..3)
  139. *
  140. * HAS_TRINAMIC: 22 bytes
  141. * 560 M906 X Stepper X current (uint16_t)
  142. * 562 M906 Y Stepper Y current (uint16_t)
  143. * 564 M906 Z Stepper Z current (uint16_t)
  144. * 566 M906 X2 Stepper X2 current (uint16_t)
  145. * 568 M906 Y2 Stepper Y2 current (uint16_t)
  146. * 570 M906 Z2 Stepper Z2 current (uint16_t)
  147. * 572 M906 E0 Stepper E0 current (uint16_t)
  148. * 574 M906 E1 Stepper E1 current (uint16_t)
  149. * 576 M906 E2 Stepper E2 current (uint16_t)
  150. * 578 M906 E3 Stepper E3 current (uint16_t)
  151. * 580 M906 E4 Stepper E4 current (uint16_t)
  152. *
  153. * SENSORLESS HOMING 4 bytes
  154. * 582 M914 X Stepper X and X2 threshold (int16_t)
  155. * 584 M914 Y Stepper Y and Y2 threshold (int16_t)
  156. *
  157. * LIN_ADVANCE: 8 bytes
  158. * 586 M900 K extruder_advance_k (float)
  159. * 590 M900 WHD advance_ed_ratio (float)
  160. *
  161. * HAS_MOTOR_CURRENT_PWM:
  162. * 594 M907 X Stepper XY current (uint32_t)
  163. * 598 M907 Z Stepper Z current (uint32_t)
  164. * 602 M907 E Stepper E current (uint32_t)
  165. *
  166. * CNC_COORDINATE_SYSTEMS 108 bytes
  167. * 606 G54-G59.3 coordinate_system (float x 27)
  168. *
  169. * SKEW_CORRECTION: 12 bytes
  170. * 714 M852 I planner.xy_skew_factor (float)
  171. * 718 M852 J planner.xz_skew_factor (float)
  172. * 722 M852 K planner.yz_skew_factor (float)
  173. *
  174. * 726 Minimum end-point
  175. * 2255 (726 + 208 + 36 + 9 + 288 + 988) Maximum end-point
  176. *
  177. * ========================================================================
  178. * meshes_begin (between max and min end-point, directly above)
  179. * -- MESHES --
  180. * meshes_end
  181. * -- MAT (Mesh Allocation Table) -- 128 bytes (placeholder size)
  182. * mat_end = E2END (0xFFF)
  183. *
  184. */
  185. #include "configuration_store.h"
  186. MarlinSettings settings;
  187. #include "endstops.h"
  188. #include "planner.h"
  189. #include "stepper.h"
  190. #include "temperature.h"
  191. #include "../lcd/ultralcd.h"
  192. #include "../core/language.h"
  193. #include "../Marlin.h"
  194. #include "../gcode/parser.h"
  195. #if HAS_LEVELING
  196. #include "../feature/bedlevel/bedlevel.h"
  197. #endif
  198. #if HAS_BED_PROBE
  199. #include "../module/probe.h"
  200. #endif
  201. #if ENABLED(HAVE_TMC2130)
  202. #include "stepper_indirection.h"
  203. #endif
  204. #if ENABLED(FWRETRACT)
  205. #include "../feature/fwretract.h"
  206. #endif
  207. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  208. float new_z_fade_height;
  209. #endif
  210. /**
  211. * Post-process after Retrieve or Reset
  212. */
  213. void MarlinSettings::postprocess() {
  214. const float oldpos[] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };
  215. // steps per s2 needs to be updated to agree with units per s2
  216. planner.reset_acceleration_rates();
  217. // Make sure delta kinematics are updated before refreshing the
  218. // planner position so the stepper counts will be set correctly.
  219. #if ENABLED(DELTA)
  220. recalc_delta_settings();
  221. #endif
  222. #if ENABLED(PIDTEMP)
  223. thermalManager.updatePID();
  224. #endif
  225. #if DISABLED(NO_VOLUMETRICS)
  226. planner.calculate_volumetric_multipliers();
  227. #else
  228. for (uint8_t i = COUNT(planner.e_factor); i--;)
  229. planner.refresh_e_factor(i);
  230. #endif
  231. #if HAS_HOME_OFFSET || ENABLED(DUAL_X_CARRIAGE)
  232. // Software endstops depend on home_offset
  233. LOOP_XYZ(i) update_software_endstops((AxisEnum)i);
  234. #endif
  235. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  236. set_z_fade_height(new_z_fade_height, false); // false = no report
  237. #endif
  238. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  239. refresh_bed_level();
  240. //set_bed_leveling_enabled(leveling_is_on);
  241. #endif
  242. #if HAS_MOTOR_CURRENT_PWM
  243. stepper.refresh_motor_power();
  244. #endif
  245. #if ENABLED(FWRETRACT)
  246. fwretract.refresh_autoretract();
  247. #endif
  248. // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm
  249. // and init stepper.count[], planner.position[] with current_position
  250. planner.refresh_positioning();
  251. // Various factors can change the current position
  252. if (memcmp(oldpos, current_position, sizeof(oldpos)))
  253. report_current_position();
  254. }
  255. #if ENABLED(EEPROM_SETTINGS)
  256. #include "../HAL/persistent_store_api.h"
  257. #define DUMMY_PID_VALUE 3000.0f
  258. #define EEPROM_START() int eeprom_index = EEPROM_OFFSET; HAL::PersistentStore::access_start()
  259. #define EEPROM_FINISH() HAL::PersistentStore::access_finish()
  260. #define EEPROM_SKIP(VAR) eeprom_index += sizeof(VAR)
  261. #define EEPROM_WRITE(VAR) HAL::PersistentStore::write_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR), &working_crc)
  262. #define EEPROM_READ(VAR) HAL::PersistentStore::read_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR), &working_crc)
  263. #define EEPROM_ASSERT(TST,ERR) if (!(TST)) do{ SERIAL_ERROR_START(); SERIAL_ERRORLNPGM(ERR); eeprom_read_error = true; }while(0)
  264. const char version[4] = EEPROM_VERSION;
  265. bool MarlinSettings::eeprom_error;
  266. #if ENABLED(AUTO_BED_LEVELING_UBL)
  267. int16_t MarlinSettings::meshes_begin;
  268. #endif
  269. /**
  270. * M500 - Store Configuration
  271. */
  272. bool MarlinSettings::save() {
  273. float dummy = 0.0f;
  274. char ver[4] = "000";
  275. uint16_t working_crc = 0;
  276. EEPROM_START();
  277. eeprom_error = false;
  278. #if ENABLED(FLASH_EEPROM_EMULATION)
  279. EEPROM_SKIP(ver); // Flash doesn't allow rewriting without erase
  280. #else
  281. EEPROM_WRITE(ver); // invalidate data first
  282. #endif
  283. EEPROM_SKIP(working_crc); // Skip the checksum slot
  284. working_crc = 0; // clear before first "real data"
  285. const uint8_t esteppers = COUNT(planner.axis_steps_per_mm) - XYZ;
  286. EEPROM_WRITE(esteppers);
  287. EEPROM_WRITE(planner.axis_steps_per_mm);
  288. EEPROM_WRITE(planner.max_feedrate_mm_s);
  289. EEPROM_WRITE(planner.max_acceleration_mm_per_s2);
  290. EEPROM_WRITE(planner.acceleration);
  291. EEPROM_WRITE(planner.retract_acceleration);
  292. EEPROM_WRITE(planner.travel_acceleration);
  293. EEPROM_WRITE(planner.min_feedrate_mm_s);
  294. EEPROM_WRITE(planner.min_travel_feedrate_mm_s);
  295. EEPROM_WRITE(planner.min_segment_time_us);
  296. EEPROM_WRITE(planner.max_jerk);
  297. #if !HAS_HOME_OFFSET
  298. const float home_offset[XYZ] = { 0 };
  299. #endif
  300. EEPROM_WRITE(home_offset);
  301. #if HOTENDS > 1
  302. // Skip hotend 0 which must be 0
  303. for (uint8_t e = 1; e < HOTENDS; e++)
  304. LOOP_XYZ(i) EEPROM_WRITE(hotend_offset[i][e]);
  305. #endif
  306. //
  307. // Global Leveling
  308. //
  309. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  310. const float zfh = planner.z_fade_height;
  311. #else
  312. const float zfh = 10.0;
  313. #endif
  314. EEPROM_WRITE(zfh);
  315. //
  316. // Mesh Bed Leveling
  317. //
  318. #if ENABLED(MESH_BED_LEVELING)
  319. // Compile time test that sizeof(mbl.z_values) is as expected
  320. static_assert(
  321. sizeof(mbl.z_values) == GRID_MAX_POINTS * sizeof(mbl.z_values[0][0]),
  322. "MBL Z array is the wrong size."
  323. );
  324. const uint8_t mesh_num_x = GRID_MAX_POINTS_X, mesh_num_y = GRID_MAX_POINTS_Y;
  325. EEPROM_WRITE(mbl.has_mesh);
  326. EEPROM_WRITE(mbl.z_offset);
  327. EEPROM_WRITE(mesh_num_x);
  328. EEPROM_WRITE(mesh_num_y);
  329. EEPROM_WRITE(mbl.z_values);
  330. #else // For disabled MBL write a default mesh
  331. const bool leveling_is_on = false;
  332. dummy = 0.0f;
  333. const uint8_t mesh_num_x = 3, mesh_num_y = 3;
  334. EEPROM_WRITE(leveling_is_on);
  335. EEPROM_WRITE(dummy); // z_offset
  336. EEPROM_WRITE(mesh_num_x);
  337. EEPROM_WRITE(mesh_num_y);
  338. for (uint8_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_WRITE(dummy);
  339. #endif // MESH_BED_LEVELING
  340. #if !HAS_BED_PROBE
  341. const float zprobe_zoffset = 0;
  342. #endif
  343. EEPROM_WRITE(zprobe_zoffset);
  344. //
  345. // Planar Bed Leveling matrix
  346. //
  347. #if ABL_PLANAR
  348. EEPROM_WRITE(planner.bed_level_matrix);
  349. #else
  350. dummy = 0.0;
  351. for (uint8_t q = 9; q--;) EEPROM_WRITE(dummy);
  352. #endif
  353. //
  354. // Bilinear Auto Bed Leveling
  355. //
  356. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  357. // Compile time test that sizeof(z_values) is as expected
  358. static_assert(
  359. sizeof(z_values) == GRID_MAX_POINTS * sizeof(z_values[0][0]),
  360. "Bilinear Z array is the wrong size."
  361. );
  362. const uint8_t grid_max_x = GRID_MAX_POINTS_X, grid_max_y = GRID_MAX_POINTS_Y;
  363. EEPROM_WRITE(grid_max_x); // 1 byte
  364. EEPROM_WRITE(grid_max_y); // 1 byte
  365. EEPROM_WRITE(bilinear_grid_spacing); // 2 ints
  366. EEPROM_WRITE(bilinear_start); // 2 ints
  367. EEPROM_WRITE(z_values); // 9-256 floats
  368. #else
  369. // For disabled Bilinear Grid write an empty 3x3 grid
  370. const uint8_t grid_max_x = 3, grid_max_y = 3;
  371. const int bilinear_start[2] = { 0 }, bilinear_grid_spacing[2] = { 0 };
  372. dummy = 0.0f;
  373. EEPROM_WRITE(grid_max_x);
  374. EEPROM_WRITE(grid_max_y);
  375. EEPROM_WRITE(bilinear_grid_spacing);
  376. EEPROM_WRITE(bilinear_start);
  377. for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_WRITE(dummy);
  378. #endif // AUTO_BED_LEVELING_BILINEAR
  379. #if ENABLED(AUTO_BED_LEVELING_UBL)
  380. EEPROM_WRITE(planner.leveling_active);
  381. EEPROM_WRITE(ubl.storage_slot);
  382. #else
  383. const bool ubl_active = false;
  384. const int8_t storage_slot = -1;
  385. EEPROM_WRITE(ubl_active);
  386. EEPROM_WRITE(storage_slot);
  387. #endif // AUTO_BED_LEVELING_UBL
  388. // 11 floats for DELTA / [XYZ]_DUAL_ENDSTOPS
  389. #if ENABLED(DELTA)
  390. EEPROM_WRITE(delta_height); // 1 float
  391. EEPROM_WRITE(delta_endstop_adj); // 3 floats
  392. EEPROM_WRITE(delta_radius); // 1 float
  393. EEPROM_WRITE(delta_diagonal_rod); // 1 float
  394. EEPROM_WRITE(delta_segments_per_second); // 1 float
  395. EEPROM_WRITE(delta_calibration_radius); // 1 float
  396. EEPROM_WRITE(delta_tower_angle_trim); // 3 floats
  397. #elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
  398. // Write dual endstops in X, Y, Z order. Unused = 0.0
  399. dummy = 0.0f;
  400. #if ENABLED(X_DUAL_ENDSTOPS)
  401. EEPROM_WRITE(endstops.x_endstop_adj); // 1 float
  402. #else
  403. EEPROM_WRITE(dummy);
  404. #endif
  405. #if ENABLED(Y_DUAL_ENDSTOPS)
  406. EEPROM_WRITE(endstops.y_endstop_adj); // 1 float
  407. #else
  408. EEPROM_WRITE(dummy);
  409. #endif
  410. #if ENABLED(Z_DUAL_ENDSTOPS)
  411. EEPROM_WRITE(endstops.z_endstop_adj); // 1 float
  412. #else
  413. EEPROM_WRITE(dummy);
  414. #endif
  415. for (uint8_t q = 8; q--;) EEPROM_WRITE(dummy);
  416. #else
  417. dummy = 0.0f;
  418. for (uint8_t q = 11; q--;) EEPROM_WRITE(dummy);
  419. #endif
  420. #if DISABLED(ULTIPANEL)
  421. constexpr int lcd_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
  422. lcd_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED },
  423. lcd_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
  424. #endif
  425. EEPROM_WRITE(lcd_preheat_hotend_temp);
  426. EEPROM_WRITE(lcd_preheat_bed_temp);
  427. EEPROM_WRITE(lcd_preheat_fan_speed);
  428. for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
  429. #if ENABLED(PIDTEMP)
  430. if (e < HOTENDS) {
  431. EEPROM_WRITE(PID_PARAM(Kp, e));
  432. EEPROM_WRITE(PID_PARAM(Ki, e));
  433. EEPROM_WRITE(PID_PARAM(Kd, e));
  434. #if ENABLED(PID_EXTRUSION_SCALING)
  435. EEPROM_WRITE(PID_PARAM(Kc, e));
  436. #else
  437. dummy = 1.0f; // 1.0 = default kc
  438. EEPROM_WRITE(dummy);
  439. #endif
  440. }
  441. else
  442. #endif // !PIDTEMP
  443. {
  444. dummy = DUMMY_PID_VALUE; // When read, will not change the existing value
  445. EEPROM_WRITE(dummy); // Kp
  446. dummy = 0.0f;
  447. for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy); // Ki, Kd, Kc
  448. }
  449. } // Hotends Loop
  450. #if DISABLED(PID_EXTRUSION_SCALING)
  451. int lpq_len = 20;
  452. #endif
  453. EEPROM_WRITE(lpq_len);
  454. #if DISABLED(PIDTEMPBED)
  455. dummy = DUMMY_PID_VALUE;
  456. for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy);
  457. #else
  458. EEPROM_WRITE(thermalManager.bedKp);
  459. EEPROM_WRITE(thermalManager.bedKi);
  460. EEPROM_WRITE(thermalManager.bedKd);
  461. #endif
  462. #if !HAS_LCD_CONTRAST
  463. const uint16_t lcd_contrast = 32;
  464. #endif
  465. EEPROM_WRITE(lcd_contrast);
  466. #if DISABLED(FWRETRACT)
  467. const bool autoretract_enabled = false;
  468. const float autoretract_defaults[] = { 3, 45, 0, 0, 0, 13, 0, 8 };
  469. EEPROM_WRITE(autoretract_enabled);
  470. EEPROM_WRITE(autoretract_defaults);
  471. #else
  472. EEPROM_WRITE(fwretract.autoretract_enabled);
  473. EEPROM_WRITE(fwretract.retract_length);
  474. EEPROM_WRITE(fwretract.retract_feedrate_mm_s);
  475. EEPROM_WRITE(fwretract.retract_zlift);
  476. EEPROM_WRITE(fwretract.retract_recover_length);
  477. EEPROM_WRITE(fwretract.retract_recover_feedrate_mm_s);
  478. EEPROM_WRITE(fwretract.swap_retract_length);
  479. EEPROM_WRITE(fwretract.swap_retract_recover_length);
  480. EEPROM_WRITE(fwretract.swap_retract_recover_feedrate_mm_s);
  481. #endif
  482. //
  483. // Volumetric & Filament Size
  484. //
  485. #if DISABLED(NO_VOLUMETRICS)
  486. EEPROM_WRITE(parser.volumetric_enabled);
  487. // Save filament sizes
  488. for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
  489. if (q < COUNT(planner.filament_size)) dummy = planner.filament_size[q];
  490. EEPROM_WRITE(dummy);
  491. }
  492. #endif
  493. // Save TMC2130 or TMC2208 Configuration, and placeholder values
  494. uint16_t val;
  495. #if HAS_TRINAMIC
  496. #if X_IS_TRINAMIC
  497. val = stepperX.getCurrent();
  498. #else
  499. val = 0;
  500. #endif
  501. EEPROM_WRITE(val);
  502. #if Y_IS_TRINAMIC
  503. val = stepperY.getCurrent();
  504. #else
  505. val = 0;
  506. #endif
  507. EEPROM_WRITE(val);
  508. #if Z_IS_TRINAMIC
  509. val = stepperZ.getCurrent();
  510. #else
  511. val = 0;
  512. #endif
  513. EEPROM_WRITE(val);
  514. #if X2_IS_TRINAMIC
  515. val = stepperX2.getCurrent();
  516. #else
  517. val = 0;
  518. #endif
  519. EEPROM_WRITE(val);
  520. #if Y2_IS_TRINAMIC
  521. val = stepperY2.getCurrent();
  522. #else
  523. val = 0;
  524. #endif
  525. EEPROM_WRITE(val);
  526. #if Z2_IS_TRINAMIC
  527. val = stepperZ2.getCurrent();
  528. #else
  529. val = 0;
  530. #endif
  531. EEPROM_WRITE(val);
  532. #if E0_IS_TRINAMIC
  533. val = stepperE0.getCurrent();
  534. #else
  535. val = 0;
  536. #endif
  537. EEPROM_WRITE(val);
  538. #if E1_IS_TRINAMIC
  539. val = stepperE1.getCurrent();
  540. #else
  541. val = 0;
  542. #endif
  543. EEPROM_WRITE(val);
  544. #if E2_IS_TRINAMIC
  545. val = stepperE2.getCurrent();
  546. #else
  547. val = 0;
  548. #endif
  549. EEPROM_WRITE(val);
  550. #if E3_IS_TRINAMIC
  551. val = stepperE3.getCurrent();
  552. #else
  553. val = 0;
  554. #endif
  555. EEPROM_WRITE(val);
  556. #if E4_IS_TRINAMIC
  557. val = stepperE4.getCurrent();
  558. #else
  559. val = 0;
  560. #endif
  561. EEPROM_WRITE(val);
  562. #else
  563. val = 0;
  564. for (uint8_t q = 11; q--;) EEPROM_WRITE(val);
  565. #endif
  566. //
  567. // TMC2130 Sensorless homing threshold
  568. //
  569. int16_t thrs;
  570. #if ENABLED(SENSORLESS_HOMING)
  571. #if ENABLED(X_IS_TMC2130)
  572. thrs = stepperX.sgt();
  573. #else
  574. thrs = 0;
  575. #endif
  576. EEPROM_WRITE(thrs);
  577. #if ENABLED(Y_IS_TMC2130)
  578. thrs = stepperY.sgt();
  579. #else
  580. thrs = 0;
  581. #endif
  582. EEPROM_WRITE(thrs);
  583. #else
  584. thrs = 0;
  585. for (uint8_t q = 2; q--;) EEPROM_WRITE(thrs);
  586. #endif
  587. //
  588. // Linear Advance
  589. //
  590. #if ENABLED(LIN_ADVANCE)
  591. EEPROM_WRITE(planner.extruder_advance_k);
  592. EEPROM_WRITE(planner.advance_ed_ratio);
  593. #else
  594. dummy = 0.0f;
  595. EEPROM_WRITE(dummy);
  596. EEPROM_WRITE(dummy);
  597. #endif
  598. #if HAS_MOTOR_CURRENT_PWM
  599. for (uint8_t q = 3; q--;) EEPROM_WRITE(stepper.motor_current_setting[q]);
  600. #else
  601. const uint32_t dummyui32 = 0;
  602. for (uint8_t q = 3; q--;) EEPROM_WRITE(dummyui32);
  603. #endif
  604. //
  605. // CNC Coordinate Systems
  606. //
  607. #if ENABLED(CNC_COORDINATE_SYSTEMS)
  608. EEPROM_WRITE(coordinate_system); // 27 floats
  609. #else
  610. dummy = 0.0f;
  611. for (uint8_t q = 27; q--;) EEPROM_WRITE(dummy);
  612. #endif
  613. //
  614. // Skew correction factors
  615. //
  616. #if ENABLED(SKEW_CORRECTION)
  617. EEPROM_WRITE(planner.xy_skew_factor);
  618. EEPROM_WRITE(planner.xz_skew_factor);
  619. EEPROM_WRITE(planner.yz_skew_factor);
  620. #else
  621. dummy = 0.0f;
  622. for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy);
  623. #endif
  624. if (!eeprom_error) {
  625. #if ENABLED(EEPROM_CHITCHAT)
  626. const int eeprom_size = eeprom_index;
  627. #endif
  628. const uint16_t final_crc = working_crc;
  629. // Write the EEPROM header
  630. eeprom_index = EEPROM_OFFSET;
  631. EEPROM_WRITE(version);
  632. EEPROM_WRITE(final_crc);
  633. // Report storage size
  634. #if ENABLED(EEPROM_CHITCHAT)
  635. SERIAL_ECHO_START();
  636. SERIAL_ECHOPAIR("Settings Stored (", eeprom_size - (EEPROM_OFFSET));
  637. SERIAL_ECHOPAIR(" bytes; crc ", (uint32_t)final_crc);
  638. SERIAL_ECHOLNPGM(")");
  639. #endif
  640. }
  641. EEPROM_FINISH();
  642. #if ENABLED(UBL_SAVE_ACTIVE_ON_M500)
  643. if (ubl.storage_slot >= 0)
  644. store_mesh(ubl.storage_slot);
  645. #endif
  646. return !eeprom_error;
  647. }
  648. /**
  649. * M501 - Retrieve Configuration
  650. */
  651. bool MarlinSettings::load() {
  652. uint16_t working_crc = 0;
  653. EEPROM_START();
  654. char stored_ver[4];
  655. EEPROM_READ(stored_ver);
  656. uint16_t stored_crc;
  657. EEPROM_READ(stored_crc);
  658. // Version has to match or defaults are used
  659. if (strncmp(version, stored_ver, 3) != 0) {
  660. if (stored_ver[0] != 'V') {
  661. stored_ver[0] = '?';
  662. stored_ver[1] = '\0';
  663. }
  664. #if ENABLED(EEPROM_CHITCHAT)
  665. SERIAL_ECHO_START();
  666. SERIAL_ECHOPGM("EEPROM version mismatch ");
  667. SERIAL_ECHOPAIR("(EEPROM=", stored_ver);
  668. SERIAL_ECHOLNPGM(" Marlin=" EEPROM_VERSION ")");
  669. #endif
  670. reset();
  671. }
  672. else {
  673. float dummy = 0;
  674. #if DISABLED(AUTO_BED_LEVELING_UBL) || DISABLED(FWRETRACT)
  675. bool dummyb;
  676. #endif
  677. working_crc = 0; // Init to 0. Accumulated by EEPROM_READ
  678. // Number of esteppers may change
  679. uint8_t esteppers;
  680. EEPROM_READ(esteppers);
  681. //
  682. // Planner Motion
  683. //
  684. // Get only the number of E stepper parameters previously stored
  685. // Any steppers added later are set to their defaults
  686. const float def1[] = DEFAULT_AXIS_STEPS_PER_UNIT, def2[] = DEFAULT_MAX_FEEDRATE;
  687. const uint32_t def3[] = DEFAULT_MAX_ACCELERATION;
  688. float tmp1[XYZ + esteppers], tmp2[XYZ + esteppers];
  689. uint32_t tmp3[XYZ + esteppers];
  690. EEPROM_READ(tmp1);
  691. EEPROM_READ(tmp2);
  692. EEPROM_READ(tmp3);
  693. LOOP_XYZE_N(i) {
  694. planner.axis_steps_per_mm[i] = i < XYZ + esteppers ? tmp1[i] : def1[i < COUNT(def1) ? i : COUNT(def1) - 1];
  695. planner.max_feedrate_mm_s[i] = i < XYZ + esteppers ? tmp2[i] : def2[i < COUNT(def2) ? i : COUNT(def2) - 1];
  696. planner.max_acceleration_mm_per_s2[i] = i < XYZ + esteppers ? tmp3[i] : def3[i < COUNT(def3) ? i : COUNT(def3) - 1];
  697. }
  698. EEPROM_READ(planner.acceleration);
  699. EEPROM_READ(planner.retract_acceleration);
  700. EEPROM_READ(planner.travel_acceleration);
  701. EEPROM_READ(planner.min_feedrate_mm_s);
  702. EEPROM_READ(planner.min_travel_feedrate_mm_s);
  703. EEPROM_READ(planner.min_segment_time_us);
  704. EEPROM_READ(planner.max_jerk);
  705. //
  706. // Home Offset (M206)
  707. //
  708. #if !HAS_HOME_OFFSET
  709. float home_offset[XYZ];
  710. #endif
  711. EEPROM_READ(home_offset);
  712. //
  713. // Hotend Offsets, if any
  714. //
  715. #if HOTENDS > 1
  716. // Skip hotend 0 which must be 0
  717. for (uint8_t e = 1; e < HOTENDS; e++)
  718. LOOP_XYZ(i) EEPROM_READ(hotend_offset[i][e]);
  719. #endif
  720. //
  721. // Global Leveling
  722. //
  723. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  724. EEPROM_READ(new_z_fade_height);
  725. #else
  726. EEPROM_READ(dummy);
  727. #endif
  728. //
  729. // Mesh (Manual) Bed Leveling
  730. //
  731. bool leveling_is_on;
  732. uint8_t mesh_num_x, mesh_num_y;
  733. EEPROM_READ(leveling_is_on);
  734. EEPROM_READ(dummy);
  735. EEPROM_READ(mesh_num_x);
  736. EEPROM_READ(mesh_num_y);
  737. #if ENABLED(MESH_BED_LEVELING)
  738. mbl.has_mesh = leveling_is_on;
  739. mbl.z_offset = dummy;
  740. if (mesh_num_x == GRID_MAX_POINTS_X && mesh_num_y == GRID_MAX_POINTS_Y) {
  741. // EEPROM data fits the current mesh
  742. EEPROM_READ(mbl.z_values);
  743. }
  744. else {
  745. // EEPROM data is stale
  746. mbl.reset();
  747. for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
  748. }
  749. #else
  750. // MBL is disabled - skip the stored data
  751. for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
  752. #endif // MESH_BED_LEVELING
  753. #if !HAS_BED_PROBE
  754. float zprobe_zoffset;
  755. #endif
  756. EEPROM_READ(zprobe_zoffset);
  757. //
  758. // Planar Bed Leveling matrix
  759. //
  760. #if ABL_PLANAR
  761. EEPROM_READ(planner.bed_level_matrix);
  762. #else
  763. for (uint8_t q = 9; q--;) EEPROM_READ(dummy);
  764. #endif
  765. //
  766. // Bilinear Auto Bed Leveling
  767. //
  768. uint8_t grid_max_x, grid_max_y;
  769. EEPROM_READ(grid_max_x); // 1 byte
  770. EEPROM_READ(grid_max_y); // 1 byte
  771. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  772. if (grid_max_x == GRID_MAX_POINTS_X && grid_max_y == GRID_MAX_POINTS_Y) {
  773. set_bed_leveling_enabled(false);
  774. EEPROM_READ(bilinear_grid_spacing); // 2 ints
  775. EEPROM_READ(bilinear_start); // 2 ints
  776. EEPROM_READ(z_values); // 9 to 256 floats
  777. }
  778. else // EEPROM data is stale
  779. #endif // AUTO_BED_LEVELING_BILINEAR
  780. {
  781. // Skip past disabled (or stale) Bilinear Grid data
  782. int bgs[2], bs[2];
  783. EEPROM_READ(bgs);
  784. EEPROM_READ(bs);
  785. for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummy);
  786. }
  787. //
  788. // Unified Bed Leveling active state
  789. //
  790. #if ENABLED(AUTO_BED_LEVELING_UBL)
  791. EEPROM_READ(planner.leveling_active);
  792. EEPROM_READ(ubl.storage_slot);
  793. #else
  794. uint8_t dummyui8;
  795. EEPROM_READ(dummyb);
  796. EEPROM_READ(dummyui8);
  797. #endif // AUTO_BED_LEVELING_UBL
  798. //
  799. // DELTA Geometry or Dual Endstops offsets
  800. //
  801. #if ENABLED(DELTA)
  802. EEPROM_READ(delta_height); // 1 float
  803. EEPROM_READ(delta_endstop_adj); // 3 floats
  804. EEPROM_READ(delta_radius); // 1 float
  805. EEPROM_READ(delta_diagonal_rod); // 1 float
  806. EEPROM_READ(delta_segments_per_second); // 1 float
  807. EEPROM_READ(delta_calibration_radius); // 1 float
  808. EEPROM_READ(delta_tower_angle_trim); // 3 floats
  809. #elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
  810. #if ENABLED(X_DUAL_ENDSTOPS)
  811. EEPROM_READ(endstops.x_endstop_adj); // 1 float
  812. #else
  813. EEPROM_READ(dummy);
  814. #endif
  815. #if ENABLED(Y_DUAL_ENDSTOPS)
  816. EEPROM_READ(endstops.y_endstop_adj); // 1 float
  817. #else
  818. EEPROM_READ(dummy);
  819. #endif
  820. #if ENABLED(Z_DUAL_ENDSTOPS)
  821. EEPROM_READ(endstops.z_endstop_adj); // 1 float
  822. #else
  823. EEPROM_READ(dummy);
  824. #endif
  825. for (uint8_t q=8; q--;) EEPROM_READ(dummy);
  826. #else
  827. for (uint8_t q=11; q--;) EEPROM_READ(dummy);
  828. #endif
  829. //
  830. // LCD Preheat settings
  831. //
  832. #if DISABLED(ULTIPANEL)
  833. int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
  834. #endif
  835. EEPROM_READ(lcd_preheat_hotend_temp); // 2 floats
  836. EEPROM_READ(lcd_preheat_bed_temp); // 2 floats
  837. EEPROM_READ(lcd_preheat_fan_speed); // 2 floats
  838. //EEPROM_ASSERT(
  839. // WITHIN(lcd_preheat_fan_speed, 0, 255),
  840. // "lcd_preheat_fan_speed out of range"
  841. //);
  842. //
  843. // Hotend PID
  844. //
  845. #if ENABLED(PIDTEMP)
  846. for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
  847. EEPROM_READ(dummy); // Kp
  848. if (e < HOTENDS && dummy != DUMMY_PID_VALUE) {
  849. // do not need to scale PID values as the values in EEPROM are already scaled
  850. PID_PARAM(Kp, e) = dummy;
  851. EEPROM_READ(PID_PARAM(Ki, e));
  852. EEPROM_READ(PID_PARAM(Kd, e));
  853. #if ENABLED(PID_EXTRUSION_SCALING)
  854. EEPROM_READ(PID_PARAM(Kc, e));
  855. #else
  856. EEPROM_READ(dummy);
  857. #endif
  858. }
  859. else {
  860. for (uint8_t q=3; q--;) EEPROM_READ(dummy); // Ki, Kd, Kc
  861. }
  862. }
  863. #else // !PIDTEMP
  864. // 4 x 4 = 16 slots for PID parameters
  865. for (uint8_t q = MAX_EXTRUDERS * 4; q--;) EEPROM_READ(dummy); // Kp, Ki, Kd, Kc
  866. #endif // !PIDTEMP
  867. //
  868. // PID Extrusion Scaling
  869. //
  870. #if DISABLED(PID_EXTRUSION_SCALING)
  871. int lpq_len;
  872. #endif
  873. EEPROM_READ(lpq_len);
  874. //
  875. // Heated Bed PID
  876. //
  877. #if ENABLED(PIDTEMPBED)
  878. EEPROM_READ(dummy); // bedKp
  879. if (dummy != DUMMY_PID_VALUE) {
  880. thermalManager.bedKp = dummy;
  881. EEPROM_READ(thermalManager.bedKi);
  882. EEPROM_READ(thermalManager.bedKd);
  883. }
  884. #else
  885. for (uint8_t q=3; q--;) EEPROM_READ(dummy); // bedKp, bedKi, bedKd
  886. #endif
  887. //
  888. // LCD Contrast
  889. //
  890. #if !HAS_LCD_CONTRAST
  891. uint16_t lcd_contrast;
  892. #endif
  893. EEPROM_READ(lcd_contrast);
  894. //
  895. // Firmware Retraction
  896. //
  897. #if ENABLED(FWRETRACT)
  898. EEPROM_READ(fwretract.autoretract_enabled);
  899. EEPROM_READ(fwretract.retract_length);
  900. EEPROM_READ(fwretract.retract_feedrate_mm_s);
  901. EEPROM_READ(fwretract.retract_zlift);
  902. EEPROM_READ(fwretract.retract_recover_length);
  903. EEPROM_READ(fwretract.retract_recover_feedrate_mm_s);
  904. EEPROM_READ(fwretract.swap_retract_length);
  905. EEPROM_READ(fwretract.swap_retract_recover_length);
  906. EEPROM_READ(fwretract.swap_retract_recover_feedrate_mm_s);
  907. #else
  908. EEPROM_READ(dummyb);
  909. for (uint8_t q=8; q--;) EEPROM_READ(dummy);
  910. #endif
  911. //
  912. // Volumetric & Filament Size
  913. //
  914. #if DISABLED(NO_VOLUMETRICS)
  915. EEPROM_READ(parser.volumetric_enabled);
  916. for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
  917. EEPROM_READ(dummy);
  918. if (q < COUNT(planner.filament_size)) planner.filament_size[q] = dummy;
  919. }
  920. #endif
  921. //
  922. // TMC2130 Stepper Current
  923. //
  924. uint16_t val;
  925. #if HAS_TRINAMIC
  926. EEPROM_READ(val);
  927. #if X_IS_TRINAMIC
  928. stepperX.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  929. #endif
  930. EEPROM_READ(val);
  931. #if Y_IS_TRINAMIC
  932. stepperY.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  933. #endif
  934. EEPROM_READ(val);
  935. #if Z_IS_TRINAMIC
  936. stepperZ.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  937. #endif
  938. EEPROM_READ(val);
  939. #if X2_IS_TRINAMIC
  940. stepperX2.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  941. #endif
  942. EEPROM_READ(val);
  943. #if Y2_IS_TRINAMIC
  944. stepperY2.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  945. #endif
  946. EEPROM_READ(val);
  947. #if Z2_IS_TRINAMIC
  948. stepperZ2.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  949. #endif
  950. EEPROM_READ(val);
  951. #if E0_IS_TRINAMIC
  952. stepperE0.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  953. #endif
  954. EEPROM_READ(val);
  955. #if E1_IS_TRINAMIC
  956. stepperE1.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  957. #endif
  958. EEPROM_READ(val);
  959. #if E2_IS_TRINAMIC
  960. stepperE2.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  961. #endif
  962. EEPROM_READ(val);
  963. #if E3_IS_TRINAMIC
  964. stepperE3.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  965. #endif
  966. EEPROM_READ(val);
  967. #if E4_IS_TRINAMIC
  968. stepperE4.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  969. #endif
  970. #else
  971. for (uint8_t q = 11; q--;) EEPROM_READ(val);
  972. #endif
  973. /*
  974. * TMC2130 Sensorless homing threshold.
  975. * X and X2 use the same value
  976. * Y and Y2 use the same value
  977. */
  978. int16_t thrs;
  979. #if ENABLED(SENSORLESS_HOMING)
  980. EEPROM_READ(thrs);
  981. #if ENABLED(X_IS_TMC2130)
  982. stepperX.sgt(thrs);
  983. #endif
  984. #if ENABLED(X2_IS_TMC2130)
  985. stepperX2.sgt(thrs);
  986. #endif
  987. EEPROM_READ(thrs);
  988. #if ENABLED(Y_IS_TMC2130)
  989. stepperY.sgt(thrs);
  990. #endif
  991. #if ENABLED(Y2_IS_TMC2130)
  992. stepperY2.sgt(thrs);
  993. #endif
  994. #else
  995. for (uint8_t q = 0; q < 2; q++) EEPROM_READ(thrs);
  996. #endif
  997. //
  998. // Linear Advance
  999. //
  1000. #if ENABLED(LIN_ADVANCE)
  1001. EEPROM_READ(planner.extruder_advance_k);
  1002. EEPROM_READ(planner.advance_ed_ratio);
  1003. #else
  1004. EEPROM_READ(dummy);
  1005. EEPROM_READ(dummy);
  1006. #endif
  1007. //
  1008. // Motor Current PWM
  1009. //
  1010. #if HAS_MOTOR_CURRENT_PWM
  1011. for (uint8_t q = 3; q--;) EEPROM_READ(stepper.motor_current_setting[q]);
  1012. #else
  1013. uint32_t dummyui32;
  1014. for (uint8_t q = 3; q--;) EEPROM_READ(dummyui32);
  1015. #endif
  1016. //
  1017. // CNC Coordinate System
  1018. //
  1019. #if ENABLED(CNC_COORDINATE_SYSTEMS)
  1020. (void)gcode.select_coordinate_system(-1); // Go back to machine space
  1021. EEPROM_READ(gcode.coordinate_system); // 27 floats
  1022. #else
  1023. for (uint8_t q = 27; q--;) EEPROM_READ(dummy);
  1024. #endif
  1025. //
  1026. // Skew correction factors
  1027. //
  1028. #if ENABLED(SKEW_CORRECTION_GCODE)
  1029. EEPROM_READ(planner.xy_skew_factor);
  1030. #if ENABLED(SKEW_CORRECTION_FOR_Z)
  1031. EEPROM_READ(planner.xz_skew_factor);
  1032. EEPROM_READ(planner.yz_skew_factor);
  1033. #else
  1034. EEPROM_READ(dummy);
  1035. EEPROM_READ(dummy);
  1036. #endif
  1037. #else
  1038. for (uint8_t q = 3; q--;) EEPROM_READ(dummy);
  1039. #endif
  1040. if (working_crc == stored_crc) {
  1041. postprocess();
  1042. #if ENABLED(EEPROM_CHITCHAT)
  1043. SERIAL_ECHO_START();
  1044. SERIAL_ECHO(version);
  1045. SERIAL_ECHOPAIR(" stored settings retrieved (", eeprom_index - (EEPROM_OFFSET));
  1046. SERIAL_ECHOPAIR(" bytes; crc ", (uint32_t)working_crc);
  1047. SERIAL_ECHOLNPGM(")");
  1048. #endif
  1049. }
  1050. else {
  1051. #if ENABLED(EEPROM_CHITCHAT)
  1052. SERIAL_ERROR_START();
  1053. SERIAL_ERRORPGM("EEPROM CRC mismatch - (stored) ");
  1054. SERIAL_ERROR(stored_crc);
  1055. SERIAL_ERRORPGM(" != ");
  1056. SERIAL_ERROR(working_crc);
  1057. SERIAL_ERRORLNPGM(" (calculated)!");
  1058. #endif
  1059. reset();
  1060. }
  1061. #if ENABLED(AUTO_BED_LEVELING_UBL)
  1062. meshes_begin = (eeprom_index + 32) & 0xFFF8; // Pad the end of configuration data so it
  1063. // can float up or down a little bit without
  1064. // disrupting the mesh data
  1065. ubl.report_state();
  1066. if (!ubl.sanity_check()) {
  1067. SERIAL_EOL();
  1068. #if ENABLED(EEPROM_CHITCHAT)
  1069. ubl.echo_name();
  1070. SERIAL_ECHOLNPGM(" initialized.\n");
  1071. #endif
  1072. }
  1073. else {
  1074. #if ENABLED(EEPROM_CHITCHAT)
  1075. SERIAL_PROTOCOLPGM("?Can't enable ");
  1076. ubl.echo_name();
  1077. SERIAL_PROTOCOLLNPGM(".");
  1078. #endif
  1079. ubl.reset();
  1080. }
  1081. if (ubl.storage_slot >= 0) {
  1082. load_mesh(ubl.storage_slot);
  1083. #if ENABLED(EEPROM_CHITCHAT)
  1084. SERIAL_ECHOPAIR("Mesh ", ubl.storage_slot);
  1085. SERIAL_ECHOLNPGM(" loaded from storage.");
  1086. #endif
  1087. }
  1088. else {
  1089. ubl.reset();
  1090. #if ENABLED(EEPROM_CHITCHAT)
  1091. SERIAL_ECHOLNPGM("UBL System reset()");
  1092. #endif
  1093. }
  1094. #endif
  1095. }
  1096. #if ENABLED(EEPROM_CHITCHAT) && DISABLED(DISABLE_M503)
  1097. report();
  1098. #endif
  1099. EEPROM_FINISH();
  1100. return !eeprom_error;
  1101. }
  1102. #if ENABLED(AUTO_BED_LEVELING_UBL)
  1103. #if ENABLED(EEPROM_CHITCHAT)
  1104. void ubl_invalid_slot(const int s) {
  1105. SERIAL_PROTOCOLLNPGM("?Invalid slot.");
  1106. SERIAL_PROTOCOL(s);
  1107. SERIAL_PROTOCOLLNPGM(" mesh slots available.");
  1108. }
  1109. #endif
  1110. uint16_t MarlinSettings::calc_num_meshes() {
  1111. //obviously this will get more sophisticated once we've added an actual MAT
  1112. if (meshes_begin <= 0) return 0;
  1113. return (meshes_end - meshes_begin) / sizeof(ubl.z_values);
  1114. }
  1115. void MarlinSettings::store_mesh(const int8_t slot) {
  1116. #if ENABLED(AUTO_BED_LEVELING_UBL)
  1117. const int16_t a = calc_num_meshes();
  1118. if (!WITHIN(slot, 0, a - 1)) {
  1119. #if ENABLED(EEPROM_CHITCHAT)
  1120. ubl_invalid_slot(a);
  1121. SERIAL_PROTOCOLPAIR("E2END=", E2END);
  1122. SERIAL_PROTOCOLPAIR(" meshes_end=", meshes_end);
  1123. SERIAL_PROTOCOLLNPAIR(" slot=", slot);
  1124. SERIAL_EOL();
  1125. #endif
  1126. return;
  1127. }
  1128. uint16_t crc = 0;
  1129. int pos = meshes_end - (slot + 1) * sizeof(ubl.z_values);
  1130. HAL::PersistentStore::access_start();
  1131. const bool status = HAL::PersistentStore::write_data(pos, (uint8_t *)&ubl.z_values, sizeof(ubl.z_values), &crc);
  1132. HAL::PersistentStore::access_finish();
  1133. if (status)
  1134. SERIAL_PROTOCOL("?Unable to save mesh data.\n");
  1135. // Write crc to MAT along with other data, or just tack on to the beginning or end
  1136. #if ENABLED(EEPROM_CHITCHAT)
  1137. if (!status)
  1138. SERIAL_PROTOCOLLNPAIR("Mesh saved in slot ", slot);
  1139. #endif
  1140. #else
  1141. // Other mesh types
  1142. #endif
  1143. }
  1144. void MarlinSettings::load_mesh(const int8_t slot, void * const into/*=NULL*/) {
  1145. #if ENABLED(AUTO_BED_LEVELING_UBL)
  1146. const int16_t a = settings.calc_num_meshes();
  1147. if (!WITHIN(slot, 0, a - 1)) {
  1148. #if ENABLED(EEPROM_CHITCHAT)
  1149. ubl_invalid_slot(a);
  1150. #endif
  1151. return;
  1152. }
  1153. uint16_t crc = 0;
  1154. int pos = meshes_end - (slot + 1) * sizeof(ubl.z_values);
  1155. uint8_t * const dest = into ? (uint8_t*)into : (uint8_t*)&ubl.z_values;
  1156. HAL::PersistentStore::access_start();
  1157. const uint16_t status = HAL::PersistentStore::read_data(pos, dest, sizeof(ubl.z_values), &crc);
  1158. HAL::PersistentStore::access_finish();
  1159. if (status)
  1160. SERIAL_PROTOCOL("?Unable to load mesh data.\n");
  1161. #if ENABLED(EEPROM_CHITCHAT)
  1162. else
  1163. SERIAL_PROTOCOLLNPAIR("Mesh loaded from slot ", slot);
  1164. #endif
  1165. EEPROM_FINISH();
  1166. #else
  1167. // Other mesh types
  1168. #endif
  1169. }
  1170. //void MarlinSettings::delete_mesh() { return; }
  1171. //void MarlinSettings::defrag_meshes() { return; }
  1172. #endif // AUTO_BED_LEVELING_UBL
  1173. #else // !EEPROM_SETTINGS
  1174. bool MarlinSettings::save() {
  1175. SERIAL_ERROR_START();
  1176. SERIAL_ERRORLNPGM("EEPROM disabled");
  1177. return false;
  1178. }
  1179. #endif // !EEPROM_SETTINGS
  1180. /**
  1181. * M502 - Reset Configuration
  1182. */
  1183. void MarlinSettings::reset() {
  1184. static const float tmp1[] PROGMEM = DEFAULT_AXIS_STEPS_PER_UNIT, tmp2[] PROGMEM = DEFAULT_MAX_FEEDRATE;
  1185. static const uint32_t tmp3[] PROGMEM = DEFAULT_MAX_ACCELERATION;
  1186. LOOP_XYZE_N(i) {
  1187. planner.axis_steps_per_mm[i] = pgm_read_float(&tmp1[i < COUNT(tmp1) ? i : COUNT(tmp1) - 1]);
  1188. planner.max_feedrate_mm_s[i] = pgm_read_float(&tmp2[i < COUNT(tmp2) ? i : COUNT(tmp2) - 1]);
  1189. planner.max_acceleration_mm_per_s2[i] = pgm_read_dword_near(&tmp3[i < COUNT(tmp3) ? i : COUNT(tmp3) - 1]);
  1190. }
  1191. planner.acceleration = DEFAULT_ACCELERATION;
  1192. planner.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
  1193. planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
  1194. planner.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE;
  1195. planner.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
  1196. planner.min_segment_time_us = DEFAULT_MINSEGMENTTIME;
  1197. planner.max_jerk[X_AXIS] = DEFAULT_XJERK;
  1198. planner.max_jerk[Y_AXIS] = DEFAULT_YJERK;
  1199. planner.max_jerk[Z_AXIS] = DEFAULT_ZJERK;
  1200. planner.max_jerk[E_AXIS] = DEFAULT_EJERK;
  1201. #if HAS_HOME_OFFSET
  1202. ZERO(home_offset);
  1203. #endif
  1204. #if HOTENDS > 1
  1205. constexpr float tmp4[XYZ][HOTENDS] = {
  1206. HOTEND_OFFSET_X,
  1207. HOTEND_OFFSET_Y
  1208. #ifdef HOTEND_OFFSET_Z
  1209. , HOTEND_OFFSET_Z
  1210. #else
  1211. , { 0 }
  1212. #endif
  1213. };
  1214. static_assert(
  1215. tmp4[X_AXIS][0] == 0 && tmp4[Y_AXIS][0] == 0 && tmp4[Z_AXIS][0] == 0,
  1216. "Offsets for the first hotend must be 0.0."
  1217. );
  1218. LOOP_XYZ(i) HOTEND_LOOP() hotend_offset[i][e] = tmp4[i][e];
  1219. #endif
  1220. //
  1221. // Global Leveling
  1222. //
  1223. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  1224. new_z_fade_height = 0.0;
  1225. #endif
  1226. #if HAS_LEVELING
  1227. reset_bed_level();
  1228. #endif
  1229. #if HAS_BED_PROBE
  1230. zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
  1231. #endif
  1232. #if ENABLED(DELTA)
  1233. const float adj[ABC] = DELTA_ENDSTOP_ADJ,
  1234. dta[ABC] = DELTA_TOWER_ANGLE_TRIM;
  1235. delta_height = DELTA_HEIGHT;
  1236. COPY(delta_endstop_adj, adj);
  1237. delta_radius = DELTA_RADIUS;
  1238. delta_diagonal_rod = DELTA_DIAGONAL_ROD;
  1239. delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
  1240. delta_calibration_radius = DELTA_CALIBRATION_RADIUS;
  1241. COPY(delta_tower_angle_trim, dta);
  1242. #elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
  1243. #if ENABLED(X_DUAL_ENDSTOPS)
  1244. endstops.x_endstop_adj = (
  1245. #ifdef X_DUAL_ENDSTOPS_ADJUSTMENT
  1246. X_DUAL_ENDSTOPS_ADJUSTMENT
  1247. #else
  1248. 0
  1249. #endif
  1250. );
  1251. #endif
  1252. #if ENABLED(Y_DUAL_ENDSTOPS)
  1253. endstops.y_endstop_adj = (
  1254. #ifdef Y_DUAL_ENDSTOPS_ADJUSTMENT
  1255. Y_DUAL_ENDSTOPS_ADJUSTMENT
  1256. #else
  1257. 0
  1258. #endif
  1259. );
  1260. #endif
  1261. #if ENABLED(Z_DUAL_ENDSTOPS)
  1262. endstops.z_endstop_adj = (
  1263. #ifdef Z_DUAL_ENDSTOPS_ADJUSTMENT
  1264. Z_DUAL_ENDSTOPS_ADJUSTMENT
  1265. #else
  1266. 0
  1267. #endif
  1268. );
  1269. #endif
  1270. #endif
  1271. #if ENABLED(ULTIPANEL)
  1272. lcd_preheat_hotend_temp[0] = PREHEAT_1_TEMP_HOTEND;
  1273. lcd_preheat_hotend_temp[1] = PREHEAT_2_TEMP_HOTEND;
  1274. lcd_preheat_bed_temp[0] = PREHEAT_1_TEMP_BED;
  1275. lcd_preheat_bed_temp[1] = PREHEAT_2_TEMP_BED;
  1276. lcd_preheat_fan_speed[0] = PREHEAT_1_FAN_SPEED;
  1277. lcd_preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
  1278. #endif
  1279. #if ENABLED(PIDTEMP)
  1280. #if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
  1281. HOTEND_LOOP()
  1282. #endif
  1283. {
  1284. PID_PARAM(Kp, e) = DEFAULT_Kp;
  1285. PID_PARAM(Ki, e) = scalePID_i(DEFAULT_Ki);
  1286. PID_PARAM(Kd, e) = scalePID_d(DEFAULT_Kd);
  1287. #if ENABLED(PID_EXTRUSION_SCALING)
  1288. PID_PARAM(Kc, e) = DEFAULT_Kc;
  1289. #endif
  1290. }
  1291. #if ENABLED(PID_EXTRUSION_SCALING)
  1292. lpq_len = 20; // default last-position-queue size
  1293. #endif
  1294. #endif // PIDTEMP
  1295. #if ENABLED(PIDTEMPBED)
  1296. thermalManager.bedKp = DEFAULT_bedKp;
  1297. thermalManager.bedKi = scalePID_i(DEFAULT_bedKi);
  1298. thermalManager.bedKd = scalePID_d(DEFAULT_bedKd);
  1299. #endif
  1300. #if HAS_LCD_CONTRAST
  1301. lcd_contrast = DEFAULT_LCD_CONTRAST;
  1302. #endif
  1303. #if ENABLED(FWRETRACT)
  1304. fwretract.reset();
  1305. #endif
  1306. #if DISABLED(NO_VOLUMETRICS)
  1307. parser.volumetric_enabled =
  1308. #if ENABLED(VOLUMETRIC_DEFAULT_ON)
  1309. true
  1310. #else
  1311. false
  1312. #endif
  1313. ;
  1314. for (uint8_t q = 0; q < COUNT(planner.filament_size); q++)
  1315. planner.filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
  1316. #endif
  1317. endstops.enable_globally(
  1318. #if ENABLED(ENDSTOPS_ALWAYS_ON_DEFAULT)
  1319. true
  1320. #else
  1321. false
  1322. #endif
  1323. );
  1324. #if X_IS_TRINAMIC
  1325. stepperX.setCurrent(X_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  1326. #endif
  1327. #if Y_IS_TRINAMIC
  1328. stepperY.setCurrent(Y_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  1329. #endif
  1330. #if Z_IS_TRINAMIC
  1331. stepperZ.setCurrent(Z_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  1332. #endif
  1333. #if X2_IS_TRINAMIC
  1334. stepperX2.setCurrent(X2_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  1335. #endif
  1336. #if Y2_IS_TRINAMIC
  1337. stepperY2.setCurrent(Y2_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  1338. #endif
  1339. #if Z2_IS_TRINAMIC
  1340. stepperZ2.setCurrent(Z2_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  1341. #endif
  1342. #if E0_IS_TRINAMIC
  1343. stepperE0.setCurrent(E0_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  1344. #endif
  1345. #if E1_IS_TRINAMIC
  1346. stepperE1.setCurrent(E1_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  1347. #endif
  1348. #if E2_IS_TRINAMIC
  1349. stepperE2.setCurrent(E2_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  1350. #endif
  1351. #if E3_IS_TRINAMIC
  1352. stepperE3.setCurrent(E3_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  1353. #endif
  1354. #if E4_IS_TRINAMIC
  1355. stepperE4.setCurrent(E4_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  1356. #endif
  1357. #if ENABLED(SENSORLESS_HOMING)
  1358. #if ENABLED(X_IS_TMC2130)
  1359. stepperX.sgt(X_HOMING_SENSITIVITY);
  1360. #endif
  1361. #if ENABLED(X2_IS_TMC2130)
  1362. stepperX2.sgt(X_HOMING_SENSITIVITY);
  1363. #endif
  1364. #if ENABLED(Y_IS_TMC2130)
  1365. stepperY.sgt(Y_HOMING_SENSITIVITY);
  1366. #endif
  1367. #if ENABLED(Y2_IS_TMC2130)
  1368. stepperY2.sgt(Y_HOMING_SENSITIVITY);
  1369. #endif
  1370. #endif
  1371. #if ENABLED(LIN_ADVANCE)
  1372. planner.extruder_advance_k = LIN_ADVANCE_K;
  1373. planner.advance_ed_ratio = LIN_ADVANCE_E_D_RATIO;
  1374. #endif
  1375. #if HAS_MOTOR_CURRENT_PWM
  1376. uint32_t tmp_motor_current_setting[3] = PWM_MOTOR_CURRENT;
  1377. for (uint8_t q = 3; q--;)
  1378. stepper.digipot_current(q, (stepper.motor_current_setting[q] = tmp_motor_current_setting[q]));
  1379. #endif
  1380. #if ENABLED(SKEW_CORRECTION_GCODE)
  1381. planner.xy_skew_factor = XY_SKEW_FACTOR;
  1382. #if ENABLED(SKEW_CORRECTION_FOR_Z)
  1383. planner.xz_skew_factor = XZ_SKEW_FACTOR;
  1384. planner.yz_skew_factor = YZ_SKEW_FACTOR;
  1385. #endif
  1386. #endif
  1387. postprocess();
  1388. #if ENABLED(EEPROM_CHITCHAT)
  1389. SERIAL_ECHO_START();
  1390. SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
  1391. #endif
  1392. }
  1393. #if DISABLED(DISABLE_M503)
  1394. #define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START(); }while(0)
  1395. /**
  1396. * M503 - Report current settings in RAM
  1397. *
  1398. * Unless specifically disabled, M503 is available even without EEPROM
  1399. */
  1400. void MarlinSettings::report(const bool forReplay) {
  1401. /**
  1402. * Announce current units, in case inches are being displayed
  1403. */
  1404. CONFIG_ECHO_START;
  1405. #if ENABLED(INCH_MODE_SUPPORT)
  1406. #define LINEAR_UNIT(N) (float(N) / parser.linear_unit_factor)
  1407. #define VOLUMETRIC_UNIT(N) (float(N) / (parser.volumetric_enabled ? parser.volumetric_unit_factor : parser.linear_unit_factor))
  1408. SERIAL_ECHOPGM(" G2");
  1409. SERIAL_CHAR(parser.linear_unit_factor == 1.0 ? '1' : '0');
  1410. SERIAL_ECHOPGM(" ; Units in ");
  1411. serialprintPGM(parser.linear_unit_factor == 1.0 ? PSTR("mm\n") : PSTR("inches\n"));
  1412. #else
  1413. #define LINEAR_UNIT(N) (N)
  1414. #define VOLUMETRIC_UNIT(N) (N)
  1415. SERIAL_ECHOLNPGM(" G21 ; Units in mm");
  1416. #endif
  1417. #if ENABLED(ULTIPANEL)
  1418. // Temperature units - for Ultipanel temperature options
  1419. CONFIG_ECHO_START;
  1420. #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
  1421. #define TEMP_UNIT(N) parser.to_temp_units(N)
  1422. SERIAL_ECHOPGM(" M149 ");
  1423. SERIAL_CHAR(parser.temp_units_code());
  1424. SERIAL_ECHOPGM(" ; Units in ");
  1425. serialprintPGM(parser.temp_units_name());
  1426. #else
  1427. #define TEMP_UNIT(N) (N)
  1428. SERIAL_ECHOLNPGM(" M149 C ; Units in Celsius");
  1429. #endif
  1430. #endif
  1431. SERIAL_EOL();
  1432. #if DISABLED(NO_VOLUMETRICS)
  1433. /**
  1434. * Volumetric extrusion M200
  1435. */
  1436. if (!forReplay) {
  1437. CONFIG_ECHO_START;
  1438. SERIAL_ECHOPGM("Filament settings:");
  1439. if (parser.volumetric_enabled)
  1440. SERIAL_EOL();
  1441. else
  1442. SERIAL_ECHOLNPGM(" Disabled");
  1443. }
  1444. CONFIG_ECHO_START;
  1445. SERIAL_ECHOPAIR(" M200 D", LINEAR_UNIT(planner.filament_size[0]));
  1446. SERIAL_EOL();
  1447. #if EXTRUDERS > 1
  1448. CONFIG_ECHO_START;
  1449. SERIAL_ECHOPAIR(" M200 T1 D", LINEAR_UNIT(planner.filament_size[1]));
  1450. SERIAL_EOL();
  1451. #if EXTRUDERS > 2
  1452. CONFIG_ECHO_START;
  1453. SERIAL_ECHOPAIR(" M200 T2 D", LINEAR_UNIT(planner.filament_size[2]));
  1454. SERIAL_EOL();
  1455. #if EXTRUDERS > 3
  1456. CONFIG_ECHO_START;
  1457. SERIAL_ECHOPAIR(" M200 T3 D", LINEAR_UNIT(planner.filament_size[3]));
  1458. SERIAL_EOL();
  1459. #if EXTRUDERS > 4
  1460. CONFIG_ECHO_START;
  1461. SERIAL_ECHOPAIR(" M200 T4 D", LINEAR_UNIT(planner.filament_size[4]));
  1462. SERIAL_EOL();
  1463. #endif // EXTRUDERS > 4
  1464. #endif // EXTRUDERS > 3
  1465. #endif // EXTRUDERS > 2
  1466. #endif // EXTRUDERS > 1
  1467. if (!parser.volumetric_enabled) {
  1468. CONFIG_ECHO_START;
  1469. SERIAL_ECHOLNPGM(" M200 D0");
  1470. }
  1471. #endif // !NO_VOLUMETRICS
  1472. if (!forReplay) {
  1473. CONFIG_ECHO_START;
  1474. SERIAL_ECHOLNPGM("Steps per unit:");
  1475. }
  1476. CONFIG_ECHO_START;
  1477. SERIAL_ECHOPAIR(" M92 X", LINEAR_UNIT(planner.axis_steps_per_mm[X_AXIS]));
  1478. SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(planner.axis_steps_per_mm[Y_AXIS]));
  1479. SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.axis_steps_per_mm[Z_AXIS]));
  1480. #if DISABLED(DISTINCT_E_FACTORS)
  1481. SERIAL_ECHOPAIR(" E", VOLUMETRIC_UNIT(planner.axis_steps_per_mm[E_AXIS]));
  1482. #endif
  1483. SERIAL_EOL();
  1484. #if ENABLED(DISTINCT_E_FACTORS)
  1485. CONFIG_ECHO_START;
  1486. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  1487. SERIAL_ECHOPAIR(" M92 T", (int)i);
  1488. SERIAL_ECHOLNPAIR(" E", VOLUMETRIC_UNIT(planner.axis_steps_per_mm[E_AXIS + i]));
  1489. }
  1490. #endif
  1491. if (!forReplay) {
  1492. CONFIG_ECHO_START;
  1493. SERIAL_ECHOLNPGM("Maximum feedrates (units/s):");
  1494. }
  1495. CONFIG_ECHO_START;
  1496. SERIAL_ECHOPAIR(" M203 X", LINEAR_UNIT(planner.max_feedrate_mm_s[X_AXIS]));
  1497. SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(planner.max_feedrate_mm_s[Y_AXIS]));
  1498. SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.max_feedrate_mm_s[Z_AXIS]));
  1499. #if DISABLED(DISTINCT_E_FACTORS)
  1500. SERIAL_ECHOPAIR(" E", VOLUMETRIC_UNIT(planner.max_feedrate_mm_s[E_AXIS]));
  1501. #endif
  1502. SERIAL_EOL();
  1503. #if ENABLED(DISTINCT_E_FACTORS)
  1504. CONFIG_ECHO_START;
  1505. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  1506. SERIAL_ECHOPAIR(" M203 T", (int)i);
  1507. SERIAL_ECHOLNPAIR(" E", VOLUMETRIC_UNIT(planner.max_feedrate_mm_s[E_AXIS + i]));
  1508. }
  1509. #endif
  1510. if (!forReplay) {
  1511. CONFIG_ECHO_START;
  1512. SERIAL_ECHOLNPGM("Maximum Acceleration (units/s2):");
  1513. }
  1514. CONFIG_ECHO_START;
  1515. SERIAL_ECHOPAIR(" M201 X", LINEAR_UNIT(planner.max_acceleration_mm_per_s2[X_AXIS]));
  1516. SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(planner.max_acceleration_mm_per_s2[Y_AXIS]));
  1517. SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.max_acceleration_mm_per_s2[Z_AXIS]));
  1518. #if DISABLED(DISTINCT_E_FACTORS)
  1519. SERIAL_ECHOPAIR(" E", VOLUMETRIC_UNIT(planner.max_acceleration_mm_per_s2[E_AXIS]));
  1520. #endif
  1521. SERIAL_EOL();
  1522. #if ENABLED(DISTINCT_E_FACTORS)
  1523. CONFIG_ECHO_START;
  1524. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  1525. SERIAL_ECHOPAIR(" M201 T", (int)i);
  1526. SERIAL_ECHOLNPAIR(" E", VOLUMETRIC_UNIT(planner.max_acceleration_mm_per_s2[E_AXIS + i]));
  1527. }
  1528. #endif
  1529. if (!forReplay) {
  1530. CONFIG_ECHO_START;
  1531. SERIAL_ECHOLNPGM("Acceleration (units/s2): P<print_accel> R<retract_accel> T<travel_accel>");
  1532. }
  1533. CONFIG_ECHO_START;
  1534. SERIAL_ECHOPAIR(" M204 P", LINEAR_UNIT(planner.acceleration));
  1535. SERIAL_ECHOPAIR(" R", LINEAR_UNIT(planner.retract_acceleration));
  1536. SERIAL_ECHOLNPAIR(" T", LINEAR_UNIT(planner.travel_acceleration));
  1537. if (!forReplay) {
  1538. CONFIG_ECHO_START;
  1539. SERIAL_ECHOLNPGM("Advanced: S<min_feedrate> T<min_travel_feedrate> B<min_segment_time_us> X<max_xy_jerk> Z<max_z_jerk> E<max_e_jerk>");
  1540. }
  1541. CONFIG_ECHO_START;
  1542. SERIAL_ECHOPAIR(" M205 S", LINEAR_UNIT(planner.min_feedrate_mm_s));
  1543. SERIAL_ECHOPAIR(" T", LINEAR_UNIT(planner.min_travel_feedrate_mm_s));
  1544. SERIAL_ECHOPAIR(" B", planner.min_segment_time_us);
  1545. SERIAL_ECHOPAIR(" X", LINEAR_UNIT(planner.max_jerk[X_AXIS]));
  1546. SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(planner.max_jerk[Y_AXIS]));
  1547. SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.max_jerk[Z_AXIS]));
  1548. SERIAL_ECHOLNPAIR(" E", LINEAR_UNIT(planner.max_jerk[E_AXIS]));
  1549. #if HAS_M206_COMMAND
  1550. if (!forReplay) {
  1551. CONFIG_ECHO_START;
  1552. SERIAL_ECHOLNPGM("Home offset:");
  1553. }
  1554. CONFIG_ECHO_START;
  1555. SERIAL_ECHOPAIR(" M206 X", LINEAR_UNIT(home_offset[X_AXIS]));
  1556. SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(home_offset[Y_AXIS]));
  1557. SERIAL_ECHOLNPAIR(" Z", LINEAR_UNIT(home_offset[Z_AXIS]));
  1558. #endif
  1559. #if HOTENDS > 1
  1560. if (!forReplay) {
  1561. CONFIG_ECHO_START;
  1562. SERIAL_ECHOLNPGM("Hotend offsets:");
  1563. }
  1564. CONFIG_ECHO_START;
  1565. for (uint8_t e = 1; e < HOTENDS; e++) {
  1566. SERIAL_ECHOPAIR(" M218 T", (int)e);
  1567. SERIAL_ECHOPAIR(" X", LINEAR_UNIT(hotend_offset[X_AXIS][e]));
  1568. SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(hotend_offset[Y_AXIS][e]));
  1569. #if ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_NOZZLE) ||ENABLED(PARKING_EXTRUDER)
  1570. SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(hotend_offset[Z_AXIS][e]));
  1571. #endif
  1572. SERIAL_EOL();
  1573. }
  1574. #endif
  1575. #if ENABLED(MESH_BED_LEVELING)
  1576. if (!forReplay) {
  1577. CONFIG_ECHO_START;
  1578. SERIAL_ECHOLNPGM("Mesh Bed Leveling:");
  1579. }
  1580. CONFIG_ECHO_START;
  1581. SERIAL_ECHOPAIR(" M420 S", leveling_is_valid() ? 1 : 0);
  1582. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  1583. SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.z_fade_height));
  1584. #endif
  1585. SERIAL_EOL();
  1586. for (uint8_t py = 0; py < GRID_MAX_POINTS_Y; py++) {
  1587. for (uint8_t px = 0; px < GRID_MAX_POINTS_X; px++) {
  1588. CONFIG_ECHO_START;
  1589. SERIAL_ECHOPAIR(" G29 S3 X", (int)px + 1);
  1590. SERIAL_ECHOPAIR(" Y", (int)py + 1);
  1591. SERIAL_ECHOPGM(" Z");
  1592. SERIAL_PROTOCOL_F(LINEAR_UNIT(mbl.z_values[px][py]), 5);
  1593. SERIAL_EOL();
  1594. }
  1595. }
  1596. #elif ENABLED(AUTO_BED_LEVELING_UBL)
  1597. if (!forReplay) {
  1598. CONFIG_ECHO_START;
  1599. ubl.echo_name();
  1600. SERIAL_ECHOLNPGM(":");
  1601. }
  1602. CONFIG_ECHO_START;
  1603. SERIAL_ECHOPAIR(" M420 S", planner.leveling_active ? 1 : 0);
  1604. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  1605. SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.z_fade_height));
  1606. #endif
  1607. SERIAL_EOL();
  1608. if (!forReplay) {
  1609. SERIAL_EOL();
  1610. ubl.report_state();
  1611. SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.storage_slot);
  1612. SERIAL_ECHOPAIR("EEPROM can hold ", calc_num_meshes());
  1613. SERIAL_ECHOLNPGM(" meshes.\n");
  1614. }
  1615. #elif HAS_ABL
  1616. if (!forReplay) {
  1617. CONFIG_ECHO_START;
  1618. SERIAL_ECHOLNPGM("Auto Bed Leveling:");
  1619. }
  1620. CONFIG_ECHO_START;
  1621. SERIAL_ECHOPAIR(" M420 S", planner.leveling_active ? 1 : 0);
  1622. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  1623. SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.z_fade_height));
  1624. #endif
  1625. SERIAL_EOL();
  1626. #endif
  1627. #if ENABLED(DELTA)
  1628. if (!forReplay) {
  1629. CONFIG_ECHO_START;
  1630. SERIAL_ECHOLNPGM("Endstop adjustment:");
  1631. }
  1632. CONFIG_ECHO_START;
  1633. SERIAL_ECHOPAIR(" M666 X", LINEAR_UNIT(delta_endstop_adj[X_AXIS]));
  1634. SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(delta_endstop_adj[Y_AXIS]));
  1635. SERIAL_ECHOLNPAIR(" Z", LINEAR_UNIT(delta_endstop_adj[Z_AXIS]));
  1636. if (!forReplay) {
  1637. CONFIG_ECHO_START;
  1638. SERIAL_ECHOLNPGM("Delta settings: L<diagonal_rod> R<radius> H<height> S<segments_per_s> B<calibration radius> XYZ<tower angle corrections>");
  1639. }
  1640. CONFIG_ECHO_START;
  1641. SERIAL_ECHOPAIR(" M665 L", LINEAR_UNIT(delta_diagonal_rod));
  1642. SERIAL_ECHOPAIR(" R", LINEAR_UNIT(delta_radius));
  1643. SERIAL_ECHOPAIR(" H", LINEAR_UNIT(delta_height));
  1644. SERIAL_ECHOPAIR(" S", delta_segments_per_second);
  1645. SERIAL_ECHOPAIR(" B", LINEAR_UNIT(delta_calibration_radius));
  1646. SERIAL_ECHOPAIR(" X", LINEAR_UNIT(delta_tower_angle_trim[A_AXIS]));
  1647. SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(delta_tower_angle_trim[B_AXIS]));
  1648. SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(delta_tower_angle_trim[C_AXIS]));
  1649. SERIAL_EOL();
  1650. #elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
  1651. if (!forReplay) {
  1652. CONFIG_ECHO_START;
  1653. SERIAL_ECHOLNPGM("Endstop adjustment:");
  1654. }
  1655. CONFIG_ECHO_START;
  1656. SERIAL_ECHOPGM(" M666");
  1657. #if ENABLED(X_DUAL_ENDSTOPS)
  1658. SERIAL_ECHOPAIR(" X", LINEAR_UNIT(endstops.x_endstop_adj));
  1659. #endif
  1660. #if ENABLED(Y_DUAL_ENDSTOPS)
  1661. SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(endstops.y_endstop_adj));
  1662. #endif
  1663. #if ENABLED(Z_DUAL_ENDSTOPS)
  1664. SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(endstops.z_endstop_adj));
  1665. #endif
  1666. SERIAL_EOL();
  1667. #endif // DELTA
  1668. #if ENABLED(ULTIPANEL)
  1669. if (!forReplay) {
  1670. CONFIG_ECHO_START;
  1671. SERIAL_ECHOLNPGM("Material heatup parameters:");
  1672. }
  1673. for (uint8_t i = 0; i < COUNT(lcd_preheat_hotend_temp); i++) {
  1674. CONFIG_ECHO_START;
  1675. SERIAL_ECHOPAIR(" M145 S", (int)i);
  1676. SERIAL_ECHOPAIR(" H", TEMP_UNIT(lcd_preheat_hotend_temp[i]));
  1677. SERIAL_ECHOPAIR(" B", TEMP_UNIT(lcd_preheat_bed_temp[i]));
  1678. SERIAL_ECHOLNPAIR(" F", lcd_preheat_fan_speed[i]);
  1679. }
  1680. #endif // ULTIPANEL
  1681. #if HAS_PID_HEATING
  1682. if (!forReplay) {
  1683. CONFIG_ECHO_START;
  1684. SERIAL_ECHOLNPGM("PID settings:");
  1685. }
  1686. #if ENABLED(PIDTEMP)
  1687. #if HOTENDS > 1
  1688. if (forReplay) {
  1689. HOTEND_LOOP() {
  1690. CONFIG_ECHO_START;
  1691. SERIAL_ECHOPAIR(" M301 E", e);
  1692. SERIAL_ECHOPAIR(" P", PID_PARAM(Kp, e));
  1693. SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, e)));
  1694. SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, e)));
  1695. #if ENABLED(PID_EXTRUSION_SCALING)
  1696. SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, e));
  1697. if (e == 0) SERIAL_ECHOPAIR(" L", lpq_len);
  1698. #endif
  1699. SERIAL_EOL();
  1700. }
  1701. }
  1702. else
  1703. #endif // HOTENDS > 1
  1704. // !forReplay || HOTENDS == 1
  1705. {
  1706. CONFIG_ECHO_START;
  1707. SERIAL_ECHOPAIR(" M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echo values for E0
  1708. SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
  1709. SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
  1710. #if ENABLED(PID_EXTRUSION_SCALING)
  1711. SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, 0));
  1712. SERIAL_ECHOPAIR(" L", lpq_len);
  1713. #endif
  1714. SERIAL_EOL();
  1715. }
  1716. #endif // PIDTEMP
  1717. #if ENABLED(PIDTEMPBED)
  1718. CONFIG_ECHO_START;
  1719. SERIAL_ECHOPAIR(" M304 P", thermalManager.bedKp);
  1720. SERIAL_ECHOPAIR(" I", unscalePID_i(thermalManager.bedKi));
  1721. SERIAL_ECHOPAIR(" D", unscalePID_d(thermalManager.bedKd));
  1722. SERIAL_EOL();
  1723. #endif
  1724. #endif // PIDTEMP || PIDTEMPBED
  1725. #if HAS_LCD_CONTRAST
  1726. if (!forReplay) {
  1727. CONFIG_ECHO_START;
  1728. SERIAL_ECHOLNPGM("LCD Contrast:");
  1729. }
  1730. CONFIG_ECHO_START;
  1731. SERIAL_ECHOLNPAIR(" M250 C", lcd_contrast);
  1732. #endif
  1733. #if ENABLED(FWRETRACT)
  1734. if (!forReplay) {
  1735. CONFIG_ECHO_START;
  1736. SERIAL_ECHOLNPGM("Retract: S<length> F<units/m> Z<lift>");
  1737. }
  1738. CONFIG_ECHO_START;
  1739. SERIAL_ECHOPAIR(" M207 S", LINEAR_UNIT(fwretract.retract_length));
  1740. SERIAL_ECHOPAIR(" W", LINEAR_UNIT(fwretract.swap_retract_length));
  1741. SERIAL_ECHOPAIR(" F", MMS_TO_MMM(LINEAR_UNIT(fwretract.retract_feedrate_mm_s)));
  1742. SERIAL_ECHOLNPAIR(" Z", LINEAR_UNIT(fwretract.retract_zlift));
  1743. if (!forReplay) {
  1744. CONFIG_ECHO_START;
  1745. SERIAL_ECHOLNPGM("Recover: S<length> F<units/m>");
  1746. }
  1747. CONFIG_ECHO_START;
  1748. SERIAL_ECHOPAIR(" M208 S", LINEAR_UNIT(fwretract.retract_recover_length));
  1749. SERIAL_ECHOPAIR(" W", LINEAR_UNIT(fwretract.swap_retract_recover_length));
  1750. SERIAL_ECHOLNPAIR(" F", MMS_TO_MMM(LINEAR_UNIT(fwretract.retract_recover_feedrate_mm_s)));
  1751. if (!forReplay) {
  1752. CONFIG_ECHO_START;
  1753. SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret E-only moves as retract/recover");
  1754. }
  1755. CONFIG_ECHO_START;
  1756. SERIAL_ECHOLNPAIR(" M209 S", fwretract.autoretract_enabled ? 1 : 0);
  1757. #endif // FWRETRACT
  1758. /**
  1759. * Probe Offset
  1760. */
  1761. #if HAS_BED_PROBE
  1762. if (!forReplay) {
  1763. CONFIG_ECHO_START;
  1764. SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
  1765. }
  1766. CONFIG_ECHO_START;
  1767. SERIAL_ECHOLNPAIR(" M851 Z", LINEAR_UNIT(zprobe_zoffset));
  1768. #endif
  1769. /**
  1770. * Bed Skew Correction
  1771. */
  1772. #if ENABLED(SKEW_CORRECTION_GCODE)
  1773. if (!forReplay) {
  1774. CONFIG_ECHO_START;
  1775. SERIAL_ECHOLNPGM("Skew Factor: ");
  1776. }
  1777. CONFIG_ECHO_START;
  1778. #if ENABLED(SKEW_CORRECTION_FOR_Z)
  1779. SERIAL_ECHO(" M852 I");
  1780. SERIAL_ECHO_F(LINEAR_UNIT(planner.xy_skew_factor),6);
  1781. SERIAL_ECHOPAIR(" J", LINEAR_UNIT(planner.xz_skew_factor));
  1782. SERIAL_ECHOLNPAIR(" K", LINEAR_UNIT(planner.yz_skew_factor));
  1783. #else
  1784. SERIAL_ECHO(" M852 S");
  1785. SERIAL_ECHO_F(planner.xy_skew_factor, 6);
  1786. SERIAL_ECHO("\n");
  1787. #endif
  1788. #endif
  1789. /**
  1790. * TMC2130 stepper driver current
  1791. */
  1792. #if ENABLED(HAVE_TMC2130)
  1793. if (!forReplay) {
  1794. CONFIG_ECHO_START;
  1795. SERIAL_ECHOLNPGM("Stepper driver current:");
  1796. }
  1797. CONFIG_ECHO_START;
  1798. SERIAL_ECHO(" M906");
  1799. #if ENABLED(X_IS_TMC2130) || ENABLED(X_IS_TMC2208)
  1800. SERIAL_ECHOPAIR(" X ", stepperX.getCurrent());
  1801. #endif
  1802. #if ENABLED(Y_IS_TMC2130) || ENABLED(Y_IS_TMC2208)
  1803. SERIAL_ECHOPAIR(" Y ", stepperY.getCurrent());
  1804. #endif
  1805. #if ENABLED(Z_IS_TMC2130) || ENABLED(Z_IS_TMC2208)
  1806. SERIAL_ECHOPAIR(" Z ", stepperZ.getCurrent());
  1807. #endif
  1808. #if ENABLED(X2_IS_TMC2130) || ENABLED(X2_IS_TMC2208)
  1809. SERIAL_ECHOPAIR(" X2 ", stepperX2.getCurrent());
  1810. #endif
  1811. #if ENABLED(Y2_IS_TMC2130) || ENABLED(Y2_IS_TMC2208)
  1812. SERIAL_ECHOPAIR(" Y2 ", stepperY2.getCurrent());
  1813. #endif
  1814. #if ENABLED(Z2_IS_TMC2130) || ENABLED(Z2_IS_TMC2208)
  1815. SERIAL_ECHOPAIR(" Z2 ", stepperZ2.getCurrent());
  1816. #endif
  1817. #if ENABLED(E0_IS_TMC2130) || ENABLED(E0_IS_TMC2208)
  1818. SERIAL_ECHOPAIR(" E0 ", stepperE0.getCurrent());
  1819. #endif
  1820. #if ENABLED(E1_IS_TMC2130) || ENABLED(E1_IS_TMC2208)
  1821. SERIAL_ECHOPAIR(" E1 ", stepperE1.getCurrent());
  1822. #endif
  1823. #if ENABLED(E2_IS_TMC2130) || ENABLED(E2_IS_TMC2208)
  1824. SERIAL_ECHOPAIR(" E2 ", stepperE2.getCurrent());
  1825. #endif
  1826. #if ENABLED(E3_IS_TMC2130) || ENABLED(E3_IS_TMC2208)
  1827. SERIAL_ECHOPAIR(" E3 ", stepperE3.getCurrent());
  1828. #endif
  1829. #if ENABLED(E4_IS_TMC2130) || ENABLED(E4_IS_TMC2208)
  1830. SERIAL_ECHOPAIR(" E4 ", stepperE4.getCurrent());
  1831. #endif
  1832. SERIAL_EOL();
  1833. #endif
  1834. /**
  1835. * TMC2130 Sensorless homing thresholds
  1836. */
  1837. #if ENABLED(HAVE_TMC2130) && ENABLED(SENSORLESS_HOMING)
  1838. if (!forReplay) {
  1839. CONFIG_ECHO_START;
  1840. SERIAL_ECHOLNPGM("Sensorless homing threshold:");
  1841. }
  1842. CONFIG_ECHO_START;
  1843. SERIAL_ECHO(" M914");
  1844. #if ENABLED(X_IS_TMC2130)
  1845. SERIAL_ECHOPAIR(" X", stepperX.sgt());
  1846. #endif
  1847. #if ENABLED(X2_IS_TMC2130)
  1848. SERIAL_ECHOPAIR(" X2 ", stepperX2.sgt());
  1849. #endif
  1850. #if ENABLED(Y_IS_TMC2130)
  1851. SERIAL_ECHOPAIR(" Y", stepperY.sgt());
  1852. #endif
  1853. #if ENABLED(X2_IS_TMC2130)
  1854. SERIAL_ECHOPAIR(" Y2 ", stepperY2.sgt());
  1855. #endif
  1856. SERIAL_EOL();
  1857. #endif
  1858. /**
  1859. * Linear Advance
  1860. */
  1861. #if ENABLED(LIN_ADVANCE)
  1862. if (!forReplay) {
  1863. CONFIG_ECHO_START;
  1864. SERIAL_ECHOLNPGM("Linear Advance:");
  1865. }
  1866. CONFIG_ECHO_START;
  1867. SERIAL_ECHOPAIR(" M900 K", planner.extruder_advance_k);
  1868. SERIAL_ECHOLNPAIR(" R", planner.advance_ed_ratio);
  1869. #endif
  1870. #if HAS_MOTOR_CURRENT_PWM
  1871. CONFIG_ECHO_START;
  1872. if (!forReplay) {
  1873. SERIAL_ECHOLNPGM("Stepper motor currents:");
  1874. CONFIG_ECHO_START;
  1875. }
  1876. SERIAL_ECHOPAIR(" M907 X", stepper.motor_current_setting[0]);
  1877. SERIAL_ECHOPAIR(" Z", stepper.motor_current_setting[1]);
  1878. SERIAL_ECHOPAIR(" E", stepper.motor_current_setting[2]);
  1879. SERIAL_EOL();
  1880. #endif
  1881. }
  1882. #endif // !DISABLE_M503