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 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. /**
  2. * ConfigurationStore.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 "V19"
  17. /**
  18. * V19 EEPROM Layout:
  19. *
  20. * ver
  21. * axis_steps_per_unit (x4)
  22. * max_feedrate (x4)
  23. * max_acceleration_units_per_sq_second (x4)
  24. * acceleration
  25. * retract_acceleration
  26. * travel_acceleration
  27. * minimumfeedrate
  28. * mintravelfeedrate
  29. * minsegmenttime
  30. * max_xy_jerk
  31. * max_z_jerk
  32. * max_e_jerk
  33. * home_offset (x3)
  34. *
  35. * Mesh bed leveling:
  36. * active
  37. * mesh_num_x
  38. * mesh_num_y
  39. * z_values[][]
  40. * zprobe_zoffset
  41. *
  42. * DELTA:
  43. * endstop_adj (x3)
  44. * delta_radius
  45. * delta_diagonal_rod
  46. * delta_segments_per_second
  47. *
  48. * ULTIPANEL:
  49. * plaPreheatHotendTemp
  50. * plaPreheatHPBTemp
  51. * plaPreheatFanSpeed
  52. * absPreheatHotendTemp
  53. * absPreheatHPBTemp
  54. * absPreheatFanSpeed
  55. *
  56. * PIDTEMP:
  57. * Kp[0], Ki[0], Kd[0], Kc[0]
  58. * Kp[1], Ki[1], Kd[1], Kc[1]
  59. * Kp[2], Ki[2], Kd[2], Kc[2]
  60. * Kp[3], Ki[3], Kd[3], Kc[3]
  61. *
  62. * PIDTEMPBED:
  63. * bedKp, bedKi, bedKd
  64. *
  65. * DOGLCD:
  66. * lcd_contrast
  67. *
  68. * SCARA:
  69. * axis_scaling (x3)
  70. *
  71. * FWRETRACT:
  72. * autoretract_enabled
  73. * retract_length
  74. * retract_length_swap
  75. * retract_feedrate
  76. * retract_zlift
  77. * retract_recover_length
  78. * retract_recover_length_swap
  79. * retract_recover_feedrate
  80. *
  81. * volumetric_enabled
  82. *
  83. * filament_size (x4)
  84. *
  85. * Z_DUAL_ENDSTOPS
  86. * 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 "ConfigurationStore.h"
  95. #ifdef MESH_BED_LEVELING
  96. #include "mesh_bed_leveling.h"
  97. #endif // MESH_BED_LEVELING
  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. #define DUMMY_PID_VALUE 3000.0f
  122. #define EEPROM_OFFSET 100
  123. #ifdef EEPROM_SETTINGS
  124. void Config_StoreSettings() {
  125. float dummy = 0.0f;
  126. char ver[4] = "000";
  127. int i = EEPROM_OFFSET;
  128. EEPROM_WRITE_VAR(i, ver); // invalidate data first
  129. EEPROM_WRITE_VAR(i, axis_steps_per_unit);
  130. EEPROM_WRITE_VAR(i, max_feedrate);
  131. EEPROM_WRITE_VAR(i, max_acceleration_units_per_sq_second);
  132. EEPROM_WRITE_VAR(i, acceleration);
  133. EEPROM_WRITE_VAR(i, retract_acceleration);
  134. EEPROM_WRITE_VAR(i, travel_acceleration);
  135. EEPROM_WRITE_VAR(i, minimumfeedrate);
  136. EEPROM_WRITE_VAR(i, mintravelfeedrate);
  137. EEPROM_WRITE_VAR(i, minsegmenttime);
  138. EEPROM_WRITE_VAR(i, max_xy_jerk);
  139. EEPROM_WRITE_VAR(i, max_z_jerk);
  140. EEPROM_WRITE_VAR(i, max_e_jerk);
  141. EEPROM_WRITE_VAR(i, home_offset);
  142. uint8_t mesh_num_x = 3;
  143. uint8_t mesh_num_y = 3;
  144. #ifdef MESH_BED_LEVELING
  145. // Compile time test that sizeof(mbl.z_values) is as expected
  146. typedef char c_assert[(sizeof(mbl.z_values) == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS*sizeof(dummy)) ? 1 : -1];
  147. mesh_num_x = MESH_NUM_X_POINTS;
  148. mesh_num_y = MESH_NUM_Y_POINTS;
  149. EEPROM_WRITE_VAR(i, mbl.active);
  150. EEPROM_WRITE_VAR(i, mesh_num_x);
  151. EEPROM_WRITE_VAR(i, mesh_num_y);
  152. EEPROM_WRITE_VAR(i, mbl.z_values);
  153. #else
  154. uint8_t dummy_uint8 = 0;
  155. EEPROM_WRITE_VAR(i, dummy_uint8);
  156. EEPROM_WRITE_VAR(i, mesh_num_x);
  157. EEPROM_WRITE_VAR(i, mesh_num_y);
  158. dummy = 0.0f;
  159. for (int q=0; q<mesh_num_x*mesh_num_y; q++) {
  160. EEPROM_WRITE_VAR(i, dummy);
  161. }
  162. #endif // MESH_BED_LEVELING
  163. #ifndef ENABLE_AUTO_BED_LEVELING
  164. float zprobe_zoffset = 0;
  165. #endif
  166. EEPROM_WRITE_VAR(i, zprobe_zoffset);
  167. #ifdef 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 defined(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. #ifndef 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. #ifdef 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. #ifdef 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. #ifndef 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. #ifndef DOGLCD
  219. int lcd_contrast = 32;
  220. #endif
  221. EEPROM_WRITE_VAR(i, lcd_contrast);
  222. #ifdef 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. #ifdef 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. void Config_RetrieveSettings() {
  263. int i = EEPROM_OFFSET;
  264. char stored_ver[4];
  265. char ver[4] = EEPROM_VERSION;
  266. EEPROM_READ_VAR(i, stored_ver); //read stored version
  267. // SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
  268. if (strncmp(ver, stored_ver, 3) != 0) {
  269. Config_ResetDefault();
  270. }
  271. else {
  272. float dummy = 0;
  273. // version number match
  274. EEPROM_READ_VAR(i, axis_steps_per_unit);
  275. EEPROM_READ_VAR(i, max_feedrate);
  276. EEPROM_READ_VAR(i, max_acceleration_units_per_sq_second);
  277. // 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)
  278. reset_acceleration_rates();
  279. EEPROM_READ_VAR(i, acceleration);
  280. EEPROM_READ_VAR(i, retract_acceleration);
  281. EEPROM_READ_VAR(i, travel_acceleration);
  282. EEPROM_READ_VAR(i, minimumfeedrate);
  283. EEPROM_READ_VAR(i, mintravelfeedrate);
  284. EEPROM_READ_VAR(i, minsegmenttime);
  285. EEPROM_READ_VAR(i, max_xy_jerk);
  286. EEPROM_READ_VAR(i, max_z_jerk);
  287. EEPROM_READ_VAR(i, max_e_jerk);
  288. EEPROM_READ_VAR(i, home_offset);
  289. uint8_t mesh_num_x = 0;
  290. uint8_t mesh_num_y = 0;
  291. #ifdef MESH_BED_LEVELING
  292. EEPROM_READ_VAR(i, mbl.active);
  293. EEPROM_READ_VAR(i, mesh_num_x);
  294. EEPROM_READ_VAR(i, mesh_num_y);
  295. if (mesh_num_x != MESH_NUM_X_POINTS ||
  296. mesh_num_y != MESH_NUM_Y_POINTS) {
  297. mbl.reset();
  298. for (int q=0; q<mesh_num_x*mesh_num_y; q++) {
  299. EEPROM_READ_VAR(i, dummy);
  300. }
  301. } else {
  302. EEPROM_READ_VAR(i, mbl.z_values);
  303. }
  304. #else
  305. uint8_t dummy_uint8 = 0;
  306. EEPROM_READ_VAR(i, dummy_uint8);
  307. EEPROM_READ_VAR(i, mesh_num_x);
  308. EEPROM_READ_VAR(i, mesh_num_y);
  309. for (int q=0; q<mesh_num_x*mesh_num_y; q++) {
  310. EEPROM_READ_VAR(i, dummy);
  311. }
  312. #endif // MESH_BED_LEVELING
  313. #ifndef ENABLE_AUTO_BED_LEVELING
  314. float zprobe_zoffset = 0;
  315. #endif
  316. EEPROM_READ_VAR(i, zprobe_zoffset);
  317. #ifdef DELTA
  318. EEPROM_READ_VAR(i, endstop_adj); // 3 floats
  319. EEPROM_READ_VAR(i, delta_radius); // 1 float
  320. EEPROM_READ_VAR(i, delta_diagonal_rod); // 1 float
  321. EEPROM_READ_VAR(i, delta_segments_per_second); // 1 float
  322. #elif defined(Z_DUAL_ENDSTOPS)
  323. EEPROM_READ_VAR(i, z_endstop_adj);
  324. dummy = 0.0f;
  325. for (int q=5; q--;) EEPROM_READ_VAR(i, dummy);
  326. #else
  327. dummy = 0.0f;
  328. for (int q=6; q--;) EEPROM_READ_VAR(i, dummy);
  329. #endif
  330. #ifndef ULTIPANEL
  331. int plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed,
  332. absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed;
  333. #endif
  334. EEPROM_READ_VAR(i, plaPreheatHotendTemp);
  335. EEPROM_READ_VAR(i, plaPreheatHPBTemp);
  336. EEPROM_READ_VAR(i, plaPreheatFanSpeed);
  337. EEPROM_READ_VAR(i, absPreheatHotendTemp);
  338. EEPROM_READ_VAR(i, absPreheatHPBTemp);
  339. EEPROM_READ_VAR(i, absPreheatFanSpeed);
  340. #ifdef PIDTEMP
  341. for (int e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin
  342. EEPROM_READ_VAR(i, dummy); // Kp
  343. if (e < EXTRUDERS && dummy != DUMMY_PID_VALUE) {
  344. // do not need to scale PID values as the values in EEPROM are already scaled
  345. PID_PARAM(Kp, e) = dummy;
  346. EEPROM_READ_VAR(i, PID_PARAM(Ki, e));
  347. EEPROM_READ_VAR(i, PID_PARAM(Kd, e));
  348. #ifdef PID_ADD_EXTRUSION_RATE
  349. EEPROM_READ_VAR(i, PID_PARAM(Kc, e));
  350. #else
  351. EEPROM_READ_VAR(i, dummy);
  352. #endif
  353. }
  354. else {
  355. for (int q=3; q--;) EEPROM_READ_VAR(i, dummy); // Ki, Kd, Kc
  356. }
  357. }
  358. #else // !PIDTEMP
  359. // 4 x 4 = 16 slots for PID parameters
  360. for (int q=16; q--;) EEPROM_READ_VAR(i, dummy); // 4x Kp, Ki, Kd, Kc
  361. #endif // !PIDTEMP
  362. #ifndef PIDTEMPBED
  363. float bedKp, bedKi, bedKd;
  364. #endif
  365. EEPROM_READ_VAR(i, dummy); // bedKp
  366. if (dummy != DUMMY_PID_VALUE) {
  367. bedKp = dummy;
  368. EEPROM_READ_VAR(i, bedKi);
  369. EEPROM_READ_VAR(i, bedKd);
  370. }
  371. else {
  372. for (int q=2; q--;) EEPROM_READ_VAR(i, dummy); // bedKi, bedKd
  373. }
  374. #ifndef DOGLCD
  375. int lcd_contrast;
  376. #endif
  377. EEPROM_READ_VAR(i, lcd_contrast);
  378. #ifdef SCARA
  379. EEPROM_READ_VAR(i, axis_scaling); // 3 floats
  380. #else
  381. EEPROM_READ_VAR(i, dummy);
  382. #endif
  383. #ifdef FWRETRACT
  384. EEPROM_READ_VAR(i, autoretract_enabled);
  385. EEPROM_READ_VAR(i, retract_length);
  386. #if EXTRUDERS > 1
  387. EEPROM_READ_VAR(i, retract_length_swap);
  388. #else
  389. EEPROM_READ_VAR(i, dummy);
  390. #endif
  391. EEPROM_READ_VAR(i, retract_feedrate);
  392. EEPROM_READ_VAR(i, retract_zlift);
  393. EEPROM_READ_VAR(i, retract_recover_length);
  394. #if EXTRUDERS > 1
  395. EEPROM_READ_VAR(i, retract_recover_length_swap);
  396. #else
  397. EEPROM_READ_VAR(i, dummy);
  398. #endif
  399. EEPROM_READ_VAR(i, retract_recover_feedrate);
  400. #endif // FWRETRACT
  401. EEPROM_READ_VAR(i, volumetric_enabled);
  402. for (int q = 0; q < 4; q++) {
  403. EEPROM_READ_VAR(i, dummy);
  404. if (q < EXTRUDERS) filament_size[q] = dummy;
  405. }
  406. calculate_volumetric_multipliers();
  407. // Call updatePID (similar to when we have processed M301)
  408. updatePID();
  409. // Report settings retrieved and length
  410. SERIAL_ECHO_START;
  411. SERIAL_ECHO(ver);
  412. SERIAL_ECHOPAIR(" stored settings retrieved (", (unsigned long)i);
  413. SERIAL_ECHOLNPGM(" bytes)");
  414. }
  415. #ifdef EEPROM_CHITCHAT
  416. Config_PrintSettings();
  417. #endif
  418. }
  419. #endif // EEPROM_SETTINGS
  420. void Config_ResetDefault() {
  421. float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT;
  422. float tmp2[] = DEFAULT_MAX_FEEDRATE;
  423. long tmp3[] = DEFAULT_MAX_ACCELERATION;
  424. for (uint16_t i = 0; i < NUM_AXIS; i++) {
  425. axis_steps_per_unit[i] = tmp1[i];
  426. max_feedrate[i] = tmp2[i];
  427. max_acceleration_units_per_sq_second[i] = tmp3[i];
  428. #ifdef SCARA
  429. if (i < sizeof(axis_scaling) / sizeof(*axis_scaling))
  430. axis_scaling[i] = 1;
  431. #endif
  432. }
  433. // steps per sq second need to be updated to agree with the units per sq second
  434. reset_acceleration_rates();
  435. acceleration = DEFAULT_ACCELERATION;
  436. retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
  437. travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
  438. minimumfeedrate = DEFAULT_MINIMUMFEEDRATE;
  439. minsegmenttime = DEFAULT_MINSEGMENTTIME;
  440. mintravelfeedrate = DEFAULT_MINTRAVELFEEDRATE;
  441. max_xy_jerk = DEFAULT_XYJERK;
  442. max_z_jerk = DEFAULT_ZJERK;
  443. max_e_jerk = DEFAULT_EJERK;
  444. home_offset[X_AXIS] = home_offset[Y_AXIS] = home_offset[Z_AXIS] = 0;
  445. #ifdef MESH_BED_LEVELING
  446. mbl.active = 0;
  447. #endif
  448. #ifdef ENABLE_AUTO_BED_LEVELING
  449. zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
  450. #endif
  451. #ifdef DELTA
  452. endstop_adj[X_AXIS] = endstop_adj[Y_AXIS] = endstop_adj[Z_AXIS] = 0;
  453. delta_radius = DELTA_RADIUS;
  454. delta_diagonal_rod = DELTA_DIAGONAL_ROD;
  455. delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
  456. recalc_delta_settings(delta_radius, delta_diagonal_rod);
  457. #elif defined(Z_DUAL_ENDSTOPS)
  458. z_endstop_adj = 0;
  459. #endif
  460. #ifdef ULTIPANEL
  461. plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP;
  462. plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP;
  463. plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED;
  464. absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP;
  465. absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP;
  466. absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
  467. #endif
  468. #ifdef DOGLCD
  469. lcd_contrast = DEFAULT_LCD_CONTRAST;
  470. #endif
  471. #ifdef PIDTEMP
  472. #ifdef PID_PARAMS_PER_EXTRUDER
  473. for (int e = 0; e < EXTRUDERS; e++)
  474. #else
  475. int e = 0; // only need to write once
  476. #endif
  477. {
  478. PID_PARAM(Kp, e) = DEFAULT_Kp;
  479. PID_PARAM(Ki, e) = scalePID_i(DEFAULT_Ki);
  480. PID_PARAM(Kd, e) = scalePID_d(DEFAULT_Kd);
  481. #ifdef PID_ADD_EXTRUSION_RATE
  482. PID_PARAM(Kc, e) = DEFAULT_Kc;
  483. #endif
  484. }
  485. // call updatePID (similar to when we have processed M301)
  486. updatePID();
  487. #endif // PIDTEMP
  488. #ifdef PIDTEMPBED
  489. bedKp = DEFAULT_bedKp;
  490. bedKi = scalePID_i(DEFAULT_bedKi);
  491. bedKd = scalePID_d(DEFAULT_bedKd);
  492. #endif
  493. #ifdef FWRETRACT
  494. autoretract_enabled = false;
  495. retract_length = RETRACT_LENGTH;
  496. #if EXTRUDERS > 1
  497. retract_length_swap = RETRACT_LENGTH_SWAP;
  498. #endif
  499. retract_feedrate = RETRACT_FEEDRATE;
  500. retract_zlift = RETRACT_ZLIFT;
  501. retract_recover_length = RETRACT_RECOVER_LENGTH;
  502. #if EXTRUDERS > 1
  503. retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
  504. #endif
  505. retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
  506. #endif
  507. volumetric_enabled = false;
  508. filament_size[0] = DEFAULT_NOMINAL_FILAMENT_DIA;
  509. #if EXTRUDERS > 1
  510. filament_size[1] = DEFAULT_NOMINAL_FILAMENT_DIA;
  511. #if EXTRUDERS > 2
  512. filament_size[2] = DEFAULT_NOMINAL_FILAMENT_DIA;
  513. #if EXTRUDERS > 3
  514. filament_size[3] = DEFAULT_NOMINAL_FILAMENT_DIA;
  515. #endif
  516. #endif
  517. #endif
  518. calculate_volumetric_multipliers();
  519. SERIAL_ECHO_START;
  520. SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
  521. }
  522. #ifndef DISABLE_M503
  523. void Config_PrintSettings(bool forReplay) {
  524. // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
  525. SERIAL_ECHO_START;
  526. if (!forReplay) {
  527. SERIAL_ECHOLNPGM("Steps per unit:");
  528. SERIAL_ECHO_START;
  529. }
  530. SERIAL_ECHOPAIR(" M92 X", axis_steps_per_unit[X_AXIS]);
  531. SERIAL_ECHOPAIR(" Y", axis_steps_per_unit[Y_AXIS]);
  532. SERIAL_ECHOPAIR(" Z", axis_steps_per_unit[Z_AXIS]);
  533. SERIAL_ECHOPAIR(" E", axis_steps_per_unit[E_AXIS]);
  534. SERIAL_EOL;
  535. SERIAL_ECHO_START;
  536. #ifdef SCARA
  537. if (!forReplay) {
  538. SERIAL_ECHOLNPGM("Scaling factors:");
  539. SERIAL_ECHO_START;
  540. }
  541. SERIAL_ECHOPAIR(" M365 X", axis_scaling[X_AXIS]);
  542. SERIAL_ECHOPAIR(" Y", axis_scaling[Y_AXIS]);
  543. SERIAL_ECHOPAIR(" Z", axis_scaling[Z_AXIS]);
  544. SERIAL_EOL;
  545. SERIAL_ECHO_START;
  546. #endif // SCARA
  547. if (!forReplay) {
  548. SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
  549. SERIAL_ECHO_START;
  550. }
  551. SERIAL_ECHOPAIR(" M203 X", max_feedrate[X_AXIS]);
  552. SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]);
  553. SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]);
  554. SERIAL_ECHOPAIR(" E", max_feedrate[E_AXIS]);
  555. SERIAL_EOL;
  556. SERIAL_ECHO_START;
  557. if (!forReplay) {
  558. SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
  559. SERIAL_ECHO_START;
  560. }
  561. SERIAL_ECHOPAIR(" M201 X", max_acceleration_units_per_sq_second[X_AXIS] );
  562. SERIAL_ECHOPAIR(" Y", max_acceleration_units_per_sq_second[Y_AXIS] );
  563. SERIAL_ECHOPAIR(" Z", max_acceleration_units_per_sq_second[Z_AXIS] );
  564. SERIAL_ECHOPAIR(" E", max_acceleration_units_per_sq_second[E_AXIS]);
  565. SERIAL_EOL;
  566. SERIAL_ECHO_START;
  567. if (!forReplay) {
  568. SERIAL_ECHOLNPGM("Accelerations: P=printing, R=retract and T=travel");
  569. SERIAL_ECHO_START;
  570. }
  571. SERIAL_ECHOPAIR(" M204 P", acceleration );
  572. SERIAL_ECHOPAIR(" R", retract_acceleration);
  573. SERIAL_ECHOPAIR(" T", travel_acceleration);
  574. SERIAL_EOL;
  575. SERIAL_ECHO_START;
  576. if (!forReplay) {
  577. 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)");
  578. SERIAL_ECHO_START;
  579. }
  580. SERIAL_ECHOPAIR(" M205 S", minimumfeedrate );
  581. SERIAL_ECHOPAIR(" T", mintravelfeedrate );
  582. SERIAL_ECHOPAIR(" B", minsegmenttime );
  583. SERIAL_ECHOPAIR(" X", max_xy_jerk );
  584. SERIAL_ECHOPAIR(" Z", max_z_jerk);
  585. SERIAL_ECHOPAIR(" E", max_e_jerk);
  586. SERIAL_EOL;
  587. SERIAL_ECHO_START;
  588. if (!forReplay) {
  589. SERIAL_ECHOLNPGM("Home offset (mm):");
  590. SERIAL_ECHO_START;
  591. }
  592. SERIAL_ECHOPAIR(" M206 X", home_offset[X_AXIS] );
  593. SERIAL_ECHOPAIR(" Y", home_offset[Y_AXIS] );
  594. SERIAL_ECHOPAIR(" Z", home_offset[Z_AXIS] );
  595. SERIAL_EOL;
  596. #ifdef DELTA
  597. SERIAL_ECHO_START;
  598. if (!forReplay) {
  599. SERIAL_ECHOLNPGM("Endstop adjustement (mm):");
  600. SERIAL_ECHO_START;
  601. }
  602. SERIAL_ECHOPAIR(" M666 X", endstop_adj[X_AXIS] );
  603. SERIAL_ECHOPAIR(" Y", endstop_adj[Y_AXIS] );
  604. SERIAL_ECHOPAIR(" Z", endstop_adj[Z_AXIS] );
  605. SERIAL_EOL;
  606. SERIAL_ECHO_START;
  607. SERIAL_ECHOLNPGM("Delta settings: L=delta_diagonal_rod, R=delta_radius, S=delta_segments_per_second");
  608. SERIAL_ECHO_START;
  609. SERIAL_ECHOPAIR(" M665 L", delta_diagonal_rod );
  610. SERIAL_ECHOPAIR(" R", delta_radius );
  611. SERIAL_ECHOPAIR(" S", delta_segments_per_second );
  612. SERIAL_EOL;
  613. #elif defined(Z_DUAL_ENDSTOPS)
  614. SERIAL_ECHO_START;
  615. if (!forReplay) {
  616. SERIAL_ECHOLNPGM("Z2 Endstop adjustement (mm):");
  617. SERIAL_ECHO_START;
  618. }
  619. SERIAL_ECHOPAIR(" M666 Z", z_endstop_adj );
  620. SERIAL_EOL;
  621. #endif // DELTA
  622. #if defined(PIDTEMP) || defined(PIDTEMPBED)
  623. SERIAL_ECHO_START;
  624. if (!forReplay) {
  625. SERIAL_ECHOLNPGM("PID settings:");
  626. SERIAL_ECHO_START;
  627. }
  628. #if defined(PIDTEMP) && defined(PIDTEMPBED)
  629. SERIAL_EOL;
  630. #endif
  631. #ifdef PIDTEMP
  632. SERIAL_ECHOPAIR(" M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echos values for E0
  633. SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
  634. SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
  635. SERIAL_EOL;
  636. #endif
  637. #ifdef PIDTEMPBED
  638. SERIAL_ECHOPAIR(" M304 P", bedKp); // for compatibility with hosts, only echos values for E0
  639. SERIAL_ECHOPAIR(" I", unscalePID_i(bedKi));
  640. SERIAL_ECHOPAIR(" D", unscalePID_d(bedKd));
  641. SERIAL_EOL;
  642. #endif
  643. #endif
  644. #ifdef FWRETRACT
  645. SERIAL_ECHO_START;
  646. if (!forReplay) {
  647. SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
  648. SERIAL_ECHO_START;
  649. }
  650. SERIAL_ECHOPAIR(" M207 S", retract_length);
  651. SERIAL_ECHOPAIR(" F", retract_feedrate*60);
  652. SERIAL_ECHOPAIR(" Z", retract_zlift);
  653. SERIAL_EOL;
  654. SERIAL_ECHO_START;
  655. if (!forReplay) {
  656. SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
  657. SERIAL_ECHO_START;
  658. }
  659. SERIAL_ECHOPAIR(" M208 S", retract_recover_length);
  660. SERIAL_ECHOPAIR(" F", retract_recover_feedrate*60);
  661. SERIAL_EOL;
  662. SERIAL_ECHO_START;
  663. if (!forReplay) {
  664. SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
  665. SERIAL_ECHO_START;
  666. }
  667. SERIAL_ECHOPAIR(" M209 S", (unsigned long)(autoretract_enabled ? 1 : 0));
  668. SERIAL_EOL;
  669. #if EXTRUDERS > 1
  670. if (!forReplay) {
  671. SERIAL_ECHO_START;
  672. SERIAL_ECHOLNPGM("Multi-extruder settings:");
  673. SERIAL_ECHO_START;
  674. SERIAL_ECHOPAIR(" Swap retract length (mm): ", retract_length_swap);
  675. SERIAL_EOL;
  676. SERIAL_ECHO_START;
  677. SERIAL_ECHOPAIR(" Swap rec. addl. length (mm): ", retract_recover_length_swap);
  678. SERIAL_EOL;
  679. }
  680. #endif // EXTRUDERS > 1
  681. #endif // FWRETRACT
  682. SERIAL_ECHO_START;
  683. if (volumetric_enabled) {
  684. if (!forReplay) {
  685. SERIAL_ECHOLNPGM("Filament settings:");
  686. SERIAL_ECHO_START;
  687. }
  688. SERIAL_ECHOPAIR(" M200 D", filament_size[0]);
  689. SERIAL_EOL;
  690. #if EXTRUDERS > 1
  691. SERIAL_ECHO_START;
  692. SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]);
  693. SERIAL_EOL;
  694. #if EXTRUDERS > 2
  695. SERIAL_ECHO_START;
  696. SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]);
  697. SERIAL_EOL;
  698. #if EXTRUDERS > 3
  699. SERIAL_ECHO_START;
  700. SERIAL_ECHOPAIR(" M200 T3 D", filament_size[3]);
  701. SERIAL_EOL;
  702. #endif
  703. #endif
  704. #endif
  705. } else {
  706. if (!forReplay) {
  707. SERIAL_ECHOLNPGM("Filament settings: Disabled");
  708. }
  709. }
  710. #ifdef ENABLE_AUTO_BED_LEVELING
  711. SERIAL_ECHO_START;
  712. #ifdef CUSTOM_M_CODES
  713. if (!forReplay) {
  714. SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
  715. SERIAL_ECHO_START;
  716. }
  717. SERIAL_ECHOPAIR(" M", (unsigned long)CUSTOM_M_CODE_SET_Z_PROBE_OFFSET);
  718. SERIAL_ECHOPAIR(" Z", -zprobe_zoffset);
  719. #else
  720. if (!forReplay) {
  721. SERIAL_ECHOPAIR("Z-Probe Offset (mm):", -zprobe_zoffset);
  722. }
  723. #endif
  724. SERIAL_EOL;
  725. #endif
  726. }
  727. #endif // !DISABLE_M503