My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ConfigurationStore.cpp 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. /**
  2. * ConfigurationStore.cpp
  3. *
  4. * Configuration and EEPROM storage
  5. *
  6. * V16 EEPROM Layout:
  7. *
  8. * ver
  9. * axis_steps_per_unit (x4)
  10. * max_feedrate (x4)
  11. * max_acceleration_units_per_sq_second (x4)
  12. * acceleration
  13. * retract_acceleration
  14. * travel_aceeleration
  15. * minimumfeedrate
  16. * mintravelfeedrate
  17. * minsegmenttime
  18. * max_xy_jerk
  19. * max_z_jerk
  20. * max_e_jerk
  21. * add_homing (x3)
  22. *
  23. * Mesh bed leveling:
  24. * active
  25. * mesh_num_x
  26. * mesh_num_y
  27. * z_values[][]
  28. *
  29. * DELTA:
  30. * endstop_adj (x3)
  31. * delta_radius
  32. * delta_diagonal_rod
  33. * delta_segments_per_second
  34. *
  35. * ULTIPANEL:
  36. * plaPreheatHotendTemp
  37. * plaPreheatHPBTemp
  38. * plaPreheatFanSpeed
  39. * absPreheatHotendTemp
  40. * absPreheatHPBTemp
  41. * absPreheatFanSpeed
  42. * zprobe_zoffset
  43. *
  44. * PIDTEMP:
  45. * Kp[0], Ki[0], Kd[0], Kc[0]
  46. * Kp[1], Ki[1], Kd[1], Kc[1]
  47. * Kp[2], Ki[2], Kd[2], Kc[2]
  48. * Kp[3], Ki[3], Kd[3], Kc[3]
  49. *
  50. * DOGLCD:
  51. * lcd_contrast
  52. *
  53. * SCARA:
  54. * axis_scaling (x3)
  55. *
  56. * FWRETRACT:
  57. * autoretract_enabled
  58. * retract_length
  59. * retract_length_swap
  60. * retract_feedrate
  61. * retract_zlift
  62. * retract_recover_length
  63. * retract_recover_length_swap
  64. * retract_recover_feedrate
  65. *
  66. * volumetric_enabled
  67. *
  68. * filament_size (x4)
  69. *
  70. */
  71. #include "Marlin.h"
  72. #include "language.h"
  73. #include "planner.h"
  74. #include "temperature.h"
  75. #include "ultralcd.h"
  76. #include "ConfigurationStore.h"
  77. #if defined(MESH_BED_LEVELING)
  78. #include "mesh_bed_leveling.h"
  79. #endif // MESH_BED_LEVELING
  80. void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) {
  81. uint8_t c;
  82. while(size--) {
  83. eeprom_write_byte((unsigned char*)pos, *value);
  84. c = eeprom_read_byte((unsigned char*)pos);
  85. if (c != *value) {
  86. SERIAL_ECHO_START;
  87. SERIAL_ECHOLNPGM(MSG_ERR_EEPROM_WRITE);
  88. }
  89. pos++;
  90. value++;
  91. };
  92. }
  93. void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
  94. do {
  95. *value = eeprom_read_byte((unsigned char*)pos);
  96. pos++;
  97. value++;
  98. } while (--size);
  99. }
  100. #define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value))
  101. #define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value))
  102. //======================================================================================
  103. #define DUMMY_PID_VALUE 3000.0f
  104. #define EEPROM_OFFSET 100
  105. // IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
  106. // in the functions below, also increment the version number. This makes sure that
  107. // the default values are used whenever there is a change to the data, to prevent
  108. // wrong data being written to the variables.
  109. // ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
  110. #define EEPROM_VERSION "V17"
  111. #ifdef EEPROM_SETTINGS
  112. void Config_StoreSettings() {
  113. float dummy = 0.0f;
  114. char ver[4] = "000";
  115. int i = EEPROM_OFFSET;
  116. EEPROM_WRITE_VAR(i, ver); // invalidate data first
  117. EEPROM_WRITE_VAR(i, axis_steps_per_unit);
  118. EEPROM_WRITE_VAR(i, max_feedrate);
  119. EEPROM_WRITE_VAR(i, max_acceleration_units_per_sq_second);
  120. EEPROM_WRITE_VAR(i, acceleration);
  121. EEPROM_WRITE_VAR(i, retract_acceleration);
  122. EEPROM_WRITE_VAR(i, travel_acceleration);
  123. EEPROM_WRITE_VAR(i, minimumfeedrate);
  124. EEPROM_WRITE_VAR(i, mintravelfeedrate);
  125. EEPROM_WRITE_VAR(i, minsegmenttime);
  126. EEPROM_WRITE_VAR(i, max_xy_jerk);
  127. EEPROM_WRITE_VAR(i, max_z_jerk);
  128. EEPROM_WRITE_VAR(i, max_e_jerk);
  129. EEPROM_WRITE_VAR(i, add_homing);
  130. uint8_t mesh_num_x = 3;
  131. uint8_t mesh_num_y = 3;
  132. #if defined(MESH_BED_LEVELING)
  133. // Compile time test that sizeof(mbl.z_values) is as expected
  134. typedef char c_assert[(sizeof(mbl.z_values) == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS*sizeof(dummy)) ? 1 : -1];
  135. mesh_num_x = MESH_NUM_X_POINTS;
  136. mesh_num_y = MESH_NUM_Y_POINTS;
  137. EEPROM_WRITE_VAR(i, mbl.active);
  138. EEPROM_WRITE_VAR(i, mesh_num_x);
  139. EEPROM_WRITE_VAR(i, mesh_num_y);
  140. EEPROM_WRITE_VAR(i, mbl.z_values);
  141. #else
  142. uint8_t dummy_uint8 = 0;
  143. EEPROM_WRITE_VAR(i, dummy_uint8);
  144. EEPROM_WRITE_VAR(i, mesh_num_x);
  145. EEPROM_WRITE_VAR(i, mesh_num_y);
  146. dummy = 0.0f;
  147. for (int q=0; q<mesh_num_x*mesh_num_y; q++) {
  148. EEPROM_WRITE_VAR(i, dummy);
  149. }
  150. #endif // MESH_BED_LEVELING
  151. #ifdef DELTA
  152. EEPROM_WRITE_VAR(i, endstop_adj); // 3 floats
  153. EEPROM_WRITE_VAR(i, delta_radius); // 1 float
  154. EEPROM_WRITE_VAR(i, delta_diagonal_rod); // 1 float
  155. EEPROM_WRITE_VAR(i, delta_segments_per_second); // 1 float
  156. #else
  157. dummy = 0.0f;
  158. for (int q=6; q--;) EEPROM_WRITE_VAR(i, dummy);
  159. #endif
  160. #ifndef ULTIPANEL
  161. int plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP, plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP, plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED,
  162. absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP, absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP, absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
  163. #endif // !ULTIPANEL
  164. EEPROM_WRITE_VAR(i, plaPreheatHotendTemp);
  165. EEPROM_WRITE_VAR(i, plaPreheatHPBTemp);
  166. EEPROM_WRITE_VAR(i, plaPreheatFanSpeed);
  167. EEPROM_WRITE_VAR(i, absPreheatHotendTemp);
  168. EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
  169. EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
  170. EEPROM_WRITE_VAR(i, zprobe_zoffset);
  171. for (int e = 0; e < 4; e++) {
  172. #ifdef PIDTEMP
  173. if (e < EXTRUDERS) {
  174. EEPROM_WRITE_VAR(i, PID_PARAM(Kp, e));
  175. EEPROM_WRITE_VAR(i, PID_PARAM(Ki, e));
  176. EEPROM_WRITE_VAR(i, PID_PARAM(Kd, e));
  177. #ifdef PID_ADD_EXTRUSION_RATE
  178. EEPROM_WRITE_VAR(i, PID_PARAM(Kc, e));
  179. #else
  180. dummy = 1.0f; // 1.0 = default kc
  181. EEPROM_WRITE_VAR(i, dummy);
  182. #endif
  183. }
  184. else {
  185. #else // !PIDTEMP
  186. {
  187. #endif // !PIDTEMP
  188. dummy = DUMMY_PID_VALUE;
  189. EEPROM_WRITE_VAR(i, dummy);
  190. dummy = 0.0f;
  191. for (int q = 3; q--;) EEPROM_WRITE_VAR(i, dummy);
  192. }
  193. } // Extruders Loop
  194. #ifndef DOGLCD
  195. int lcd_contrast = 32;
  196. #endif
  197. EEPROM_WRITE_VAR(i, lcd_contrast);
  198. #ifdef SCARA
  199. EEPROM_WRITE_VAR(i, axis_scaling); // 3 floats
  200. #else
  201. dummy = 1.0f;
  202. EEPROM_WRITE_VAR(i, dummy);
  203. #endif
  204. #ifdef FWRETRACT
  205. EEPROM_WRITE_VAR(i, autoretract_enabled);
  206. EEPROM_WRITE_VAR(i, retract_length);
  207. #if EXTRUDERS > 1
  208. EEPROM_WRITE_VAR(i, retract_length_swap);
  209. #else
  210. dummy = 0.0f;
  211. EEPROM_WRITE_VAR(i, dummy);
  212. #endif
  213. EEPROM_WRITE_VAR(i, retract_feedrate);
  214. EEPROM_WRITE_VAR(i, retract_zlift);
  215. EEPROM_WRITE_VAR(i, retract_recover_length);
  216. #if EXTRUDERS > 1
  217. EEPROM_WRITE_VAR(i, retract_recover_length_swap);
  218. #else
  219. dummy = 0.0f;
  220. EEPROM_WRITE_VAR(i, dummy);
  221. #endif
  222. EEPROM_WRITE_VAR(i, retract_recover_feedrate);
  223. #endif // FWRETRACT
  224. EEPROM_WRITE_VAR(i, volumetric_enabled);
  225. // Save filament sizes
  226. for (int q = 0; q < 4; q++) {
  227. if (q < EXTRUDERS) dummy = filament_size[q];
  228. EEPROM_WRITE_VAR(i, dummy);
  229. }
  230. int storageSize = i;
  231. char ver2[4] = EEPROM_VERSION;
  232. int j = EEPROM_OFFSET;
  233. EEPROM_WRITE_VAR(j, ver2); // validate data
  234. // Report storage size
  235. SERIAL_ECHO_START;
  236. SERIAL_ECHOPAIR("Settings Stored (", (unsigned long)i);
  237. SERIAL_ECHOLNPGM(" bytes)");
  238. }
  239. void Config_RetrieveSettings() {
  240. int i = EEPROM_OFFSET;
  241. char stored_ver[4];
  242. char ver[4] = EEPROM_VERSION;
  243. EEPROM_READ_VAR(i, stored_ver); //read stored version
  244. // SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
  245. if (strncmp(ver, stored_ver, 3) != 0) {
  246. Config_ResetDefault();
  247. }
  248. else {
  249. float dummy = 0;
  250. // version number match
  251. EEPROM_READ_VAR(i, axis_steps_per_unit);
  252. EEPROM_READ_VAR(i, max_feedrate);
  253. EEPROM_READ_VAR(i, max_acceleration_units_per_sq_second);
  254. // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
  255. reset_acceleration_rates();
  256. EEPROM_READ_VAR(i, acceleration);
  257. EEPROM_READ_VAR(i, retract_acceleration);
  258. EEPROM_READ_VAR(i, travel_acceleration);
  259. EEPROM_READ_VAR(i, minimumfeedrate);
  260. EEPROM_READ_VAR(i, mintravelfeedrate);
  261. EEPROM_READ_VAR(i, minsegmenttime);
  262. EEPROM_READ_VAR(i, max_xy_jerk);
  263. EEPROM_READ_VAR(i, max_z_jerk);
  264. EEPROM_READ_VAR(i, max_e_jerk);
  265. EEPROM_READ_VAR(i, add_homing);
  266. uint8_t mesh_num_x = 0;
  267. uint8_t mesh_num_y = 0;
  268. #if defined(MESH_BED_LEVELING)
  269. EEPROM_READ_VAR(i, mbl.active);
  270. EEPROM_READ_VAR(i, mesh_num_x);
  271. EEPROM_READ_VAR(i, mesh_num_y);
  272. if (mesh_num_x != MESH_NUM_X_POINTS ||
  273. mesh_num_y != MESH_NUM_Y_POINTS) {
  274. mbl.reset();
  275. for (int q=0; q<mesh_num_x*mesh_num_y; q++) {
  276. EEPROM_READ_VAR(i, dummy);
  277. }
  278. } else {
  279. EEPROM_READ_VAR(i, mbl.z_values);
  280. }
  281. #else
  282. uint8_t dummy_uint8 = 0;
  283. EEPROM_READ_VAR(i, dummy_uint8);
  284. EEPROM_READ_VAR(i, mesh_num_x);
  285. EEPROM_READ_VAR(i, mesh_num_y);
  286. for (int q=0; q<mesh_num_x*mesh_num_y; q++) {
  287. EEPROM_READ_VAR(i, dummy);
  288. }
  289. #endif // MESH_BED_LEVELING
  290. #ifdef DELTA
  291. EEPROM_READ_VAR(i, endstop_adj); // 3 floats
  292. EEPROM_READ_VAR(i, delta_radius); // 1 float
  293. EEPROM_READ_VAR(i, delta_diagonal_rod); // 1 float
  294. EEPROM_READ_VAR(i, delta_segments_per_second); // 1 float
  295. #else
  296. for (int q=6; q--;) EEPROM_READ_VAR(i, dummy);
  297. #endif
  298. #ifndef ULTIPANEL
  299. int plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed,
  300. absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed;
  301. #endif
  302. EEPROM_READ_VAR(i, plaPreheatHotendTemp);
  303. EEPROM_READ_VAR(i, plaPreheatHPBTemp);
  304. EEPROM_READ_VAR(i, plaPreheatFanSpeed);
  305. EEPROM_READ_VAR(i, absPreheatHotendTemp);
  306. EEPROM_READ_VAR(i, absPreheatHPBTemp);
  307. EEPROM_READ_VAR(i, absPreheatFanSpeed);
  308. EEPROM_READ_VAR(i, zprobe_zoffset);
  309. #ifdef PIDTEMP
  310. for (int e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin
  311. EEPROM_READ_VAR(i, dummy);
  312. if (e < EXTRUDERS && dummy != DUMMY_PID_VALUE) {
  313. // do not need to scale PID values as the values in EEPROM are already scaled
  314. PID_PARAM(Kp, e) = dummy;
  315. EEPROM_READ_VAR(i, PID_PARAM(Ki, e));
  316. EEPROM_READ_VAR(i, PID_PARAM(Kd, e));
  317. #ifdef PID_ADD_EXTRUSION_RATE
  318. EEPROM_READ_VAR(i, PID_PARAM(Kc, e));
  319. #else
  320. EEPROM_READ_VAR(i, dummy);
  321. #endif
  322. }
  323. else {
  324. for (int q=3; q--;) EEPROM_READ_VAR(i, dummy); // Ki, Kd, Kc
  325. }
  326. }
  327. #else // !PIDTEMP
  328. // 4 x 4 = 16 slots for PID parameters
  329. for (int q=16; q--;) EEPROM_READ_VAR(i, dummy); // 4x Kp, Ki, Kd, Kc
  330. #endif // !PIDTEMP
  331. #ifndef DOGLCD
  332. int lcd_contrast;
  333. #endif
  334. EEPROM_READ_VAR(i, lcd_contrast);
  335. #ifdef SCARA
  336. EEPROM_READ_VAR(i, axis_scaling); // 3 floats
  337. #else
  338. EEPROM_READ_VAR(i, dummy);
  339. #endif
  340. #ifdef FWRETRACT
  341. EEPROM_READ_VAR(i, autoretract_enabled);
  342. EEPROM_READ_VAR(i, retract_length);
  343. #if EXTRUDERS > 1
  344. EEPROM_READ_VAR(i, retract_length_swap);
  345. #else
  346. EEPROM_READ_VAR(i, dummy);
  347. #endif
  348. EEPROM_READ_VAR(i, retract_feedrate);
  349. EEPROM_READ_VAR(i, retract_zlift);
  350. EEPROM_READ_VAR(i, retract_recover_length);
  351. #if EXTRUDERS > 1
  352. EEPROM_READ_VAR(i, retract_recover_length_swap);
  353. #else
  354. EEPROM_READ_VAR(i, dummy);
  355. #endif
  356. EEPROM_READ_VAR(i, retract_recover_feedrate);
  357. #endif // FWRETRACT
  358. EEPROM_READ_VAR(i, volumetric_enabled);
  359. for (int q = 0; q < 4; q++) {
  360. EEPROM_READ_VAR(i, dummy);
  361. if (q < EXTRUDERS) filament_size[q] = dummy;
  362. }
  363. calculate_volumetric_multipliers();
  364. // Call updatePID (similar to when we have processed M301)
  365. updatePID();
  366. // Report settings retrieved and length
  367. SERIAL_ECHO_START;
  368. SERIAL_ECHO(ver);
  369. SERIAL_ECHOPAIR(" stored settings retrieved (", (unsigned long)i);
  370. SERIAL_ECHOLNPGM(" bytes)");
  371. }
  372. #ifdef EEPROM_CHITCHAT
  373. Config_PrintSettings();
  374. #endif
  375. }
  376. #endif // EEPROM_SETTINGS
  377. void Config_ResetDefault() {
  378. float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT;
  379. float tmp2[] = DEFAULT_MAX_FEEDRATE;
  380. long tmp3[] = DEFAULT_MAX_ACCELERATION;
  381. for (int i = 0; i < NUM_AXIS; i++) {
  382. axis_steps_per_unit[i] = tmp1[i];
  383. max_feedrate[i] = tmp2[i];
  384. max_acceleration_units_per_sq_second[i] = tmp3[i];
  385. #ifdef SCARA
  386. if (i < sizeof(axis_scaling) / sizeof(*axis_scaling))
  387. axis_scaling[i] = 1;
  388. #endif
  389. }
  390. // steps per sq second need to be updated to agree with the units per sq second
  391. reset_acceleration_rates();
  392. acceleration = DEFAULT_ACCELERATION;
  393. retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
  394. travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
  395. minimumfeedrate = DEFAULT_MINIMUMFEEDRATE;
  396. minsegmenttime = DEFAULT_MINSEGMENTTIME;
  397. mintravelfeedrate = DEFAULT_MINTRAVELFEEDRATE;
  398. max_xy_jerk = DEFAULT_XYJERK;
  399. max_z_jerk = DEFAULT_ZJERK;
  400. max_e_jerk = DEFAULT_EJERK;
  401. add_homing[X_AXIS] = add_homing[Y_AXIS] = add_homing[Z_AXIS] = 0;
  402. #if defined(MESH_BED_LEVELING)
  403. mbl.active = 0;
  404. #endif // MESH_BED_LEVELING
  405. #ifdef DELTA
  406. endstop_adj[X_AXIS] = endstop_adj[Y_AXIS] = endstop_adj[Z_AXIS] = 0;
  407. delta_radius = DELTA_RADIUS;
  408. delta_diagonal_rod = DELTA_DIAGONAL_ROD;
  409. delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
  410. recalc_delta_settings(delta_radius, delta_diagonal_rod);
  411. #endif
  412. #ifdef ULTIPANEL
  413. plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP;
  414. plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP;
  415. plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED;
  416. absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP;
  417. absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP;
  418. absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
  419. #endif
  420. #ifdef ENABLE_AUTO_BED_LEVELING
  421. zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
  422. #endif
  423. #ifdef DOGLCD
  424. lcd_contrast = DEFAULT_LCD_CONTRAST;
  425. #endif
  426. #ifdef PIDTEMP
  427. #ifdef PID_PARAMS_PER_EXTRUDER
  428. for (int e = 0; e < EXTRUDERS; e++)
  429. #else
  430. int e = 0; // only need to write once
  431. #endif
  432. {
  433. PID_PARAM(Kp, e) = DEFAULT_Kp;
  434. PID_PARAM(Ki, e) = scalePID_i(DEFAULT_Ki);
  435. PID_PARAM(Kd, e) = scalePID_d(DEFAULT_Kd);
  436. #ifdef PID_ADD_EXTRUSION_RATE
  437. PID_PARAM(Kc, e) = DEFAULT_Kc;
  438. #endif
  439. }
  440. // call updatePID (similar to when we have processed M301)
  441. updatePID();
  442. #endif // PIDTEMP
  443. #ifdef FWRETRACT
  444. autoretract_enabled = false;
  445. retract_length = RETRACT_LENGTH;
  446. #if EXTRUDERS > 1
  447. retract_length_swap = RETRACT_LENGTH_SWAP;
  448. #endif
  449. retract_feedrate = RETRACT_FEEDRATE;
  450. retract_zlift = RETRACT_ZLIFT;
  451. retract_recover_length = RETRACT_RECOVER_LENGTH;
  452. #if EXTRUDERS > 1
  453. retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
  454. #endif
  455. retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
  456. #endif
  457. volumetric_enabled = false;
  458. filament_size[0] = DEFAULT_NOMINAL_FILAMENT_DIA;
  459. #if EXTRUDERS > 1
  460. filament_size[1] = DEFAULT_NOMINAL_FILAMENT_DIA;
  461. #if EXTRUDERS > 2
  462. filament_size[2] = DEFAULT_NOMINAL_FILAMENT_DIA;
  463. #if EXTRUDERS > 3
  464. filament_size[3] = DEFAULT_NOMINAL_FILAMENT_DIA;
  465. #endif
  466. #endif
  467. #endif
  468. calculate_volumetric_multipliers();
  469. SERIAL_ECHO_START;
  470. SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
  471. }
  472. #ifndef DISABLE_M503
  473. void Config_PrintSettings(bool forReplay) {
  474. // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
  475. SERIAL_ECHO_START;
  476. if (!forReplay) {
  477. SERIAL_ECHOLNPGM("Steps per unit:");
  478. SERIAL_ECHO_START;
  479. }
  480. SERIAL_ECHOPAIR(" M92 X", axis_steps_per_unit[X_AXIS]);
  481. SERIAL_ECHOPAIR(" Y", axis_steps_per_unit[Y_AXIS]);
  482. SERIAL_ECHOPAIR(" Z", axis_steps_per_unit[Z_AXIS]);
  483. SERIAL_ECHOPAIR(" E", axis_steps_per_unit[E_AXIS]);
  484. SERIAL_EOL;
  485. SERIAL_ECHO_START;
  486. #ifdef SCARA
  487. if (!forReplay) {
  488. SERIAL_ECHOLNPGM("Scaling factors:");
  489. SERIAL_ECHO_START;
  490. }
  491. SERIAL_ECHOPAIR(" M365 X", axis_scaling[X_AXIS]);
  492. SERIAL_ECHOPAIR(" Y", axis_scaling[Y_AXIS]);
  493. SERIAL_ECHOPAIR(" Z", axis_scaling[Z_AXIS]);
  494. SERIAL_EOL;
  495. SERIAL_ECHO_START;
  496. #endif // SCARA
  497. if (!forReplay) {
  498. SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
  499. SERIAL_ECHO_START;
  500. }
  501. SERIAL_ECHOPAIR(" M203 X", max_feedrate[X_AXIS]);
  502. SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]);
  503. SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]);
  504. SERIAL_ECHOPAIR(" E", max_feedrate[E_AXIS]);
  505. SERIAL_EOL;
  506. SERIAL_ECHO_START;
  507. if (!forReplay) {
  508. SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
  509. SERIAL_ECHO_START;
  510. }
  511. SERIAL_ECHOPAIR(" M201 X", max_acceleration_units_per_sq_second[X_AXIS] );
  512. SERIAL_ECHOPAIR(" Y", max_acceleration_units_per_sq_second[Y_AXIS] );
  513. SERIAL_ECHOPAIR(" Z", max_acceleration_units_per_sq_second[Z_AXIS] );
  514. SERIAL_ECHOPAIR(" E", max_acceleration_units_per_sq_second[E_AXIS]);
  515. SERIAL_EOL;
  516. SERIAL_ECHO_START;
  517. if (!forReplay) {
  518. SERIAL_ECHOLNPGM("Accelerations: P=printing, R=retract and T=travel");
  519. SERIAL_ECHO_START;
  520. }
  521. SERIAL_ECHOPAIR(" M204 P", acceleration );
  522. SERIAL_ECHOPAIR(" R", retract_acceleration);
  523. SERIAL_ECHOPAIR(" T", travel_acceleration);
  524. SERIAL_EOL;
  525. SERIAL_ECHO_START;
  526. if (!forReplay) {
  527. SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)");
  528. SERIAL_ECHO_START;
  529. }
  530. SERIAL_ECHOPAIR(" M205 S", minimumfeedrate );
  531. SERIAL_ECHOPAIR(" T", mintravelfeedrate );
  532. SERIAL_ECHOPAIR(" B", minsegmenttime );
  533. SERIAL_ECHOPAIR(" X", max_xy_jerk );
  534. SERIAL_ECHOPAIR(" Z", max_z_jerk);
  535. SERIAL_ECHOPAIR(" E", max_e_jerk);
  536. SERIAL_EOL;
  537. SERIAL_ECHO_START;
  538. if (!forReplay) {
  539. SERIAL_ECHOLNPGM("Home offset (mm):");
  540. SERIAL_ECHO_START;
  541. }
  542. SERIAL_ECHOPAIR(" M206 X", add_homing[X_AXIS] );
  543. SERIAL_ECHOPAIR(" Y", add_homing[Y_AXIS] );
  544. SERIAL_ECHOPAIR(" Z", add_homing[Z_AXIS] );
  545. SERIAL_EOL;
  546. #ifdef DELTA
  547. SERIAL_ECHO_START;
  548. if (!forReplay) {
  549. SERIAL_ECHOLNPGM("Endstop adjustement (mm):");
  550. SERIAL_ECHO_START;
  551. }
  552. SERIAL_ECHOPAIR(" M666 X", endstop_adj[X_AXIS] );
  553. SERIAL_ECHOPAIR(" Y", endstop_adj[Y_AXIS] );
  554. SERIAL_ECHOPAIR(" Z", endstop_adj[Z_AXIS] );
  555. SERIAL_EOL;
  556. SERIAL_ECHO_START;
  557. SERIAL_ECHOLNPGM("Delta settings: L=delta_diagonal_rod, R=delta_radius, S=delta_segments_per_second");
  558. SERIAL_ECHO_START;
  559. SERIAL_ECHOPAIR(" M665 L", delta_diagonal_rod );
  560. SERIAL_ECHOPAIR(" R", delta_radius );
  561. SERIAL_ECHOPAIR(" S", delta_segments_per_second );
  562. SERIAL_EOL;
  563. #endif // DELTA
  564. #ifdef PIDTEMP
  565. SERIAL_ECHO_START;
  566. if (!forReplay) {
  567. SERIAL_ECHOLNPGM("PID settings:");
  568. SERIAL_ECHO_START;
  569. }
  570. SERIAL_ECHOPAIR(" M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echos values for E0
  571. SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
  572. SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
  573. SERIAL_EOL;
  574. #endif // PIDTEMP
  575. #ifdef FWRETRACT
  576. SERIAL_ECHO_START;
  577. if (!forReplay) {
  578. SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
  579. SERIAL_ECHO_START;
  580. }
  581. SERIAL_ECHOPAIR(" M207 S", retract_length);
  582. SERIAL_ECHOPAIR(" F", retract_feedrate*60);
  583. SERIAL_ECHOPAIR(" Z", retract_zlift);
  584. SERIAL_EOL;
  585. SERIAL_ECHO_START;
  586. if (!forReplay) {
  587. SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
  588. SERIAL_ECHO_START;
  589. }
  590. SERIAL_ECHOPAIR(" M208 S", retract_recover_length);
  591. SERIAL_ECHOPAIR(" F", retract_recover_feedrate*60);
  592. SERIAL_EOL;
  593. SERIAL_ECHO_START;
  594. if (!forReplay) {
  595. SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
  596. SERIAL_ECHO_START;
  597. }
  598. SERIAL_ECHOPAIR(" M209 S", (unsigned long)(autoretract_enabled ? 1 : 0));
  599. SERIAL_EOL;
  600. #if EXTRUDERS > 1
  601. if (!forReplay) {
  602. SERIAL_ECHO_START;
  603. SERIAL_ECHOLNPGM("Multi-extruder settings:");
  604. SERIAL_ECHO_START;
  605. SERIAL_ECHOPAIR(" Swap retract length (mm): ", retract_length_swap);
  606. SERIAL_EOL;
  607. SERIAL_ECHO_START;
  608. SERIAL_ECHOPAIR(" Swap rec. addl. length (mm): ", retract_recover_length_swap);
  609. SERIAL_EOL;
  610. }
  611. #endif // EXTRUDERS > 1
  612. #endif // FWRETRACT
  613. SERIAL_ECHO_START;
  614. if (volumetric_enabled) {
  615. if (!forReplay) {
  616. SERIAL_ECHOLNPGM("Filament settings:");
  617. SERIAL_ECHO_START;
  618. }
  619. SERIAL_ECHOPAIR(" M200 D", filament_size[0]);
  620. SERIAL_EOL;
  621. #if EXTRUDERS > 1
  622. SERIAL_ECHO_START;
  623. SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]);
  624. SERIAL_EOL;
  625. #if EXTRUDERS > 2
  626. SERIAL_ECHO_START;
  627. SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]);
  628. SERIAL_EOL;
  629. #if EXTRUDERS > 3
  630. SERIAL_ECHO_START;
  631. SERIAL_ECHOPAIR(" M200 T3 D", filament_size[3]);
  632. SERIAL_EOL;
  633. #endif
  634. #endif
  635. #endif
  636. } else {
  637. if (!forReplay) {
  638. SERIAL_ECHOLNPGM("Filament settings: Disabled");
  639. }
  640. }
  641. #ifdef CUSTOM_M_CODES
  642. SERIAL_ECHO_START;
  643. if (!forReplay) {
  644. SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
  645. SERIAL_ECHO_START;
  646. }
  647. SERIAL_ECHO(" M");
  648. SERIAL_ECHO(CUSTOM_M_CODE_SET_Z_PROBE_OFFSET);
  649. SERIAL_ECHOPAIR(" Z", -zprobe_zoffset);
  650. SERIAL_EOL;
  651. #endif
  652. }
  653. #endif // !DISABLE_M503