Thu, 04 Jul 2019 21:48:53 +0200
Version 0.3.4
0 | 1 | /** |
2 | * @file setup.c | |
3 | * @brief Setup functions. | |
4 | */ | |
5 | ||
6 | #include "config.h" | |
7 | ||
8 | ||
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
9 | extern sButton Buttons[MAXBUTTONS]; |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
10 | extern int Main_Screen; |
0 | 11 | |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
12 | bool UpdateRec = false; ///< Update record flag |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
13 | int CurrentRec = 1; ///< Current record |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
14 | int Records = 1; ///< Total records. |
0 | 15 | |
16 | ||
17 | static const char *TAG = "setup"; | |
18 | ||
19 | ||
20 | ||
21 | /* | |
22 | * Setup init function that only runs once a new screen | |
23 | * is entered. | |
24 | */ | |
25 | void Setup_Init(void) | |
26 | { | |
27 | FILE *f; | |
28 | size_t bytes; | |
29 | uint8_t *dst; | |
30 | ||
31 | switch (Main_Screen) { | |
32 | ||
33 | case MAIN_TOOLS_SETUP: | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
34 | TopMessage((char *)"Setup menu"); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
35 | Buttons_Add( 20, 40,120, 40, (char *)"Config", 0); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
36 | Buttons_Add(180, 40,120, 40, (char *)"Apparatuur", 1); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
37 | Buttons_Add( 20,120,120, 40, (char *)"WiFi", 2); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
38 | Buttons_Add(180,120,120, 40, (char *)"Calibratie", 3); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
39 | Buttons_Add(130, 200, 60, 40, (char *)"Ok", 4); |
0 | 40 | Buttons[4].dark = true; |
41 | Buttons_Show(); | |
42 | break; | |
43 | ||
44 | case MAIN_TOOLS_SETUP_CONFIG: | |
45 | _bg = TFT_BLACK; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
46 | TopMessage((char *)"Configuratie"); |
0 | 47 | TFT_setFont(DEFAULT_FONT, NULL); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
48 | ShowFloat(2, 28, (char *)"Kook temp.", (char *)"C", config.BoilTemperature, 2); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
49 | ShowBool(2, 44, (char *)"Vraag mout storten", config.AskAdd); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
50 | ShowBool(2, 60, (char *)"Vraag mout verwijderen", config.AskRemove); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
51 | ShowBool(2, 76, (char *)"Vraag Jodium proef", config.AskIodine); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
52 | ShowInteger(2, 92, (char *)"Jodiumtest wachttijd", (char *)" min.", config.IodineTime); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
53 | ShowText(2, 108, (char *)"Hostnaam", config.hostname); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
54 | ShowText(2, 124, (char *)"AP SSID", config.ap_ssid); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
55 | ShowText(2, 140, (char *)"AP pwd", config.ap_pwd); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
56 | ShowInteger(2, 156, (char *)"AP kanaal", NULL, config.ap_channel); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
57 | ShowBool(2, 172, (char *)"AP SSID verborgen", config.ap_ssid_hidden); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
58 | ShowText(2, 188, (char *)"NTP server", config.ntp_server); |
0 | 59 | Buttons_Clear(); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
60 | Buttons_Add( 0, 210, 45, 30, (char *)"Ok" , 0); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
61 | Buttons_Add(276, 210, 45, 30, (char *)"Ed" , 1); |
0 | 62 | Buttons[0].dark = true; |
63 | Buttons_Show(); | |
64 | break; | |
65 | ||
66 | case MAIN_TOOLS_SETUP_CO_EDIT: | |
67 | break; | |
68 | ||
69 | case MAIN_TOOLS_SETUP_EQUIPMENT: | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
70 | TopMessage((char *)"Apparatuur"); |
0 | 71 | f = fopen("/spiffs/etc/equipments.conf", "r"); |
72 | dst = (uint8_t*)&equipment; | |
73 | Records = 0; | |
74 | while ((bytes = fread(dst, 1, sizeof(equipment), f))) { | |
75 | Records++; | |
76 | } | |
77 | fclose(f); | |
78 | // Load the default record. | |
79 | CurrentRec = config.EquipmentRec; | |
80 | UpdateRec = true; | |
81 | break; | |
82 | ||
83 | case MAIN_TOOLS_SETUP_EQ_EDIT: | |
84 | break; | |
85 | ||
86 | case MAIN_TOOLS_SETUP_CALIBRATION: | |
87 | Calibration_Init(); | |
88 | break; | |
89 | ||
90 | default: | |
91 | break; | |
92 | } | |
93 | } | |
94 | ||
95 | ||
96 | ||
97 | /* | |
98 | * Setup loop screens, non-blocking. | |
99 | */ | |
100 | void Setup_Loop(void) | |
101 | { | |
102 | uint32_t crc1, crc2; | |
103 | uint8_t *dst; | |
104 | ||
105 | switch (Main_Screen) { | |
106 | ||
107 | case MAIN_TOOLS_SETUP: | |
108 | switch (Buttons_Scan()) { | |
109 | case 0: Main_Screen = MAIN_TOOLS_SETUP_CONFIG; | |
110 | break; | |
111 | ||
112 | case 1: Main_Screen = MAIN_TOOLS_SETUP_EQUIPMENT; | |
113 | break; | |
114 | ||
115 | case 2: Main_Screen = MAIN_TOOLS_SETUP_WIFI; | |
116 | break; | |
117 | ||
118 | case 3: Main_Screen = MAIN_TOOLS_SETUP_CALIBRATION; | |
119 | break; | |
120 | ||
121 | case 4: Main_Screen = MAIN_TOOLS; | |
122 | break; | |
123 | ||
124 | default: break; | |
125 | } | |
126 | break; | |
127 | ||
128 | case MAIN_TOOLS_SETUP_CONFIG: | |
129 | switch (Buttons_Scan()) { | |
130 | case 0: Main_Screen = MAIN_TOOLS_SETUP; | |
131 | break; | |
132 | ||
133 | case 1: Main_Screen = MAIN_TOOLS_SETUP_CO_EDIT; | |
134 | break; | |
135 | ||
136 | default: break; | |
137 | } | |
138 | break; | |
139 | ||
140 | case MAIN_TOOLS_SETUP_CO_EDIT: | |
141 | dst = (uint8_t*)&config; | |
142 | crc1 = crc32_le(0, dst, sizeof(config)); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
143 | EditFloat((char *)"Kook temperatuur", &config.BoilTemperature, 80, 105, 2); |
0 | 144 | // Round to 0.25 degrees |
145 | config.BoilTemperature = ((int)(config.BoilTemperature * 4)) / 4.0; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
146 | EditBool((char *)"Vraag mout storten", &config.AskAdd); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
147 | EditBool((char *)"Vraag mout verwijderen", &config.AskRemove); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
148 | EditBool((char *)"Vraag Jodium proef", &config.AskIodine); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
149 | EditUint8((char *)"Jodium test wachttijd", &config.IodineTime, 0, 120); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
150 | EditText((char *)"DHCP hostnaam", config.hostname, 31); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
151 | EditText((char *)"AP SSID", config.ap_ssid, 31); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
152 | EditTextMin((char *)"AP password", config.ap_pwd, 40, 8); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
153 | EditUint8((char *)"AP kanaal", &config.ap_channel, 1, 14); |
0 | 154 | bool hidden = config.ap_ssid_hidden; |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
155 | EditBool((char *)"AP SSID verborgen", &hidden); |
0 | 156 | config.ap_ssid_hidden = (uint8_t)hidden; |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
157 | EditText((char *)"Voorkeur NTP server", config.ntp_server, 31); |
0 | 158 | |
159 | crc2 = crc32_le(0, dst, sizeof(config)); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
160 | if ((crc1 != crc2) && Confirm((char *)"Gewijzigd, opslaan?", (char *)"Ja", (char *)"Nee")) { |
0 | 161 | write_config(); |
162 | } else { | |
163 | read_config(); | |
164 | } | |
165 | Main_Screen = MAIN_TOOLS_SETUP_CONFIG; | |
166 | break; | |
167 | ||
168 | case MAIN_TOOLS_SETUP_EQUIPMENT: | |
169 | if (UpdateRec) { | |
170 | _bg = TFT_BLACK; | |
171 | TFT_fillScreen(_bg); | |
172 | TFT_resetclipwin(); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
173 | TopMessage((char *)"Apparatuur"); |
0 | 174 | UpdateRec = false; |
175 | read_equipment(CurrentRec); | |
176 | TFT_setFont(DEFAULT_FONT, NULL); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
177 | ShowText(2, 28, (char *)"Naam", equipment.Name); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
178 | ShowInteger( 2, 44, (char *)"Kook vermogen", (char *)"%", equipment.BoilPower); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
179 | ShowInteger(161, 44, (char *)"Maisch verm.", (char *)"%", equipment.MashPower); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
180 | ShowInteger( 2, 60, (char *)"Pomp cyclus", (char *)"m", equipment.PumpCycle); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
181 | ShowInteger(161, 60, (char *)"Pomp rust", (char *)"m", equipment.PumpRest); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
182 | ShowBool( 2, 76, (char *)"Pomp opwarmen", equipment.PumpPreMash); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
183 | ShowBool(161, 76, (char *)"Pomp maischen", equipment.PumpOnMash); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
184 | ShowBool( 2, 92, (char *)"Pomp uitmaischen", equipment.PumpMashOut); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
185 | ShowBool(161, 92, (char *)"Pomp bij koken", equipment.PumpOnBoil); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
186 | ShowInteger(2, 108, (char *)"Pomp maxtemp.", (char *)"C", equipment.PumpMaxTemp); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
187 | ShowBool(161, 108, (char *)"PID bij mout weg", equipment.PIDPipe); |
0 | 188 | ShowSSR2(2, 124, equipment.SSR2); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
189 | ShowFloat(161, 124, (char *)"Spoelwater", NULL, equipment.TempHLT, 2); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
190 | ShowDouble(2, 140, (char *)"PID P", NULL, equipment.PID_kP, 3); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
191 | ShowBool(161, 140, (char *)"PID klassiek", equipment.PID_POn); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
192 | ShowDouble(2, 156, (char *)"PID I", NULL, equipment.PID_kI, 3); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
193 | ShowInteger(161, 156, (char *)"Sample tijd", (char *)"mS", equipment.SampleTime); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
194 | ShowDouble(2, 172, (char *)"PID D", NULL, equipment.PID_kD, 3); |
0 | 195 | Buttons_Clear(); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
196 | Buttons_Add( 0, 210, 45, 30, (char *)"Ok" , 0); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
197 | Buttons_Add( 46, 210, 45, 30, (char *)"+" , 1); |
0 | 198 | if (CurrentRec != config.EquipmentRec) |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
199 | Buttons_Add( 92, 210, 45, 30, (char *)"-", 2); |
0 | 200 | else |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
201 | Buttons_Add( 92, 210, 45, 30, (char *)"" , 2); |
0 | 202 | if (CurrentRec > 1) |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
203 | Buttons_Add(138, 210, 45, 30, (char *)"<", 3); |
0 | 204 | else |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
205 | Buttons_Add(138, 210, 45, 30, (char *)"", 3); |
0 | 206 | if (CurrentRec < Records) |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
207 | Buttons_Add(184, 210, 45, 30, (char *)">", 4); |
0 | 208 | else |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
209 | Buttons_Add(184, 210, 45, 30, (char *)"", 4); |
0 | 210 | if (CurrentRec != config.EquipmentRec) |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
211 | Buttons_Add(230, 210, 45, 30, (char *)"Std", 5); |
0 | 212 | else |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
213 | Buttons_Add(230, 210, 45, 30, (char *)"", 5); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
214 | Buttons_Add(276, 210, 45, 30, (char *)"Ed" , 6); |
0 | 215 | Buttons[0].dark = true; |
216 | Buttons_Show(); | |
217 | } | |
218 | switch (Buttons_Scan()) { | |
219 | case 0: Main_Screen = MAIN_TOOLS_SETUP; | |
220 | break; | |
221 | ||
222 | case 1: memset(&equipment, 0, sizeof(equipment)); | |
223 | equipment.Version = 1; | |
224 | equipment.Record = Records + 1; | |
225 | sprintf(equipment.Name, "new eq %d", Records + 1); | |
226 | equipment.BoilPower = 80; | |
227 | equipment.MashPower = 100; | |
228 | equipment.PumpCycle = 8; | |
229 | equipment.PumpRest = 2; | |
230 | equipment.PumpPreMash = true; | |
231 | equipment.PumpOnMash = true; | |
232 | equipment.PumpMashOut = true; | |
233 | equipment.PumpOnBoil = false; | |
234 | equipment.PumpMaxTemp = 80; | |
235 | equipment.PIDPipe = true; | |
236 | equipment.SSR2 = 0; | |
237 | equipment.TempHLT = 85.0; | |
238 | equipment.PID_kP = 150.0; | |
239 | equipment.PID_kI = 1.5; | |
240 | equipment.PID_kD = 15000.0; | |
241 | equipment.PID_POn = PID_P_ON_E; | |
242 | equipment.SampleTime = 5000; | |
243 | append_equipment(); | |
244 | Records++; | |
245 | CurrentRec = Records; | |
246 | UpdateRec = true; | |
247 | ESP_LOGI(TAG, "New equipment record %d", equipment.Record); | |
248 | break; | |
249 | ||
250 | case 2: if ((CurrentRec != config.EquipmentRec) && (Records > 1)) { | |
251 | delete_equipment(CurrentRec); | |
252 | Records--; | |
253 | if (CurrentRec > Records) | |
254 | CurrentRec = Records; | |
255 | UpdateRec = true; | |
256 | } | |
257 | break; | |
258 | ||
259 | case 3: if (CurrentRec > 1) { | |
260 | CurrentRec--; | |
261 | UpdateRec = true; | |
262 | } | |
263 | break; | |
264 | ||
265 | case 4: if (CurrentRec < Records) { | |
266 | CurrentRec++; | |
267 | UpdateRec = true; | |
268 | } | |
269 | break; | |
270 | ||
271 | case 5: if (CurrentRec != config.EquipmentRec) { | |
272 | config.EquipmentRec = CurrentRec; | |
273 | write_config(); | |
274 | UpdateRec = true; | |
275 | ESP_LOGI(TAG, "Equipment %d `%s' set as default", CurrentRec, equipment.Name); | |
276 | } | |
277 | break; | |
278 | ||
279 | case 6: Main_Screen = MAIN_TOOLS_SETUP_EQ_EDIT; | |
280 | break; | |
281 | ||
282 | default: break; | |
283 | } | |
284 | break; | |
285 | ||
286 | case MAIN_TOOLS_SETUP_EQ_EDIT: | |
287 | dst = (uint8_t*)&equipment; | |
288 | crc1 = crc32_le(0, dst, sizeof(equipment)); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
289 | EditText((char *)"Naam", equipment.Name, 31); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
290 | EditInt((char *)"Kook vermogen in %", &equipment.BoilPower, 0, 100); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
291 | EditInt((char *)"Maisch vermogen in %", &equipment.MashPower, 0, 100); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
292 | EditInt((char *)"Pomp cyclus minuten", &equipment.PumpCycle, 5, 15); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
293 | EditInt((char *)"Pomp rust minuten", &equipment.PumpRest, 0, 5); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
294 | EditBool((char *)"Pomp bij opwarmen", &equipment.PumpPreMash); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
295 | EditBool((char *)"Pomp bij maischen", &equipment.PumpOnMash); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
296 | EditBool((char *)"Pomp bij uitmaischen", &equipment.PumpMashOut); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
297 | EditBool((char *)"Pomp tijdens koken", &equipment.PumpOnBoil); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
298 | EditInt((char *)"Pomp max. temperatuur", &equipment.PumpMaxTemp, 60, 105); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
299 | EditBool((char *)"PID by mout verwijderen", &equipment.PIDPipe); |
0 | 300 | EditSSR2(&equipment.SSR2); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
301 | EditFloat((char *)"Spoelwater temp", &equipment.TempHLT, 75, 98, 2); |
0 | 302 | // Round to 0.25 values. |
303 | equipment.TempHLT = ((int)(equipment.TempHLT * 4)) / 4.0; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
304 | EditBool((char *)"PID klassiek", &equipment.PID_POn); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
305 | EditDouble((char *)"PID P", &equipment.PID_kP, 20, 2000, 3); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
306 | EditDouble((char *)"PID I", &equipment.PID_kI, 0, 100, 3); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
307 | EditDouble((char *)"PID D", &equipment.PID_kD, 0, 50000, 3); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
308 | EditInt((char *)"Sample tijd in mS", &equipment.SampleTime, 1000, 20000); |
0 | 309 | // Round to 250 mSec units. |
310 | equipment.SampleTime = ((int)(equipment.SampleTime / 250)) * 250; | |
311 | ||
312 | crc2 = crc32_le(0, dst, sizeof(equipment)); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
313 | if ((crc1 != crc2) && Confirm((char *)"Gewijzigd, opslaan?", (char *)"Ja", (char *)"Nee")) { |
0 | 314 | write_equipment(equipment.Record); |
315 | } | |
316 | Main_Screen = MAIN_TOOLS_SETUP_EQUIPMENT; | |
317 | break; | |
318 | ||
319 | case MAIN_TOOLS_SETUP_WIFI: | |
320 | break; | |
321 | ||
322 | case MAIN_TOOLS_SETUP_CALIBRATION: | |
323 | Calibration_Loop(); | |
324 | Main_Screen = MAIN_TOOLS_SETUP; | |
325 | break; | |
326 | ||
327 | default: | |
328 | break; | |
329 | } | |
330 | } | |
331 |