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.

ConfigurationStore.cpp 22KB

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