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

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