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

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