EEPROMwrite.h

Thu, 07 Jul 2016 12:23:34 +0200

author
mbayer
date
Thu, 07 Jul 2016 12:23:34 +0200
changeset 2
b373b0288715
parent 0
2c8ba1964db7
permissions
-rw-r--r--

added missing sanguino files

0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1 #ifndef EEPROM_H
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
2 #define EEPROM_H
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
3
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
4 #include "Marlin.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
5 #include "planner.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
6 #include "temperature.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
7 #include "FPUTransform.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
8 //#include <EEPROM.h>
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
9
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
10
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
11
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
12 template <class T> int EEPROM_writeAnything(int &ee, const T& value)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
13 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
14 const byte* p = (const byte*)(const void*)&value;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
15 int i;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
16 for (i = 0; i < (int)sizeof(value); i++)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
17 eeprom_write_byte((unsigned char *)ee++, *p++);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
18 return i;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
19 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
20
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
21 template <class T> int EEPROM_readAnything(int &ee, T& value)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
22 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
23 byte* p = (byte*)(void*)&value;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
24 int i;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
25 for (i = 0; i < (int)sizeof(value); i++)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
26 *p++ = eeprom_read_byte((unsigned char *)ee++);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
27 return i;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
28 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
29 //======================================================================================
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
30
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
31
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
32
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
33
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
34 #define EEPROM_OFFSET 100
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
35
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
36
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
37 // IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
38 // in the functions below, also increment the version number. This makes sure that
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
39 // the default values are used whenever there is a change to the data, to prevent
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
40 // wrong data being written to the variables.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
41 // ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
42 #define EEPROM_VERSION "V05"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
43
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
44 inline void EEPROM_StoreSettings()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
45 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
46 #ifdef EEPROM_SETTINGS
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
47 char ver[4]= "000";
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
48 int i=EEPROM_OFFSET;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
49 EEPROM_writeAnything(i,ver); // invalidate data first
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
50 EEPROM_writeAnything(i,axis_steps_per_unit);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
51 EEPROM_writeAnything(i,max_feedrate);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
52 EEPROM_writeAnything(i,max_acceleration_units_per_sq_second);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
53 EEPROM_writeAnything(i,acceleration);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
54 EEPROM_writeAnything(i,retract_acceleration);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
55 EEPROM_writeAnything(i,minimumfeedrate);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
56 EEPROM_writeAnything(i,mintravelfeedrate);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
57 EEPROM_writeAnything(i,minsegmenttime);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
58 EEPROM_writeAnything(i,max_xy_jerk);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
59 EEPROM_writeAnything(i,max_z_jerk);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
60 EEPROM_writeAnything(i,max_e_jerk);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
61 EEPROM_writeAnything(i,add_homeing);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
62 #ifdef PIDTEMP
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
63 EEPROM_writeAnything(i,Kp);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
64 EEPROM_writeAnything(i,Ki);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
65 EEPROM_writeAnything(i,Kd);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
66 EEPROM_writeAnything(i,Ki_Max);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
67 #else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
68 EEPROM_writeAnything(i,3000);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
69 EEPROM_writeAnything(i,0);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
70 EEPROM_writeAnything(i,0);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
71 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
72 #if defined(UMFPUSUPPORT) && (UMFPUSUPPORT > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
73 EEPROM_writeAnything(i,FPUEnabled);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
74 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
75 EEPROM_writeAnything(i,max_length);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
76 #ifdef ADVANCE
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
77 EEPROM_writeAnything(i,advance_k);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
78 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
79 EEPROM_writeAnything(i,b_beta);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
80 EEPROM_writeAnything(i,b_resistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
81 EEPROM_writeAnything(i,b_thermistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
82 EEPROM_writeAnything(i,b_inf);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
83 EEPROM_writeAnything(i,n_beta);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
84 EEPROM_writeAnything(i,n_resistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
85 EEPROM_writeAnything(i,n_thermistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
86 EEPROM_writeAnything(i,n_inf);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
87 char ver2[4]=EEPROM_VERSION;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
88 i=EEPROM_OFFSET;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
89 EEPROM_writeAnything(i,ver2); // validate data
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
90 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
91 SERIAL_ECHOLNPGM("Settings Stored");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
92 #endif //EEPROM_SETTINGS
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
93 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
94
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
95
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
96 inline void EEPROM_printSettings()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
97 { // if def=true, the default values will be used
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
98 #ifdef EEPROM_SETTINGS
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
99 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
100 SERIAL_ECHOLNPGM("Steps per unit:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
101 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
102 SERIAL_ECHOPAIR(" M92 X",axis_steps_per_unit[0]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
103 SERIAL_ECHOPAIR(" Y",axis_steps_per_unit[1]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
104 SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[2]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
105 SERIAL_ECHOPAIR(" E",axis_steps_per_unit[3]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
106 SERIAL_ECHOLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
107
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
108 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
109 SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
110 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
111 SERIAL_ECHOPAIR(" M203 X",max_feedrate[0]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
112 SERIAL_ECHOPAIR(" Y",max_feedrate[1] );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
113 SERIAL_ECHOPAIR(" Z", max_feedrate[2] );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
114 SERIAL_ECHOPAIR(" E", max_feedrate[3]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
115 SERIAL_ECHOLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
116 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
117 SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
118 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
119 SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[0] );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
120 SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[1] );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
121 SERIAL_ECHOPAIR(" Z" ,max_acceleration_units_per_sq_second[2] );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
122 SERIAL_ECHOPAIR(" E" ,max_acceleration_units_per_sq_second[3]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
123 SERIAL_ECHOLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
124 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
125 SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
126 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
127 SERIAL_ECHOPAIR(" M204 S",acceleration );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
128 SERIAL_ECHOPAIR(" T" ,retract_acceleration);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
129 SERIAL_ECHOLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
130 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
131 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), K=advance_k");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
132 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
133 SERIAL_ECHOPAIR(" M205 S",minimumfeedrate );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
134 SERIAL_ECHOPAIR(" T" ,mintravelfeedrate );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
135 SERIAL_ECHOPAIR(" B" ,minsegmenttime );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
136 SERIAL_ECHOPAIR(" X" ,max_xy_jerk );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
137 SERIAL_ECHOPAIR(" Z" ,max_z_jerk);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
138 SERIAL_ECHOPAIR(" E" ,max_e_jerk);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
139 #ifdef ADVANCE
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
140 SERIAL_ECHOPAIR(" K" ,advance_k);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
141 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
142 SERIAL_ECHOLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
143 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
144 SERIAL_ECHOPAIR(" M206 X",add_homeing[0]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
145 SERIAL_ECHOPAIR(" Y",add_homeing[1] );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
146 SERIAL_ECHOPAIR(" Z", add_homeing[2] );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
147 SERIAL_ECHOLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
148 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
149 SERIAL_ECHOPAIR(" M208 X",max_length[0]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
150 SERIAL_ECHOPAIR(" Y",max_length[1] );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
151 SERIAL_ECHOPAIR(" Z", max_length[2] );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
152 SERIAL_ECHOLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
153 #ifdef PIDTEMP
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
154 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
155 SERIAL_ECHOLNPGM("PID settings:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
156 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
157 SERIAL_ECHOPAIR(" M301 P",Kp);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
158 SERIAL_ECHOPAIR(" I" ,Ki/PID_dT);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
159 SERIAL_ECHOPAIR(" D" ,Kd*PID_dT);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
160 SERIAL_ECHOPAIR(" W" ,Ki_Max);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
161 SERIAL_ECHOLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
162 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
163 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
164 SERIAL_ECHOLNPGM("Thermistor settings: M304 Hh Bb Rr Tt, H0=Bed, H1..n=nozzle, b=thermistor beta value, r=series resistor, t=thermistor resistance as 25C");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
165 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
166 SERIAL_ECHOLN(" M304 H0");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
167 SERIAL_ECHOPAIR(" B",b_beta);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
168 SERIAL_ECHOPAIR(" R",b_resistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
169 SERIAL_ECHOPAIR(" T",b_thermistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
170 SERIAL_ECHOLN(" M304 H1");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
171 SERIAL_ECHOPAIR(" B",n_beta);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
172 SERIAL_ECHOPAIR(" R",n_resistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
173 SERIAL_ECHOPAIR(" T",n_thermistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
174 SERIAL_ECHOLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
175 #if defined(UMFPUSUPPORT) && (UMFPUSUPPORT > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
176 SERIAL_ECHOPAIR(" FPU Enabled" , FPUEnabled?" yes":" no");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
177 SERIAL_ECHOLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
178 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
179 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
180 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
181
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
182
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
183 inline void EEPROM_RetrieveSettings(bool def=false)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
184 { // if def=true, the default values will be used
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
185 #ifdef EEPROM_SETTINGS
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
186 int i=EEPROM_OFFSET;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
187 char stored_ver[4];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
188 char ver[4]=EEPROM_VERSION;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
189 EEPROM_readAnything(i,stored_ver); //read stored version
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
190 // SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
191 if ((!def)&&(strncmp(ver,stored_ver,3)==0))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
192 { // version number match
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
193 EEPROM_readAnything(i,axis_steps_per_unit);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
194 EEPROM_readAnything(i,max_feedrate);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
195 EEPROM_readAnything(i,max_acceleration_units_per_sq_second);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
196 EEPROM_readAnything(i,acceleration);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
197 EEPROM_readAnything(i,retract_acceleration);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
198 EEPROM_readAnything(i,minimumfeedrate);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
199 EEPROM_readAnything(i,mintravelfeedrate);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
200 EEPROM_readAnything(i,minsegmenttime);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
201 EEPROM_readAnything(i,max_xy_jerk);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
202 EEPROM_readAnything(i,max_z_jerk);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
203 EEPROM_readAnything(i,max_e_jerk);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
204 EEPROM_readAnything(i,add_homeing);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
205 #ifndef PIDTEMP
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
206 float Kp,Ki,Kd;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
207 int Ki_Max;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
208 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
209 EEPROM_readAnything(i,Kp);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
210 EEPROM_readAnything(i,Ki);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
211 EEPROM_readAnything(i,Kd);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
212 EEPROM_readAnything(i,Ki_Max);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
213 #if defined(UMFPUSUPPORT) && (UMFPUSUPPORT > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
214 EEPROM_readAnything(i,FPUEnabled);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
215 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
216 EEPROM_readAnything(i,max_length);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
217 #ifdef ADVANCE
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
218 EEPROM_readAnything(i,advance_k);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
219 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
220 EEPROM_readAnything(i,b_beta);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
221 EEPROM_readAnything(i,b_resistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
222 EEPROM_readAnything(i,b_thermistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
223 EEPROM_readAnything(i,b_inf);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
224 EEPROM_readAnything(i,n_beta);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
225 EEPROM_readAnything(i,n_resistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
226 EEPROM_readAnything(i,n_thermistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
227 EEPROM_readAnything(i,n_inf);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
228
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
229 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
230 SERIAL_ECHOLNPGM("Stored settings retreived:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
231 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
232 else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
233 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
234 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
235 float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
236 float tmp2[]=DEFAULT_MAX_FEEDRATE;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
237 long tmp3[]=DEFAULT_MAX_ACCELERATION;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
238 float tmp4[]=AXES_MAX_LENGTHS;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
239 for (short i=0;i<4;i++)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
240 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
241 axis_steps_per_unit[i]=tmp1[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
242 max_feedrate[i]=tmp2[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
243 max_acceleration_units_per_sq_second[i]=tmp3[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
244 max_length[i]=tmp4[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
245 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
246 acceleration=DEFAULT_ACCELERATION;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
247 retract_acceleration=DEFAULT_RETRACT_ACCELERATION;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
248 minimumfeedrate=DEFAULT_MINIMUMFEEDRATE;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
249 minsegmenttime=DEFAULT_MINSEGMENTTIME;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
250 mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
251 max_xy_jerk=DEFAULT_XYJERK;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
252 max_z_jerk=DEFAULT_ZJERK;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
253 max_e_jerk=DEFAULT_EJERK;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
254 #ifdef ADVANCE
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
255 advance_k=EXTRUDER_ADVANCE_K;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
256 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
257 b_beta = BED_BETA;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
258 b_resistor = BED_RS;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
259 b_thermistor = BED_NTC;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
260 b_inf = BED_R_INF;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
261 n_beta = E_BETA;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
262 n_resistor = E_RS;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
263 n_thermistor = E_NTC;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
264 n_inf = E_R_INF;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
265 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
266 SERIAL_ECHOLN("Using Default settings:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
267 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
268 #ifdef EEPROM_CHITCHAT
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
269 EEPROM_printSettings();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
270 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
271 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
272
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
273 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
274
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
275

mercurial