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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498
  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. * Configuration 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 "V31"
  38. // Change EEPROM version if these are changed:
  39. #define EEPROM_OFFSET 100
  40. /**
  41. * V31 EEPROM Layout:
  42. *
  43. * 100 Version (char x4)
  44. * 104 EEPROM Checksum (uint16_t)
  45. *
  46. * 106 E_STEPPERS (uint8_t)
  47. * 107 M92 XYZE planner.axis_steps_per_mm (float x4 ... x7)
  48. * 123 M203 XYZE planner.max_feedrate_mm_s (float x4 ... x7)
  49. * 139 M201 XYZE planner.max_acceleration_mm_per_s2 (uint32_t x4 ... x7)
  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 (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)
  62. *
  63. * Mesh bed leveling:
  64. * 219 M420 S from mbl.status (bool)
  65. * 220 mbl.z_offset (float)
  66. * 224 MESH_NUM_X_POINTS (uint8 as set in firmware)
  67. * 225 MESH_NUM_Y_POINTS (uint8 as set in firmware)
  68. * 226 G29 S3 XYZ z_values[][] (float x9, by default, up to float x 81) +288
  69. *
  70. * AUTO BED LEVELING
  71. * 262 M851 zprobe_zoffset (float)
  72. *
  73. * ABL_PLANAR (or placeholder): 36 bytes
  74. * 266 planner.bed_level_matrix (matrix_3x3 = float x9)
  75. *
  76. * AUTO_BED_LEVELING_BILINEAR (or placeholder): 47 bytes
  77. * 302 ABL_GRID_MAX_POINTS_X (uint8_t)
  78. * 303 ABL_GRID_MAX_POINTS_Y (uint8_t)
  79. * 304 bilinear_grid_spacing (int x2) from G29: (B-F)/X, (R-L)/Y
  80. * 308 G29 L F bilinear_start (int x2)
  81. * 312 bed_level_grid[][] (float x9, up to float x256) +988
  82. *
  83. * DELTA (if deltabot): 48 bytes
  84. * 348 M666 XYZ endstop_adj (float x3)
  85. * 360 M665 R delta_radius (float)
  86. * 364 M665 L delta_diagonal_rod (float)
  87. * 368 M665 S delta_segments_per_second (float)
  88. * 372 M665 A delta_diagonal_rod_trim[A] (float)
  89. * 376 M665 B delta_diagonal_rod_trim[B] (float)
  90. * 380 M665 C delta_diagonal_rod_trim[C] (float)
  91. * 384 M665 I delta_tower_angle_trim[A] (float)
  92. * 388 M665 J delta_tower_angle_trim[B] (float)
  93. * 392 M665 K delta_tower_angle_trim[C] (float)
  94. *
  95. * Z_DUAL_ENDSTOPS (if not deltabot): 48 bytes
  96. * 348 M666 Z z_endstop_adj (float)
  97. * --- dummy data (float x11)
  98. *
  99. * ULTIPANEL: 6 bytes
  100. * 396 M145 S0 H lcd_preheat_hotend_temp (int x2)
  101. * 400 M145 S0 B lcd_preheat_bed_temp (int x2)
  102. * 404 M145 S0 F lcd_preheat_fan_speed (int x2)
  103. *
  104. * PIDTEMP: 66 bytes
  105. * 408 M301 E0 PIDC Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
  106. * 424 M301 E1 PIDC Kp[1], Ki[1], Kd[1], Kc[1] (float x4)
  107. * 440 M301 E2 PIDC Kp[2], Ki[2], Kd[2], Kc[2] (float x4)
  108. * 456 M301 E3 PIDC Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
  109. * 472 M301 L lpq_len (int)
  110. *
  111. * PIDTEMPBED: 12 bytes
  112. * 474 M304 PID thermalManager.bedKp, .bedKi, .bedKd (float x3)
  113. *
  114. * DOGLCD: 2 bytes
  115. * 486 M250 C lcd_contrast (int)
  116. *
  117. * FWRETRACT: 29 bytes
  118. * 488 M209 S autoretract_enabled (bool)
  119. * 489 M207 S retract_length (float)
  120. * 493 M207 W retract_length_swap (float)
  121. * 497 M207 F retract_feedrate_mm_s (float)
  122. * 501 M207 Z retract_zlift (float)
  123. * 505 M208 S retract_recover_length (float)
  124. * 509 M208 W retract_recover_length_swap (float)
  125. * 513 M208 F retract_recover_feedrate_mm_s (float)
  126. *
  127. * Volumetric Extrusion: 17 bytes
  128. * 517 M200 D volumetric_enabled (bool)
  129. * 518 M200 T D filament_size (float x4) (T0..3)
  130. *
  131. * TMC2130 Stepper Current: 20 bytes
  132. * 534 M906 X stepperX current (uint16_t)
  133. * 536 M906 Y stepperY current (uint16_t)
  134. * 538 M906 Z stepperZ current (uint16_t)
  135. * 540 M906 X2 stepperX2 current (uint16_t)
  136. * 542 M906 Y2 stepperY2 current (uint16_t)
  137. * 544 M906 Z2 stepperZ2 current (uint16_t)
  138. * 546 M906 E0 stepperE0 current (uint16_t)
  139. * 548 M906 E1 stepperE1 current (uint16_t)
  140. * 550 M906 E2 stepperE2 current (uint16_t)
  141. * 552 M906 E3 stepperE3 current (uint16_t)
  142. *
  143. * 554 Minimum end-point
  144. * 1875 (554 + 36 + 9 + 288 + 988) Maximum end-point
  145. *
  146. */
  147. #include "Marlin.h"
  148. #include "language.h"
  149. #include "endstops.h"
  150. #include "planner.h"
  151. #include "temperature.h"
  152. #include "ultralcd.h"
  153. #include "configuration_store.h"
  154. #if ENABLED(MESH_BED_LEVELING)
  155. #include "mesh_bed_leveling.h"
  156. #endif
  157. #if ENABLED(HAVE_TMC2130)
  158. #include "stepper_indirection.h"
  159. #endif
  160. #if ENABLED(AUTO_BED_LEVELING_UBL)
  161. #include "UBL.h"
  162. #endif
  163. #if ENABLED(ABL_BILINEAR_SUBDIVISION)
  164. extern void bed_level_virt_interpolate();
  165. #endif
  166. /**
  167. * Post-process after Retrieve or Reset
  168. */
  169. void Config_Postprocess() {
  170. // steps per s2 needs to be updated to agree with units per s2
  171. planner.reset_acceleration_rates();
  172. // Make sure delta kinematics are updated before refreshing the
  173. // planner position so the stepper counts will be set correctly.
  174. #if ENABLED(DELTA)
  175. recalc_delta_settings(delta_radius, delta_diagonal_rod);
  176. #endif
  177. // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm
  178. // and init stepper.count[], planner.position[] with current_position
  179. planner.refresh_positioning();
  180. #if ENABLED(PIDTEMP)
  181. thermalManager.updatePID();
  182. #endif
  183. calculate_volumetric_multipliers();
  184. #if DISABLED(NO_WORKSPACE_OFFSETS) || ENABLED(DUAL_X_CARRIAGE) || ENABLED(DELTA)
  185. // Software endstops depend on home_offset
  186. LOOP_XYZ(i) update_software_endstops((AxisEnum)i);
  187. #endif
  188. }
  189. #if ENABLED(EEPROM_SETTINGS)
  190. uint16_t eeprom_checksum;
  191. const char version[4] = EEPROM_VERSION;
  192. bool eeprom_write_error;
  193. void _EEPROM_writeData(int &pos, const uint8_t* value, uint16_t size) {
  194. if (eeprom_write_error) return;
  195. while (size--) {
  196. uint8_t * const p = (uint8_t * const)pos;
  197. const uint8_t v = *value;
  198. // EEPROM has only ~100,000 write cycles,
  199. // so only write bytes that have changed!
  200. if (v != eeprom_read_byte(p)) {
  201. eeprom_write_byte(p, v);
  202. if (eeprom_read_byte(p) != v) {
  203. SERIAL_ECHO_START;
  204. SERIAL_ECHOLNPGM(MSG_ERR_EEPROM_WRITE);
  205. eeprom_write_error = true;
  206. return;
  207. }
  208. }
  209. eeprom_checksum += v;
  210. pos++;
  211. value++;
  212. };
  213. }
  214. bool eeprom_read_error;
  215. void _EEPROM_readData(int &pos, uint8_t* value, uint16_t size) {
  216. do {
  217. uint8_t c = eeprom_read_byte((unsigned char*)pos);
  218. if (!eeprom_read_error) *value = c;
  219. eeprom_checksum += c;
  220. pos++;
  221. value++;
  222. } while (--size);
  223. }
  224. #define DUMMY_PID_VALUE 3000.0f
  225. #define EEPROM_START() int eeprom_index = EEPROM_OFFSET
  226. #define EEPROM_SKIP(VAR) eeprom_index += sizeof(VAR)
  227. #define EEPROM_WRITE(VAR) _EEPROM_writeData(eeprom_index, (uint8_t*)&VAR, sizeof(VAR))
  228. #define EEPROM_READ(VAR) _EEPROM_readData(eeprom_index, (uint8_t*)&VAR, sizeof(VAR))
  229. #define EEPROM_ASSERT(TST,ERR) if () do{ SERIAL_ERROR_START; SERIAL_ERRORLNPGM(ERR); eeprom_read_error |= true; }while(0)
  230. /**
  231. * M500 - Store Configuration
  232. */
  233. bool Config_StoreSettings() {
  234. float dummy = 0.0f;
  235. char ver[4] = "000";
  236. EEPROM_START();
  237. eeprom_write_error = false;
  238. EEPROM_WRITE(ver); // invalidate data first
  239. EEPROM_SKIP(eeprom_checksum); // Skip the checksum slot
  240. eeprom_checksum = 0; // clear before first "real data"
  241. const uint8_t esteppers = COUNT(planner.axis_steps_per_mm) - XYZ;
  242. EEPROM_WRITE(esteppers);
  243. EEPROM_WRITE(planner.axis_steps_per_mm);
  244. EEPROM_WRITE(planner.max_feedrate_mm_s);
  245. EEPROM_WRITE(planner.max_acceleration_mm_per_s2);
  246. EEPROM_WRITE(planner.acceleration);
  247. EEPROM_WRITE(planner.retract_acceleration);
  248. EEPROM_WRITE(planner.travel_acceleration);
  249. EEPROM_WRITE(planner.min_feedrate_mm_s);
  250. EEPROM_WRITE(planner.min_travel_feedrate_mm_s);
  251. EEPROM_WRITE(planner.min_segment_time);
  252. EEPROM_WRITE(planner.max_jerk);
  253. #if ENABLED(NO_WORKSPACE_OFFSETS)
  254. float home_offset[XYZ] = { 0 };
  255. #endif
  256. EEPROM_WRITE(home_offset);
  257. #if HOTENDS > 1
  258. // Skip hotend 0 which must be 0
  259. for (uint8_t e = 1; e < HOTENDS; e++)
  260. LOOP_XYZ(i) EEPROM_WRITE(hotend_offset[i][e]);
  261. #endif
  262. //
  263. // Mesh Bed Leveling
  264. //
  265. #if ENABLED(MESH_BED_LEVELING)
  266. // Compile time test that sizeof(mbl.z_values) is as expected
  267. typedef char c_assert[(sizeof(mbl.z_values) == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS) * sizeof(dummy)) ? 1 : -1];
  268. const bool leveling_is_on = TEST(mbl.status, MBL_STATUS_HAS_MESH_BIT);
  269. const uint8_t mesh_num_x = MESH_NUM_X_POINTS, mesh_num_y = MESH_NUM_Y_POINTS;
  270. EEPROM_WRITE(leveling_is_on);
  271. EEPROM_WRITE(mbl.z_offset);
  272. EEPROM_WRITE(mesh_num_x);
  273. EEPROM_WRITE(mesh_num_y);
  274. EEPROM_WRITE(mbl.z_values);
  275. #else
  276. // For disabled MBL write a default mesh
  277. const bool leveling_is_on = false;
  278. dummy = 0.0f;
  279. const uint8_t mesh_num_x = 3, mesh_num_y = 3;
  280. EEPROM_WRITE(leveling_is_on);
  281. EEPROM_WRITE(dummy); // z_offset
  282. EEPROM_WRITE(mesh_num_x);
  283. EEPROM_WRITE(mesh_num_y);
  284. for (uint8_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_WRITE(dummy);
  285. #endif // MESH_BED_LEVELING
  286. #if !HAS_BED_PROBE
  287. float zprobe_zoffset = 0;
  288. #endif
  289. EEPROM_WRITE(zprobe_zoffset);
  290. //
  291. // Planar Bed Leveling matrix
  292. //
  293. #if ABL_PLANAR
  294. EEPROM_WRITE(planner.bed_level_matrix);
  295. #else
  296. dummy = 0.0;
  297. for (uint8_t q = 9; q--;) EEPROM_WRITE(dummy);
  298. #endif
  299. //
  300. // Bilinear Auto Bed Leveling
  301. //
  302. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  303. // Compile time test that sizeof(bed_level_grid) is as expected
  304. typedef char c_assert[(sizeof(bed_level_grid) == (ABL_GRID_MAX_POINTS_X) * (ABL_GRID_MAX_POINTS_Y) * sizeof(dummy)) ? 1 : -1];
  305. const uint8_t grid_max_x = ABL_GRID_MAX_POINTS_X, grid_max_y = ABL_GRID_MAX_POINTS_Y;
  306. EEPROM_WRITE(grid_max_x); // 1 byte
  307. EEPROM_WRITE(grid_max_y); // 1 byte
  308. EEPROM_WRITE(bilinear_grid_spacing); // 2 ints
  309. EEPROM_WRITE(bilinear_start); // 2 ints
  310. EEPROM_WRITE(bed_level_grid); // 9-256 floats
  311. #else
  312. // For disabled Bilinear Grid write an empty 3x3 grid
  313. const uint8_t grid_max_x = 3, grid_max_y = 3;
  314. const int bilinear_start[2] = { 0 }, bilinear_grid_spacing[2] = { 0 };
  315. dummy = 0.0f;
  316. EEPROM_WRITE(grid_max_x);
  317. EEPROM_WRITE(grid_max_y);
  318. EEPROM_WRITE(bilinear_grid_spacing);
  319. EEPROM_WRITE(bilinear_start);
  320. for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_WRITE(dummy);
  321. #endif // AUTO_BED_LEVELING_BILINEAR
  322. // 9 floats for DELTA / Z_DUAL_ENDSTOPS
  323. #if ENABLED(DELTA)
  324. EEPROM_WRITE(endstop_adj); // 3 floats
  325. EEPROM_WRITE(delta_radius); // 1 float
  326. EEPROM_WRITE(delta_diagonal_rod); // 1 float
  327. EEPROM_WRITE(delta_segments_per_second); // 1 float
  328. EEPROM_WRITE(delta_diagonal_rod_trim); // 3 floats
  329. EEPROM_WRITE(delta_tower_angle_trim); // 3 floats
  330. #elif ENABLED(Z_DUAL_ENDSTOPS)
  331. EEPROM_WRITE(z_endstop_adj); // 1 float
  332. dummy = 0.0f;
  333. for (uint8_t q = 11; q--;) EEPROM_WRITE(dummy);
  334. #else
  335. dummy = 0.0f;
  336. for (uint8_t q = 12; q--;) EEPROM_WRITE(dummy);
  337. #endif
  338. #if DISABLED(ULTIPANEL)
  339. const int lcd_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
  340. lcd_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED },
  341. lcd_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
  342. #endif // !ULTIPANEL
  343. EEPROM_WRITE(lcd_preheat_hotend_temp);
  344. EEPROM_WRITE(lcd_preheat_bed_temp);
  345. EEPROM_WRITE(lcd_preheat_fan_speed);
  346. for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
  347. #if ENABLED(PIDTEMP)
  348. if (e < HOTENDS) {
  349. EEPROM_WRITE(PID_PARAM(Kp, e));
  350. EEPROM_WRITE(PID_PARAM(Ki, e));
  351. EEPROM_WRITE(PID_PARAM(Kd, e));
  352. #if ENABLED(PID_EXTRUSION_SCALING)
  353. EEPROM_WRITE(PID_PARAM(Kc, e));
  354. #else
  355. dummy = 1.0f; // 1.0 = default kc
  356. EEPROM_WRITE(dummy);
  357. #endif
  358. }
  359. else
  360. #endif // !PIDTEMP
  361. {
  362. dummy = DUMMY_PID_VALUE; // When read, will not change the existing value
  363. EEPROM_WRITE(dummy); // Kp
  364. dummy = 0.0f;
  365. for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy); // Ki, Kd, Kc
  366. }
  367. } // Hotends Loop
  368. #if DISABLED(PID_EXTRUSION_SCALING)
  369. int lpq_len = 20;
  370. #endif
  371. EEPROM_WRITE(lpq_len);
  372. #if DISABLED(PIDTEMPBED)
  373. dummy = DUMMY_PID_VALUE;
  374. for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy);
  375. #else
  376. EEPROM_WRITE(thermalManager.bedKp);
  377. EEPROM_WRITE(thermalManager.bedKi);
  378. EEPROM_WRITE(thermalManager.bedKd);
  379. #endif
  380. #if !HAS_LCD_CONTRAST
  381. const int lcd_contrast = 32;
  382. #endif
  383. EEPROM_WRITE(lcd_contrast);
  384. #if ENABLED(FWRETRACT)
  385. EEPROM_WRITE(autoretract_enabled);
  386. EEPROM_WRITE(retract_length);
  387. #if EXTRUDERS > 1
  388. EEPROM_WRITE(retract_length_swap);
  389. #else
  390. dummy = 0.0f;
  391. EEPROM_WRITE(dummy);
  392. #endif
  393. EEPROM_WRITE(retract_feedrate_mm_s);
  394. EEPROM_WRITE(retract_zlift);
  395. EEPROM_WRITE(retract_recover_length);
  396. #if EXTRUDERS > 1
  397. EEPROM_WRITE(retract_recover_length_swap);
  398. #else
  399. dummy = 0.0f;
  400. EEPROM_WRITE(dummy);
  401. #endif
  402. EEPROM_WRITE(retract_recover_feedrate_mm_s);
  403. #endif // FWRETRACT
  404. EEPROM_WRITE(volumetric_enabled);
  405. // Save filament sizes
  406. for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
  407. if (q < COUNT(filament_size)) dummy = filament_size[q];
  408. EEPROM_WRITE(dummy);
  409. }
  410. // Save TCM2130 Configuration, and placeholder values
  411. uint16_t val;
  412. #if ENABLED(HAVE_TMC2130)
  413. #if ENABLED(X_IS_TMC2130)
  414. val = stepperX.getCurrent();
  415. #else
  416. val = 0;
  417. #endif
  418. EEPROM_WRITE(val);
  419. #if ENABLED(Y_IS_TMC2130)
  420. val = stepperY.getCurrent();
  421. #else
  422. val = 0;
  423. #endif
  424. EEPROM_WRITE(val);
  425. #if ENABLED(Z_IS_TMC2130)
  426. val = stepperZ.getCurrent();
  427. #else
  428. val = 0;
  429. #endif
  430. EEPROM_WRITE(val);
  431. #if ENABLED(X2_IS_TMC2130)
  432. val = stepperX2.getCurrent();
  433. #else
  434. val = 0;
  435. #endif
  436. EEPROM_WRITE(val);
  437. #if ENABLED(Y2_IS_TMC2130)
  438. val = stepperY2.getCurrent();
  439. #else
  440. val = 0;
  441. #endif
  442. EEPROM_WRITE(val);
  443. #if ENABLED(Z2_IS_TMC2130)
  444. val = stepperZ2.getCurrent();
  445. #else
  446. val = 0;
  447. #endif
  448. EEPROM_WRITE(val);
  449. #if ENABLED(E0_IS_TMC2130)
  450. val = stepperE0.getCurrent();
  451. #else
  452. val = 0;
  453. #endif
  454. EEPROM_WRITE(val);
  455. #if ENABLED(E1_IS_TMC2130)
  456. val = stepperE1.getCurrent();
  457. #else
  458. val = 0;
  459. #endif
  460. EEPROM_WRITE(val);
  461. #if ENABLED(E2_IS_TMC2130)
  462. val = stepperE2.getCurrent();
  463. #else
  464. val = 0;
  465. #endif
  466. EEPROM_WRITE(val);
  467. #if ENABLED(E3_IS_TMC2130)
  468. val = stepperE3.getCurrent();
  469. #else
  470. val = 0;
  471. #endif
  472. EEPROM_WRITE(val);
  473. #else
  474. val = 0;
  475. for (uint8_t q = 0; q < 10; ++q) EEPROM_WRITE(val);
  476. #endif
  477. if (!eeprom_write_error) {
  478. const uint16_t final_checksum = eeprom_checksum,
  479. eeprom_size = eeprom_index;
  480. // Write the EEPROM header
  481. eeprom_index = EEPROM_OFFSET;
  482. EEPROM_WRITE(version);
  483. EEPROM_WRITE(final_checksum);
  484. // Report storage size
  485. SERIAL_ECHO_START;
  486. SERIAL_ECHOPAIR("Settings Stored (", eeprom_size - (EEPROM_OFFSET));
  487. SERIAL_ECHOLNPGM(" bytes)");
  488. }
  489. #if ENABLED(AUTO_BED_LEVELING_UBL)
  490. ubl.store_state();
  491. if (ubl.state.eeprom_storage_slot >= 0)
  492. ubl.store_mesh(ubl.state.eeprom_storage_slot);
  493. #endif
  494. return !eeprom_write_error;
  495. }
  496. /**
  497. * M501 - Retrieve Configuration
  498. */
  499. bool Config_RetrieveSettings() {
  500. EEPROM_START();
  501. eeprom_read_error = false; // If set EEPROM_READ won't write into RAM
  502. char stored_ver[4];
  503. EEPROM_READ(stored_ver);
  504. uint16_t stored_checksum;
  505. EEPROM_READ(stored_checksum);
  506. // Version has to match or defaults are used
  507. if (strncmp(version, stored_ver, 3) != 0) {
  508. if (stored_ver[0] != 'V') {
  509. stored_ver[0] = '?';
  510. stored_ver[1] = '\0';
  511. }
  512. SERIAL_ECHO_START;
  513. SERIAL_ECHOPGM("EEPROM version mismatch ");
  514. SERIAL_ECHOPAIR("(EEPROM=", stored_ver);
  515. SERIAL_ECHOLNPGM(" Marlin=" EEPROM_VERSION ")");
  516. Config_ResetDefault();
  517. }
  518. else {
  519. float dummy = 0;
  520. eeprom_checksum = 0; // clear before reading first "real data"
  521. // Number of esteppers may change
  522. uint8_t esteppers;
  523. EEPROM_READ(esteppers);
  524. // Get only the number of E stepper parameters previously stored
  525. // Any steppers added later are set to their defaults
  526. const float def1[] = DEFAULT_AXIS_STEPS_PER_UNIT, def2[] = DEFAULT_MAX_FEEDRATE;
  527. const uint32_t def3[] = DEFAULT_MAX_ACCELERATION;
  528. float tmp1[XYZ + esteppers], tmp2[XYZ + esteppers];
  529. uint32_t tmp3[XYZ + esteppers];
  530. EEPROM_READ(tmp1);
  531. EEPROM_READ(tmp2);
  532. EEPROM_READ(tmp3);
  533. LOOP_XYZE_N(i) {
  534. planner.axis_steps_per_mm[i] = i < XYZ + esteppers ? tmp1[i] : def1[i < COUNT(def1) ? i : COUNT(def1) - 1];
  535. planner.max_feedrate_mm_s[i] = i < XYZ + esteppers ? tmp2[i] : def2[i < COUNT(def2) ? i : COUNT(def2) - 1];
  536. planner.max_acceleration_mm_per_s2[i] = i < XYZ + esteppers ? tmp3[i] : def3[i < COUNT(def3) ? i : COUNT(def3) - 1];
  537. }
  538. EEPROM_READ(planner.acceleration);
  539. EEPROM_READ(planner.retract_acceleration);
  540. EEPROM_READ(planner.travel_acceleration);
  541. EEPROM_READ(planner.min_feedrate_mm_s);
  542. EEPROM_READ(planner.min_travel_feedrate_mm_s);
  543. EEPROM_READ(planner.min_segment_time);
  544. EEPROM_READ(planner.max_jerk);
  545. #if ENABLED(NO_WORKSPACE_OFFSETS)
  546. float home_offset[XYZ];
  547. #endif
  548. EEPROM_READ(home_offset);
  549. #if HOTENDS > 1
  550. // Skip hotend 0 which must be 0
  551. for (uint8_t e = 1; e < HOTENDS; e++)
  552. LOOP_XYZ(i) EEPROM_READ(hotend_offset[i][e]);
  553. #endif
  554. //
  555. // Mesh (Manual) Bed Leveling
  556. //
  557. bool leveling_is_on;
  558. uint8_t mesh_num_x, mesh_num_y;
  559. EEPROM_READ(leveling_is_on);
  560. EEPROM_READ(dummy);
  561. EEPROM_READ(mesh_num_x);
  562. EEPROM_READ(mesh_num_y);
  563. #if ENABLED(MESH_BED_LEVELING)
  564. mbl.status = leveling_is_on ? _BV(MBL_STATUS_HAS_MESH_BIT) : 0;
  565. mbl.z_offset = dummy;
  566. if (mesh_num_x == MESH_NUM_X_POINTS && mesh_num_y == MESH_NUM_Y_POINTS) {
  567. // EEPROM data fits the current mesh
  568. EEPROM_READ(mbl.z_values);
  569. }
  570. else {
  571. // EEPROM data is stale
  572. mbl.reset();
  573. for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
  574. }
  575. #else
  576. // MBL is disabled - skip the stored data
  577. for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
  578. #endif // MESH_BED_LEVELING
  579. #if !HAS_BED_PROBE
  580. float zprobe_zoffset = 0;
  581. #endif
  582. EEPROM_READ(zprobe_zoffset);
  583. //
  584. // Planar Bed Leveling matrix
  585. //
  586. #if ABL_PLANAR
  587. EEPROM_READ(planner.bed_level_matrix);
  588. #else
  589. for (uint8_t q = 9; q--;) EEPROM_READ(dummy);
  590. #endif
  591. //
  592. // Bilinear Auto Bed Leveling
  593. //
  594. uint8_t grid_max_x, grid_max_y;
  595. EEPROM_READ(grid_max_x); // 1 byte
  596. EEPROM_READ(grid_max_y); // 1 byte
  597. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  598. if (grid_max_x == ABL_GRID_MAX_POINTS_X && grid_max_y == ABL_GRID_MAX_POINTS_Y) {
  599. set_bed_leveling_enabled(false);
  600. EEPROM_READ(bilinear_grid_spacing); // 2 ints
  601. EEPROM_READ(bilinear_start); // 2 ints
  602. EEPROM_READ(bed_level_grid); // 9 to 256 floats
  603. #if ENABLED(ABL_BILINEAR_SUBDIVISION)
  604. bed_level_virt_interpolate();
  605. #endif
  606. //set_bed_leveling_enabled(leveling_is_on);
  607. }
  608. else // EEPROM data is stale
  609. #endif // AUTO_BED_LEVELING_BILINEAR
  610. {
  611. // Skip past disabled (or stale) Bilinear Grid data
  612. int bgs[2], bs[2];
  613. EEPROM_READ(bgs);
  614. EEPROM_READ(bs);
  615. for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummy);
  616. }
  617. #if ENABLED(DELTA)
  618. EEPROM_READ(endstop_adj); // 3 floats
  619. EEPROM_READ(delta_radius); // 1 float
  620. EEPROM_READ(delta_diagonal_rod); // 1 float
  621. EEPROM_READ(delta_segments_per_second); // 1 float
  622. EEPROM_READ(delta_diagonal_rod_trim); // 3 floats
  623. EEPROM_READ(delta_tower_angle_trim); // 3 floats
  624. #elif ENABLED(Z_DUAL_ENDSTOPS)
  625. EEPROM_READ(z_endstop_adj);
  626. dummy = 0.0f;
  627. for (uint8_t q=11; q--;) EEPROM_READ(dummy);
  628. #else
  629. dummy = 0.0f;
  630. for (uint8_t q=12; q--;) EEPROM_READ(dummy);
  631. #endif
  632. #if DISABLED(ULTIPANEL)
  633. int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
  634. #endif
  635. EEPROM_READ(lcd_preheat_hotend_temp);
  636. EEPROM_READ(lcd_preheat_bed_temp);
  637. EEPROM_READ(lcd_preheat_fan_speed);
  638. #if ENABLED(PIDTEMP)
  639. for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
  640. EEPROM_READ(dummy); // Kp
  641. if (e < HOTENDS && dummy != DUMMY_PID_VALUE) {
  642. // do not need to scale PID values as the values in EEPROM are already scaled
  643. PID_PARAM(Kp, e) = dummy;
  644. EEPROM_READ(PID_PARAM(Ki, e));
  645. EEPROM_READ(PID_PARAM(Kd, e));
  646. #if ENABLED(PID_EXTRUSION_SCALING)
  647. EEPROM_READ(PID_PARAM(Kc, e));
  648. #else
  649. EEPROM_READ(dummy);
  650. #endif
  651. }
  652. else {
  653. for (uint8_t q=3; q--;) EEPROM_READ(dummy); // Ki, Kd, Kc
  654. }
  655. }
  656. #else // !PIDTEMP
  657. // 4 x 4 = 16 slots for PID parameters
  658. for (uint8_t q = MAX_EXTRUDERS * 4; q--;) EEPROM_READ(dummy); // Kp, Ki, Kd, Kc
  659. #endif // !PIDTEMP
  660. #if DISABLED(PID_EXTRUSION_SCALING)
  661. int lpq_len;
  662. #endif
  663. EEPROM_READ(lpq_len);
  664. #if ENABLED(PIDTEMPBED)
  665. EEPROM_READ(dummy); // bedKp
  666. if (dummy != DUMMY_PID_VALUE) {
  667. thermalManager.bedKp = dummy;
  668. EEPROM_READ(thermalManager.bedKi);
  669. EEPROM_READ(thermalManager.bedKd);
  670. }
  671. #else
  672. for (uint8_t q=3; q--;) EEPROM_READ(dummy); // bedKp, bedKi, bedKd
  673. #endif
  674. #if !HAS_LCD_CONTRAST
  675. int lcd_contrast;
  676. #endif
  677. EEPROM_READ(lcd_contrast);
  678. #if ENABLED(FWRETRACT)
  679. EEPROM_READ(autoretract_enabled);
  680. EEPROM_READ(retract_length);
  681. #if EXTRUDERS > 1
  682. EEPROM_READ(retract_length_swap);
  683. #else
  684. EEPROM_READ(dummy);
  685. #endif
  686. EEPROM_READ(retract_feedrate_mm_s);
  687. EEPROM_READ(retract_zlift);
  688. EEPROM_READ(retract_recover_length);
  689. #if EXTRUDERS > 1
  690. EEPROM_READ(retract_recover_length_swap);
  691. #else
  692. EEPROM_READ(dummy);
  693. #endif
  694. EEPROM_READ(retract_recover_feedrate_mm_s);
  695. #endif // FWRETRACT
  696. EEPROM_READ(volumetric_enabled);
  697. for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
  698. EEPROM_READ(dummy);
  699. if (q < COUNT(filament_size)) filament_size[q] = dummy;
  700. }
  701. uint16_t val;
  702. #if ENABLED(HAVE_TMC2130)
  703. EEPROM_READ(val);
  704. #if ENABLED(X_IS_TMC2130)
  705. stepperX.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  706. #endif
  707. EEPROM_READ(val);
  708. #if ENABLED(Y_IS_TMC2130)
  709. stepperY.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  710. #endif
  711. EEPROM_READ(val);
  712. #if ENABLED(Z_IS_TMC2130)
  713. stepperZ.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  714. #endif
  715. EEPROM_READ(val);
  716. #if ENABLED(X2_IS_TMC2130)
  717. stepperX2.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  718. #endif
  719. EEPROM_READ(val);
  720. #if ENABLED(Y2_IS_TMC2130)
  721. stepperY2.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  722. #endif
  723. EEPROM_READ(val);
  724. #if ENABLED(Z2_IS_TMC2130)
  725. stepperZ2.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  726. #endif
  727. EEPROM_READ(val);
  728. #if ENABLED(E0_IS_TMC2130)
  729. stepperE0.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  730. #endif
  731. EEPROM_READ(val);
  732. #if ENABLED(E1_IS_TMC2130)
  733. stepperE1.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  734. #endif
  735. EEPROM_READ(val);
  736. #if ENABLED(E2_IS_TMC2130)
  737. stepperE2.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  738. #endif
  739. EEPROM_READ(val);
  740. #if ENABLED(E3_IS_TMC2130)
  741. stepperE3.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
  742. #endif
  743. #else
  744. for (uint8_t q = 0; q < 10; q++) EEPROM_READ(val);
  745. #endif
  746. if (eeprom_checksum == stored_checksum) {
  747. if (eeprom_read_error)
  748. Config_ResetDefault();
  749. else {
  750. Config_Postprocess();
  751. SERIAL_ECHO_START;
  752. SERIAL_ECHO(version);
  753. SERIAL_ECHOPAIR(" stored settings retrieved (", eeprom_index - (EEPROM_OFFSET));
  754. SERIAL_ECHOLNPGM(" bytes)");
  755. }
  756. }
  757. else {
  758. SERIAL_ERROR_START;
  759. SERIAL_ERRORLNPGM("EEPROM checksum mismatch");
  760. Config_ResetDefault();
  761. }
  762. #if ENABLED(AUTO_BED_LEVELING_UBL)
  763. ubl_eeprom_start = (eeprom_index + 32) & 0xFFF8; // Pad the end of configuration data so it
  764. // can float up or down a little bit without
  765. // disrupting the Unified Bed Leveling data
  766. ubl.load_state();
  767. SERIAL_ECHOPGM(" UBL ");
  768. if (!ubl.state.active) SERIAL_ECHO("not ");
  769. SERIAL_ECHOLNPGM("active!");
  770. if (!ubl.sanity_check()) {
  771. int tmp_mesh; // We want to preserve whether the UBL System is Active
  772. bool tmp_active; // If it is, we want to preserve the Mesh that is being used.
  773. tmp_mesh = ubl.state.eeprom_storage_slot;
  774. tmp_active = ubl.state.active;
  775. SERIAL_ECHOLNPGM("\nInitializing Bed Leveling State to current firmware settings.\n");
  776. ubl.state = ubl.pre_initialized; // Initialize with the pre_initialized data structure
  777. ubl.state.eeprom_storage_slot = tmp_mesh; // But then restore some data we don't want mangled
  778. ubl.state.active = tmp_active;
  779. }
  780. else {
  781. SERIAL_PROTOCOLPGM("?Unable to enable Unified Bed Leveling.\n");
  782. ubl.state = ubl.pre_initialized;
  783. ubl.reset();
  784. ubl.store_state();
  785. }
  786. if (ubl.state.eeprom_storage_slot >= 0) {
  787. ubl.load_mesh(ubl.state.eeprom_storage_slot);
  788. SERIAL_ECHOPAIR("Mesh ", ubl.state.eeprom_storage_slot);
  789. SERIAL_ECHOLNPGM(" loaded from storage.");
  790. }
  791. else {
  792. ubl.reset();
  793. SERIAL_ECHOLNPGM("UBL System reset()");
  794. }
  795. #endif
  796. }
  797. #if ENABLED(EEPROM_CHITCHAT)
  798. Config_PrintSettings();
  799. #endif
  800. return !eeprom_read_error;
  801. }
  802. #else // !EEPROM_SETTINGS
  803. bool Config_StoreSettings() {
  804. SERIAL_ERROR_START;
  805. SERIAL_ERRORLNPGM("EEPROM disabled");
  806. return false;
  807. }
  808. #endif // !EEPROM_SETTINGS
  809. /**
  810. * M502 - Reset Configuration
  811. */
  812. void Config_ResetDefault() {
  813. const float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT, tmp2[] = DEFAULT_MAX_FEEDRATE;
  814. const uint32_t tmp3[] = DEFAULT_MAX_ACCELERATION;
  815. LOOP_XYZE_N(i) {
  816. planner.axis_steps_per_mm[i] = tmp1[i < COUNT(tmp1) ? i : COUNT(tmp1) - 1];
  817. planner.max_feedrate_mm_s[i] = tmp2[i < COUNT(tmp2) ? i : COUNT(tmp2) - 1];
  818. planner.max_acceleration_mm_per_s2[i] = tmp3[i < COUNT(tmp3) ? i : COUNT(tmp3) - 1];
  819. }
  820. planner.acceleration = DEFAULT_ACCELERATION;
  821. planner.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
  822. planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
  823. planner.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE;
  824. planner.min_segment_time = DEFAULT_MINSEGMENTTIME;
  825. planner.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
  826. planner.max_jerk[X_AXIS] = DEFAULT_XJERK;
  827. planner.max_jerk[Y_AXIS] = DEFAULT_YJERK;
  828. planner.max_jerk[Z_AXIS] = DEFAULT_ZJERK;
  829. planner.max_jerk[E_AXIS] = DEFAULT_EJERK;
  830. #if DISABLED(NO_WORKSPACE_OFFSETS)
  831. ZERO(home_offset);
  832. #endif
  833. #if HOTENDS > 1
  834. constexpr float tmp4[XYZ][HOTENDS] = {
  835. HOTEND_OFFSET_X,
  836. HOTEND_OFFSET_Y
  837. #ifdef HOTEND_OFFSET_Z
  838. , HOTEND_OFFSET_Z
  839. #else
  840. , { 0 }
  841. #endif
  842. };
  843. static_assert(
  844. tmp4[X_AXIS][0] == 0 && tmp4[Y_AXIS][0] == 0 && tmp4[Z_AXIS][0] == 0,
  845. "Offsets for the first hotend must be 0.0."
  846. );
  847. LOOP_XYZ(i) HOTEND_LOOP() hotend_offset[i][e] = tmp4[i][e];
  848. #endif
  849. // Applies to all MBL and ABL
  850. #if PLANNER_LEVELING
  851. reset_bed_level();
  852. #endif
  853. #if HAS_BED_PROBE
  854. zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
  855. #endif
  856. #if ENABLED(DELTA)
  857. const float adj[ABC] = DELTA_ENDSTOP_ADJ,
  858. drt[ABC] = { DELTA_DIAGONAL_ROD_TRIM_TOWER_1, DELTA_DIAGONAL_ROD_TRIM_TOWER_2, DELTA_DIAGONAL_ROD_TRIM_TOWER_3 },
  859. dta[ABC] = { DELTA_TOWER_ANGLE_TRIM_1, DELTA_TOWER_ANGLE_TRIM_2, DELTA_TOWER_ANGLE_TRIM_3 };
  860. COPY(endstop_adj, adj);
  861. delta_radius = DELTA_RADIUS;
  862. delta_diagonal_rod = DELTA_DIAGONAL_ROD;
  863. delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
  864. COPY(delta_diagonal_rod_trim, drt);
  865. COPY(delta_tower_angle_trim, dta);
  866. #elif ENABLED(Z_DUAL_ENDSTOPS)
  867. z_endstop_adj = 0;
  868. #endif
  869. #if ENABLED(ULTIPANEL)
  870. lcd_preheat_hotend_temp[0] = PREHEAT_1_TEMP_HOTEND;
  871. lcd_preheat_hotend_temp[1] = PREHEAT_2_TEMP_HOTEND;
  872. lcd_preheat_bed_temp[0] = PREHEAT_1_TEMP_BED;
  873. lcd_preheat_bed_temp[1] = PREHEAT_2_TEMP_BED;
  874. lcd_preheat_fan_speed[0] = PREHEAT_1_FAN_SPEED;
  875. lcd_preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
  876. #endif
  877. #if HAS_LCD_CONTRAST
  878. lcd_contrast = DEFAULT_LCD_CONTRAST;
  879. #endif
  880. #if ENABLED(PIDTEMP)
  881. #if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
  882. HOTEND_LOOP()
  883. #endif
  884. {
  885. PID_PARAM(Kp, e) = DEFAULT_Kp;
  886. PID_PARAM(Ki, e) = scalePID_i(DEFAULT_Ki);
  887. PID_PARAM(Kd, e) = scalePID_d(DEFAULT_Kd);
  888. #if ENABLED(PID_EXTRUSION_SCALING)
  889. PID_PARAM(Kc, e) = DEFAULT_Kc;
  890. #endif
  891. }
  892. #if ENABLED(PID_EXTRUSION_SCALING)
  893. lpq_len = 20; // default last-position-queue size
  894. #endif
  895. #endif // PIDTEMP
  896. #if ENABLED(PIDTEMPBED)
  897. thermalManager.bedKp = DEFAULT_bedKp;
  898. thermalManager.bedKi = scalePID_i(DEFAULT_bedKi);
  899. thermalManager.bedKd = scalePID_d(DEFAULT_bedKd);
  900. #endif
  901. #if ENABLED(FWRETRACT)
  902. autoretract_enabled = false;
  903. retract_length = RETRACT_LENGTH;
  904. #if EXTRUDERS > 1
  905. retract_length_swap = RETRACT_LENGTH_SWAP;
  906. #endif
  907. retract_feedrate_mm_s = RETRACT_FEEDRATE;
  908. retract_zlift = RETRACT_ZLIFT;
  909. retract_recover_length = RETRACT_RECOVER_LENGTH;
  910. #if EXTRUDERS > 1
  911. retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
  912. #endif
  913. retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE;
  914. #endif
  915. volumetric_enabled =
  916. #if ENABLED(VOLUMETRIC_DEFAULT_ON)
  917. true
  918. #else
  919. false
  920. #endif
  921. ;
  922. for (uint8_t q = 0; q < COUNT(filament_size); q++)
  923. filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
  924. endstops.enable_globally(
  925. #if ENABLED(ENDSTOPS_ALWAYS_ON_DEFAULT)
  926. (true)
  927. #else
  928. (false)
  929. #endif
  930. );
  931. #if ENABLED(HAVE_TMC2130)
  932. #if ENABLED(X_IS_TMC2130)
  933. stepperX.setCurrent(X_MAX_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  934. #endif
  935. #if ENABLED(Y_IS_TMC2130)
  936. stepperY.setCurrent(Y_MAX_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  937. #endif
  938. #if ENABLED(Z_IS_TMC2130)
  939. stepperZ.setCurrent(Z_MAX_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  940. #endif
  941. #if ENABLED(X2_IS_TMC2130)
  942. stepperX2.setCurrent(X2_MAX_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  943. #endif
  944. #if ENABLED(Y2_IS_TMC2130)
  945. stepperY2.setCurrent(Y2_MAX_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  946. #endif
  947. #if ENABLED(Z2_IS_TMC2130)
  948. stepperZ2.setCurrent(Z2_MAX_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  949. #endif
  950. #if ENABLED(E0_IS_TMC2130)
  951. stepperE0.setCurrent(E0_MAX_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  952. #endif
  953. #if ENABLED(E1_IS_TMC2130)
  954. stepperE1.setCurrent(E1_MAX_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  955. #endif
  956. #if ENABLED(E2_IS_TMC2130)
  957. stepperE2.setCurrent(E2_MAX_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  958. #endif
  959. #if ENABLED(E3_IS_TMC2130)
  960. stepperE3.setCurrent(E3_MAX_CURRENT, R_SENSE, HOLD_MULTIPLIER);
  961. #endif
  962. #endif
  963. Config_Postprocess();
  964. SERIAL_ECHO_START;
  965. SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
  966. }
  967. #if DISABLED(DISABLE_M503)
  968. #define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START; }while(0)
  969. /**
  970. * M503 - Print Configuration
  971. */
  972. void Config_PrintSettings(bool forReplay) {
  973. // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
  974. CONFIG_ECHO_START;
  975. if (!forReplay) {
  976. SERIAL_ECHOLNPGM("Steps per unit:");
  977. CONFIG_ECHO_START;
  978. }
  979. SERIAL_ECHOPAIR(" M92 X", planner.axis_steps_per_mm[X_AXIS]);
  980. SERIAL_ECHOPAIR(" Y", planner.axis_steps_per_mm[Y_AXIS]);
  981. SERIAL_ECHOPAIR(" Z", planner.axis_steps_per_mm[Z_AXIS]);
  982. #if DISABLED(DISTINCT_E_FACTORS)
  983. SERIAL_ECHOPAIR(" E", planner.axis_steps_per_mm[E_AXIS]);
  984. #endif
  985. SERIAL_EOL;
  986. #if ENABLED(DISTINCT_E_FACTORS)
  987. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  988. SERIAL_ECHOPAIR(" M92 T", (int)i);
  989. SERIAL_ECHOLNPAIR(" E", planner.axis_steps_per_mm[E_AXIS + i]);
  990. }
  991. #endif
  992. CONFIG_ECHO_START;
  993. if (!forReplay) {
  994. SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
  995. CONFIG_ECHO_START;
  996. }
  997. SERIAL_ECHOPAIR(" M203 X", planner.max_feedrate_mm_s[X_AXIS]);
  998. SERIAL_ECHOPAIR(" Y", planner.max_feedrate_mm_s[Y_AXIS]);
  999. SERIAL_ECHOPAIR(" Z", planner.max_feedrate_mm_s[Z_AXIS]);
  1000. #if DISABLED(DISTINCT_E_FACTORS)
  1001. SERIAL_ECHOPAIR(" E", planner.max_feedrate_mm_s[E_AXIS]);
  1002. #endif
  1003. SERIAL_EOL;
  1004. #if ENABLED(DISTINCT_E_FACTORS)
  1005. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  1006. SERIAL_ECHOPAIR(" M203 T", (int)i);
  1007. SERIAL_ECHOLNPAIR(" E", planner.max_feedrate_mm_s[E_AXIS + i]);
  1008. }
  1009. #endif
  1010. CONFIG_ECHO_START;
  1011. if (!forReplay) {
  1012. SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
  1013. CONFIG_ECHO_START;
  1014. }
  1015. SERIAL_ECHOPAIR(" M201 X", planner.max_acceleration_mm_per_s2[X_AXIS]);
  1016. SERIAL_ECHOPAIR(" Y", planner.max_acceleration_mm_per_s2[Y_AXIS]);
  1017. SERIAL_ECHOPAIR(" Z", planner.max_acceleration_mm_per_s2[Z_AXIS]);
  1018. #if DISABLED(DISTINCT_E_FACTORS)
  1019. SERIAL_ECHOPAIR(" E", planner.max_acceleration_mm_per_s2[E_AXIS]);
  1020. #endif
  1021. SERIAL_EOL;
  1022. #if ENABLED(DISTINCT_E_FACTORS)
  1023. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  1024. SERIAL_ECHOPAIR(" M201 T", (int)i);
  1025. SERIAL_ECHOLNPAIR(" E", planner.max_acceleration_mm_per_s2[E_AXIS + i]);
  1026. }
  1027. #endif
  1028. CONFIG_ECHO_START;
  1029. if (!forReplay) {
  1030. SERIAL_ECHOLNPGM("Accelerations: P=printing, R=retract and T=travel");
  1031. CONFIG_ECHO_START;
  1032. }
  1033. SERIAL_ECHOPAIR(" M204 P", planner.acceleration);
  1034. SERIAL_ECHOPAIR(" R", planner.retract_acceleration);
  1035. SERIAL_ECHOPAIR(" T", planner.travel_acceleration);
  1036. SERIAL_EOL;
  1037. CONFIG_ECHO_START;
  1038. if (!forReplay) {
  1039. SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)");
  1040. CONFIG_ECHO_START;
  1041. }
  1042. SERIAL_ECHOPAIR(" M205 S", planner.min_feedrate_mm_s);
  1043. SERIAL_ECHOPAIR(" T", planner.min_travel_feedrate_mm_s);
  1044. SERIAL_ECHOPAIR(" B", planner.min_segment_time);
  1045. SERIAL_ECHOPAIR(" X", planner.max_jerk[X_AXIS]);
  1046. SERIAL_ECHOPAIR(" Y", planner.max_jerk[Y_AXIS]);
  1047. SERIAL_ECHOPAIR(" Z", planner.max_jerk[Z_AXIS]);
  1048. SERIAL_ECHOPAIR(" E", planner.max_jerk[E_AXIS]);
  1049. SERIAL_EOL;
  1050. #if DISABLED(NO_WORKSPACE_OFFSETS)
  1051. CONFIG_ECHO_START;
  1052. if (!forReplay) {
  1053. SERIAL_ECHOLNPGM("Home offset (mm)");
  1054. CONFIG_ECHO_START;
  1055. }
  1056. SERIAL_ECHOPAIR(" M206 X", home_offset[X_AXIS]);
  1057. SERIAL_ECHOPAIR(" Y", home_offset[Y_AXIS]);
  1058. SERIAL_ECHOPAIR(" Z", home_offset[Z_AXIS]);
  1059. SERIAL_EOL;
  1060. #endif
  1061. #if HOTENDS > 1
  1062. CONFIG_ECHO_START;
  1063. if (!forReplay) {
  1064. SERIAL_ECHOLNPGM("Hotend offsets (mm)");
  1065. CONFIG_ECHO_START;
  1066. }
  1067. for (uint8_t e = 1; e < HOTENDS; e++) {
  1068. SERIAL_ECHOPAIR(" M218 T", (int)e);
  1069. SERIAL_ECHOPAIR(" X", hotend_offset[X_AXIS][e]);
  1070. SERIAL_ECHOPAIR(" Y", hotend_offset[Y_AXIS][e]);
  1071. #if ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_EXTRUDER)
  1072. SERIAL_ECHOPAIR(" Z", hotend_offset[Z_AXIS][e]);
  1073. #endif
  1074. SERIAL_EOL;
  1075. }
  1076. #endif
  1077. #if ENABLED(MESH_BED_LEVELING)
  1078. if (!forReplay) {
  1079. SERIAL_ECHOLNPGM("Mesh Bed Leveling:");
  1080. CONFIG_ECHO_START;
  1081. }
  1082. SERIAL_ECHOLNPAIR(" M420 S", mbl.has_mesh() ? 1 : 0);
  1083. for (uint8_t py = 1; py <= MESH_NUM_Y_POINTS; py++) {
  1084. for (uint8_t px = 1; px <= MESH_NUM_X_POINTS; px++) {
  1085. CONFIG_ECHO_START;
  1086. SERIAL_ECHOPAIR(" G29 S3 X", (int)px);
  1087. SERIAL_ECHOPAIR(" Y", (int)py);
  1088. SERIAL_ECHOPGM(" Z");
  1089. SERIAL_PROTOCOL_F(mbl.z_values[py-1][px-1], 5);
  1090. SERIAL_EOL;
  1091. }
  1092. }
  1093. #elif ENABLED(AUTO_BED_LEVELING_UBL)
  1094. if (!forReplay) {
  1095. SERIAL_ECHOLNPGM("Unified Bed Leveling:");
  1096. CONFIG_ECHO_START;
  1097. }
  1098. SERIAL_ECHOLNPAIR(" M420 S", ubl.state.active ? 1 : 0);
  1099. if (!forReplay) {
  1100. SERIAL_ECHOPGM("\nUBL is ");
  1101. ubl.state.active ? SERIAL_CHAR('A') : SERIAL_ECHOPGM("Ina");
  1102. SERIAL_ECHOLNPAIR("ctive\n\nActive Mesh Slot: ", ubl.state.eeprom_storage_slot);
  1103. SERIAL_ECHOPGM("z_offset: ");
  1104. SERIAL_ECHO_F(ubl.state.z_offset, 6);
  1105. SERIAL_EOL;
  1106. SERIAL_ECHOPAIR("EEPROM can hold ", (int)((UBL_LAST_EEPROM_INDEX - ubl_eeprom_start) / sizeof(z_values)));
  1107. SERIAL_ECHOLNPGM(" meshes.\n");
  1108. SERIAL_ECHOLNPGM("UBL_MESH_NUM_X_POINTS " STRINGIFY(UBL_MESH_NUM_X_POINTS));
  1109. SERIAL_ECHOLNPGM("UBL_MESH_NUM_Y_POINTS " STRINGIFY(UBL_MESH_NUM_Y_POINTS));
  1110. SERIAL_ECHOLNPGM("UBL_MESH_MIN_X " STRINGIFY(UBL_MESH_MIN_X));
  1111. SERIAL_ECHOLNPGM("UBL_MESH_MIN_Y " STRINGIFY(UBL_MESH_MIN_Y));
  1112. SERIAL_ECHOLNPGM("UBL_MESH_MAX_X " STRINGIFY(UBL_MESH_MAX_X));
  1113. SERIAL_ECHOLNPGM("UBL_MESH_MAX_Y " STRINGIFY(UBL_MESH_MAX_Y));
  1114. SERIAL_ECHOLNPGM("MESH_X_DIST " STRINGIFY(MESH_X_DIST));
  1115. SERIAL_ECHOLNPGM("MESH_Y_DIST " STRINGIFY(MESH_Y_DIST));
  1116. SERIAL_EOL;
  1117. }
  1118. #elif HAS_ABL
  1119. if (!forReplay) {
  1120. SERIAL_ECHOLNPGM("Auto Bed Leveling:");
  1121. CONFIG_ECHO_START;
  1122. }
  1123. SERIAL_ECHOLNPAIR(" M420 S", planner.abl_enabled ? 1 : 0);
  1124. #endif
  1125. #if ENABLED(DELTA)
  1126. CONFIG_ECHO_START;
  1127. if (!forReplay) {
  1128. SERIAL_ECHOLNPGM("Endstop adjustment (mm):");
  1129. CONFIG_ECHO_START;
  1130. }
  1131. SERIAL_ECHOPAIR(" M666 X", endstop_adj[X_AXIS]);
  1132. SERIAL_ECHOPAIR(" Y", endstop_adj[Y_AXIS]);
  1133. SERIAL_ECHOPAIR(" Z", endstop_adj[Z_AXIS]);
  1134. SERIAL_EOL;
  1135. CONFIG_ECHO_START;
  1136. if (!forReplay) {
  1137. SERIAL_ECHOLNPGM("Delta settings: L=diagonal rod, R=radius, S=segments-per-second, ABC=diagonal rod trim, IJK=tower angle trim");
  1138. CONFIG_ECHO_START;
  1139. }
  1140. SERIAL_ECHOPAIR(" M665 L", delta_diagonal_rod);
  1141. SERIAL_ECHOPAIR(" R", delta_radius);
  1142. SERIAL_ECHOPAIR(" S", delta_segments_per_second);
  1143. SERIAL_ECHOPAIR(" A", delta_diagonal_rod_trim[A_AXIS]);
  1144. SERIAL_ECHOPAIR(" B", delta_diagonal_rod_trim[B_AXIS]);
  1145. SERIAL_ECHOPAIR(" C", delta_diagonal_rod_trim[C_AXIS]);
  1146. SERIAL_ECHOPAIR(" I", delta_tower_angle_trim[A_AXIS]);
  1147. SERIAL_ECHOPAIR(" J", delta_tower_angle_trim[B_AXIS]);
  1148. SERIAL_ECHOPAIR(" K", delta_tower_angle_trim[C_AXIS]);
  1149. SERIAL_EOL;
  1150. #elif ENABLED(Z_DUAL_ENDSTOPS)
  1151. CONFIG_ECHO_START;
  1152. if (!forReplay) {
  1153. SERIAL_ECHOLNPGM("Z2 Endstop adjustment (mm):");
  1154. CONFIG_ECHO_START;
  1155. }
  1156. SERIAL_ECHOPAIR(" M666 Z", z_endstop_adj);
  1157. SERIAL_EOL;
  1158. #endif // DELTA
  1159. #if ENABLED(ULTIPANEL)
  1160. CONFIG_ECHO_START;
  1161. if (!forReplay) {
  1162. SERIAL_ECHOLNPGM("Material heatup parameters:");
  1163. CONFIG_ECHO_START;
  1164. }
  1165. for (uint8_t i = 0; i < COUNT(lcd_preheat_hotend_temp); i++) {
  1166. SERIAL_ECHOPAIR(" M145 S", (int)i);
  1167. SERIAL_ECHOPAIR(" H", lcd_preheat_hotend_temp[i]);
  1168. SERIAL_ECHOPAIR(" B", lcd_preheat_bed_temp[i]);
  1169. SERIAL_ECHOPAIR(" F", lcd_preheat_fan_speed[i]);
  1170. SERIAL_EOL;
  1171. }
  1172. #endif // ULTIPANEL
  1173. #if HAS_PID_HEATING
  1174. CONFIG_ECHO_START;
  1175. if (!forReplay) {
  1176. SERIAL_ECHOLNPGM("PID settings:");
  1177. }
  1178. #if ENABLED(PIDTEMP)
  1179. #if HOTENDS > 1
  1180. if (forReplay) {
  1181. HOTEND_LOOP() {
  1182. CONFIG_ECHO_START;
  1183. SERIAL_ECHOPAIR(" M301 E", e);
  1184. SERIAL_ECHOPAIR(" P", PID_PARAM(Kp, e));
  1185. SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, e)));
  1186. SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, e)));
  1187. #if ENABLED(PID_EXTRUSION_SCALING)
  1188. SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, e));
  1189. if (e == 0) SERIAL_ECHOPAIR(" L", lpq_len);
  1190. #endif
  1191. SERIAL_EOL;
  1192. }
  1193. }
  1194. else
  1195. #endif // HOTENDS > 1
  1196. // !forReplay || HOTENDS == 1
  1197. {
  1198. CONFIG_ECHO_START;
  1199. SERIAL_ECHOPAIR(" M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echo values for E0
  1200. SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
  1201. SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
  1202. #if ENABLED(PID_EXTRUSION_SCALING)
  1203. SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, 0));
  1204. SERIAL_ECHOPAIR(" L", lpq_len);
  1205. #endif
  1206. SERIAL_EOL;
  1207. }
  1208. #endif // PIDTEMP
  1209. #if ENABLED(PIDTEMPBED)
  1210. CONFIG_ECHO_START;
  1211. SERIAL_ECHOPAIR(" M304 P", thermalManager.bedKp);
  1212. SERIAL_ECHOPAIR(" I", unscalePID_i(thermalManager.bedKi));
  1213. SERIAL_ECHOPAIR(" D", unscalePID_d(thermalManager.bedKd));
  1214. SERIAL_EOL;
  1215. #endif
  1216. #endif // PIDTEMP || PIDTEMPBED
  1217. #if HAS_LCD_CONTRAST
  1218. CONFIG_ECHO_START;
  1219. if (!forReplay) {
  1220. SERIAL_ECHOLNPGM("LCD Contrast:");
  1221. CONFIG_ECHO_START;
  1222. }
  1223. SERIAL_ECHOPAIR(" M250 C", lcd_contrast);
  1224. SERIAL_EOL;
  1225. #endif
  1226. #if ENABLED(FWRETRACT)
  1227. CONFIG_ECHO_START;
  1228. if (!forReplay) {
  1229. SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
  1230. CONFIG_ECHO_START;
  1231. }
  1232. SERIAL_ECHOPAIR(" M207 S", retract_length);
  1233. #if EXTRUDERS > 1
  1234. SERIAL_ECHOPAIR(" W", retract_length_swap);
  1235. #endif
  1236. SERIAL_ECHOPAIR(" F", MMS_TO_MMM(retract_feedrate_mm_s));
  1237. SERIAL_ECHOPAIR(" Z", retract_zlift);
  1238. SERIAL_EOL;
  1239. CONFIG_ECHO_START;
  1240. if (!forReplay) {
  1241. SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
  1242. CONFIG_ECHO_START;
  1243. }
  1244. SERIAL_ECHOPAIR(" M208 S", retract_recover_length);
  1245. #if EXTRUDERS > 1
  1246. SERIAL_ECHOPAIR(" W", retract_recover_length_swap);
  1247. #endif
  1248. SERIAL_ECHOPAIR(" F", MMS_TO_MMM(retract_recover_feedrate_mm_s));
  1249. SERIAL_EOL;
  1250. CONFIG_ECHO_START;
  1251. if (!forReplay) {
  1252. SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
  1253. CONFIG_ECHO_START;
  1254. }
  1255. SERIAL_ECHOPAIR(" M209 S", autoretract_enabled ? 1 : 0);
  1256. SERIAL_EOL;
  1257. #endif // FWRETRACT
  1258. /**
  1259. * Volumetric extrusion M200
  1260. */
  1261. if (!forReplay) {
  1262. CONFIG_ECHO_START;
  1263. SERIAL_ECHOPGM("Filament settings:");
  1264. if (volumetric_enabled)
  1265. SERIAL_EOL;
  1266. else
  1267. SERIAL_ECHOLNPGM(" Disabled");
  1268. }
  1269. CONFIG_ECHO_START;
  1270. SERIAL_ECHOPAIR(" M200 D", filament_size[0]);
  1271. SERIAL_EOL;
  1272. #if EXTRUDERS > 1
  1273. CONFIG_ECHO_START;
  1274. SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]);
  1275. SERIAL_EOL;
  1276. #if EXTRUDERS > 2
  1277. CONFIG_ECHO_START;
  1278. SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]);
  1279. SERIAL_EOL;
  1280. #if EXTRUDERS > 3
  1281. CONFIG_ECHO_START;
  1282. SERIAL_ECHOPAIR(" M200 T3 D", filament_size[3]);
  1283. SERIAL_EOL;
  1284. #endif
  1285. #endif
  1286. #endif
  1287. if (!volumetric_enabled) {
  1288. CONFIG_ECHO_START;
  1289. SERIAL_ECHOLNPGM(" M200 D0");
  1290. }
  1291. /**
  1292. * Auto Bed Leveling
  1293. */
  1294. #if HAS_BED_PROBE
  1295. CONFIG_ECHO_START;
  1296. if (!forReplay) {
  1297. SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
  1298. CONFIG_ECHO_START;
  1299. }
  1300. SERIAL_ECHOPAIR(" M851 Z", zprobe_zoffset);
  1301. SERIAL_EOL;
  1302. #endif
  1303. /**
  1304. * TMC2130 stepper driver current
  1305. */
  1306. #if ENABLED(HAVE_TMC2130)
  1307. CONFIG_ECHO_START;
  1308. if (!forReplay) {
  1309. SERIAL_ECHOLNPGM("Stepper driver current:");
  1310. CONFIG_ECHO_START;
  1311. }
  1312. SERIAL_ECHO(" M906");
  1313. #if ENABLED(X_IS_TMC2130)
  1314. SERIAL_ECHOPAIR(" X", stepperX.getCurrent());
  1315. #endif
  1316. #if ENABLED(Y_IS_TMC2130)
  1317. SERIAL_ECHOPAIR(" Y", stepperY.getCurrent());
  1318. #endif
  1319. #if ENABLED(Z_IS_TMC2130)
  1320. SERIAL_ECHOPAIR(" Z", stepperZ.getCurrent());
  1321. #endif
  1322. #if ENABLED(X2_IS_TMC2130)
  1323. SERIAL_ECHOPAIR(" X2", stepperX2.getCurrent());
  1324. #endif
  1325. #if ENABLED(Y2_IS_TMC2130)
  1326. SERIAL_ECHOPAIR(" Y2", stepperY2.getCurrent());
  1327. #endif
  1328. #if ENABLED(Z2_IS_TMC2130)
  1329. SERIAL_ECHOPAIR(" Z2", stepperZ2.getCurrent());
  1330. #endif
  1331. #if ENABLED(E0_IS_TMC2130)
  1332. SERIAL_ECHOPAIR(" E0", stepperE0.getCurrent());
  1333. #endif
  1334. #if ENABLED(E1_IS_TMC2130)
  1335. SERIAL_ECHOPAIR(" E1", stepperE1.getCurrent());
  1336. #endif
  1337. #if ENABLED(E2_IS_TMC2130)
  1338. SERIAL_ECHOPAIR(" E2", stepperE2.getCurrent());
  1339. #endif
  1340. #if ENABLED(E3_IS_TMC2130)
  1341. SERIAL_ECHOPAIR(" E3", stepperE3.getCurrent());
  1342. #endif
  1343. SERIAL_EOL;
  1344. #endif
  1345. }
  1346. #endif // !DISABLE_M503