Wed, 19 May 2021 17:21:33 +0200
Version 0.3.14. Log brewing essentials at brew start.
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); |
95
c02e12e9c884
Removed AP configuration settings.
Michiel Broek <mbroek@mbse.eu>
parents:
87
diff
changeset
|
54 | ShowText(2, 124, (char *)"NTP server", config.ntp_server); |
0 | 55 | 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
|
56 | 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
|
57 | Buttons_Add(276, 210, 45, 30, (char *)"Ed" , 1); |
0 | 58 | Buttons[0].dark = true; |
59 | Buttons_Show(); | |
60 | break; | |
61 | ||
62 | case MAIN_TOOLS_SETUP_CO_EDIT: | |
63 | break; | |
64 | ||
65 | 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
|
66 | TopMessage((char *)"Apparatuur"); |
0 | 67 | f = fopen("/spiffs/etc/equipments.conf", "r"); |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
68 | fseek(f, equipment_hdr.hdrsize, SEEK_SET); |
0 | 69 | dst = (uint8_t*)&equipment; |
70 | Records = 0; | |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
71 | while ((bytes = fread(dst, 1, equipment_hdr.recsize, f))) { |
0 | 72 | Records++; |
73 | } | |
74 | fclose(f); | |
75 | // Load the default record. | |
76 | CurrentRec = config.EquipmentRec; | |
77 | UpdateRec = true; | |
78 | break; | |
79 | ||
80 | case MAIN_TOOLS_SETUP_EQ_EDIT: | |
81 | break; | |
82 | ||
83 | case MAIN_TOOLS_SETUP_CALIBRATION: | |
84 | Calibration_Init(); | |
85 | break; | |
86 | ||
87 | default: | |
88 | break; | |
89 | } | |
90 | } | |
91 | ||
92 | ||
93 | ||
94 | /* | |
95 | * Setup loop screens, non-blocking. | |
96 | */ | |
97 | void Setup_Loop(void) | |
98 | { | |
99 | uint32_t crc1, crc2; | |
100 | uint8_t *dst; | |
101 | ||
102 | switch (Main_Screen) { | |
103 | ||
104 | case MAIN_TOOLS_SETUP: | |
105 | switch (Buttons_Scan()) { | |
106 | case 0: Main_Screen = MAIN_TOOLS_SETUP_CONFIG; | |
107 | break; | |
108 | ||
109 | case 1: Main_Screen = MAIN_TOOLS_SETUP_EQUIPMENT; | |
110 | break; | |
111 | ||
112 | case 2: Main_Screen = MAIN_TOOLS_SETUP_WIFI; | |
113 | break; | |
114 | ||
115 | case 3: Main_Screen = MAIN_TOOLS_SETUP_CALIBRATION; | |
116 | break; | |
117 | ||
118 | case 4: Main_Screen = MAIN_TOOLS; | |
119 | break; | |
120 | ||
121 | default: break; | |
122 | } | |
123 | break; | |
124 | ||
125 | case MAIN_TOOLS_SETUP_CONFIG: | |
126 | switch (Buttons_Scan()) { | |
127 | case 0: Main_Screen = MAIN_TOOLS_SETUP; | |
128 | break; | |
129 | ||
130 | case 1: Main_Screen = MAIN_TOOLS_SETUP_CO_EDIT; | |
131 | break; | |
132 | ||
133 | default: break; | |
134 | } | |
135 | break; | |
136 | ||
137 | case MAIN_TOOLS_SETUP_CO_EDIT: | |
138 | dst = (uint8_t*)&config; | |
139 | 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
|
140 | EditFloat((char *)"Kook temperatuur", &config.BoilTemperature, 80, 105, 2); |
0 | 141 | // Round to 0.25 degrees |
142 | 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
|
143 | 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
|
144 | 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
|
145 | 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
|
146 | 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
|
147 | 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
|
148 | EditText((char *)"Voorkeur NTP server", config.ntp_server, 31); |
0 | 149 | |
150 | 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
|
151 | if ((crc1 != crc2) && Confirm((char *)"Gewijzigd, opslaan?", (char *)"Ja", (char *)"Nee")) { |
0 | 152 | write_config(); |
153 | } else { | |
154 | read_config(); | |
155 | } | |
156 | Main_Screen = MAIN_TOOLS_SETUP_CONFIG; | |
157 | break; | |
158 | ||
159 | case MAIN_TOOLS_SETUP_EQUIPMENT: | |
160 | if (UpdateRec) { | |
161 | _bg = TFT_BLACK; | |
162 | TFT_fillScreen(_bg); | |
163 | 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
|
164 | TopMessage((char *)"Apparatuur"); |
0 | 165 | UpdateRec = false; |
166 | read_equipment(CurrentRec); | |
167 | 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
|
168 | 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
|
169 | 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
|
170 | 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
|
171 | 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
|
172 | 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
|
173 | 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
|
174 | 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
|
175 | 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
|
176 | 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
|
177 | 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
|
178 | ShowBool(161, 108, (char *)"PID bij mout weg", equipment.PIDPipe); |
0 | 179 | 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
|
180 | 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
|
181 | ShowDouble(2, 140, (char *)"PID P", NULL, equipment.PID_kP, 3); |
82 | 182 | ShowInteger(161, 140, (char *)"Sample tijd", (char *)"mS", equipment.SampleTime); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
183 | ShowDouble(2, 156, (char *)"PID I", NULL, equipment.PID_kI, 3); |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
184 | ShowInteger(161, 156, (char *)"MLT watt", NULL, equipment.MLT_watt); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
185 | ShowDouble(2, 172, (char *)"PID D", NULL, equipment.PID_kD, 3); |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
186 | ShowInteger(161, 172, (char *)"HLT watt", NULL, equipment.HLT_watt); |
0 | 187 | 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
|
188 | 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
|
189 | Buttons_Add( 46, 210, 45, 30, (char *)"+" , 1); |
0 | 190 | 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
|
191 | Buttons_Add( 92, 210, 45, 30, (char *)"-", 2); |
0 | 192 | 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
|
193 | Buttons_Add( 92, 210, 45, 30, (char *)"" , 2); |
0 | 194 | 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
|
195 | Buttons_Add(138, 210, 45, 30, (char *)"<", 3); |
0 | 196 | 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
|
197 | Buttons_Add(138, 210, 45, 30, (char *)"", 3); |
0 | 198 | 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
|
199 | Buttons_Add(184, 210, 45, 30, (char *)">", 4); |
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(184, 210, 45, 30, (char *)"", 4); |
0 | 202 | 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
|
203 | Buttons_Add(230, 210, 45, 30, (char *)"Std", 5); |
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(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
|
206 | Buttons_Add(276, 210, 45, 30, (char *)"Ed" , 6); |
0 | 207 | Buttons[0].dark = true; |
208 | Buttons_Show(); | |
209 | } | |
210 | switch (Buttons_Scan()) { | |
211 | case 0: Main_Screen = MAIN_TOOLS_SETUP; | |
212 | break; | |
213 | ||
214 | case 1: memset(&equipment, 0, sizeof(equipment)); | |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
215 | equipment.MLT_watt = 2000; |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
216 | equipment.HLT_watt = 2000; |
0 | 217 | sprintf(equipment.Name, "new eq %d", Records + 1); |
218 | equipment.BoilPower = 80; | |
219 | equipment.MashPower = 100; | |
220 | equipment.PumpCycle = 8; | |
221 | equipment.PumpRest = 2; | |
222 | equipment.PumpPreMash = true; | |
223 | equipment.PumpOnMash = true; | |
224 | equipment.PumpMashOut = true; | |
225 | equipment.PumpOnBoil = false; | |
226 | equipment.PumpMaxTemp = 80; | |
227 | equipment.PIDPipe = true; | |
228 | equipment.SSR2 = 0; | |
229 | equipment.TempHLT = 85.0; | |
82 | 230 | equipment.PID_kP = 200.0; |
231 | equipment.PID_kI = 2.0; | |
232 | equipment.PID_kD = 1.5; | |
233 | equipment.SampleTime = 3000; | |
0 | 234 | append_equipment(); |
235 | Records++; | |
236 | CurrentRec = Records; | |
237 | UpdateRec = true; | |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
238 | ESP_LOGI(TAG, "New equipment record %d", CurrentRec); |
0 | 239 | break; |
240 | ||
241 | case 2: if ((CurrentRec != config.EquipmentRec) && (Records > 1)) { | |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
242 | _bg = TFT_BLACK; |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
243 | TFT_fillScreen(_bg); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
244 | TFT_resetclipwin(); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
245 | TopMessage((char *)"Apparatuur verwijderen"); |
0 | 246 | delete_equipment(CurrentRec); |
247 | Records--; | |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
248 | if (CurrentRec >= Records) |
0 | 249 | CurrentRec = Records; |
250 | UpdateRec = true; | |
251 | } | |
252 | break; | |
253 | ||
254 | case 3: if (CurrentRec > 1) { | |
255 | CurrentRec--; | |
256 | UpdateRec = true; | |
257 | } | |
258 | break; | |
259 | ||
260 | case 4: if (CurrentRec < Records) { | |
261 | CurrentRec++; | |
262 | UpdateRec = true; | |
263 | } | |
264 | break; | |
265 | ||
266 | case 5: if (CurrentRec != config.EquipmentRec) { | |
267 | config.EquipmentRec = CurrentRec; | |
268 | write_config(); | |
269 | UpdateRec = true; | |
270 | ESP_LOGI(TAG, "Equipment %d `%s' set as default", CurrentRec, equipment.Name); | |
271 | } | |
272 | break; | |
273 | ||
274 | case 6: Main_Screen = MAIN_TOOLS_SETUP_EQ_EDIT; | |
275 | break; | |
276 | ||
277 | default: break; | |
278 | } | |
279 | break; | |
280 | ||
281 | case MAIN_TOOLS_SETUP_EQ_EDIT: | |
282 | dst = (uint8_t*)&equipment; | |
283 | 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
|
284 | 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
|
285 | 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
|
286 | 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
|
287 | 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
|
288 | 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
|
289 | 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
|
290 | 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
|
291 | 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
|
292 | 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
|
293 | 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
|
294 | EditBool((char *)"PID by mout verwijderen", &equipment.PIDPipe); |
0 | 295 | 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
|
296 | EditFloat((char *)"Spoelwater temp", &equipment.TempHLT, 75, 98, 2); |
0 | 297 | // Round to 0.25 values. |
298 | 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
|
299 | 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
|
300 | 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
|
301 | 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
|
302 | EditInt((char *)"Sample tijd in mS", &equipment.SampleTime, 1000, 20000); |
0 | 303 | // Round to 250 mSec units. |
304 | equipment.SampleTime = ((int)(equipment.SampleTime / 250)) * 250; | |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
305 | EditInt((char *)"MLT watt", &equipment.MLT_watt, 100, 45000); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
306 | EditInt((char *)"HLT watt", &equipment.HLT_watt, 100, 45000); |
0 | 307 | |
308 | 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
|
309 | if ((crc1 != crc2) && Confirm((char *)"Gewijzigd, opslaan?", (char *)"Ja", (char *)"Nee")) { |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
310 | write_equipment(CurrentRec); |
0 | 311 | } |
312 | Main_Screen = MAIN_TOOLS_SETUP_EQUIPMENT; | |
313 | break; | |
314 | ||
315 | case MAIN_TOOLS_SETUP_WIFI: | |
316 | break; | |
317 | ||
318 | case MAIN_TOOLS_SETUP_CALIBRATION: | |
319 | Calibration_Loop(); | |
320 | Main_Screen = MAIN_TOOLS_SETUP; | |
321 | break; | |
322 | ||
323 | default: | |
324 | break; | |
325 | } | |
326 | } | |
327 |