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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. #include "Marlin.h"
  2. #include "planner.h"
  3. #include "temperature.h"
  4. #include "ultralcd.h"
  5. #include "ConfigurationStore.h"
  6. void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size)
  7. {
  8. do
  9. {
  10. eeprom_write_byte((unsigned char*)pos, *value);
  11. pos++;
  12. value++;
  13. }while(--size);
  14. }
  15. #define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value))
  16. void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size)
  17. {
  18. do
  19. {
  20. *value = eeprom_read_byte((unsigned char*)pos);
  21. pos++;
  22. value++;
  23. }while(--size);
  24. }
  25. #define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value))
  26. //======================================================================================
  27. #define EEPROM_OFFSET 100
  28. // IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
  29. // in the functions below, also increment the version number. This makes sure that
  30. // the default values are used whenever there is a change to the data, to prevent
  31. // wrong data being written to the variables.
  32. // ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
  33. #define EEPROM_VERSION "V14"
  34. #ifdef EEPROM_SETTINGS
  35. void Config_StoreSettings()
  36. {
  37. char ver[4]= "000";
  38. int i=EEPROM_OFFSET;
  39. EEPROM_WRITE_VAR(i,ver); // invalidate data first
  40. EEPROM_WRITE_VAR(i,axis_steps_per_unit);
  41. EEPROM_WRITE_VAR(i,max_feedrate);
  42. EEPROM_WRITE_VAR(i,max_acceleration_units_per_sq_second);
  43. EEPROM_WRITE_VAR(i,acceleration);
  44. EEPROM_WRITE_VAR(i,retract_acceleration);
  45. EEPROM_WRITE_VAR(i,minimumfeedrate);
  46. EEPROM_WRITE_VAR(i,mintravelfeedrate);
  47. EEPROM_WRITE_VAR(i,minsegmenttime);
  48. EEPROM_WRITE_VAR(i,max_xy_jerk);
  49. EEPROM_WRITE_VAR(i,max_z_jerk);
  50. EEPROM_WRITE_VAR(i,max_e_jerk);
  51. EEPROM_WRITE_VAR(i,add_homing);
  52. #ifdef DELTA
  53. EEPROM_WRITE_VAR(i,endstop_adj);
  54. EEPROM_WRITE_VAR(i,delta_radius);
  55. EEPROM_WRITE_VAR(i,delta_diagonal_rod);
  56. EEPROM_WRITE_VAR(i,delta_segments_per_second);
  57. #endif//DELTA
  58. #ifndef ULTIPANEL
  59. int plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP, plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP, plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED;
  60. int absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP, absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP, absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
  61. #endif//ULTIPANEL
  62. EEPROM_WRITE_VAR(i,plaPreheatHotendTemp);
  63. EEPROM_WRITE_VAR(i,plaPreheatHPBTemp);
  64. EEPROM_WRITE_VAR(i,plaPreheatFanSpeed);
  65. EEPROM_WRITE_VAR(i,absPreheatHotendTemp);
  66. EEPROM_WRITE_VAR(i,absPreheatHPBTemp);
  67. EEPROM_WRITE_VAR(i,absPreheatFanSpeed);
  68. EEPROM_WRITE_VAR(i,zprobe_zoffset);
  69. #ifdef PIDTEMP
  70. float dummy = 0.0f;
  71. for (int e = 0; e < 4; e++)
  72. {
  73. if (e < EXTRUDERS)
  74. {
  75. EEPROM_WRITE_VAR(i,PID_PARAM(Kp,e));
  76. EEPROM_WRITE_VAR(i,PID_PARAM(Ki,e));
  77. EEPROM_WRITE_VAR(i,PID_PARAM(Kd,e));
  78. #ifdef PID_ADD_EXTRUSION_RATE
  79. EEPROM_WRITE_VAR(i,PID_PARAM(Kc,e));
  80. #else//PID_ADD_EXTRUSION_RATE
  81. dummy = 1.0f; // 1.0 = default kc
  82. EEPROM_WRITE_VAR(dummmy);
  83. #endif//PID_ADD_EXTRUSION_RATE
  84. }
  85. else
  86. {
  87. dummy = 3000.0f;
  88. EEPROM_WRITE_VAR(i, dummy);
  89. dummy = 0.0f;
  90. EEPROM_WRITE_VAR(i,dummy);
  91. EEPROM_WRITE_VAR(i,dummy);
  92. }
  93. }
  94. #else//PIDTEMP
  95. float dummy = 3000.0f;
  96. EEPROM_WRITE_VAR(i,dummy);
  97. dummy = 0.0f;
  98. EEPROM_WRITE_VAR(i,dummy);
  99. EEPROM_WRITE_VAR(i,dummy);
  100. #endif//PIDTEMP
  101. #ifndef DOGLCD
  102. int lcd_contrast = 32;
  103. #endif//DOGLCD
  104. EEPROM_WRITE_VAR(i,lcd_contrast);
  105. #ifdef SCARA
  106. EEPROM_WRITE_VAR(i,axis_scaling); // Add scaling for SCARA
  107. #endif//SCARA
  108. #ifdef FWRETRACT
  109. EEPROM_WRITE_VAR(i,autoretract_enabled);
  110. EEPROM_WRITE_VAR(i,retract_length);
  111. #if EXTRUDERS > 1
  112. EEPROM_WRITE_VAR(i,retract_length_swap);
  113. #endif//EXTRUDERS > 1
  114. EEPROM_WRITE_VAR(i,retract_feedrate);
  115. EEPROM_WRITE_VAR(i,retract_zlift);
  116. EEPROM_WRITE_VAR(i,retract_recover_length);
  117. #if EXTRUDERS > 1
  118. EEPROM_WRITE_VAR(i,retract_recover_length_swap);
  119. #endif//EXTRUDERS > 1
  120. EEPROM_WRITE_VAR(i,retract_recover_feedrate);
  121. #endif//FWRETRACT
  122. // Save filament sizes
  123. EEPROM_WRITE_VAR(i, volumetric_enabled);
  124. EEPROM_WRITE_VAR(i, filament_size[0]);
  125. #if EXTRUDERS > 1
  126. EEPROM_WRITE_VAR(i, filament_size[1]);
  127. #if EXTRUDERS > 2
  128. EEPROM_WRITE_VAR(i, filament_size[2]);
  129. #if EXTRUDERS > 3
  130. EEPROM_WRITE_VAR(i, filament_size[3]);
  131. #endif //EXTRUDERS > 3
  132. #endif //EXTRUDERS > 2
  133. #endif //EXTRUDERS > 1
  134. char ver2[4]=EEPROM_VERSION;
  135. i=EEPROM_OFFSET;
  136. EEPROM_WRITE_VAR(i,ver2); // validate data
  137. SERIAL_ECHO_START;
  138. SERIAL_ECHOLNPGM("Settings Stored");
  139. }
  140. #endif //EEPROM_SETTINGS
  141. #ifndef DISABLE_M503
  142. void Config_PrintSettings()
  143. { // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
  144. SERIAL_ECHO_START;
  145. SERIAL_ECHOLNPGM("Steps per unit:");
  146. SERIAL_ECHO_START;
  147. SERIAL_ECHOPAIR(" M92 X",axis_steps_per_unit[X_AXIS]);
  148. SERIAL_ECHOPAIR(" Y",axis_steps_per_unit[Y_AXIS]);
  149. SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[Z_AXIS]);
  150. SERIAL_ECHOPAIR(" E",axis_steps_per_unit[E_AXIS]);
  151. SERIAL_ECHOLN("");
  152. SERIAL_ECHO_START;
  153. #ifdef SCARA
  154. SERIAL_ECHOLNPGM("Scaling factors:");
  155. SERIAL_ECHO_START;
  156. SERIAL_ECHOPAIR(" M365 X",axis_scaling[X_AXIS]);
  157. SERIAL_ECHOPAIR(" Y",axis_scaling[Y_AXIS]);
  158. SERIAL_ECHOPAIR(" Z",axis_scaling[Z_AXIS]);
  159. SERIAL_ECHOLN("");
  160. SERIAL_ECHO_START;
  161. #endif//SCARA
  162. SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
  163. SERIAL_ECHO_START;
  164. SERIAL_ECHOPAIR(" M203 X", max_feedrate[X_AXIS]);
  165. SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]);
  166. SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]);
  167. SERIAL_ECHOPAIR(" E", max_feedrate[E_AXIS]);
  168. SERIAL_ECHOLN("");
  169. SERIAL_ECHO_START;
  170. SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
  171. SERIAL_ECHO_START;
  172. SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] );
  173. SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] );
  174. SERIAL_ECHOPAIR(" Z" ,max_acceleration_units_per_sq_second[Z_AXIS] );
  175. SERIAL_ECHOPAIR(" E" ,max_acceleration_units_per_sq_second[E_AXIS]);
  176. SERIAL_ECHOLN("");
  177. SERIAL_ECHO_START;
  178. SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration");
  179. SERIAL_ECHO_START;
  180. SERIAL_ECHOPAIR(" M204 S",acceleration );
  181. SERIAL_ECHOPAIR(" T" ,retract_acceleration);
  182. SERIAL_ECHOLN("");
  183. SERIAL_ECHO_START;
  184. 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)");
  185. SERIAL_ECHO_START;
  186. SERIAL_ECHOPAIR(" M205 S",minimumfeedrate );
  187. SERIAL_ECHOPAIR(" T" ,mintravelfeedrate );
  188. SERIAL_ECHOPAIR(" B" ,minsegmenttime );
  189. SERIAL_ECHOPAIR(" X" ,max_xy_jerk );
  190. SERIAL_ECHOPAIR(" Z" ,max_z_jerk);
  191. SERIAL_ECHOPAIR(" E" ,max_e_jerk);
  192. SERIAL_ECHOLN("");
  193. SERIAL_ECHO_START;
  194. SERIAL_ECHOLNPGM("Home offset (mm):");
  195. SERIAL_ECHO_START;
  196. SERIAL_ECHOPAIR(" M206 X",add_homing[X_AXIS] );
  197. SERIAL_ECHOPAIR(" Y" ,add_homing[Y_AXIS] );
  198. SERIAL_ECHOPAIR(" Z" ,add_homing[Z_AXIS] );
  199. SERIAL_ECHOLN("");
  200. #ifdef DELTA
  201. SERIAL_ECHO_START;
  202. SERIAL_ECHOLNPGM("Endstop adjustement (mm):");
  203. SERIAL_ECHO_START;
  204. SERIAL_ECHOPAIR(" M666 X",endstop_adj[X_AXIS] );
  205. SERIAL_ECHOPAIR(" Y" ,endstop_adj[Y_AXIS] );
  206. SERIAL_ECHOPAIR(" Z" ,endstop_adj[Z_AXIS] );
  207. SERIAL_ECHOLN("");
  208. SERIAL_ECHO_START;
  209. SERIAL_ECHOLNPGM("Delta settings: L=delta_diagonal_rod, R=delta_radius, S=delta_segments_per_second");
  210. SERIAL_ECHO_START;
  211. SERIAL_ECHOPAIR(" M665 L",delta_diagonal_rod );
  212. SERIAL_ECHOPAIR(" R" ,delta_radius );
  213. SERIAL_ECHOPAIR(" S" ,delta_segments_per_second );
  214. SERIAL_ECHOLN("");
  215. #endif//DELTA
  216. #ifdef PIDTEMP
  217. SERIAL_ECHO_START;
  218. SERIAL_ECHOLNPGM("PID settings:");
  219. SERIAL_ECHO_START;
  220. SERIAL_ECHOPAIR(" M301 P", PID_PARAM(Kp,0)); // for compatibility with hosts, only echos values for E0
  221. SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
  222. SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
  223. SERIAL_ECHOLN("");
  224. #endif//PIDTEMP
  225. #ifdef FWRETRACT
  226. SERIAL_ECHO_START;
  227. SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
  228. SERIAL_ECHO_START;
  229. SERIAL_ECHOPAIR(" M207 S",retract_length);
  230. SERIAL_ECHOPAIR(" F" ,retract_feedrate*60);
  231. SERIAL_ECHOPAIR(" Z" ,retract_zlift);
  232. SERIAL_ECHOLN("");
  233. SERIAL_ECHO_START;
  234. SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
  235. SERIAL_ECHO_START;
  236. SERIAL_ECHOPAIR(" M208 S",retract_recover_length);
  237. SERIAL_ECHOPAIR(" F", retract_recover_feedrate*60);
  238. SERIAL_ECHOLN("");
  239. SERIAL_ECHO_START;
  240. SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
  241. SERIAL_ECHO_START;
  242. SERIAL_ECHOPAIR(" M209 S", (unsigned long)(autoretract_enabled ? 1 : 0));
  243. SERIAL_ECHOLN("");
  244. #if EXTRUDERS > 1
  245. SERIAL_ECHO_START;
  246. SERIAL_ECHOLNPGM("Multi-extruder settings:");
  247. SERIAL_ECHO_START;
  248. SERIAL_ECHOPAIR(" Swap retract length (mm): ", retract_length_swap);
  249. SERIAL_ECHOLN("");
  250. SERIAL_ECHO_START;
  251. SERIAL_ECHOPAIR(" Swap rec. addl. length (mm): ", retract_recover_length_swap);
  252. SERIAL_ECHOLN("");
  253. #endif//EXTRUDERS > 1
  254. SERIAL_ECHO_START;
  255. if (volumetric_enabled) {
  256. SERIAL_ECHOLNPGM("Filament settings:");
  257. SERIAL_ECHO_START;
  258. SERIAL_ECHOPAIR(" M200 D", filament_size[0]);
  259. SERIAL_ECHOLN("");
  260. #if EXTRUDERS > 1
  261. SERIAL_ECHO_START;
  262. SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]);
  263. SERIAL_ECHOLN("");
  264. #if EXTRUDERS > 2
  265. SERIAL_ECHO_START;
  266. SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]);
  267. SERIAL_ECHOLN("");
  268. #if EXTRUDERS > 3
  269. SERIAL_ECHO_START;
  270. SERIAL_ECHOPAIR(" M200 T3 D", filament_size[3]);
  271. SERIAL_ECHOLN("");
  272. #endif //EXTRUDERS > 3
  273. #endif //EXTRUDERS > 2
  274. #endif //EXTRUDERS > 1
  275. } else {
  276. SERIAL_ECHOLNPGM("Filament settings: Disabled");
  277. }
  278. #endif//FWRETRACT
  279. #ifdef CUSTOM_M_CODES
  280. SERIAL_ECHO_START;
  281. SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
  282. SERIAL_ECHO_START;
  283. SERIAL_ECHO(" M");
  284. SERIAL_ECHO(CUSTOM_M_CODE_SET_Z_PROBE_OFFSET);
  285. SERIAL_ECHOPAIR(" Z",-zprobe_zoffset);
  286. SERIAL_ECHOLN("");
  287. #endif
  288. }
  289. #endif//DISABLE_M503
  290. #ifdef EEPROM_SETTINGS
  291. void Config_RetrieveSettings()
  292. {
  293. int i=EEPROM_OFFSET;
  294. char stored_ver[4];
  295. char ver[4]=EEPROM_VERSION;
  296. EEPROM_READ_VAR(i,stored_ver); //read stored version
  297. // SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
  298. if (strncmp(ver,stored_ver,3) == 0)
  299. {
  300. // version number match
  301. EEPROM_READ_VAR(i,axis_steps_per_unit);
  302. EEPROM_READ_VAR(i,max_feedrate);
  303. EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second);
  304. // 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)
  305. reset_acceleration_rates();
  306. EEPROM_READ_VAR(i,acceleration);
  307. EEPROM_READ_VAR(i,retract_acceleration);
  308. EEPROM_READ_VAR(i,minimumfeedrate);
  309. EEPROM_READ_VAR(i,mintravelfeedrate);
  310. EEPROM_READ_VAR(i,minsegmenttime);
  311. EEPROM_READ_VAR(i,max_xy_jerk);
  312. EEPROM_READ_VAR(i,max_z_jerk);
  313. EEPROM_READ_VAR(i,max_e_jerk);
  314. EEPROM_READ_VAR(i,add_homing);
  315. #ifdef DELTA
  316. EEPROM_READ_VAR(i,endstop_adj);
  317. EEPROM_READ_VAR(i,delta_radius);
  318. EEPROM_READ_VAR(i,delta_diagonal_rod);
  319. EEPROM_READ_VAR(i,delta_segments_per_second);
  320. #endif//DELTA
  321. #ifndef ULTIPANEL
  322. int plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed;
  323. int absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed;
  324. #endif//ULTIPANEL
  325. EEPROM_READ_VAR(i,plaPreheatHotendTemp);
  326. EEPROM_READ_VAR(i,plaPreheatHPBTemp);
  327. EEPROM_READ_VAR(i,plaPreheatFanSpeed);
  328. EEPROM_READ_VAR(i,absPreheatHotendTemp);
  329. EEPROM_READ_VAR(i,absPreheatHPBTemp);
  330. EEPROM_READ_VAR(i,absPreheatFanSpeed);
  331. EEPROM_READ_VAR(i,zprobe_zoffset);
  332. #ifdef PIDTEMP
  333. float dummy = 0.0f;
  334. for (int e = 0; e < 4; e++) // 4 = max extruders supported by marlin
  335. {
  336. if (e < EXTRUDERS)
  337. {
  338. // do not need to scale PID values as the values in EEPROM are already scaled
  339. EEPROM_READ_VAR(i,PID_PARAM(Kp,e));
  340. EEPROM_READ_VAR(i,PID_PARAM(Ki,e));
  341. EEPROM_READ_VAR(i,PID_PARAM(Kd,e));
  342. #ifdef PID_ADD_EXTRUSION_RATE
  343. EEPROM_READ_VAR(i,PID_PARAM(Kc,e));
  344. #else//PID_ADD_EXTRUSION_RATE
  345. EEPROM_READ_VAR(i,dummy);
  346. #endif//PID_ADD_EXTRUSION_RATE
  347. }
  348. else
  349. {
  350. EEPROM_READ_VAR(i,dummy);
  351. EEPROM_READ_VAR(i,dummy);
  352. EEPROM_READ_VAR(i,dummy);
  353. EEPROM_READ_VAR(i,dummy);
  354. }
  355. }
  356. #else//PIDTEMP
  357. // 4 x 3 = 12 slots for PID parameters
  358. float dummy = 0.0f;
  359. EEPROM_READ_VAR(i,dummy);
  360. EEPROM_READ_VAR(i,dummy);
  361. EEPROM_READ_VAR(i,dummy);
  362. EEPROM_READ_VAR(i,dummy);
  363. EEPROM_READ_VAR(i,dummy);
  364. EEPROM_READ_VAR(i,dummy);
  365. EEPROM_READ_VAR(i,dummy);
  366. EEPROM_READ_VAR(i,dummy);
  367. EEPROM_READ_VAR(i,dummy);
  368. EEPROM_READ_VAR(i,dummy);
  369. EEPROM_READ_VAR(i,dummy);
  370. EEPROM_READ_VAR(i,dummy);
  371. #endif//PIDTEMP
  372. #ifndef DOGLCD
  373. int lcd_contrast;
  374. #endif//DOGLCD
  375. EEPROM_READ_VAR(i,lcd_contrast);
  376. #ifdef SCARA
  377. EEPROM_READ_VAR(i,axis_scaling);
  378. #endif//SCARA
  379. #ifdef FWRETRACT
  380. EEPROM_READ_VAR(i,autoretract_enabled);
  381. EEPROM_READ_VAR(i,retract_length);
  382. #if EXTRUDERS > 1
  383. EEPROM_READ_VAR(i,retract_length_swap);
  384. #endif//EXTRUDERS > 1
  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. #endif//EXTRUDERS > 1
  391. EEPROM_READ_VAR(i,retract_recover_feedrate);
  392. #endif//FWRETRACT
  393. EEPROM_READ_VAR(i, volumetric_enabled);
  394. EEPROM_READ_VAR(i, filament_size[0]);
  395. #if EXTRUDERS > 1
  396. EEPROM_READ_VAR(i, filament_size[1]);
  397. #if EXTRUDERS > 2
  398. EEPROM_READ_VAR(i, filament_size[2]);
  399. #if EXTRUDERS > 3
  400. EEPROM_READ_VAR(i, filament_size[3]);
  401. #endif //EXTRUDERS > 3
  402. #endif //EXTRUDERS > 2
  403. #endif //EXTRUDERS > 1
  404. calculate_volumetric_multipliers();
  405. // Call updatePID (similar to when we have processed M301)
  406. updatePID();
  407. SERIAL_ECHO_START;
  408. SERIAL_ECHOLNPGM("Stored settings retrieved");
  409. }
  410. else
  411. {
  412. Config_ResetDefault();
  413. }
  414. #ifdef EEPROM_CHITCHAT
  415. Config_PrintSettings();
  416. #endif//EEPROM_CHITCHAT
  417. }
  418. #endif//EEPROM_SETTINGS
  419. void Config_ResetDefault()
  420. {
  421. float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
  422. float tmp2[]=DEFAULT_MAX_FEEDRATE;
  423. long tmp3[]=DEFAULT_MAX_ACCELERATION;
  424. for (short i=0;i<4;i++)
  425. {
  426. axis_steps_per_unit[i]=tmp1[i];
  427. max_feedrate[i]=tmp2[i];
  428. max_acceleration_units_per_sq_second[i]=tmp3[i];
  429. #ifdef SCARA
  430. axis_scaling[i]=1;
  431. #endif//SCARA
  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. minimumfeedrate=DEFAULT_MINIMUMFEEDRATE;
  438. minsegmenttime=DEFAULT_MINSEGMENTTIME;
  439. mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE;
  440. max_xy_jerk=DEFAULT_XYJERK;
  441. max_z_jerk=DEFAULT_ZJERK;
  442. max_e_jerk=DEFAULT_EJERK;
  443. add_homing[X_AXIS] = add_homing[Y_AXIS] = add_homing[Z_AXIS] = 0;
  444. #ifdef DELTA
  445. endstop_adj[X_AXIS] = endstop_adj[Y_AXIS] = endstop_adj[Z_AXIS] = 0;
  446. delta_radius= DELTA_RADIUS;
  447. delta_diagonal_rod= DELTA_DIAGONAL_ROD;
  448. delta_segments_per_second= DELTA_SEGMENTS_PER_SECOND;
  449. recalc_delta_settings(delta_radius, delta_diagonal_rod);
  450. #endif//DELTA
  451. #ifdef ULTIPANEL
  452. plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP;
  453. plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP;
  454. plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED;
  455. absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP;
  456. absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP;
  457. absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
  458. #endif//ULTIPANEL
  459. #ifdef ENABLE_AUTO_BED_LEVELING
  460. zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
  461. #endif//ENABLE_AUTO_BED_LEVELING
  462. #ifdef DOGLCD
  463. lcd_contrast = DEFAULT_LCD_CONTRAST;
  464. #endif//DOGLCD
  465. #ifdef PIDTEMP
  466. #ifdef PID_PARAMS_PER_EXTRUDER
  467. for (int e = 0; e < EXTRUDERS; e++)
  468. #else // PID_PARAMS_PER_EXTRUDER
  469. int e = 0; // only need to write once
  470. #endif // PID_PARAMS_PER_EXTRUDER
  471. {
  472. PID_PARAM(Kp,e) = DEFAULT_Kp;
  473. PID_PARAM(Ki,e) = scalePID_i(DEFAULT_Ki);
  474. PID_PARAM(Kd,e) = scalePID_d(DEFAULT_Kd);
  475. #ifdef PID_ADD_EXTRUSION_RATE
  476. PID_PARAM(Kc,e) = DEFAULT_Kc;
  477. #endif//PID_ADD_EXTRUSION_RATE
  478. }
  479. // call updatePID (similar to when we have processed M301)
  480. updatePID();
  481. #endif//PIDTEMP
  482. #ifdef FWRETRACT
  483. autoretract_enabled = false;
  484. retract_length = RETRACT_LENGTH;
  485. #if EXTRUDERS > 1
  486. retract_length_swap = RETRACT_LENGTH_SWAP;
  487. #endif//EXTRUDERS > 1
  488. retract_feedrate = RETRACT_FEEDRATE;
  489. retract_zlift = RETRACT_ZLIFT;
  490. retract_recover_length = RETRACT_RECOVER_LENGTH;
  491. #if EXTRUDERS > 1
  492. retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
  493. #endif//EXTRUDERS > 1
  494. retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
  495. #endif//FWRETRACT
  496. volumetric_enabled = false;
  497. filament_size[0] = DEFAULT_NOMINAL_FILAMENT_DIA;
  498. #if EXTRUDERS > 1
  499. filament_size[1] = DEFAULT_NOMINAL_FILAMENT_DIA;
  500. #if EXTRUDERS > 2
  501. filament_size[2] = DEFAULT_NOMINAL_FILAMENT_DIA;
  502. #if EXTRUDERS > 3
  503. filament_size[3] = DEFAULT_NOMINAL_FILAMENT_DIA;
  504. #endif //EXTRUDERS > 3
  505. #endif //EXTRUDERS > 2
  506. #endif //EXTRUDERS > 1
  507. calculate_volumetric_multipliers();
  508. SERIAL_ECHO_START;
  509. SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
  510. }