My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

configuration_store.cpp 51KB

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