29 uint8_t *dst; |
29 uint8_t *dst; |
30 |
30 |
31 switch (Main_Screen) { |
31 switch (Main_Screen) { |
32 |
32 |
33 case MAIN_TOOLS_SETUP: |
33 case MAIN_TOOLS_SETUP: |
34 TopMessage("Setup menu"); |
34 TopMessage((char *)"Setup menu"); |
35 Buttons_Add( 20, 40,120, 40, "Config", 0); |
35 Buttons_Add( 20, 40,120, 40, (char *)"Config", 0); |
36 Buttons_Add(180, 40,120, 40, "Apparatuur", 1); |
36 Buttons_Add(180, 40,120, 40, (char *)"Apparatuur", 1); |
37 Buttons_Add( 20,120,120, 40, "WiFi", 2); |
37 Buttons_Add( 20,120,120, 40, (char *)"WiFi", 2); |
38 Buttons_Add(180,120,120, 40, "Calibratie", 3); |
38 Buttons_Add(180,120,120, 40, (char *)"Calibratie", 3); |
39 Buttons_Add(130, 200, 60, 40, "Ok", 4); |
39 Buttons_Add(130, 200, 60, 40, (char *)"Ok", 4); |
40 Buttons[4].dark = true; |
40 Buttons[4].dark = true; |
41 Buttons_Show(); |
41 Buttons_Show(); |
42 break; |
42 break; |
43 |
43 |
44 case MAIN_TOOLS_SETUP_CONFIG: |
44 case MAIN_TOOLS_SETUP_CONFIG: |
45 _bg = TFT_BLACK; |
45 _bg = TFT_BLACK; |
46 TopMessage("Configuratie"); |
46 TopMessage((char *)"Configuratie"); |
47 TFT_setFont(DEFAULT_FONT, NULL); |
47 TFT_setFont(DEFAULT_FONT, NULL); |
48 ShowFloat(2, 28, "Kook temp.", "C", config.BoilTemperature, 2); |
48 ShowFloat(2, 28, (char *)"Kook temp.", (char *)"C", config.BoilTemperature, 2); |
49 ShowBool(2, 44, "Vraag mout storten", config.AskAdd); |
49 ShowBool(2, 44, (char *)"Vraag mout storten", config.AskAdd); |
50 ShowBool(2, 60, "Vraag mout verwijderen", config.AskRemove); |
50 ShowBool(2, 60, (char *)"Vraag mout verwijderen", config.AskRemove); |
51 ShowBool(2, 76, "Vraag Jodium proef", config.AskIodine); |
51 ShowBool(2, 76, (char *)"Vraag Jodium proef", config.AskIodine); |
52 ShowInteger(2, 92, "Jodiumtest wachttijd", " min.", config.IodineTime); |
52 ShowInteger(2, 92, (char *)"Jodiumtest wachttijd", (char *)" min.", config.IodineTime); |
53 ShowText(2, 108, "Hostnaam", config.hostname); |
53 ShowText(2, 108, (char *)"Hostnaam", config.hostname); |
54 ShowText(2, 124, "AP SSID", config.ap_ssid); |
54 ShowText(2, 124, (char *)"AP SSID", config.ap_ssid); |
55 ShowText(2, 140, "AP pwd", config.ap_pwd); |
55 ShowText(2, 140, (char *)"AP pwd", config.ap_pwd); |
56 ShowInteger(2, 156, "AP kanaal", NULL, config.ap_channel); |
56 ShowInteger(2, 156, (char *)"AP kanaal", NULL, config.ap_channel); |
57 ShowBool(2, 172, "AP SSID verborgen", config.ap_ssid_hidden); |
57 ShowBool(2, 172, (char *)"AP SSID verborgen", config.ap_ssid_hidden); |
58 ShowText(2, 188, "NTP server", config.ntp_server); |
58 ShowText(2, 188, (char *)"NTP server", config.ntp_server); |
59 Buttons_Clear(); |
59 Buttons_Clear(); |
60 Buttons_Add( 0, 210, 45, 30, "Ok" , 0); |
60 Buttons_Add( 0, 210, 45, 30, (char *)"Ok" , 0); |
61 Buttons_Add(276, 210, 45, 30, "Ed" , 1); |
61 Buttons_Add(276, 210, 45, 30, (char *)"Ed" , 1); |
62 Buttons[0].dark = true; |
62 Buttons[0].dark = true; |
63 Buttons_Show(); |
63 Buttons_Show(); |
64 break; |
64 break; |
65 |
65 |
66 case MAIN_TOOLS_SETUP_CO_EDIT: |
66 case MAIN_TOOLS_SETUP_CO_EDIT: |
67 break; |
67 break; |
68 |
68 |
69 case MAIN_TOOLS_SETUP_EQUIPMENT: |
69 case MAIN_TOOLS_SETUP_EQUIPMENT: |
70 TopMessage("Apparatuur"); |
70 TopMessage((char *)"Apparatuur"); |
71 f = fopen("/spiffs/etc/equipments.conf", "r"); |
71 f = fopen("/spiffs/etc/equipments.conf", "r"); |
72 dst = (uint8_t*)&equipment; |
72 dst = (uint8_t*)&equipment; |
73 Records = 0; |
73 Records = 0; |
74 while ((bytes = fread(dst, 1, sizeof(equipment), f))) { |
74 while ((bytes = fread(dst, 1, sizeof(equipment), f))) { |
75 Records++; |
75 Records++; |
138 break; |
138 break; |
139 |
139 |
140 case MAIN_TOOLS_SETUP_CO_EDIT: |
140 case MAIN_TOOLS_SETUP_CO_EDIT: |
141 dst = (uint8_t*)&config; |
141 dst = (uint8_t*)&config; |
142 crc1 = crc32_le(0, dst, sizeof(config)); |
142 crc1 = crc32_le(0, dst, sizeof(config)); |
143 EditFloat("Kook temperatuur", &config.BoilTemperature, 80, 105, 2); |
143 EditFloat((char *)"Kook temperatuur", &config.BoilTemperature, 80, 105, 2); |
144 // Round to 0.25 degrees |
144 // Round to 0.25 degrees |
145 config.BoilTemperature = ((int)(config.BoilTemperature * 4)) / 4.0; |
145 config.BoilTemperature = ((int)(config.BoilTemperature * 4)) / 4.0; |
146 EditBool("Vraag mout storten", &config.AskAdd); |
146 EditBool((char *)"Vraag mout storten", &config.AskAdd); |
147 EditBool("Vraag mout verwijderen", &config.AskRemove); |
147 EditBool((char *)"Vraag mout verwijderen", &config.AskRemove); |
148 EditBool("Vraag Jodium proef", &config.AskIodine); |
148 EditBool((char *)"Vraag Jodium proef", &config.AskIodine); |
149 EditUint8("Jodium test wachttijd", &config.IodineTime, 0, 120); |
149 EditUint8((char *)"Jodium test wachttijd", &config.IodineTime, 0, 120); |
150 EditText("DHCP hostnaam", config.hostname, 31); |
150 EditText((char *)"DHCP hostnaam", config.hostname, 31); |
151 EditText("AP SSID", config.ap_ssid, 31); |
151 EditText((char *)"AP SSID", config.ap_ssid, 31); |
152 EditTextMin("AP password", config.ap_pwd, 40, 8); |
152 EditTextMin((char *)"AP password", config.ap_pwd, 40, 8); |
153 EditUint8("AP kanaal", &config.ap_channel, 1, 14); |
153 EditUint8((char *)"AP kanaal", &config.ap_channel, 1, 14); |
154 bool hidden = config.ap_ssid_hidden; |
154 bool hidden = config.ap_ssid_hidden; |
155 EditBool("AP SSID verborgen", &hidden); |
155 EditBool((char *)"AP SSID verborgen", &hidden); |
156 config.ap_ssid_hidden = (uint8_t)hidden; |
156 config.ap_ssid_hidden = (uint8_t)hidden; |
157 EditText("Voorkeur NTP server", config.ntp_server, 31); |
157 EditText((char *)"Voorkeur NTP server", config.ntp_server, 31); |
158 |
158 |
159 crc2 = crc32_le(0, dst, sizeof(config)); |
159 crc2 = crc32_le(0, dst, sizeof(config)); |
160 if ((crc1 != crc2) && Confirm("Gewijzigd, opslaan?", "Ja", "Nee")) { |
160 if ((crc1 != crc2) && Confirm((char *)"Gewijzigd, opslaan?", (char *)"Ja", (char *)"Nee")) { |
161 write_config(); |
161 write_config(); |
162 } else { |
162 } else { |
163 read_config(); |
163 read_config(); |
164 } |
164 } |
165 Main_Screen = MAIN_TOOLS_SETUP_CONFIG; |
165 Main_Screen = MAIN_TOOLS_SETUP_CONFIG; |
168 case MAIN_TOOLS_SETUP_EQUIPMENT: |
168 case MAIN_TOOLS_SETUP_EQUIPMENT: |
169 if (UpdateRec) { |
169 if (UpdateRec) { |
170 _bg = TFT_BLACK; |
170 _bg = TFT_BLACK; |
171 TFT_fillScreen(_bg); |
171 TFT_fillScreen(_bg); |
172 TFT_resetclipwin(); |
172 TFT_resetclipwin(); |
173 TopMessage("Apparatuur"); |
173 TopMessage((char *)"Apparatuur"); |
174 UpdateRec = false; |
174 UpdateRec = false; |
175 read_equipment(CurrentRec); |
175 read_equipment(CurrentRec); |
176 TFT_setFont(DEFAULT_FONT, NULL); |
176 TFT_setFont(DEFAULT_FONT, NULL); |
177 ShowText(2, 28, "Naam", equipment.Name); |
177 ShowText(2, 28, (char *)"Naam", equipment.Name); |
178 ShowInteger( 2, 44, "Kook vermogen", "%", equipment.BoilPower); |
178 ShowInteger( 2, 44, (char *)"Kook vermogen", (char *)"%", equipment.BoilPower); |
179 ShowInteger(161, 44, "Maisch verm.", "%", equipment.MashPower); |
179 ShowInteger(161, 44, (char *)"Maisch verm.", (char *)"%", equipment.MashPower); |
180 ShowInteger( 2, 60, "Pomp cyclus", "m", equipment.PumpCycle); |
180 ShowInteger( 2, 60, (char *)"Pomp cyclus", (char *)"m", equipment.PumpCycle); |
181 ShowInteger(161, 60, "Pomp rust", "m", equipment.PumpRest); |
181 ShowInteger(161, 60, (char *)"Pomp rust", (char *)"m", equipment.PumpRest); |
182 ShowBool( 2, 76, "Pomp opwarmen", equipment.PumpPreMash); |
182 ShowBool( 2, 76, (char *)"Pomp opwarmen", equipment.PumpPreMash); |
183 ShowBool(161, 76, "Pomp maischen", equipment.PumpOnMash); |
183 ShowBool(161, 76, (char *)"Pomp maischen", equipment.PumpOnMash); |
184 ShowBool( 2, 92, "Pomp uitmaischen", equipment.PumpMashOut); |
184 ShowBool( 2, 92, (char *)"Pomp uitmaischen", equipment.PumpMashOut); |
185 ShowBool(161, 92, "Pomp bij koken", equipment.PumpOnBoil); |
185 ShowBool(161, 92, (char *)"Pomp bij koken", equipment.PumpOnBoil); |
186 ShowInteger(2, 108, "Pomp maxtemp.", "C", equipment.PumpMaxTemp); |
186 ShowInteger(2, 108, (char *)"Pomp maxtemp.", (char *)"C", equipment.PumpMaxTemp); |
187 ShowBool(161, 108, "PID bij mout weg", equipment.PIDPipe); |
187 ShowBool(161, 108, (char *)"PID bij mout weg", equipment.PIDPipe); |
188 ShowSSR2(2, 124, equipment.SSR2); |
188 ShowSSR2(2, 124, equipment.SSR2); |
189 ShowFloat(161, 124, "Spoelwater", NULL, equipment.TempHLT, 2); |
189 ShowFloat(161, 124, (char *)"Spoelwater", NULL, equipment.TempHLT, 2); |
190 ShowDouble(2, 140, "PID P", NULL, equipment.PID_kP, 3); |
190 ShowDouble(2, 140, (char *)"PID P", NULL, equipment.PID_kP, 3); |
191 ShowBool(161, 140, "PID klassiek", equipment.PID_POn); |
191 ShowBool(161, 140, (char *)"PID klassiek", equipment.PID_POn); |
192 ShowDouble(2, 156, "PID I", NULL, equipment.PID_kI, 3); |
192 ShowDouble(2, 156, (char *)"PID I", NULL, equipment.PID_kI, 3); |
193 ShowInteger(161, 156, "Sample tijd", "mS", equipment.SampleTime); |
193 ShowInteger(161, 156, (char *)"Sample tijd", (char *)"mS", equipment.SampleTime); |
194 ShowDouble(2, 172, "PID D", NULL, equipment.PID_kD, 3); |
194 ShowDouble(2, 172, (char *)"PID D", NULL, equipment.PID_kD, 3); |
195 Buttons_Clear(); |
195 Buttons_Clear(); |
196 Buttons_Add( 0, 210, 45, 30, "Ok" , 0); |
196 Buttons_Add( 0, 210, 45, 30, (char *)"Ok" , 0); |
197 Buttons_Add( 46, 210, 45, 30, "+" , 1); |
197 Buttons_Add( 46, 210, 45, 30, (char *)"+" , 1); |
198 if (CurrentRec != config.EquipmentRec) |
198 if (CurrentRec != config.EquipmentRec) |
199 Buttons_Add( 92, 210, 45, 30, "-", 2); |
199 Buttons_Add( 92, 210, 45, 30, (char *)"-", 2); |
200 else |
200 else |
201 Buttons_Add( 92, 210, 45, 30, "" , 2); |
201 Buttons_Add( 92, 210, 45, 30, (char *)"" , 2); |
202 if (CurrentRec > 1) |
202 if (CurrentRec > 1) |
203 Buttons_Add(138, 210, 45, 30, "<", 3); |
203 Buttons_Add(138, 210, 45, 30, (char *)"<", 3); |
204 else |
204 else |
205 Buttons_Add(138, 210, 45, 30, "", 3); |
205 Buttons_Add(138, 210, 45, 30, (char *)"", 3); |
206 if (CurrentRec < Records) |
206 if (CurrentRec < Records) |
207 Buttons_Add(184, 210, 45, 30, ">", 4); |
207 Buttons_Add(184, 210, 45, 30, (char *)">", 4); |
208 else |
208 else |
209 Buttons_Add(184, 210, 45, 30, "", 4); |
209 Buttons_Add(184, 210, 45, 30, (char *)"", 4); |
210 if (CurrentRec != config.EquipmentRec) |
210 if (CurrentRec != config.EquipmentRec) |
211 Buttons_Add(230, 210, 45, 30, "Std", 5); |
211 Buttons_Add(230, 210, 45, 30, (char *)"Std", 5); |
212 else |
212 else |
213 Buttons_Add(230, 210, 45, 30, "", 5); |
213 Buttons_Add(230, 210, 45, 30, (char *)"", 5); |
214 Buttons_Add(276, 210, 45, 30, "Ed" , 6); |
214 Buttons_Add(276, 210, 45, 30, (char *)"Ed" , 6); |
215 Buttons[0].dark = true; |
215 Buttons[0].dark = true; |
216 Buttons_Show(); |
216 Buttons_Show(); |
217 } |
217 } |
218 switch (Buttons_Scan()) { |
218 switch (Buttons_Scan()) { |
219 case 0: Main_Screen = MAIN_TOOLS_SETUP; |
219 case 0: Main_Screen = MAIN_TOOLS_SETUP; |
284 break; |
284 break; |
285 |
285 |
286 case MAIN_TOOLS_SETUP_EQ_EDIT: |
286 case MAIN_TOOLS_SETUP_EQ_EDIT: |
287 dst = (uint8_t*)&equipment; |
287 dst = (uint8_t*)&equipment; |
288 crc1 = crc32_le(0, dst, sizeof(equipment)); |
288 crc1 = crc32_le(0, dst, sizeof(equipment)); |
289 EditText("Naam", equipment.Name, 31); |
289 EditText((char *)"Naam", equipment.Name, 31); |
290 EditInt("Kook vermogen in %", &equipment.BoilPower, 0, 100); |
290 EditInt((char *)"Kook vermogen in %", &equipment.BoilPower, 0, 100); |
291 EditInt("Maisch vermogen in %", &equipment.MashPower, 0, 100); |
291 EditInt((char *)"Maisch vermogen in %", &equipment.MashPower, 0, 100); |
292 EditInt("Pomp cyclus minuten", &equipment.PumpCycle, 5, 15); |
292 EditInt((char *)"Pomp cyclus minuten", &equipment.PumpCycle, 5, 15); |
293 EditInt("Pomp rust minuten", &equipment.PumpRest, 0, 5); |
293 EditInt((char *)"Pomp rust minuten", &equipment.PumpRest, 0, 5); |
294 EditBool("Pomp bij opwarmen", &equipment.PumpPreMash); |
294 EditBool((char *)"Pomp bij opwarmen", &equipment.PumpPreMash); |
295 EditBool("Pomp bij maischen", &equipment.PumpOnMash); |
295 EditBool((char *)"Pomp bij maischen", &equipment.PumpOnMash); |
296 EditBool("Pomp bij uitmaischen", &equipment.PumpMashOut); |
296 EditBool((char *)"Pomp bij uitmaischen", &equipment.PumpMashOut); |
297 EditBool("Pomp tijdens koken", &equipment.PumpOnBoil); |
297 EditBool((char *)"Pomp tijdens koken", &equipment.PumpOnBoil); |
298 EditInt("Pomp max. temperatuur", &equipment.PumpMaxTemp, 60, 105); |
298 EditInt((char *)"Pomp max. temperatuur", &equipment.PumpMaxTemp, 60, 105); |
299 EditBool("PID by mout verwijderen", &equipment.PIDPipe); |
299 EditBool((char *)"PID by mout verwijderen", &equipment.PIDPipe); |
300 EditSSR2(&equipment.SSR2); |
300 EditSSR2(&equipment.SSR2); |
301 EditFloat("Spoelwater temp", &equipment.TempHLT, 75, 98, 2); |
301 EditFloat((char *)"Spoelwater temp", &equipment.TempHLT, 75, 98, 2); |
302 // Round to 0.25 values. |
302 // Round to 0.25 values. |
303 equipment.TempHLT = ((int)(equipment.TempHLT * 4)) / 4.0; |
303 equipment.TempHLT = ((int)(equipment.TempHLT * 4)) / 4.0; |
304 EditBool("PID klassiek", &equipment.PID_POn); |
304 EditBool((char *)"PID klassiek", &equipment.PID_POn); |
305 EditDouble("PID P", &equipment.PID_kP, 20, 2000, 3); |
305 EditDouble((char *)"PID P", &equipment.PID_kP, 20, 2000, 3); |
306 EditDouble("PID I", &equipment.PID_kI, 0, 100, 3); |
306 EditDouble((char *)"PID I", &equipment.PID_kI, 0, 100, 3); |
307 EditDouble("PID D", &equipment.PID_kD, 0, 50000, 3); |
307 EditDouble((char *)"PID D", &equipment.PID_kD, 0, 50000, 3); |
308 EditInt("Sample tijd in mS", &equipment.SampleTime, 1000, 20000); |
308 EditInt((char *)"Sample tijd in mS", &equipment.SampleTime, 1000, 20000); |
309 // Round to 250 mSec units. |
309 // Round to 250 mSec units. |
310 equipment.SampleTime = ((int)(equipment.SampleTime / 250)) * 250; |
310 equipment.SampleTime = ((int)(equipment.SampleTime / 250)) * 250; |
311 |
311 |
312 crc2 = crc32_le(0, dst, sizeof(equipment)); |
312 crc2 = crc32_le(0, dst, sizeof(equipment)); |
313 if ((crc1 != crc2) && Confirm("Gewijzigd, opslaan?", "Ja", "Nee")) { |
313 if ((crc1 != crc2) && Confirm((char *)"Gewijzigd, opslaan?", (char *)"Ja", (char *)"Nee")) { |
314 write_equipment(equipment.Record); |
314 write_equipment(equipment.Record); |
315 } |
315 } |
316 Main_Screen = MAIN_TOOLS_SETUP_EQUIPMENT; |
316 Main_Screen = MAIN_TOOLS_SETUP_EQUIPMENT; |
317 break; |
317 break; |
318 |
318 |