My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ConfigurationStore.cpp 22KB

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