My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

configuration_store.cpp 54KB

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