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

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