My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

configuration_store.cpp 54KB

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