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

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