Sun, 18 Jul 2021 11:25:55 +0200
Version 0.3.17. Made the Hendi PWM change official.
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); |
101
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
171 | ShowInteger( 2, 60, (char *)"Ramp vermogen", (char *)"%", equipment.RampPower); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
172 | ShowFloat(161, 60, (char *)"Spoelwater", NULL, equipment.TempHLT, 2); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
173 | ShowInteger( 2, 76, (char *)"Sample tijd", (char *)"mS", equipment.SampleTime); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
174 | Show2Integer(161, 76, (char *)"Pomp cyclus", (char *)"m", equipment.PumpCycle, equipment.PumpRest); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
175 | ShowBool( 2, 92, (char *)"Pomp opwarmen", equipment.PumpPreMash); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
176 | ShowBool(161, 92, (char *)"Pomp maischen", equipment.PumpOnMash); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
177 | ShowBool( 2, 108, (char *)"Pomp uitmaischen", equipment.PumpMashOut); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
178 | ShowBool(161, 108, (char *)"Pomp bij koken", equipment.PumpOnBoil); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
179 | ShowInteger(2, 124, (char *)"Pomp maxtemp.", (char *)"C", equipment.PumpMaxTemp); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
180 | ShowBool(161, 124, (char *)"PID bij mout weg", equipment.PIDPipe); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
181 | ShowSSR2(2, 140, equipment.SSR2); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
182 | ShowBool(161, 140, (char *)"Hendi PWM", equipment.Hendi); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
183 | ShowDouble(2, 156, (char *)"PID P", NULL, equipment.PID_kP, 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); |
101
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
185 | ShowDouble(2, 172, (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
|
186 | ShowInteger(161, 172, (char *)"HLT watt", NULL, equipment.HLT_watt); |
101
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
187 | ShowDouble(2, 188, (char *)"PID D", NULL, equipment.PID_kD, 3); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
188 | ShowInteger(161, 188, (char *)"Max watt", NULL, equipment.Max_watt); |
0 | 189 | 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
|
190 | 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
|
191 | Buttons_Add( 46, 210, 45, 30, (char *)"+" , 1); |
0 | 192 | 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
|
193 | Buttons_Add( 92, 210, 45, 30, (char *)"-", 2); |
0 | 194 | 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
|
195 | Buttons_Add( 92, 210, 45, 30, (char *)"" , 2); |
0 | 196 | 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
|
197 | Buttons_Add(138, 210, 45, 30, (char *)"<", 3); |
0 | 198 | 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
|
199 | Buttons_Add(138, 210, 45, 30, (char *)"", 3); |
0 | 200 | 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
|
201 | Buttons_Add(184, 210, 45, 30, (char *)">", 4); |
0 | 202 | 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
|
203 | Buttons_Add(184, 210, 45, 30, (char *)"", 4); |
0 | 204 | 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
|
205 | Buttons_Add(230, 210, 45, 30, (char *)"Std", 5); |
0 | 206 | 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
|
207 | 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
|
208 | Buttons_Add(276, 210, 45, 30, (char *)"Ed" , 6); |
0 | 209 | Buttons[0].dark = true; |
210 | Buttons_Show(); | |
211 | } | |
212 | switch (Buttons_Scan()) { | |
213 | case 0: Main_Screen = MAIN_TOOLS_SETUP; | |
214 | break; | |
215 | ||
216 | 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
|
217 | 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
|
218 | equipment.HLT_watt = 2000; |
103
1885d0c75c48
Default equipment max_watt set to 2750. Added defaults for new equipment record. Switched PWM timer to high-speed. Implemented the safety timer to prevent the MLT + HLT will draw too much power in shared mode. Removed some code ideas that were not used. The fake heater now uses the faked PWM power.
Michiel Broek <mbroek@mbse.eu>
parents:
101
diff
changeset
|
219 | equipment.Max_watt = 2750; |
0 | 220 | sprintf(equipment.Name, "new eq %d", Records + 1); |
221 | equipment.BoilPower = 80; | |
103
1885d0c75c48
Default equipment max_watt set to 2750. Added defaults for new equipment record. Switched PWM timer to high-speed. Implemented the safety timer to prevent the MLT + HLT will draw too much power in shared mode. Removed some code ideas that were not used. The fake heater now uses the faked PWM power.
Michiel Broek <mbroek@mbse.eu>
parents:
101
diff
changeset
|
222 | equipment.RampPower = 100; |
0 | 223 | equipment.MashPower = 100; |
224 | equipment.PumpCycle = 8; | |
225 | equipment.PumpRest = 2; | |
226 | equipment.PumpPreMash = true; | |
227 | equipment.PumpOnMash = true; | |
228 | equipment.PumpMashOut = true; | |
229 | equipment.PumpOnBoil = false; | |
230 | equipment.PumpMaxTemp = 80; | |
231 | equipment.PIDPipe = true; | |
232 | equipment.SSR2 = 0; | |
103
1885d0c75c48
Default equipment max_watt set to 2750. Added defaults for new equipment record. Switched PWM timer to high-speed. Implemented the safety timer to prevent the MLT + HLT will draw too much power in shared mode. Removed some code ideas that were not used. The fake heater now uses the faked PWM power.
Michiel Broek <mbroek@mbse.eu>
parents:
101
diff
changeset
|
233 | equipment.Hendi = false; |
0 | 234 | equipment.TempHLT = 85.0; |
82 | 235 | equipment.PID_kP = 200.0; |
236 | equipment.PID_kI = 2.0; | |
237 | equipment.PID_kD = 1.5; | |
238 | equipment.SampleTime = 3000; | |
0 | 239 | append_equipment(); |
240 | Records++; | |
241 | CurrentRec = Records; | |
242 | 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
|
243 | ESP_LOGI(TAG, "New equipment record %d", CurrentRec); |
0 | 244 | break; |
245 | ||
246 | 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
|
247 | _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
|
248 | 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
|
249 | 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
|
250 | TopMessage((char *)"Apparatuur verwijderen"); |
0 | 251 | delete_equipment(CurrentRec); |
252 | 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
|
253 | if (CurrentRec >= Records) |
0 | 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); |
101
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
292 | EditInt((char *)"Ramp vermogen in %", &equipment.RampPower, 0, 100); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
293 | EditFloat((char *)"Spoelwater temp", &equipment.TempHLT, 75, 98, 2); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
294 | // Round to 0.25 values. |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
295 | equipment.TempHLT = ((int)(equipment.TempHLT * 4)) / 4.0; |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
296 | EditInt((char *)"Sample tijd in mS", &equipment.SampleTime, 1000, 20000); |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
297 | // Round to 250 mSec units. |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
298 | equipment.SampleTime = ((int)(equipment.SampleTime / 250)) * 250; |
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 | 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
|
300 | 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
|
301 | 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
|
302 | 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
|
303 | 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
|
304 | 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
|
305 | 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
|
306 | EditBool((char *)"PID by mout verwijderen", &equipment.PIDPipe); |
0 | 307 | EditSSR2(&equipment.SSR2); |
101
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
308 | EditBool((char *)"Hendi PWM", &equipment.Hendi); |
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 | 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
|
310 | 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
|
311 | EditDouble((char *)"PID D", &equipment.PID_kD, 0, 50000, 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
|
312 | 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
|
313 | EditInt((char *)"HLT watt", &equipment.HLT_watt, 100, 45000); |
101
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
314 | EditInt((char *)"Max watt", &equipment.Max_watt, 100, 45000); |
0 | 315 | |
316 | 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
|
317 | 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
|
318 | write_equipment(CurrentRec); |
0 | 319 | } |
320 | Main_Screen = MAIN_TOOLS_SETUP_EQUIPMENT; | |
321 | break; | |
322 | ||
323 | case MAIN_TOOLS_SETUP_WIFI: | |
324 | break; | |
325 | ||
326 | case MAIN_TOOLS_SETUP_CALIBRATION: | |
327 | Calibration_Loop(); | |
328 | Main_Screen = MAIN_TOOLS_SETUP; | |
329 | break; | |
330 | ||
331 | default: | |
332 | break; | |
333 | } | |
334 | } | |
335 |