My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

configuration_store.cpp 54KB

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