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.

configuration_store.cpp 26KB

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