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

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