My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

configuration_store.cpp 38KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179
  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. #else
  699. int e = 0; UNUSED(e); // only need to write once
  700. #endif
  701. {
  702. PID_PARAM(Kp, e) = DEFAULT_Kp;
  703. PID_PARAM(Ki, e) = scalePID_i(DEFAULT_Ki);
  704. PID_PARAM(Kd, e) = scalePID_d(DEFAULT_Kd);
  705. #if ENABLED(PID_EXTRUSION_SCALING)
  706. PID_PARAM(Kc, e) = DEFAULT_Kc;
  707. #endif
  708. }
  709. #if ENABLED(PID_EXTRUSION_SCALING)
  710. lpq_len = 20; // default last-position-queue size
  711. #endif
  712. #endif // PIDTEMP
  713. #if ENABLED(PIDTEMPBED)
  714. thermalManager.bedKp = DEFAULT_bedKp;
  715. thermalManager.bedKi = scalePID_i(DEFAULT_bedKi);
  716. thermalManager.bedKd = scalePID_d(DEFAULT_bedKd);
  717. #endif
  718. #if ENABLED(FWRETRACT)
  719. autoretract_enabled = false;
  720. retract_length = RETRACT_LENGTH;
  721. #if EXTRUDERS > 1
  722. retract_length_swap = RETRACT_LENGTH_SWAP;
  723. #endif
  724. retract_feedrate_mm_s = RETRACT_FEEDRATE;
  725. retract_zlift = RETRACT_ZLIFT;
  726. retract_recover_length = RETRACT_RECOVER_LENGTH;
  727. #if EXTRUDERS > 1
  728. retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
  729. #endif
  730. retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE;
  731. #endif
  732. volumetric_enabled = false;
  733. for (uint8_t q = 0; q < COUNT(filament_size); q++)
  734. filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
  735. endstops.enable_globally(
  736. #if ENABLED(ENDSTOPS_ALWAYS_ON_DEFAULT)
  737. (true)
  738. #else
  739. (false)
  740. #endif
  741. );
  742. Config_Postprocess();
  743. SERIAL_ECHO_START;
  744. SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
  745. }
  746. #if DISABLED(DISABLE_M503)
  747. #define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START; }while(0)
  748. /**
  749. * M503 - Print Configuration
  750. */
  751. void Config_PrintSettings(bool forReplay) {
  752. // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
  753. CONFIG_ECHO_START;
  754. if (!forReplay) {
  755. SERIAL_ECHOLNPGM("Steps per unit:");
  756. CONFIG_ECHO_START;
  757. }
  758. SERIAL_ECHOPAIR(" M92 X", planner.axis_steps_per_mm[X_AXIS]);
  759. SERIAL_ECHOPAIR(" Y", planner.axis_steps_per_mm[Y_AXIS]);
  760. SERIAL_ECHOPAIR(" Z", planner.axis_steps_per_mm[Z_AXIS]);
  761. #if DISABLED(DISTINCT_E_FACTORS)
  762. SERIAL_ECHOPAIR(" E", planner.axis_steps_per_mm[E_AXIS]);
  763. #endif
  764. SERIAL_EOL;
  765. #if ENABLED(DISTINCT_E_FACTORS)
  766. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  767. SERIAL_ECHOPAIR(" M92 T", (int)i);
  768. SERIAL_ECHOLNPAIR(" E", planner.axis_steps_per_mm[E_AXIS + i]);
  769. }
  770. #endif
  771. CONFIG_ECHO_START;
  772. if (!forReplay) {
  773. SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
  774. CONFIG_ECHO_START;
  775. }
  776. SERIAL_ECHOPAIR(" M203 X", planner.max_feedrate_mm_s[X_AXIS]);
  777. SERIAL_ECHOPAIR(" Y", planner.max_feedrate_mm_s[Y_AXIS]);
  778. SERIAL_ECHOPAIR(" Z", planner.max_feedrate_mm_s[Z_AXIS]);
  779. #if DISABLED(DISTINCT_E_FACTORS)
  780. SERIAL_ECHOPAIR(" E", planner.max_feedrate_mm_s[E_AXIS]);
  781. #endif
  782. SERIAL_EOL;
  783. #if ENABLED(DISTINCT_E_FACTORS)
  784. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  785. SERIAL_ECHOPAIR(" M203 T", (int)i);
  786. SERIAL_ECHOLNPAIR(" E", planner.max_feedrate_mm_s[E_AXIS + i]);
  787. }
  788. #endif
  789. CONFIG_ECHO_START;
  790. if (!forReplay) {
  791. SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
  792. CONFIG_ECHO_START;
  793. }
  794. SERIAL_ECHOPAIR(" M201 X", planner.max_acceleration_mm_per_s2[X_AXIS]);
  795. SERIAL_ECHOPAIR(" Y", planner.max_acceleration_mm_per_s2[Y_AXIS]);
  796. SERIAL_ECHOPAIR(" Z", planner.max_acceleration_mm_per_s2[Z_AXIS]);
  797. #if DISABLED(DISTINCT_E_FACTORS)
  798. SERIAL_ECHOPAIR(" E", planner.max_acceleration_mm_per_s2[E_AXIS]);
  799. #endif
  800. SERIAL_EOL;
  801. #if ENABLED(DISTINCT_E_FACTORS)
  802. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  803. SERIAL_ECHOPAIR(" M201 T", (int)i);
  804. SERIAL_ECHOLNPAIR(" E", planner.max_acceleration_mm_per_s2[E_AXIS + i]);
  805. }
  806. #endif
  807. CONFIG_ECHO_START;
  808. if (!forReplay) {
  809. SERIAL_ECHOLNPGM("Accelerations: P=printing, R=retract and T=travel");
  810. CONFIG_ECHO_START;
  811. }
  812. SERIAL_ECHOPAIR(" M204 P", planner.acceleration);
  813. SERIAL_ECHOPAIR(" R", planner.retract_acceleration);
  814. SERIAL_ECHOPAIR(" T", planner.travel_acceleration);
  815. SERIAL_EOL;
  816. CONFIG_ECHO_START;
  817. if (!forReplay) {
  818. 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)");
  819. CONFIG_ECHO_START;
  820. }
  821. SERIAL_ECHOPAIR(" M205 S", planner.min_feedrate_mm_s);
  822. SERIAL_ECHOPAIR(" T", planner.min_travel_feedrate_mm_s);
  823. SERIAL_ECHOPAIR(" B", planner.min_segment_time);
  824. SERIAL_ECHOPAIR(" X", planner.max_jerk[X_AXIS]);
  825. SERIAL_ECHOPAIR(" Y", planner.max_jerk[Y_AXIS]);
  826. SERIAL_ECHOPAIR(" Z", planner.max_jerk[Z_AXIS]);
  827. SERIAL_ECHOPAIR(" E", planner.max_jerk[E_AXIS]);
  828. SERIAL_EOL;
  829. CONFIG_ECHO_START;
  830. if (!forReplay) {
  831. SERIAL_ECHOLNPGM("Home offset (mm)");
  832. CONFIG_ECHO_START;
  833. }
  834. SERIAL_ECHOPAIR(" M206 X", home_offset[X_AXIS]);
  835. SERIAL_ECHOPAIR(" Y", home_offset[Y_AXIS]);
  836. SERIAL_ECHOPAIR(" Z", home_offset[Z_AXIS]);
  837. SERIAL_EOL;
  838. #if HOTENDS > 1
  839. CONFIG_ECHO_START;
  840. if (!forReplay) {
  841. SERIAL_ECHOLNPGM("Hotend offsets (mm)");
  842. CONFIG_ECHO_START;
  843. }
  844. for (uint8_t e = 1; e < HOTENDS; e++) {
  845. SERIAL_ECHOPAIR(" M218 T", (int)e);
  846. SERIAL_ECHOPAIR(" X", hotend_offset[X_AXIS][e]);
  847. SERIAL_ECHOPAIR(" Y", hotend_offset[Y_AXIS][e]);
  848. #if ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_EXTRUDER)
  849. SERIAL_ECHOPAIR(" Z", hotend_offset[Z_AXIS][e]);
  850. #endif
  851. SERIAL_EOL;
  852. }
  853. #endif
  854. #if ENABLED(MESH_BED_LEVELING)
  855. if (!forReplay) {
  856. SERIAL_ECHOLNPGM("Mesh Bed Leveling:");
  857. CONFIG_ECHO_START;
  858. }
  859. SERIAL_ECHOLNPAIR(" M420 S", mbl.has_mesh() ? 1 : 0);
  860. for (uint8_t py = 1; py <= MESH_NUM_Y_POINTS; py++) {
  861. for (uint8_t px = 1; px <= MESH_NUM_X_POINTS; px++) {
  862. CONFIG_ECHO_START;
  863. SERIAL_ECHOPAIR(" G29 S3 X", (int)px);
  864. SERIAL_ECHOPAIR(" Y", (int)py);
  865. SERIAL_ECHOPGM(" Z");
  866. SERIAL_PROTOCOL_F(mbl.z_values[py-1][px-1], 5);
  867. SERIAL_EOL;
  868. }
  869. }
  870. #elif HAS_ABL
  871. if (!forReplay) {
  872. SERIAL_ECHOLNPGM("Auto Bed Leveling:");
  873. CONFIG_ECHO_START;
  874. }
  875. SERIAL_ECHOLNPAIR(" M420 S", planner.abl_enabled ? 1 : 0);
  876. #endif
  877. #if ENABLED(DELTA)
  878. CONFIG_ECHO_START;
  879. if (!forReplay) {
  880. SERIAL_ECHOLNPGM("Endstop adjustment (mm):");
  881. CONFIG_ECHO_START;
  882. }
  883. SERIAL_ECHOPAIR(" M666 X", endstop_adj[X_AXIS]);
  884. SERIAL_ECHOPAIR(" Y", endstop_adj[Y_AXIS]);
  885. SERIAL_ECHOPAIR(" Z", endstop_adj[Z_AXIS]);
  886. SERIAL_EOL;
  887. CONFIG_ECHO_START;
  888. if (!forReplay) {
  889. SERIAL_ECHOLNPGM("Delta settings: L=diagonal_rod, R=radius, S=segments_per_second, ABC=diagonal_rod_trim_tower_[123]");
  890. CONFIG_ECHO_START;
  891. }
  892. SERIAL_ECHOPAIR(" M665 L", delta_diagonal_rod);
  893. SERIAL_ECHOPAIR(" R", delta_radius);
  894. SERIAL_ECHOPAIR(" S", delta_segments_per_second);
  895. SERIAL_ECHOPAIR(" A", delta_diagonal_rod_trim_tower_1);
  896. SERIAL_ECHOPAIR(" B", delta_diagonal_rod_trim_tower_2);
  897. SERIAL_ECHOPAIR(" C", delta_diagonal_rod_trim_tower_3);
  898. SERIAL_EOL;
  899. #elif ENABLED(Z_DUAL_ENDSTOPS)
  900. CONFIG_ECHO_START;
  901. if (!forReplay) {
  902. SERIAL_ECHOLNPGM("Z2 Endstop adjustment (mm):");
  903. CONFIG_ECHO_START;
  904. }
  905. SERIAL_ECHOPAIR(" M666 Z", z_endstop_adj);
  906. SERIAL_EOL;
  907. #endif // DELTA
  908. #if ENABLED(ULTIPANEL)
  909. CONFIG_ECHO_START;
  910. if (!forReplay) {
  911. SERIAL_ECHOLNPGM("Material heatup parameters:");
  912. CONFIG_ECHO_START;
  913. }
  914. for (uint8_t i = 0; i < COUNT(lcd_preheat_hotend_temp); i++) {
  915. SERIAL_ECHOPAIR(" M145 S", (int)i);
  916. SERIAL_ECHOPAIR(" H", lcd_preheat_hotend_temp[i]);
  917. SERIAL_ECHOPAIR(" B", lcd_preheat_bed_temp[i]);
  918. SERIAL_ECHOPAIR(" F", lcd_preheat_fan_speed[i]);
  919. SERIAL_EOL;
  920. }
  921. #endif // ULTIPANEL
  922. #if HAS_PID_HEATING
  923. CONFIG_ECHO_START;
  924. if (!forReplay) {
  925. SERIAL_ECHOLNPGM("PID settings:");
  926. }
  927. #if ENABLED(PIDTEMP)
  928. #if HOTENDS > 1
  929. if (forReplay) {
  930. HOTEND_LOOP() {
  931. CONFIG_ECHO_START;
  932. SERIAL_ECHOPAIR(" M301 E", e);
  933. SERIAL_ECHOPAIR(" P", PID_PARAM(Kp, e));
  934. SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, e)));
  935. SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, e)));
  936. #if ENABLED(PID_EXTRUSION_SCALING)
  937. SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, e));
  938. if (e == 0) SERIAL_ECHOPAIR(" L", lpq_len);
  939. #endif
  940. SERIAL_EOL;
  941. }
  942. }
  943. else
  944. #endif // HOTENDS > 1
  945. // !forReplay || HOTENDS == 1
  946. {
  947. CONFIG_ECHO_START;
  948. SERIAL_ECHOPAIR(" M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echo values for E0
  949. SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
  950. SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
  951. #if ENABLED(PID_EXTRUSION_SCALING)
  952. SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, 0));
  953. SERIAL_ECHOPAIR(" L", lpq_len);
  954. #endif
  955. SERIAL_EOL;
  956. }
  957. #endif // PIDTEMP
  958. #if ENABLED(PIDTEMPBED)
  959. CONFIG_ECHO_START;
  960. SERIAL_ECHOPAIR(" M304 P", thermalManager.bedKp);
  961. SERIAL_ECHOPAIR(" I", unscalePID_i(thermalManager.bedKi));
  962. SERIAL_ECHOPAIR(" D", unscalePID_d(thermalManager.bedKd));
  963. SERIAL_EOL;
  964. #endif
  965. #endif // PIDTEMP || PIDTEMPBED
  966. #if HAS_LCD_CONTRAST
  967. CONFIG_ECHO_START;
  968. if (!forReplay) {
  969. SERIAL_ECHOLNPGM("LCD Contrast:");
  970. CONFIG_ECHO_START;
  971. }
  972. SERIAL_ECHOPAIR(" M250 C", lcd_contrast);
  973. SERIAL_EOL;
  974. #endif
  975. #if ENABLED(FWRETRACT)
  976. CONFIG_ECHO_START;
  977. if (!forReplay) {
  978. SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
  979. CONFIG_ECHO_START;
  980. }
  981. SERIAL_ECHOPAIR(" M207 S", retract_length);
  982. #if EXTRUDERS > 1
  983. SERIAL_ECHOPAIR(" W", retract_length_swap);
  984. #endif
  985. SERIAL_ECHOPAIR(" F", MMS_TO_MMM(retract_feedrate_mm_s));
  986. SERIAL_ECHOPAIR(" Z", retract_zlift);
  987. SERIAL_EOL;
  988. CONFIG_ECHO_START;
  989. if (!forReplay) {
  990. SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
  991. CONFIG_ECHO_START;
  992. }
  993. SERIAL_ECHOPAIR(" M208 S", retract_recover_length);
  994. #if EXTRUDERS > 1
  995. SERIAL_ECHOPAIR(" W", retract_recover_length_swap);
  996. #endif
  997. SERIAL_ECHOPAIR(" F", MMS_TO_MMM(retract_recover_feedrate_mm_s));
  998. SERIAL_EOL;
  999. CONFIG_ECHO_START;
  1000. if (!forReplay) {
  1001. SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
  1002. CONFIG_ECHO_START;
  1003. }
  1004. SERIAL_ECHOPAIR(" M209 S", autoretract_enabled ? 1 : 0);
  1005. SERIAL_EOL;
  1006. #endif // FWRETRACT
  1007. /**
  1008. * Volumetric extrusion M200
  1009. */
  1010. if (!forReplay) {
  1011. CONFIG_ECHO_START;
  1012. SERIAL_ECHOPGM("Filament settings:");
  1013. if (volumetric_enabled)
  1014. SERIAL_EOL;
  1015. else
  1016. SERIAL_ECHOLNPGM(" Disabled");
  1017. }
  1018. CONFIG_ECHO_START;
  1019. SERIAL_ECHOPAIR(" M200 D", filament_size[0]);
  1020. SERIAL_EOL;
  1021. #if EXTRUDERS > 1
  1022. CONFIG_ECHO_START;
  1023. SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]);
  1024. SERIAL_EOL;
  1025. #if EXTRUDERS > 2
  1026. CONFIG_ECHO_START;
  1027. SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]);
  1028. SERIAL_EOL;
  1029. #if EXTRUDERS > 3
  1030. CONFIG_ECHO_START;
  1031. SERIAL_ECHOPAIR(" M200 T3 D", filament_size[3]);
  1032. SERIAL_EOL;
  1033. #endif
  1034. #endif
  1035. #endif
  1036. if (!volumetric_enabled) {
  1037. CONFIG_ECHO_START;
  1038. SERIAL_ECHOLNPGM(" M200 D0");
  1039. }
  1040. /**
  1041. * Auto Bed Leveling
  1042. */
  1043. #if HAS_BED_PROBE
  1044. if (!forReplay) {
  1045. CONFIG_ECHO_START;
  1046. SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
  1047. }
  1048. CONFIG_ECHO_START;
  1049. SERIAL_ECHOPAIR(" M851 Z", zprobe_zoffset);
  1050. SERIAL_EOL;
  1051. #endif
  1052. }
  1053. #endif // !DISABLE_M503