My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

configuration_store.cpp 38KB

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