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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183
  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 "V29"
  38. // Change EEPROM version if these are changed:
  39. #define EEPROM_OFFSET 100
  40. /**
  41. * V29 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): 36 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_tower_1 (float)
  89. * 376 M665 B delta_diagonal_rod_trim_tower_2 (float)
  90. * 380 M665 C delta_diagonal_rod_trim_tower_3 (float)
  91. *
  92. * Z_DUAL_ENDSTOPS: 4 bytes
  93. * 384 M666 Z z_endstop_adj (float)
  94. *
  95. * ULTIPANEL: 6 bytes
  96. * 388 M145 S0 H lcd_preheat_hotend_temp (int x2)
  97. * 392 M145 S0 B lcd_preheat_bed_temp (int x2)
  98. * 396 M145 S0 F lcd_preheat_fan_speed (int x2)
  99. *
  100. * PIDTEMP: 66 bytes
  101. * 400 M301 E0 PIDC Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
  102. * 416 M301 E1 PIDC Kp[1], Ki[1], Kd[1], Kc[1] (float x4)
  103. * 432 M301 E2 PIDC Kp[2], Ki[2], Kd[2], Kc[2] (float x4)
  104. * 448 M301 E3 PIDC Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
  105. * 464 M301 L lpq_len (int)
  106. *
  107. * PIDTEMPBED:
  108. * 466 M304 PID thermalManager.bedKp, thermalManager.bedKi, thermalManager.bedKd (float x3)
  109. *
  110. * DOGLCD: 2 bytes
  111. * 478 M250 C lcd_contrast (int)
  112. *
  113. * FWRETRACT: 29 bytes
  114. * 480 M209 S autoretract_enabled (bool)
  115. * 481 M207 S retract_length (float)
  116. * 485 M207 W retract_length_swap (float)
  117. * 489 M207 F retract_feedrate_mm_s (float)
  118. * 493 M207 Z retract_zlift (float)
  119. * 497 M208 S retract_recover_length (float)
  120. * 501 M208 W retract_recover_length_swap (float)
  121. * 505 M208 F retract_recover_feedrate_mm_s (float)
  122. *
  123. * Volumetric Extrusion: 17 bytes
  124. * 509 M200 D volumetric_enabled (bool)
  125. * 510 M200 T D filament_size (float x4) (T0..3)
  126. *
  127. * 526 Minimum end-point
  128. * 1847 (526 + 36 + 9 + 288 + 988) Maximum end-point
  129. *
  130. */
  131. #include "Marlin.h"
  132. #include "language.h"
  133. #include "endstops.h"
  134. #include "planner.h"
  135. #include "temperature.h"
  136. #include "ultralcd.h"
  137. #include "configuration_store.h"
  138. #if ENABLED(MESH_BED_LEVELING)
  139. #include "mesh_bed_leveling.h"
  140. #endif
  141. #if ENABLED(ABL_BILINEAR_SUBDIVISION)
  142. extern void bed_level_virt_prepare();
  143. extern void bed_level_virt_interpolate();
  144. #endif
  145. /**
  146. * Post-process after Retrieve or Reset
  147. */
  148. void Config_Postprocess() {
  149. // steps per s2 needs to be updated to agree with units per s2
  150. planner.reset_acceleration_rates();
  151. // Make sure delta kinematics are updated before refreshing the
  152. // planner position so the stepper counts will be set correctly.
  153. #if ENABLED(DELTA)
  154. recalc_delta_settings(delta_radius, delta_diagonal_rod);
  155. #endif
  156. // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm
  157. // and init stepper.count[], planner.position[] with current_position
  158. planner.refresh_positioning();
  159. #if ENABLED(PIDTEMP)
  160. thermalManager.updatePID();
  161. #endif
  162. calculate_volumetric_multipliers();
  163. // Software endstops depend on home_offset
  164. LOOP_XYZ(i) update_software_endstops((AxisEnum)i);
  165. }
  166. #if ENABLED(EEPROM_SETTINGS)
  167. uint16_t eeprom_checksum;
  168. const char version[4] = EEPROM_VERSION;
  169. bool eeprom_write_error;
  170. void _EEPROM_writeData(int &pos, const uint8_t* value, uint16_t size) {
  171. if (eeprom_write_error) return;
  172. while (size--) {
  173. uint8_t * const p = (uint8_t * const)pos;
  174. const uint8_t v = *value;
  175. // EEPROM has only ~100,000 write cycles,
  176. // so only write bytes that have changed!
  177. if (v != eeprom_read_byte(p)) {
  178. eeprom_write_byte(p, v);
  179. if (eeprom_read_byte(p) != v) {
  180. SERIAL_ECHO_START;
  181. SERIAL_ECHOLNPGM(MSG_ERR_EEPROM_WRITE);
  182. eeprom_write_error = true;
  183. return;
  184. }
  185. }
  186. eeprom_checksum += v;
  187. pos++;
  188. value++;
  189. };
  190. }
  191. bool eeprom_read_error;
  192. void _EEPROM_readData(int &pos, uint8_t* value, uint16_t size) {
  193. do {
  194. uint8_t c = eeprom_read_byte((unsigned char*)pos);
  195. if (!eeprom_read_error) *value = c;
  196. eeprom_checksum += c;
  197. pos++;
  198. value++;
  199. } while (--size);
  200. }
  201. #define DUMMY_PID_VALUE 3000.0f
  202. #define EEPROM_START() int eeprom_index = EEPROM_OFFSET
  203. #define EEPROM_SKIP(VAR) eeprom_index += sizeof(VAR)
  204. #define EEPROM_WRITE(VAR) _EEPROM_writeData(eeprom_index, (uint8_t*)&VAR, sizeof(VAR))
  205. #define EEPROM_READ(VAR) _EEPROM_readData(eeprom_index, (uint8_t*)&VAR, sizeof(VAR))
  206. #define EEPROM_ASSERT(TST,ERR) if () do{ SERIAL_ERROR_START; SERIAL_ERRORLNPGM(ERR); eeprom_read_error |= true; }while(0)
  207. /**
  208. * M500 - Store Configuration
  209. */
  210. void Config_StoreSettings() {
  211. float dummy = 0.0f;
  212. char ver[4] = "000";
  213. EEPROM_START();
  214. eeprom_write_error = false;
  215. EEPROM_WRITE(ver); // invalidate data first
  216. EEPROM_SKIP(eeprom_checksum); // Skip the checksum slot
  217. eeprom_checksum = 0; // clear before first "real data"
  218. const uint8_t esteppers = COUNT(planner.axis_steps_per_mm) - XYZ;
  219. EEPROM_WRITE(esteppers);
  220. EEPROM_WRITE(planner.axis_steps_per_mm);
  221. EEPROM_WRITE(planner.max_feedrate_mm_s);
  222. EEPROM_WRITE(planner.max_acceleration_mm_per_s2);
  223. EEPROM_WRITE(planner.acceleration);
  224. EEPROM_WRITE(planner.retract_acceleration);
  225. EEPROM_WRITE(planner.travel_acceleration);
  226. EEPROM_WRITE(planner.min_feedrate_mm_s);
  227. EEPROM_WRITE(planner.min_travel_feedrate_mm_s);
  228. EEPROM_WRITE(planner.min_segment_time);
  229. EEPROM_WRITE(planner.max_jerk);
  230. EEPROM_WRITE(home_offset);
  231. #if HOTENDS > 1
  232. // Skip hotend 0 which must be 0
  233. for (uint8_t e = 1; e < HOTENDS; e++)
  234. LOOP_XYZ(i) EEPROM_WRITE(hotend_offset[i][e]);
  235. #endif
  236. //
  237. // Mesh Bed Leveling
  238. //
  239. #if ENABLED(MESH_BED_LEVELING)
  240. // Compile time test that sizeof(mbl.z_values) is as expected
  241. typedef char c_assert[(sizeof(mbl.z_values) == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS) * sizeof(dummy)) ? 1 : -1];
  242. const bool leveling_is_on = TEST(mbl.status, MBL_STATUS_HAS_MESH_BIT);
  243. const uint8_t mesh_num_x = MESH_NUM_X_POINTS, mesh_num_y = MESH_NUM_Y_POINTS;
  244. EEPROM_WRITE(leveling_is_on);
  245. EEPROM_WRITE(mbl.z_offset);
  246. EEPROM_WRITE(mesh_num_x);
  247. EEPROM_WRITE(mesh_num_y);
  248. EEPROM_WRITE(mbl.z_values);
  249. #else
  250. // For disabled MBL write a default mesh
  251. const bool leveling_is_on = false;
  252. dummy = 0.0f;
  253. const uint8_t mesh_num_x = 3, mesh_num_y = 3;
  254. EEPROM_WRITE(leveling_is_on);
  255. EEPROM_WRITE(dummy); // z_offset
  256. EEPROM_WRITE(mesh_num_x);
  257. EEPROM_WRITE(mesh_num_y);
  258. for (uint8_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_WRITE(dummy);
  259. #endif // MESH_BED_LEVELING
  260. #if !HAS_BED_PROBE
  261. float zprobe_zoffset = 0;
  262. #endif
  263. EEPROM_WRITE(zprobe_zoffset);
  264. //
  265. // Planar Bed Leveling matrix
  266. //
  267. #if ABL_PLANAR
  268. EEPROM_WRITE(planner.bed_level_matrix);
  269. #else
  270. dummy = 0.0;
  271. for (uint8_t q = 9; q--;) EEPROM_WRITE(dummy);
  272. #endif
  273. //
  274. // Bilinear Auto Bed Leveling
  275. //
  276. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  277. // Compile time test that sizeof(bed_level_grid) is as expected
  278. typedef char c_assert[(sizeof(bed_level_grid) == (ABL_GRID_MAX_POINTS_X) * (ABL_GRID_MAX_POINTS_Y) * sizeof(dummy)) ? 1 : -1];
  279. const uint8_t grid_max_x = ABL_GRID_MAX_POINTS_X, grid_max_y = ABL_GRID_MAX_POINTS_Y;
  280. EEPROM_WRITE(grid_max_x); // 1 byte
  281. EEPROM_WRITE(grid_max_y); // 1 byte
  282. EEPROM_WRITE(bilinear_grid_spacing); // 2 ints
  283. EEPROM_WRITE(bilinear_start); // 2 ints
  284. EEPROM_WRITE(bed_level_grid); // 9-256 floats
  285. #else
  286. // For disabled Bilinear Grid write an empty 3x3 grid
  287. const uint8_t grid_max_x = 3, grid_max_y = 3;
  288. const int bilinear_start[2] = { 0 }, bilinear_grid_spacing[2] = { 0 };
  289. dummy = 0.0f;
  290. EEPROM_WRITE(grid_max_x);
  291. EEPROM_WRITE(grid_max_y);
  292. EEPROM_WRITE(bilinear_grid_spacing);
  293. EEPROM_WRITE(bilinear_start);
  294. for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_WRITE(dummy);
  295. #endif // AUTO_BED_LEVELING_BILINEAR
  296. // 9 floats for DELTA / Z_DUAL_ENDSTOPS
  297. #if ENABLED(DELTA)
  298. EEPROM_WRITE(endstop_adj); // 3 floats
  299. EEPROM_WRITE(delta_radius); // 1 float
  300. EEPROM_WRITE(delta_diagonal_rod); // 1 float
  301. EEPROM_WRITE(delta_segments_per_second); // 1 float
  302. EEPROM_WRITE(delta_diagonal_rod_trim_tower_1); // 1 float
  303. EEPROM_WRITE(delta_diagonal_rod_trim_tower_2); // 1 float
  304. EEPROM_WRITE(delta_diagonal_rod_trim_tower_3); // 1 float
  305. #elif ENABLED(Z_DUAL_ENDSTOPS)
  306. EEPROM_WRITE(z_endstop_adj); // 1 float
  307. dummy = 0.0f;
  308. for (uint8_t q = 8; q--;) EEPROM_WRITE(dummy);
  309. #else
  310. dummy = 0.0f;
  311. for (uint8_t q = 9; q--;) EEPROM_WRITE(dummy);
  312. #endif
  313. #if DISABLED(ULTIPANEL)
  314. const int lcd_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
  315. lcd_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED },
  316. lcd_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
  317. #endif // !ULTIPANEL
  318. EEPROM_WRITE(lcd_preheat_hotend_temp);
  319. EEPROM_WRITE(lcd_preheat_bed_temp);
  320. EEPROM_WRITE(lcd_preheat_fan_speed);
  321. for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
  322. #if ENABLED(PIDTEMP)
  323. if (e < HOTENDS) {
  324. EEPROM_WRITE(PID_PARAM(Kp, e));
  325. EEPROM_WRITE(PID_PARAM(Ki, e));
  326. EEPROM_WRITE(PID_PARAM(Kd, e));
  327. #if ENABLED(PID_EXTRUSION_SCALING)
  328. EEPROM_WRITE(PID_PARAM(Kc, e));
  329. #else
  330. dummy = 1.0f; // 1.0 = default kc
  331. EEPROM_WRITE(dummy);
  332. #endif
  333. }
  334. else
  335. #endif // !PIDTEMP
  336. {
  337. dummy = DUMMY_PID_VALUE; // When read, will not change the existing value
  338. EEPROM_WRITE(dummy); // Kp
  339. dummy = 0.0f;
  340. for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy); // Ki, Kd, Kc
  341. }
  342. } // Hotends Loop
  343. #if DISABLED(PID_EXTRUSION_SCALING)
  344. int lpq_len = 20;
  345. #endif
  346. EEPROM_WRITE(lpq_len);
  347. #if DISABLED(PIDTEMPBED)
  348. dummy = DUMMY_PID_VALUE;
  349. for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy);
  350. #else
  351. EEPROM_WRITE(thermalManager.bedKp);
  352. EEPROM_WRITE(thermalManager.bedKi);
  353. EEPROM_WRITE(thermalManager.bedKd);
  354. #endif
  355. #if !HAS_LCD_CONTRAST
  356. const int lcd_contrast = 32;
  357. #endif
  358. EEPROM_WRITE(lcd_contrast);
  359. #if ENABLED(FWRETRACT)
  360. EEPROM_WRITE(autoretract_enabled);
  361. EEPROM_WRITE(retract_length);
  362. #if EXTRUDERS > 1
  363. EEPROM_WRITE(retract_length_swap);
  364. #else
  365. dummy = 0.0f;
  366. EEPROM_WRITE(dummy);
  367. #endif
  368. EEPROM_WRITE(retract_feedrate_mm_s);
  369. EEPROM_WRITE(retract_zlift);
  370. EEPROM_WRITE(retract_recover_length);
  371. #if EXTRUDERS > 1
  372. EEPROM_WRITE(retract_recover_length_swap);
  373. #else
  374. dummy = 0.0f;
  375. EEPROM_WRITE(dummy);
  376. #endif
  377. EEPROM_WRITE(retract_recover_feedrate_mm_s);
  378. #endif // FWRETRACT
  379. EEPROM_WRITE(volumetric_enabled);
  380. // Save filament sizes
  381. for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
  382. if (q < COUNT(filament_size)) dummy = filament_size[q];
  383. EEPROM_WRITE(dummy);
  384. }
  385. if (!eeprom_write_error) {
  386. uint16_t final_checksum = eeprom_checksum,
  387. eeprom_size = eeprom_index;
  388. // Write the EEPROM header
  389. eeprom_index = EEPROM_OFFSET;
  390. EEPROM_WRITE(version);
  391. EEPROM_WRITE(final_checksum);
  392. // Report storage size
  393. SERIAL_ECHO_START;
  394. SERIAL_ECHOPAIR("Settings Stored (", eeprom_size - (EEPROM_OFFSET));
  395. SERIAL_ECHOLNPGM(" bytes)");
  396. }
  397. }
  398. /**
  399. * M501 - Retrieve Configuration
  400. */
  401. void Config_RetrieveSettings() {
  402. EEPROM_START();
  403. eeprom_read_error = false; // If set EEPROM_READ won't write into RAM
  404. char stored_ver[4];
  405. EEPROM_READ(stored_ver);
  406. uint16_t stored_checksum;
  407. EEPROM_READ(stored_checksum);
  408. // SERIAL_ECHOPAIR("Version: [", version);
  409. // SERIAL_ECHOPAIR("] Stored version: [", stored_ver);
  410. // SERIAL_CHAR(']');
  411. // SERIAL_EOL;
  412. // Version has to match or defaults are used
  413. if (strncmp(version, stored_ver, 3) != 0) {
  414. Config_ResetDefault();
  415. }
  416. else {
  417. float dummy = 0;
  418. eeprom_checksum = 0; // clear before reading first "real data"
  419. // Number of esteppers may change
  420. uint8_t esteppers;
  421. EEPROM_READ(esteppers);
  422. // Get only the number of E stepper parameters previously stored
  423. // Any steppers added later are set to their defaults
  424. const float def1[] = DEFAULT_AXIS_STEPS_PER_UNIT, def2[] = DEFAULT_MAX_FEEDRATE;
  425. const uint32_t def3[] = DEFAULT_MAX_ACCELERATION;
  426. float tmp1[XYZ + esteppers], tmp2[XYZ + esteppers];
  427. uint32_t tmp3[XYZ + esteppers];
  428. EEPROM_READ(tmp1);
  429. EEPROM_READ(tmp2);
  430. EEPROM_READ(tmp3);
  431. LOOP_XYZE_N(i) {
  432. planner.axis_steps_per_mm[i] = i < XYZ + esteppers ? tmp1[i] : def1[i < COUNT(def1) ? i : COUNT(def1) - 1];
  433. planner.max_feedrate_mm_s[i] = i < XYZ + esteppers ? tmp2[i] : def2[i < COUNT(def2) ? i : COUNT(def2) - 1];
  434. planner.max_acceleration_mm_per_s2[i] = i < XYZ + esteppers ? tmp3[i] : def3[i < COUNT(def3) ? i : COUNT(def3) - 1];
  435. }
  436. EEPROM_READ(planner.acceleration);
  437. EEPROM_READ(planner.retract_acceleration);
  438. EEPROM_READ(planner.travel_acceleration);
  439. EEPROM_READ(planner.min_feedrate_mm_s);
  440. EEPROM_READ(planner.min_travel_feedrate_mm_s);
  441. EEPROM_READ(planner.min_segment_time);
  442. EEPROM_READ(planner.max_jerk);
  443. EEPROM_READ(home_offset);
  444. #if HOTENDS > 1
  445. // Skip hotend 0 which must be 0
  446. for (uint8_t e = 1; e < HOTENDS; e++)
  447. LOOP_XYZ(i) EEPROM_READ(hotend_offset[i][e]);
  448. #endif
  449. //
  450. // Mesh (Manual) Bed Leveling
  451. //
  452. bool leveling_is_on;
  453. uint8_t mesh_num_x, mesh_num_y;
  454. EEPROM_READ(leveling_is_on);
  455. EEPROM_READ(dummy);
  456. EEPROM_READ(mesh_num_x);
  457. EEPROM_READ(mesh_num_y);
  458. #if ENABLED(MESH_BED_LEVELING)
  459. mbl.status = leveling_is_on ? _BV(MBL_STATUS_HAS_MESH_BIT) : 0;
  460. mbl.z_offset = dummy;
  461. if (mesh_num_x == MESH_NUM_X_POINTS && mesh_num_y == MESH_NUM_Y_POINTS) {
  462. // EEPROM data fits the current mesh
  463. EEPROM_READ(mbl.z_values);
  464. }
  465. else {
  466. // EEPROM data is stale
  467. mbl.reset();
  468. for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
  469. }
  470. #else
  471. // MBL is disabled - skip the stored data
  472. for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
  473. #endif // MESH_BED_LEVELING
  474. #if !HAS_BED_PROBE
  475. float zprobe_zoffset = 0;
  476. #endif
  477. EEPROM_READ(zprobe_zoffset);
  478. //
  479. // Planar Bed Leveling matrix
  480. //
  481. #if ABL_PLANAR
  482. EEPROM_READ(planner.bed_level_matrix);
  483. #else
  484. for (uint8_t q = 9; q--;) EEPROM_READ(dummy);
  485. #endif
  486. //
  487. // Bilinear Auto Bed Leveling
  488. //
  489. uint8_t grid_max_x, grid_max_y;
  490. EEPROM_READ(grid_max_x); // 1 byte
  491. EEPROM_READ(grid_max_y); // 1 byte
  492. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  493. if (grid_max_x == ABL_GRID_MAX_POINTS_X && grid_max_y == ABL_GRID_MAX_POINTS_Y) {
  494. set_bed_leveling_enabled(false);
  495. EEPROM_READ(bilinear_grid_spacing); // 2 ints
  496. EEPROM_READ(bilinear_start); // 2 ints
  497. EEPROM_READ(bed_level_grid); // 9 to 256 floats
  498. #if ENABLED(ABL_BILINEAR_SUBDIVISION)
  499. bed_level_virt_prepare();
  500. bed_level_virt_interpolate();
  501. #endif
  502. //set_bed_leveling_enabled(leveling_is_on);
  503. }
  504. else // EEPROM data is stale
  505. #endif // AUTO_BED_LEVELING_BILINEAR
  506. {
  507. // Skip past disabled (or stale) Bilinear Grid data
  508. int bgs[2], bs[2];
  509. EEPROM_READ(bgs);
  510. EEPROM_READ(bs);
  511. for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummy);
  512. }
  513. #if ENABLED(DELTA)
  514. EEPROM_READ(endstop_adj); // 3 floats
  515. EEPROM_READ(delta_radius); // 1 float
  516. EEPROM_READ(delta_diagonal_rod); // 1 float
  517. EEPROM_READ(delta_segments_per_second); // 1 float
  518. EEPROM_READ(delta_diagonal_rod_trim_tower_1); // 1 float
  519. EEPROM_READ(delta_diagonal_rod_trim_tower_2); // 1 float
  520. EEPROM_READ(delta_diagonal_rod_trim_tower_3); // 1 float
  521. #elif ENABLED(Z_DUAL_ENDSTOPS)
  522. EEPROM_READ(z_endstop_adj);
  523. dummy = 0.0f;
  524. for (uint8_t q=8; q--;) EEPROM_READ(dummy);
  525. #else
  526. dummy = 0.0f;
  527. for (uint8_t q=9; q--;) EEPROM_READ(dummy);
  528. #endif
  529. #if DISABLED(ULTIPANEL)
  530. int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
  531. #endif
  532. EEPROM_READ(lcd_preheat_hotend_temp);
  533. EEPROM_READ(lcd_preheat_bed_temp);
  534. EEPROM_READ(lcd_preheat_fan_speed);
  535. #if ENABLED(PIDTEMP)
  536. for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
  537. EEPROM_READ(dummy); // Kp
  538. if (e < HOTENDS && dummy != DUMMY_PID_VALUE) {
  539. // do not need to scale PID values as the values in EEPROM are already scaled
  540. PID_PARAM(Kp, e) = dummy;
  541. EEPROM_READ(PID_PARAM(Ki, e));
  542. EEPROM_READ(PID_PARAM(Kd, e));
  543. #if ENABLED(PID_EXTRUSION_SCALING)
  544. EEPROM_READ(PID_PARAM(Kc, e));
  545. #else
  546. EEPROM_READ(dummy);
  547. #endif
  548. }
  549. else {
  550. for (uint8_t q=3; q--;) EEPROM_READ(dummy); // Ki, Kd, Kc
  551. }
  552. }
  553. #else // !PIDTEMP
  554. // 4 x 4 = 16 slots for PID parameters
  555. for (uint8_t q = MAX_EXTRUDERS * 4; q--;) EEPROM_READ(dummy); // Kp, Ki, Kd, Kc
  556. #endif // !PIDTEMP
  557. #if DISABLED(PID_EXTRUSION_SCALING)
  558. int lpq_len;
  559. #endif
  560. EEPROM_READ(lpq_len);
  561. #if ENABLED(PIDTEMPBED)
  562. EEPROM_READ(dummy); // bedKp
  563. if (dummy != DUMMY_PID_VALUE) {
  564. thermalManager.bedKp = dummy;
  565. EEPROM_READ(thermalManager.bedKi);
  566. EEPROM_READ(thermalManager.bedKd);
  567. }
  568. #else
  569. for (uint8_t q=3; q--;) EEPROM_READ(dummy); // bedKp, bedKi, bedKd
  570. #endif
  571. #if !HAS_LCD_CONTRAST
  572. int lcd_contrast;
  573. #endif
  574. EEPROM_READ(lcd_contrast);
  575. #if ENABLED(FWRETRACT)
  576. EEPROM_READ(autoretract_enabled);
  577. EEPROM_READ(retract_length);
  578. #if EXTRUDERS > 1
  579. EEPROM_READ(retract_length_swap);
  580. #else
  581. EEPROM_READ(dummy);
  582. #endif
  583. EEPROM_READ(retract_feedrate_mm_s);
  584. EEPROM_READ(retract_zlift);
  585. EEPROM_READ(retract_recover_length);
  586. #if EXTRUDERS > 1
  587. EEPROM_READ(retract_recover_length_swap);
  588. #else
  589. EEPROM_READ(dummy);
  590. #endif
  591. EEPROM_READ(retract_recover_feedrate_mm_s);
  592. #endif // FWRETRACT
  593. EEPROM_READ(volumetric_enabled);
  594. for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
  595. EEPROM_READ(dummy);
  596. if (q < COUNT(filament_size)) filament_size[q] = dummy;
  597. }
  598. if (eeprom_checksum == stored_checksum) {
  599. if (eeprom_read_error)
  600. Config_ResetDefault();
  601. else {
  602. Config_Postprocess();
  603. SERIAL_ECHO_START;
  604. SERIAL_ECHO(version);
  605. SERIAL_ECHOPAIR(" stored settings retrieved (", eeprom_index - (EEPROM_OFFSET));
  606. SERIAL_ECHOLNPGM(" bytes)");
  607. }
  608. }
  609. else {
  610. SERIAL_ERROR_START;
  611. SERIAL_ERRORLNPGM("EEPROM checksum mismatch");
  612. Config_ResetDefault();
  613. }
  614. }
  615. #if ENABLED(EEPROM_CHITCHAT)
  616. Config_PrintSettings();
  617. #endif
  618. }
  619. #else // !EEPROM_SETTINGS
  620. void Config_StoreSettings() {
  621. SERIAL_ERROR_START;
  622. SERIAL_ERRORLNPGM("EEPROM disabled");
  623. }
  624. #endif // !EEPROM_SETTINGS
  625. /**
  626. * M502 - Reset Configuration
  627. */
  628. void Config_ResetDefault() {
  629. const float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT, tmp2[] = DEFAULT_MAX_FEEDRATE;
  630. const uint32_t tmp3[] = DEFAULT_MAX_ACCELERATION;
  631. LOOP_XYZE_N(i) {
  632. planner.axis_steps_per_mm[i] = tmp1[i < COUNT(tmp1) ? i : COUNT(tmp1) - 1];
  633. planner.max_feedrate_mm_s[i] = tmp2[i < COUNT(tmp2) ? i : COUNT(tmp2) - 1];
  634. planner.max_acceleration_mm_per_s2[i] = tmp3[i < COUNT(tmp3) ? i : COUNT(tmp3) - 1];
  635. }
  636. planner.acceleration = DEFAULT_ACCELERATION;
  637. planner.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
  638. planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
  639. planner.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE;
  640. planner.min_segment_time = DEFAULT_MINSEGMENTTIME;
  641. planner.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
  642. planner.max_jerk[X_AXIS] = DEFAULT_XJERK;
  643. planner.max_jerk[Y_AXIS] = DEFAULT_YJERK;
  644. planner.max_jerk[Z_AXIS] = DEFAULT_ZJERK;
  645. planner.max_jerk[E_AXIS] = DEFAULT_EJERK;
  646. home_offset[X_AXIS] = home_offset[Y_AXIS] = home_offset[Z_AXIS] = 0;
  647. #if HOTENDS > 1
  648. constexpr float tmp4[XYZ][HOTENDS] = {
  649. HOTEND_OFFSET_X,
  650. HOTEND_OFFSET_Y
  651. #ifdef HOTEND_OFFSET_Z
  652. , HOTEND_OFFSET_Z
  653. #else
  654. , { 0 }
  655. #endif
  656. };
  657. static_assert(
  658. tmp4[X_AXIS][0] == 0 && tmp4[Y_AXIS][0] == 0 && tmp4[Z_AXIS][0] == 0,
  659. "Offsets for the first hotend must be 0.0."
  660. );
  661. LOOP_XYZ(i) HOTEND_LOOP() hotend_offset[i][e] = tmp4[i][e];
  662. #endif
  663. // Applies to all MBL and ABL
  664. #if PLANNER_LEVELING
  665. reset_bed_level();
  666. #endif
  667. #if HAS_BED_PROBE
  668. zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
  669. #endif
  670. #if ENABLED(DELTA)
  671. const float adj[ABC] = DELTA_ENDSTOP_ADJ;
  672. endstop_adj[A_AXIS] = adj[A_AXIS];
  673. endstop_adj[B_AXIS] = adj[B_AXIS];
  674. endstop_adj[C_AXIS] = adj[C_AXIS];
  675. delta_radius = DELTA_RADIUS;
  676. delta_diagonal_rod = DELTA_DIAGONAL_ROD;
  677. delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
  678. delta_diagonal_rod_trim_tower_1 = DELTA_DIAGONAL_ROD_TRIM_TOWER_1;
  679. delta_diagonal_rod_trim_tower_2 = DELTA_DIAGONAL_ROD_TRIM_TOWER_2;
  680. delta_diagonal_rod_trim_tower_3 = DELTA_DIAGONAL_ROD_TRIM_TOWER_3;
  681. #elif ENABLED(Z_DUAL_ENDSTOPS)
  682. z_endstop_adj = 0;
  683. #endif
  684. #if ENABLED(ULTIPANEL)
  685. lcd_preheat_hotend_temp[0] = PREHEAT_1_TEMP_HOTEND;
  686. lcd_preheat_hotend_temp[1] = PREHEAT_2_TEMP_HOTEND;
  687. lcd_preheat_bed_temp[0] = PREHEAT_1_TEMP_BED;
  688. lcd_preheat_bed_temp[1] = PREHEAT_2_TEMP_BED;
  689. lcd_preheat_fan_speed[0] = PREHEAT_1_FAN_SPEED;
  690. lcd_preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
  691. #endif
  692. #if HAS_LCD_CONTRAST
  693. lcd_contrast = DEFAULT_LCD_CONTRAST;
  694. #endif
  695. #if ENABLED(PIDTEMP)
  696. #if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
  697. HOTEND_LOOP()
  698. #endif
  699. {
  700. PID_PARAM(Kp, e) = DEFAULT_Kp;
  701. PID_PARAM(Ki, e) = scalePID_i(DEFAULT_Ki);
  702. PID_PARAM(Kd, e) = scalePID_d(DEFAULT_Kd);
  703. #if ENABLED(PID_EXTRUSION_SCALING)
  704. PID_PARAM(Kc, e) = DEFAULT_Kc;
  705. #endif
  706. }
  707. #if ENABLED(PID_EXTRUSION_SCALING)
  708. lpq_len = 20; // default last-position-queue size
  709. #endif
  710. #endif // PIDTEMP
  711. #if ENABLED(PIDTEMPBED)
  712. thermalManager.bedKp = DEFAULT_bedKp;
  713. thermalManager.bedKi = scalePID_i(DEFAULT_bedKi);
  714. thermalManager.bedKd = scalePID_d(DEFAULT_bedKd);
  715. #endif
  716. #if ENABLED(FWRETRACT)
  717. autoretract_enabled = false;
  718. retract_length = RETRACT_LENGTH;
  719. #if EXTRUDERS > 1
  720. retract_length_swap = RETRACT_LENGTH_SWAP;
  721. #endif
  722. retract_feedrate_mm_s = RETRACT_FEEDRATE;
  723. retract_zlift = RETRACT_ZLIFT;
  724. retract_recover_length = RETRACT_RECOVER_LENGTH;
  725. #if EXTRUDERS > 1
  726. retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
  727. #endif
  728. retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE;
  729. #endif
  730. volumetric_enabled =
  731. #if ENABLED(VOLUMETRIC_DEFAULT_ON)
  732. true
  733. #else
  734. false
  735. #endif
  736. ;
  737. for (uint8_t q = 0; q < COUNT(filament_size); q++)
  738. filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
  739. endstops.enable_globally(
  740. #if ENABLED(ENDSTOPS_ALWAYS_ON_DEFAULT)
  741. (true)
  742. #else
  743. (false)
  744. #endif
  745. );
  746. Config_Postprocess();
  747. SERIAL_ECHO_START;
  748. SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
  749. }
  750. #if DISABLED(DISABLE_M503)
  751. #define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START; }while(0)
  752. /**
  753. * M503 - Print Configuration
  754. */
  755. void Config_PrintSettings(bool forReplay) {
  756. // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
  757. CONFIG_ECHO_START;
  758. if (!forReplay) {
  759. SERIAL_ECHOLNPGM("Steps per unit:");
  760. CONFIG_ECHO_START;
  761. }
  762. SERIAL_ECHOPAIR(" M92 X", planner.axis_steps_per_mm[X_AXIS]);
  763. SERIAL_ECHOPAIR(" Y", planner.axis_steps_per_mm[Y_AXIS]);
  764. SERIAL_ECHOPAIR(" Z", planner.axis_steps_per_mm[Z_AXIS]);
  765. #if DISABLED(DISTINCT_E_FACTORS)
  766. SERIAL_ECHOPAIR(" E", planner.axis_steps_per_mm[E_AXIS]);
  767. #endif
  768. SERIAL_EOL;
  769. #if ENABLED(DISTINCT_E_FACTORS)
  770. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  771. SERIAL_ECHOPAIR(" M92 T", (int)i);
  772. SERIAL_ECHOLNPAIR(" E", planner.axis_steps_per_mm[E_AXIS + i]);
  773. }
  774. #endif
  775. CONFIG_ECHO_START;
  776. if (!forReplay) {
  777. SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
  778. CONFIG_ECHO_START;
  779. }
  780. SERIAL_ECHOPAIR(" M203 X", planner.max_feedrate_mm_s[X_AXIS]);
  781. SERIAL_ECHOPAIR(" Y", planner.max_feedrate_mm_s[Y_AXIS]);
  782. SERIAL_ECHOPAIR(" Z", planner.max_feedrate_mm_s[Z_AXIS]);
  783. #if DISABLED(DISTINCT_E_FACTORS)
  784. SERIAL_ECHOPAIR(" E", planner.max_feedrate_mm_s[E_AXIS]);
  785. #endif
  786. SERIAL_EOL;
  787. #if ENABLED(DISTINCT_E_FACTORS)
  788. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  789. SERIAL_ECHOPAIR(" M203 T", (int)i);
  790. SERIAL_ECHOLNPAIR(" E", planner.max_feedrate_mm_s[E_AXIS + i]);
  791. }
  792. #endif
  793. CONFIG_ECHO_START;
  794. if (!forReplay) {
  795. SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
  796. CONFIG_ECHO_START;
  797. }
  798. SERIAL_ECHOPAIR(" M201 X", planner.max_acceleration_mm_per_s2[X_AXIS]);
  799. SERIAL_ECHOPAIR(" Y", planner.max_acceleration_mm_per_s2[Y_AXIS]);
  800. SERIAL_ECHOPAIR(" Z", planner.max_acceleration_mm_per_s2[Z_AXIS]);
  801. #if DISABLED(DISTINCT_E_FACTORS)
  802. SERIAL_ECHOPAIR(" E", planner.max_acceleration_mm_per_s2[E_AXIS]);
  803. #endif
  804. SERIAL_EOL;
  805. #if ENABLED(DISTINCT_E_FACTORS)
  806. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  807. SERIAL_ECHOPAIR(" M201 T", (int)i);
  808. SERIAL_ECHOLNPAIR(" E", planner.max_acceleration_mm_per_s2[E_AXIS + i]);
  809. }
  810. #endif
  811. CONFIG_ECHO_START;
  812. if (!forReplay) {
  813. SERIAL_ECHOLNPGM("Accelerations: P=printing, R=retract and T=travel");
  814. CONFIG_ECHO_START;
  815. }
  816. SERIAL_ECHOPAIR(" M204 P", planner.acceleration);
  817. SERIAL_ECHOPAIR(" R", planner.retract_acceleration);
  818. SERIAL_ECHOPAIR(" T", planner.travel_acceleration);
  819. SERIAL_EOL;
  820. CONFIG_ECHO_START;
  821. if (!forReplay) {
  822. 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)");
  823. CONFIG_ECHO_START;
  824. }
  825. SERIAL_ECHOPAIR(" M205 S", planner.min_feedrate_mm_s);
  826. SERIAL_ECHOPAIR(" T", planner.min_travel_feedrate_mm_s);
  827. SERIAL_ECHOPAIR(" B", planner.min_segment_time);
  828. SERIAL_ECHOPAIR(" X", planner.max_jerk[X_AXIS]);
  829. SERIAL_ECHOPAIR(" Y", planner.max_jerk[Y_AXIS]);
  830. SERIAL_ECHOPAIR(" Z", planner.max_jerk[Z_AXIS]);
  831. SERIAL_ECHOPAIR(" E", planner.max_jerk[E_AXIS]);
  832. SERIAL_EOL;
  833. CONFIG_ECHO_START;
  834. if (!forReplay) {
  835. SERIAL_ECHOLNPGM("Home offset (mm)");
  836. CONFIG_ECHO_START;
  837. }
  838. SERIAL_ECHOPAIR(" M206 X", home_offset[X_AXIS]);
  839. SERIAL_ECHOPAIR(" Y", home_offset[Y_AXIS]);
  840. SERIAL_ECHOPAIR(" Z", home_offset[Z_AXIS]);
  841. SERIAL_EOL;
  842. #if HOTENDS > 1
  843. CONFIG_ECHO_START;
  844. if (!forReplay) {
  845. SERIAL_ECHOLNPGM("Hotend offsets (mm)");
  846. CONFIG_ECHO_START;
  847. }
  848. for (uint8_t e = 1; e < HOTENDS; e++) {
  849. SERIAL_ECHOPAIR(" M218 T", (int)e);
  850. SERIAL_ECHOPAIR(" X", hotend_offset[X_AXIS][e]);
  851. SERIAL_ECHOPAIR(" Y", hotend_offset[Y_AXIS][e]);
  852. #if ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_EXTRUDER)
  853. SERIAL_ECHOPAIR(" Z", hotend_offset[Z_AXIS][e]);
  854. #endif
  855. SERIAL_EOL;
  856. }
  857. #endif
  858. #if ENABLED(MESH_BED_LEVELING)
  859. if (!forReplay) {
  860. SERIAL_ECHOLNPGM("Mesh Bed Leveling:");
  861. CONFIG_ECHO_START;
  862. }
  863. SERIAL_ECHOLNPAIR(" M420 S", mbl.has_mesh() ? 1 : 0);
  864. for (uint8_t py = 1; py <= MESH_NUM_Y_POINTS; py++) {
  865. for (uint8_t px = 1; px <= MESH_NUM_X_POINTS; px++) {
  866. CONFIG_ECHO_START;
  867. SERIAL_ECHOPAIR(" G29 S3 X", (int)px);
  868. SERIAL_ECHOPAIR(" Y", (int)py);
  869. SERIAL_ECHOPGM(" Z");
  870. SERIAL_PROTOCOL_F(mbl.z_values[py-1][px-1], 5);
  871. SERIAL_EOL;
  872. }
  873. }
  874. #elif HAS_ABL
  875. if (!forReplay) {
  876. SERIAL_ECHOLNPGM("Auto Bed Leveling:");
  877. CONFIG_ECHO_START;
  878. }
  879. SERIAL_ECHOLNPAIR(" M420 S", planner.abl_enabled ? 1 : 0);
  880. #endif
  881. #if ENABLED(DELTA)
  882. CONFIG_ECHO_START;
  883. if (!forReplay) {
  884. SERIAL_ECHOLNPGM("Endstop adjustment (mm):");
  885. CONFIG_ECHO_START;
  886. }
  887. SERIAL_ECHOPAIR(" M666 X", endstop_adj[X_AXIS]);
  888. SERIAL_ECHOPAIR(" Y", endstop_adj[Y_AXIS]);
  889. SERIAL_ECHOPAIR(" Z", endstop_adj[Z_AXIS]);
  890. SERIAL_EOL;
  891. CONFIG_ECHO_START;
  892. if (!forReplay) {
  893. SERIAL_ECHOLNPGM("Delta settings: L=diagonal_rod, R=radius, S=segments_per_second, ABC=diagonal_rod_trim_tower_[123]");
  894. CONFIG_ECHO_START;
  895. }
  896. SERIAL_ECHOPAIR(" M665 L", delta_diagonal_rod);
  897. SERIAL_ECHOPAIR(" R", delta_radius);
  898. SERIAL_ECHOPAIR(" S", delta_segments_per_second);
  899. SERIAL_ECHOPAIR(" A", delta_diagonal_rod_trim_tower_1);
  900. SERIAL_ECHOPAIR(" B", delta_diagonal_rod_trim_tower_2);
  901. SERIAL_ECHOPAIR(" C", delta_diagonal_rod_trim_tower_3);
  902. SERIAL_EOL;
  903. #elif ENABLED(Z_DUAL_ENDSTOPS)
  904. CONFIG_ECHO_START;
  905. if (!forReplay) {
  906. SERIAL_ECHOLNPGM("Z2 Endstop adjustment (mm):");
  907. CONFIG_ECHO_START;
  908. }
  909. SERIAL_ECHOPAIR(" M666 Z", z_endstop_adj);
  910. SERIAL_EOL;
  911. #endif // DELTA
  912. #if ENABLED(ULTIPANEL)
  913. CONFIG_ECHO_START;
  914. if (!forReplay) {
  915. SERIAL_ECHOLNPGM("Material heatup parameters:");
  916. CONFIG_ECHO_START;
  917. }
  918. for (uint8_t i = 0; i < COUNT(lcd_preheat_hotend_temp); i++) {
  919. SERIAL_ECHOPAIR(" M145 S", (int)i);
  920. SERIAL_ECHOPAIR(" H", lcd_preheat_hotend_temp[i]);
  921. SERIAL_ECHOPAIR(" B", lcd_preheat_bed_temp[i]);
  922. SERIAL_ECHOPAIR(" F", lcd_preheat_fan_speed[i]);
  923. SERIAL_EOL;
  924. }
  925. #endif // ULTIPANEL
  926. #if HAS_PID_HEATING
  927. CONFIG_ECHO_START;
  928. if (!forReplay) {
  929. SERIAL_ECHOLNPGM("PID settings:");
  930. }
  931. #if ENABLED(PIDTEMP)
  932. #if HOTENDS > 1
  933. if (forReplay) {
  934. HOTEND_LOOP() {
  935. CONFIG_ECHO_START;
  936. SERIAL_ECHOPAIR(" M301 E", e);
  937. SERIAL_ECHOPAIR(" P", PID_PARAM(Kp, e));
  938. SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, e)));
  939. SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, e)));
  940. #if ENABLED(PID_EXTRUSION_SCALING)
  941. SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, e));
  942. if (e == 0) SERIAL_ECHOPAIR(" L", lpq_len);
  943. #endif
  944. SERIAL_EOL;
  945. }
  946. }
  947. else
  948. #endif // HOTENDS > 1
  949. // !forReplay || HOTENDS == 1
  950. {
  951. CONFIG_ECHO_START;
  952. SERIAL_ECHOPAIR(" M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echo values for E0
  953. SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
  954. SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
  955. #if ENABLED(PID_EXTRUSION_SCALING)
  956. SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, 0));
  957. SERIAL_ECHOPAIR(" L", lpq_len);
  958. #endif
  959. SERIAL_EOL;
  960. }
  961. #endif // PIDTEMP
  962. #if ENABLED(PIDTEMPBED)
  963. CONFIG_ECHO_START;
  964. SERIAL_ECHOPAIR(" M304 P", thermalManager.bedKp);
  965. SERIAL_ECHOPAIR(" I", unscalePID_i(thermalManager.bedKi));
  966. SERIAL_ECHOPAIR(" D", unscalePID_d(thermalManager.bedKd));
  967. SERIAL_EOL;
  968. #endif
  969. #endif // PIDTEMP || PIDTEMPBED
  970. #if HAS_LCD_CONTRAST
  971. CONFIG_ECHO_START;
  972. if (!forReplay) {
  973. SERIAL_ECHOLNPGM("LCD Contrast:");
  974. CONFIG_ECHO_START;
  975. }
  976. SERIAL_ECHOPAIR(" M250 C", lcd_contrast);
  977. SERIAL_EOL;
  978. #endif
  979. #if ENABLED(FWRETRACT)
  980. CONFIG_ECHO_START;
  981. if (!forReplay) {
  982. SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
  983. CONFIG_ECHO_START;
  984. }
  985. SERIAL_ECHOPAIR(" M207 S", retract_length);
  986. #if EXTRUDERS > 1
  987. SERIAL_ECHOPAIR(" W", retract_length_swap);
  988. #endif
  989. SERIAL_ECHOPAIR(" F", MMS_TO_MMM(retract_feedrate_mm_s));
  990. SERIAL_ECHOPAIR(" Z", retract_zlift);
  991. SERIAL_EOL;
  992. CONFIG_ECHO_START;
  993. if (!forReplay) {
  994. SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
  995. CONFIG_ECHO_START;
  996. }
  997. SERIAL_ECHOPAIR(" M208 S", retract_recover_length);
  998. #if EXTRUDERS > 1
  999. SERIAL_ECHOPAIR(" W", retract_recover_length_swap);
  1000. #endif
  1001. SERIAL_ECHOPAIR(" F", MMS_TO_MMM(retract_recover_feedrate_mm_s));
  1002. SERIAL_EOL;
  1003. CONFIG_ECHO_START;
  1004. if (!forReplay) {
  1005. SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
  1006. CONFIG_ECHO_START;
  1007. }
  1008. SERIAL_ECHOPAIR(" M209 S", autoretract_enabled ? 1 : 0);
  1009. SERIAL_EOL;
  1010. #endif // FWRETRACT
  1011. /**
  1012. * Volumetric extrusion M200
  1013. */
  1014. if (!forReplay) {
  1015. CONFIG_ECHO_START;
  1016. SERIAL_ECHOPGM("Filament settings:");
  1017. if (volumetric_enabled)
  1018. SERIAL_EOL;
  1019. else
  1020. SERIAL_ECHOLNPGM(" Disabled");
  1021. }
  1022. CONFIG_ECHO_START;
  1023. SERIAL_ECHOPAIR(" M200 D", filament_size[0]);
  1024. SERIAL_EOL;
  1025. #if EXTRUDERS > 1
  1026. CONFIG_ECHO_START;
  1027. SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]);
  1028. SERIAL_EOL;
  1029. #if EXTRUDERS > 2
  1030. CONFIG_ECHO_START;
  1031. SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]);
  1032. SERIAL_EOL;
  1033. #if EXTRUDERS > 3
  1034. CONFIG_ECHO_START;
  1035. SERIAL_ECHOPAIR(" M200 T3 D", filament_size[3]);
  1036. SERIAL_EOL;
  1037. #endif
  1038. #endif
  1039. #endif
  1040. if (!volumetric_enabled) {
  1041. CONFIG_ECHO_START;
  1042. SERIAL_ECHOLNPGM(" M200 D0");
  1043. }
  1044. /**
  1045. * Auto Bed Leveling
  1046. */
  1047. #if HAS_BED_PROBE
  1048. if (!forReplay) {
  1049. CONFIG_ECHO_START;
  1050. SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
  1051. }
  1052. CONFIG_ECHO_START;
  1053. SERIAL_ECHOPAIR(" M851 Z", zprobe_zoffset);
  1054. SERIAL_EOL;
  1055. #endif
  1056. }
  1057. #endif // !DISABLE_M503