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

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