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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  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 < 3; 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. #endif//EXTRUDERS > 2
  130. #endif//EXTRUDERS > 1
  131. char ver2[4]=EEPROM_VERSION;
  132. i=EEPROM_OFFSET;
  133. EEPROM_WRITE_VAR(i,ver2); // validate data
  134. SERIAL_ECHO_START;
  135. SERIAL_ECHOLNPGM("Settings Stored");
  136. }
  137. #endif //EEPROM_SETTINGS
  138. #ifndef DISABLE_M503
  139. void Config_PrintSettings()
  140. { // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
  141. SERIAL_ECHO_START;
  142. SERIAL_ECHOLNPGM("Steps per unit:");
  143. SERIAL_ECHO_START;
  144. SERIAL_ECHOPAIR(" M92 X",axis_steps_per_unit[X_AXIS]);
  145. SERIAL_ECHOPAIR(" Y",axis_steps_per_unit[Y_AXIS]);
  146. SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[Z_AXIS]);
  147. SERIAL_ECHOPAIR(" E",axis_steps_per_unit[E_AXIS]);
  148. SERIAL_ECHOLN("");
  149. SERIAL_ECHO_START;
  150. #ifdef SCARA
  151. SERIAL_ECHOLNPGM("Scaling factors:");
  152. SERIAL_ECHO_START;
  153. SERIAL_ECHOPAIR(" M365 X",axis_scaling[X_AXIS]);
  154. SERIAL_ECHOPAIR(" Y",axis_scaling[Y_AXIS]);
  155. SERIAL_ECHOPAIR(" Z",axis_scaling[Z_AXIS]);
  156. SERIAL_ECHOLN("");
  157. SERIAL_ECHO_START;
  158. #endif//SCARA
  159. SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
  160. SERIAL_ECHO_START;
  161. SERIAL_ECHOPAIR(" M203 X", max_feedrate[X_AXIS]);
  162. SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]);
  163. SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]);
  164. SERIAL_ECHOPAIR(" E", max_feedrate[E_AXIS]);
  165. SERIAL_ECHOLN("");
  166. SERIAL_ECHO_START;
  167. SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
  168. SERIAL_ECHO_START;
  169. SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] );
  170. SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] );
  171. SERIAL_ECHOPAIR(" Z" ,max_acceleration_units_per_sq_second[Z_AXIS] );
  172. SERIAL_ECHOPAIR(" E" ,max_acceleration_units_per_sq_second[E_AXIS]);
  173. SERIAL_ECHOLN("");
  174. SERIAL_ECHO_START;
  175. SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration");
  176. SERIAL_ECHO_START;
  177. SERIAL_ECHOPAIR(" M204 S",acceleration );
  178. SERIAL_ECHOPAIR(" T" ,retract_acceleration);
  179. SERIAL_ECHOLN("");
  180. SERIAL_ECHO_START;
  181. 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)");
  182. SERIAL_ECHO_START;
  183. SERIAL_ECHOPAIR(" M205 S",minimumfeedrate );
  184. SERIAL_ECHOPAIR(" T" ,mintravelfeedrate );
  185. SERIAL_ECHOPAIR(" B" ,minsegmenttime );
  186. SERIAL_ECHOPAIR(" X" ,max_xy_jerk );
  187. SERIAL_ECHOPAIR(" Z" ,max_z_jerk);
  188. SERIAL_ECHOPAIR(" E" ,max_e_jerk);
  189. SERIAL_ECHOLN("");
  190. SERIAL_ECHO_START;
  191. SERIAL_ECHOLNPGM("Home offset (mm):");
  192. SERIAL_ECHO_START;
  193. SERIAL_ECHOPAIR(" M206 X",add_homing[X_AXIS] );
  194. SERIAL_ECHOPAIR(" Y" ,add_homing[Y_AXIS] );
  195. SERIAL_ECHOPAIR(" Z" ,add_homing[Z_AXIS] );
  196. SERIAL_ECHOLN("");
  197. #ifdef DELTA
  198. SERIAL_ECHO_START;
  199. SERIAL_ECHOLNPGM("Endstop adjustement (mm):");
  200. SERIAL_ECHO_START;
  201. SERIAL_ECHOPAIR(" M666 X",endstop_adj[X_AXIS] );
  202. SERIAL_ECHOPAIR(" Y" ,endstop_adj[Y_AXIS] );
  203. SERIAL_ECHOPAIR(" Z" ,endstop_adj[Z_AXIS] );
  204. SERIAL_ECHOLN("");
  205. SERIAL_ECHO_START;
  206. SERIAL_ECHOLNPGM("Delta settings: L=delta_diagonal_rod, R=delta_radius, S=delta_segments_per_second");
  207. SERIAL_ECHO_START;
  208. SERIAL_ECHOPAIR(" M665 L",delta_diagonal_rod );
  209. SERIAL_ECHOPAIR(" R" ,delta_radius );
  210. SERIAL_ECHOPAIR(" S" ,delta_segments_per_second );
  211. SERIAL_ECHOLN("");
  212. #endif//DELTA
  213. #ifdef PIDTEMP
  214. SERIAL_ECHO_START;
  215. SERIAL_ECHOLNPGM("PID settings:");
  216. SERIAL_ECHO_START;
  217. SERIAL_ECHOPAIR(" M301 P", PID_PARAM(Kp,0)); // for compatibility with hosts, only echos values for E0
  218. SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
  219. SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
  220. SERIAL_ECHOLN("");
  221. #endif//PIDTEMP
  222. #ifdef FWRETRACT
  223. SERIAL_ECHO_START;
  224. SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
  225. SERIAL_ECHO_START;
  226. SERIAL_ECHOPAIR(" M207 S",retract_length);
  227. SERIAL_ECHOPAIR(" F" ,retract_feedrate*60);
  228. SERIAL_ECHOPAIR(" Z" ,retract_zlift);
  229. SERIAL_ECHOLN("");
  230. SERIAL_ECHO_START;
  231. SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
  232. SERIAL_ECHO_START;
  233. SERIAL_ECHOPAIR(" M208 S",retract_recover_length);
  234. SERIAL_ECHOPAIR(" F", retract_recover_feedrate*60);
  235. SERIAL_ECHOLN("");
  236. SERIAL_ECHO_START;
  237. SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
  238. SERIAL_ECHO_START;
  239. SERIAL_ECHOPAIR(" M209 S", (unsigned long)(autoretract_enabled ? 1 : 0));
  240. SERIAL_ECHOLN("");
  241. #if EXTRUDERS > 1
  242. SERIAL_ECHO_START;
  243. SERIAL_ECHOLNPGM("Multi-extruder settings:");
  244. SERIAL_ECHO_START;
  245. SERIAL_ECHOPAIR(" Swap retract length (mm): ", retract_length_swap);
  246. SERIAL_ECHOLN("");
  247. SERIAL_ECHO_START;
  248. SERIAL_ECHOPAIR(" Swap rec. addl. length (mm): ", retract_recover_length_swap);
  249. SERIAL_ECHOLN("");
  250. #endif//EXTRUDERS > 1
  251. SERIAL_ECHO_START;
  252. if (volumetric_enabled) {
  253. SERIAL_ECHOLNPGM("Filament settings:");
  254. SERIAL_ECHO_START;
  255. SERIAL_ECHOPAIR(" M200 D", filament_size[0]);
  256. SERIAL_ECHOLN("");
  257. #if EXTRUDERS > 1
  258. SERIAL_ECHO_START;
  259. SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]);
  260. SERIAL_ECHOLN("");
  261. #if EXTRUDERS > 2
  262. SERIAL_ECHO_START;
  263. SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]);
  264. SERIAL_ECHOLN("");
  265. #endif//EXTRUDERS > 2
  266. #endif//EXTRUDERS > 1
  267. } else {
  268. SERIAL_ECHOLNPGM("Filament settings: Disabled");
  269. }
  270. #endif//FWRETRACT
  271. #ifdef CUSTOM_M_CODES
  272. SERIAL_ECHO_START;
  273. SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
  274. SERIAL_ECHO_START;
  275. SERIAL_ECHO(" M");
  276. SERIAL_ECHO(CUSTOM_M_CODE_SET_Z_PROBE_OFFSET);
  277. SERIAL_ECHOPAIR(" Z",-zprobe_zoffset);
  278. SERIAL_ECHOLN("");
  279. #endif
  280. }
  281. #endif//DISABLE_M503
  282. #ifdef EEPROM_SETTINGS
  283. void Config_RetrieveSettings()
  284. {
  285. int i=EEPROM_OFFSET;
  286. char stored_ver[4];
  287. char ver[4]=EEPROM_VERSION;
  288. EEPROM_READ_VAR(i,stored_ver); //read stored version
  289. // SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
  290. if (strncmp(ver,stored_ver,3) == 0)
  291. {
  292. // version number match
  293. EEPROM_READ_VAR(i,axis_steps_per_unit);
  294. EEPROM_READ_VAR(i,max_feedrate);
  295. EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second);
  296. // 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)
  297. reset_acceleration_rates();
  298. EEPROM_READ_VAR(i,acceleration);
  299. EEPROM_READ_VAR(i,retract_acceleration);
  300. EEPROM_READ_VAR(i,minimumfeedrate);
  301. EEPROM_READ_VAR(i,mintravelfeedrate);
  302. EEPROM_READ_VAR(i,minsegmenttime);
  303. EEPROM_READ_VAR(i,max_xy_jerk);
  304. EEPROM_READ_VAR(i,max_z_jerk);
  305. EEPROM_READ_VAR(i,max_e_jerk);
  306. EEPROM_READ_VAR(i,add_homing);
  307. #ifdef DELTA
  308. EEPROM_READ_VAR(i,endstop_adj);
  309. EEPROM_READ_VAR(i,delta_radius);
  310. EEPROM_READ_VAR(i,delta_diagonal_rod);
  311. EEPROM_READ_VAR(i,delta_segments_per_second);
  312. #endif//DELTA
  313. #ifndef ULTIPANEL
  314. int plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed;
  315. int absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed;
  316. #endif//ULTIPANEL
  317. EEPROM_READ_VAR(i,plaPreheatHotendTemp);
  318. EEPROM_READ_VAR(i,plaPreheatHPBTemp);
  319. EEPROM_READ_VAR(i,plaPreheatFanSpeed);
  320. EEPROM_READ_VAR(i,absPreheatHotendTemp);
  321. EEPROM_READ_VAR(i,absPreheatHPBTemp);
  322. EEPROM_READ_VAR(i,absPreheatFanSpeed);
  323. EEPROM_READ_VAR(i,zprobe_zoffset);
  324. #ifdef PIDTEMP
  325. float dummy = 0.0f;
  326. for (int e = 0; e < 3; e++) // 3 = max extruders supported by marlin
  327. {
  328. if (e < EXTRUDERS)
  329. {
  330. // do not need to scale PID values as the values in EEPROM are already scaled
  331. EEPROM_READ_VAR(i,PID_PARAM(Kp,e));
  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//PID_ADD_EXTRUSION_RATE
  337. EEPROM_READ_VAR(i,dummy);
  338. #endif//PID_ADD_EXTRUSION_RATE
  339. }
  340. else
  341. {
  342. EEPROM_READ_VAR(i,dummy);
  343. EEPROM_READ_VAR(i,dummy);
  344. EEPROM_READ_VAR(i,dummy);
  345. EEPROM_READ_VAR(i,dummy);
  346. }
  347. }
  348. #else//PIDTEMP
  349. // 4 x 3 = 12 slots for PID parameters
  350. float dummy = 0.0f;
  351. EEPROM_READ_VAR(i,dummy);
  352. EEPROM_READ_VAR(i,dummy);
  353. EEPROM_READ_VAR(i,dummy);
  354. EEPROM_READ_VAR(i,dummy);
  355. EEPROM_READ_VAR(i,dummy);
  356. EEPROM_READ_VAR(i,dummy);
  357. EEPROM_READ_VAR(i,dummy);
  358. EEPROM_READ_VAR(i,dummy);
  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. #endif//PIDTEMP
  364. #ifndef DOGLCD
  365. int lcd_contrast;
  366. #endif//DOGLCD
  367. EEPROM_READ_VAR(i,lcd_contrast);
  368. #ifdef SCARA
  369. EEPROM_READ_VAR(i,axis_scaling);
  370. #endif//SCARA
  371. #ifdef FWRETRACT
  372. EEPROM_READ_VAR(i,autoretract_enabled);
  373. EEPROM_READ_VAR(i,retract_length);
  374. #if EXTRUDERS > 1
  375. EEPROM_READ_VAR(i,retract_length_swap);
  376. #endif//EXTRUDERS > 1
  377. EEPROM_READ_VAR(i,retract_feedrate);
  378. EEPROM_READ_VAR(i,retract_zlift);
  379. EEPROM_READ_VAR(i,retract_recover_length);
  380. #if EXTRUDERS > 1
  381. EEPROM_READ_VAR(i,retract_recover_length_swap);
  382. #endif//EXTRUDERS > 1
  383. EEPROM_READ_VAR(i,retract_recover_feedrate);
  384. #endif//FWRETRACT
  385. EEPROM_READ_VAR(i, volumetric_enabled);
  386. EEPROM_READ_VAR(i, filament_size[0]);
  387. #if EXTRUDERS > 1
  388. EEPROM_READ_VAR(i, filament_size[1]);
  389. #if EXTRUDERS > 2
  390. EEPROM_READ_VAR(i, filament_size[2]);
  391. #endif//EXTRUDERS > 2
  392. #endif//EXTRUDERS > 1
  393. calculate_volumetric_multipliers();
  394. // Call updatePID (similar to when we have processed M301)
  395. updatePID();
  396. SERIAL_ECHO_START;
  397. SERIAL_ECHOLNPGM("Stored settings retrieved");
  398. }
  399. else
  400. {
  401. Config_ResetDefault();
  402. }
  403. #ifdef EEPROM_CHITCHAT
  404. Config_PrintSettings();
  405. #endif//EEPROM_CHITCHAT
  406. }
  407. #endif//EEPROM_SETTINGS
  408. void Config_ResetDefault()
  409. {
  410. float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
  411. float tmp2[]=DEFAULT_MAX_FEEDRATE;
  412. long tmp3[]=DEFAULT_MAX_ACCELERATION;
  413. for (short i=0;i<4;i++)
  414. {
  415. axis_steps_per_unit[i]=tmp1[i];
  416. max_feedrate[i]=tmp2[i];
  417. max_acceleration_units_per_sq_second[i]=tmp3[i];
  418. #ifdef SCARA
  419. axis_scaling[i]=1;
  420. #endif//SCARA
  421. }
  422. // steps per sq second need to be updated to agree with the units per sq second
  423. reset_acceleration_rates();
  424. acceleration=DEFAULT_ACCELERATION;
  425. retract_acceleration=DEFAULT_RETRACT_ACCELERATION;
  426. minimumfeedrate=DEFAULT_MINIMUMFEEDRATE;
  427. minsegmenttime=DEFAULT_MINSEGMENTTIME;
  428. mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE;
  429. max_xy_jerk=DEFAULT_XYJERK;
  430. max_z_jerk=DEFAULT_ZJERK;
  431. max_e_jerk=DEFAULT_EJERK;
  432. add_homing[X_AXIS] = add_homing[Y_AXIS] = add_homing[Z_AXIS] = 0;
  433. #ifdef DELTA
  434. endstop_adj[X_AXIS] = endstop_adj[Y_AXIS] = endstop_adj[Z_AXIS] = 0;
  435. delta_radius= DELTA_RADIUS;
  436. delta_diagonal_rod= DELTA_DIAGONAL_ROD;
  437. delta_segments_per_second= DELTA_SEGMENTS_PER_SECOND;
  438. recalc_delta_settings(delta_radius, delta_diagonal_rod);
  439. #endif//DELTA
  440. #ifdef ULTIPANEL
  441. plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP;
  442. plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP;
  443. plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED;
  444. absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP;
  445. absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP;
  446. absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
  447. #endif//ULTIPANEL
  448. #ifdef ENABLE_AUTO_BED_LEVELING
  449. zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
  450. #endif//ENABLE_AUTO_BED_LEVELING
  451. #ifdef DOGLCD
  452. lcd_contrast = DEFAULT_LCD_CONTRAST;
  453. #endif//DOGLCD
  454. #ifdef PIDTEMP
  455. #ifdef PID_PARAMS_PER_EXTRUDER
  456. for (int e = 0; e < EXTRUDERS; e++)
  457. #else // PID_PARAMS_PER_EXTRUDER
  458. int e = 0; // only need to write once
  459. #endif // PID_PARAMS_PER_EXTRUDER
  460. {
  461. PID_PARAM(Kp,e) = DEFAULT_Kp;
  462. PID_PARAM(Ki,e) = scalePID_i(DEFAULT_Ki);
  463. PID_PARAM(Kd,e) = scalePID_d(DEFAULT_Kd);
  464. #ifdef PID_ADD_EXTRUSION_RATE
  465. PID_PARAM(Kc,e) = DEFAULT_Kc;
  466. #endif//PID_ADD_EXTRUSION_RATE
  467. }
  468. // call updatePID (similar to when we have processed M301)
  469. updatePID();
  470. #endif//PIDTEMP
  471. #ifdef FWRETRACT
  472. autoretract_enabled = false;
  473. retract_length = RETRACT_LENGTH;
  474. #if EXTRUDERS > 1
  475. retract_length_swap = RETRACT_LENGTH_SWAP;
  476. #endif//EXTRUDERS > 1
  477. retract_feedrate = RETRACT_FEEDRATE;
  478. retract_zlift = RETRACT_ZLIFT;
  479. retract_recover_length = RETRACT_RECOVER_LENGTH;
  480. #if EXTRUDERS > 1
  481. retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
  482. #endif//EXTRUDERS > 1
  483. retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
  484. #endif//FWRETRACT
  485. volumetric_enabled = false;
  486. filament_size[0] = DEFAULT_NOMINAL_FILAMENT_DIA;
  487. #if EXTRUDERS > 1
  488. filament_size[1] = DEFAULT_NOMINAL_FILAMENT_DIA;
  489. #if EXTRUDERS > 2
  490. filament_size[2] = DEFAULT_NOMINAL_FILAMENT_DIA;
  491. #endif//EXTRUDERS > 2
  492. #endif//EXTRUDERS > 1
  493. calculate_volumetric_multipliers();
  494. SERIAL_ECHO_START;
  495. SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
  496. }