Thu, 04 Jul 2019 21:46:12 +0200
Added syslog like logging on the sdcard for the manual and automatic processes.
0 | 1 | /** |
2 | * @file automation.c | |
3 | * @brief Automation functions. | |
4 | */ | |
5 | ||
6 | #include "config.h" | |
7 | ||
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
8 | int BoilPower = 100; ///< Boil power 0..100% |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
9 | int LastMashStep = 0; ///< Last valid mash step |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
10 | char temp_buf[64]; ///< Temporary buffer |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
11 | char logline[128]; ///< Log line buffer |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
12 | char strftime_buf[64]; ///< Time buffer |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
13 | bool loop; ///< Loop flag |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
14 | bool CoolBeep = false; ///< Did beep during cooling |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
15 | bool Resume = false; ///< Resume brew flag |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
16 | bool pumpRest = false; ///< Pump is resting |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
17 | bool updateRuntime = false; ///< Update runtime record |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
18 | bool NewMinute = false; ///< We have a new minute |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
19 | bool TempReached = false; ///< Temperature is reached |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
20 | uint8_t MashState = MASH_NONE; ///< Mash states |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
21 | float temp_MLT; ///< MLT temperature |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
22 | float MinMash = 38.0; ///< Minimum edit value |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
23 | float MaxMash = 80.0; ///< Maximum edit value |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
24 | uint32_t power_MLT = 0; ///< MLT power |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
25 | uint32_t power_HLT = 0; ///< HLT power |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
26 | uint32_t counts = 0; ///< Counter for power average |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
27 | float stageTemp = 0.0; ///< Current stage temperature |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
28 | uint16_t stageTime = 0; ///< Current stage timer |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
29 | uint16_t TimeWhirlPool = 0; ///< Whirlpool timer |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
30 | uint32_t TimeLeft = 0; ///< Tie left in this stage |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
31 | uint32_t TimeSpent = 0; ///< Tota time spent |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
32 | uint32_t SecsCount = 0; ///< Seconds counter |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
33 | uint32_t pumpTime = 0; ///< Pump running time |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
34 | uint32_t TimeBrewing = 0; ///< Brewing time elapsed |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
35 | uint16_t Steady = 0; ///< Temperature is steady |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
36 | bool _NewMinute = false; ///< New minute slave flag |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
37 | bool _UseHLT = false; ///< Use HLT slave flag |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
38 | bool _Prompt = false; ///< Prompt display flag |
0 | 39 | |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
40 | extern bool System_TimeOk; ///< System time is valid |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
41 | extern sButton Buttons[MAXBUTTONS]; ///< Buttons definitions |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
42 | extern int Main_Screen; ///< Current screen |
42 | 43 | extern int Sub_Screen; ///< Sub screen during mash |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
44 | extern DS18B20_State *ds18b20_state; ///< DS18B20 state |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
45 | extern DRIVER_State *driver_state; ///< Relays driver state |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
46 | extern SemaphoreHandle_t xSemaphoreDS18B20; ///< DS18B20 lock semaphore |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
47 | extern SemaphoreHandle_t xSemaphoreDriver; ///< Relays driver lock semaphore |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
48 | extern double Output; ///< Cakculated outpout power |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
49 | extern time_t now; ///< Current time |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
50 | extern struct tm timeinfo; ///< Current time structure |
0 | 51 | |
52 | #ifdef CONFIG_TEMP_SENSORS_SIMULATOR | |
53 | extern float Fake_MLT; | |
54 | extern float Fake_HLT; | |
55 | #endif | |
56 | ||
19 | 57 | extern const char *mashTypes[]; |
58 | ||
0 | 59 | static const char *TAG = "automation"; |
60 | ||
61 | ||
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
62 | void change_sp(bool up) |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
63 | { |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
64 | if (up) |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
65 | stageTemp += 0.25; |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
66 | else |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
67 | stageTemp -= 0.25; |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
68 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
69 | driver_state->mlt_sp = stageTemp; |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
70 | xSemaphoreGive(xSemaphoreDriver); |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
71 | } |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
72 | log_msg(TAG, "Changed sp to %.2f", stageTemp); |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
73 | } |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
74 | |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
75 | |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
76 | |
0 | 77 | /* |
78 | * Automation init function that only runs once when a | |
79 | * new screen is entered. | |
80 | */ | |
81 | bool Automation_Init(void) | |
82 | { | |
42 | 83 | char msg[64]; |
84 | ||
0 | 85 | switch (Main_Screen) { |
42 | 86 | case MAIN_AUTO_INIT1: |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
87 | log_msg(TAG, "Automation startup"); |
0 | 88 | #ifdef CONFIG_TEMP_SENSORS_SIMULATOR |
89 | Fake_MLT = recipe.MashStep[0].Temperature - 10; | |
90 | Fake_HLT = recipe.SpargeTemp - 15; | |
91 | if (xSemaphoreTake(xSemaphoreDS18B20, 10) == pdTRUE) { | |
92 | ds18b20_state->mlt_temperature = ((int)(Fake_MLT * 16)) / 16.0; | |
93 | ds18b20_state->hlt_temperature = ((int)(Fake_HLT * 16)) / 16.0; | |
94 | xSemaphoreGive(xSemaphoreDS18B20); | |
95 | } | |
96 | #endif | |
97 | for (int i = 0; i < 7; i++) { | |
98 | if (recipe.MashStep[i].Resttime) | |
99 | LastMashStep = i; | |
100 | } | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
101 | log_msg(TAG, "Last mash step %d", LastMashStep); |
0 | 102 | |
103 | // Check for a crashed session. | |
104 | if (runtime.AutoModeStarted) { | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
105 | TopMessage((char *)"Brouwen hervatten?"); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
106 | Buttons_Add( 40, 100, 80, 40, (char *)"Ja", 0); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
107 | Buttons_Add(200, 100, 80, 40, (char *)"Nee", 1); |
0 | 108 | Buttons_Show(); |
109 | SoundPlay(SOUND_Prompt); | |
110 | loop = true; | |
111 | while (loop) { | |
112 | switch (Buttons_Scan()) { | |
113 | case 0: loop = false; | |
114 | Resume = true; | |
115 | Main_Screen = runtime.StageResume; | |
116 | TimeLeft = runtime.StageTimeLeft; | |
117 | TimeBrewing = runtime.TimeBrewing; | |
118 | _UseHLT = runtime.UseHLT; | |
119 | MashState = MASH_NONE; | |
120 | pumpTime = 0; | |
121 | pumpRest = false; | |
122 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
123 | driver_state->enable = true; | |
124 | if (_UseHLT) { | |
125 | driver_state->hlt_sp = recipe.SpargeTemp; | |
126 | driver_state->hlt_mode = HLT_MODE_BANG; | |
127 | } | |
128 | xSemaphoreGive(xSemaphoreDriver); | |
129 | } | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
130 | log_msg(TAG, "Resume brew screen %d, time left %d", Main_Screen, TimeLeft); |
0 | 131 | log_begin((time_t)0); |
132 | update_json(); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
133 | log_annotation(ANNOTATION_SYSTEM, (char *)"Resume"); |
0 | 134 | return true; |
135 | break; | |
136 | ||
137 | case 1: loop = false; | |
138 | Resume = false; | |
139 | break; | |
140 | ||
141 | default: | |
142 | break; | |
143 | } | |
144 | vTaskDelay(50 / portTICK_PERIOD_MS); | |
145 | } | |
146 | Buttons_Clear(); | |
147 | TFT_fillScreen(_bg); | |
148 | } | |
149 | ||
150 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
151 | driver_state->enable = true; | |
152 | xSemaphoreGive(xSemaphoreDriver); | |
153 | } | |
154 | runtime.AutoModeStarted = true; | |
155 | runtime.UseHLT = _UseHLT = false; | |
156 | runtime.TimeBrewing = 0; | |
157 | TimeBrewing = 0; | |
42 | 158 | runtime.StageResume = MAIN_AUTO_INIT1; |
0 | 159 | runtime.StageTimeLeft = 0; |
160 | runtime.HopAddition = 0; | |
161 | runtime.Logfile[0] = '\0'; | |
162 | runtime.PumpCooling = false; | |
163 | write_runtime(); | |
164 | power_MLT = power_HLT = counts = 0; | |
165 | log_clean(); | |
166 | vTaskDelay(250 / portTICK_PERIOD_MS); // Allow some time | |
167 | break; | |
168 | ||
42 | 169 | case MAIN_AUTO_INIT2: |
0 | 170 | case MAIN_AUTO_DELAYSTART: |
171 | break; | |
172 | ||
173 | case MAIN_AUTO_HEATUP: | |
174 | if (runtime.UseHLT) { | |
175 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
176 | driver_state->hlt_mode = HLT_MODE_BANG; | |
177 | xSemaphoreGive(xSemaphoreDriver); | |
178 | } | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
179 | TopMessage((char *)"Spoelwater opwarmen"); |
0 | 180 | MLT_info(71, 26, false); |
181 | HLT_info(71,150, false, false); | |
182 | } | |
183 | break; | |
184 | ||
185 | case MAIN_AUTO_MASH_IN: | |
186 | case MAIN_AUTO_MASH_1: | |
187 | case MAIN_AUTO_MASH_2: | |
188 | case MAIN_AUTO_MASH_3: | |
189 | case MAIN_AUTO_MASH_4: | |
190 | case MAIN_AUTO_MASH_5: | |
191 | case MAIN_AUTO_MASH_6: | |
192 | case MAIN_AUTO_MASH_OUT: | |
193 | if (Main_Screen == MAIN_AUTO_MASH_IN) { | |
194 | MinMash = 38.0; | |
195 | MaxMash = recipe.MashStep[1].Temperature + 10.0; | |
196 | TimeBrewing = 0; | |
197 | runtime.TimeBrewing = 0; | |
198 | if (System_TimeOk) { | |
199 | time(&now); | |
200 | localtime_r(&now, &timeinfo); | |
201 | log_begin(now); | |
202 | runtime.BrewStart = now; | |
203 | } else { | |
204 | log_begin((time_t)0); | |
205 | runtime.BrewStart = (time_t)0; | |
206 | } | |
207 | updateRuntime = true; | |
208 | } else if (Main_Screen == MAIN_AUTO_MASH_OUT) { | |
209 | MinMash = 75.0; | |
210 | MaxMash = 80.0; | |
211 | } else { | |
212 | MinMash = recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN - 1].Temperature; | |
213 | if (recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN + 1].Resttime) { | |
214 | MaxMash = recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN + 1].Temperature; | |
215 | } else { | |
216 | MaxMash = 75.0; | |
217 | } | |
218 | } | |
42 | 219 | MashState = Sub_Screen = MASH_NONE; |
220 | snprintf(msg, 63, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
221 | ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); |
0 | 222 | pumpTime = 0; |
223 | pumpRest = false; | |
224 | runtime.StageResume = Main_Screen; | |
225 | updateRuntime = true; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
226 | TopMessage((char *)"Maischen"); |
0 | 227 | MLT_info(71, 26, false); |
228 | if (_UseHLT) { | |
229 | HLT_info(71,170, false, true); | |
230 | } | |
231 | break; | |
232 | ||
233 | case MAIN_AUTO_TOBOIL: | |
234 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
235 | driver_state->mlt_sp = stageTemp = config.BoilTemperature; | |
236 | driver_state->mlt_mode = MLT_MODE_EXT; | |
237 | driver_state->hlt_sp = 0.0; | |
238 | driver_state->hlt_mode = HLT_MODE_NONE; | |
239 | xSemaphoreGive(xSemaphoreDriver); | |
240 | } | |
241 | ||
242 | runtime.StageResume = Main_Screen; | |
243 | updateRuntime = true; | |
244 | TempReached = false; | |
245 | ||
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
246 | TopMessage((char *)"Naar koken"); |
0 | 247 | MLT_info(71, 26, false); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
248 | Buttons_Add( 5, 30, 60, 40, (char *)"+sp", 0); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
249 | Buttons_Add(255, 30, 60, 40, (char *)"-sp", 1); |
0 | 250 | Buttons_Show(); |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
251 | log_msg(TAG, "Mash done, going to boil."); |
42 | 252 | Sub_Screen = 0; |
0 | 253 | break; |
254 | ||
255 | case MAIN_AUTO_BOILING: | |
256 | if (Resume) { | |
257 | TimeLeft = runtime.StageTimeLeft * 60; | |
258 | } else { | |
42 | 259 | // +1 minute for flameout and for a smooth transition. |
0 | 260 | runtime.StageTimeLeft = TimeLeft = (recipe.BoilTime * 60) + 60; |
261 | runtime.StageResume = Main_Screen; | |
262 | runtime.HopAddition = 0; | |
263 | } | |
264 | SecsCount = 0; | |
265 | ||
266 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
267 | driver_state->mlt_sp = stageTemp = config.BoilTemperature; | |
268 | driver_state->mlt_mode = MLT_MODE_EXT; | |
269 | xSemaphoreGive(xSemaphoreDriver); | |
270 | } | |
271 | SoundPlay(SOUND_TempReached); | |
272 | BoilPower = equipment.BoilPower; | |
273 | updateRuntime = true; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
274 | TopMessage((char *)"Koken"); |
0 | 275 | MLT_info(71, 26, false); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
276 | Buttons_Add( 3, 30, 60, 40, (char *)"+sp", 0); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
277 | Buttons_Add(257, 30, 60, 40, (char *)"-sp", 1); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
278 | Buttons_Add( 3, 190, 60, 40, (char *)"+1m", 2); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
279 | Buttons_Add(257, 190, 60, 40, (char *)"-1m", 3); |
0 | 280 | Buttons_Show(); |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
281 | log_msg(TAG, "Boil temperature reached, boil %d minutes", (TimeLeft / 60) -1); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
282 | log_annotation(ANNOTATION_STAGE, (char *)"Koken"); |
42 | 283 | Sub_Screen = 0; |
0 | 284 | break; |
285 | ||
286 | case MAIN_AUTO_COOLING_H: | |
287 | case MAIN_AUTO_COOLING_M: | |
288 | case MAIN_AUTO_COOLING_C: | |
289 | TempReached = false; | |
290 | runtime.StageResume = Main_Screen; | |
291 | runtime.StageTimeLeft = 0; | |
292 | updateRuntime = true; | |
293 | if ((Main_Screen == MAIN_AUTO_COOLING_H) && (! recipe.Whirlpool7)) { | |
294 | // Skip cooling before whirlpool 74 degrees | |
295 | Main_Screen = MAIN_AUTO_COOLING_M; | |
296 | return true; //goto startover; | |
297 | } | |
298 | if ((Main_Screen == MAIN_AUTO_COOLING_M) && (! recipe.Whirlpool6)) { | |
299 | // Skip cooling before whirlpool 63 degrees. | |
300 | Main_Screen = MAIN_AUTO_COOLING_C; | |
301 | return true; //goto startover; | |
302 | } | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
303 | TopMessage((char *)"Start koelen?"); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
304 | Buttons_Add( 40, 100, 80, 40, (char *)"Start", 0); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
305 | Buttons_Add(200, 100, 80, 40, (char *)"Stop", 1); |
0 | 306 | Buttons[1].dark = true; |
307 | Buttons_Show(); | |
308 | SoundPlay(SOUND_Prompt); | |
309 | _Prompt = true; | |
310 | break; | |
311 | ||
43
2079940c3989
Fixed missing whirlpool 88+ degrees. Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
312 | case MAIN_AUTO_WHIRLPOOL9: |
0 | 313 | case MAIN_AUTO_WHIRLPOOL7: |
314 | case MAIN_AUTO_WHIRLPOOL6: | |
315 | case MAIN_AUTO_WHIRLPOOL2: | |
316 | TempReached = true; | |
317 | runtime.StageResume = Main_Screen; | |
318 | updateRuntime = true; | |
319 | if ((Main_Screen == MAIN_AUTO_WHIRLPOOL9) && (! recipe.Whirlpool9)) { | |
320 | // Skip whirlpool 93 degrees. | |
321 | Main_Screen = MAIN_AUTO_COOLING_H; | |
322 | return true; //goto startover; | |
323 | } | |
324 | if ((Main_Screen == MAIN_AUTO_WHIRLPOOL7) && (! recipe.Whirlpool7)) { | |
325 | // Skip whirlpool 74 degrees. | |
326 | Main_Screen = MAIN_AUTO_COOLING_M; | |
327 | return true; //goto startover; | |
328 | } | |
329 | if ((Main_Screen == MAIN_AUTO_WHIRLPOOL6) && (! recipe.Whirlpool6)) { | |
330 | // Skip whirlpool 63 degrees. | |
331 | Main_Screen = MAIN_AUTO_COOLING_C; | |
332 | return true; //goto startover; | |
333 | } | |
334 | if ((Main_Screen == MAIN_AUTO_WHIRLPOOL2) && (! recipe.Whirlpool2)) { | |
335 | // Skip final whirlpool. | |
336 | Main_Screen = MAIN_AUTO_DONE; | |
337 | return true; //goto startover; | |
338 | } | |
339 | ||
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
340 | TopMessage((char *)"Start Whirlpool?"); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
341 | Buttons_Add( 40, 100, 80, 40, (char *)"Start", 0); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
342 | Buttons_Add(200, 100, 80, 40, (char *)"Stop", 1); |
0 | 343 | Buttons[1].dark = true; |
344 | Buttons_Show(); | |
345 | SoundPlay(SOUND_Prompt); | |
346 | _Prompt = true; | |
347 | break; | |
348 | ||
349 | case MAIN_AUTO_DONE: | |
350 | case MAIN_AUTO_ABORT: | |
351 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
352 | driver_state->enable = false; | |
353 | driver_state->mlt_mode = MLT_MODE_NONE; | |
354 | driver_state->mlt_sp = 0.0; | |
355 | driver_state->hlt_mode = HLT_MODE_NONE; | |
356 | driver_state->hlt_sp = 0.0; | |
357 | driver_state->pump_run = 0; | |
358 | xSemaphoreGive(xSemaphoreDriver); | |
359 | } | |
360 | _fg = TFT_YELLOW; | |
361 | TFT_setFont(DEJAVU24_FONT, NULL); | |
362 | if (Main_Screen == MAIN_AUTO_DONE) { | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
363 | TFT_print((char *)"Brouwen is gereed.", CENTER, CENTER); |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
364 | log_msg(TAG, "Brew is done"); |
0 | 365 | SoundPlay(SOUND_End); |
366 | } else { | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
367 | TFT_print((char *)"Brouwen is afgebroken.", CENTER, CENTER); |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
368 | log_msg(TAG, "Brew is aborted"); |
0 | 369 | SoundPlay(SOUND_Warn); |
370 | } | |
371 | log_close(); | |
372 | runtime.Logfile[0] = '\0'; | |
373 | runtime.BrewStart = (time_t)0; | |
374 | runtime.AutoModeStarted = false; | |
375 | runtime.StageResume = MAIN_MODE_FREE; | |
376 | runtime.PumpCooling = false; | |
377 | runtime.HopAddition = 0; | |
378 | runtime.TimeBrewing = 0; | |
379 | runtime.StageTimeLeft = 0; | |
380 | updateRuntime = true; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
381 | Buttons_Add(130, 200, 60, 40, (char *)"Ok", 0); |
0 | 382 | Buttons[0].dark = true; |
383 | Buttons_Show(); | |
384 | break; | |
385 | ||
386 | default: | |
387 | break; | |
388 | } | |
389 | ||
390 | return false; | |
391 | } | |
392 | ||
393 | ||
394 | ||
395 | /* | |
396 | * Automation loop screens. Mostly non-blocking. | |
397 | */ | |
398 | bool Automation_Loop(void) | |
399 | { | |
400 | static bool beeped = false; | |
42 | 401 | char tmp[32], msg[256]; |
0 | 402 | uint16_t y; |
403 | ||
404 | switch (Main_Screen) { | |
405 | ||
42 | 406 | case MAIN_AUTO_INIT1: |
0 | 407 | /* |
408 | * Present selected equipment and recipe. | |
409 | */ | |
42 | 410 | Sub_Screen = 1; |
0 | 411 | read_recipe(config.RecipeRec); |
42 | 412 | snprintf(msg, 255, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\",\"brew1\":\"%s\",\"brew2\":\"%s\"}", |
413 | Main_Screen, Sub_Screen, equipment.Name, recipe.Name); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
414 | ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); |
0 | 415 | y = 28; |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
416 | TopMessage((char *)"Automaat"); |
0 | 417 | 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:
43
diff
changeset
|
418 | ShowText(2,y,(char *)"Installatie", equipment.Name); |
0 | 419 | y += 16; |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
420 | ShowText(2,y,(char *)"Recept", recipe.Name); |
0 | 421 | y += 16; |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
422 | ShowFloat(2, y, (char *)"Maisch in", (char *)" C", recipe.MashStep[0].Temperature, 2); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
423 | ShowFloat(162, y, (char *)"Spoelwater", (char *)" C", recipe.SpargeTemp, 2); |
0 | 424 | y += 16; |
425 | _fg = TFT_WHITE; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
426 | TFT_print((char *)"Maisch stap", 2, y); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
427 | TFT_print((char *)"T", 200, y); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
428 | TFT_print((char *)"Temp.", 220, y); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
429 | TFT_print((char *)"Rust", 280, y); |
0 | 430 | _fg = TFT_YELLOW; |
431 | y += 16; | |
432 | for (int i = 1; i < 8; i++) { | |
433 | if (recipe.MashStep[i].Resttime) { | |
434 | TFT_print(recipe.MashStep[i].Name, 2, y); | |
19 | 435 | strcpy(tmp, mashTypes[recipe.MashStep[i].Type]); |
436 | tmp[1] = '\0'; | |
0 | 437 | TFT_print(tmp, 200, y); |
19 | 438 | sprintf(tmp, "%.2f", recipe.MashStep[i].Temperature); |
439 | TFT_print(tmp, 220, y); | |
440 | sprintf(tmp, "%2d m", recipe.MashStep[i].Resttime); | |
441 | TFT_print(tmp, 280, y); | |
0 | 442 | y += 16; |
443 | } | |
444 | } | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
445 | ShowInteger(2, y, (char *)"Kooktijd", (char *)" min", recipe.BoilTime); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
446 | ShowFloat(162, y, (char *)"Koel tot", (char *)" C", recipe.CoolTemp, 2); |
0 | 447 | y += 16; |
448 | if (recipe.Additions) { | |
449 | _fg = TFT_YELLOW; | |
450 | sprintf(tmp, "%d ", recipe.Additions); | |
451 | TFT_print(tmp, 2, y); | |
452 | _fg = TFT_WHITE; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
453 | TFT_print((char *)"toevoegingen om", LASTX, y); |
0 | 454 | _fg = TFT_YELLOW; |
455 | for (int i = 1; i <= recipe.Additions; i++) { | |
456 | sprintf(tmp, " %d", recipe.Addition[i-1].Time); | |
457 | TFT_print(tmp, LASTX, y); | |
458 | } | |
459 | _fg = TFT_WHITE; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
460 | TFT_print((char *)" minuten", LASTX, y); |
0 | 461 | } else { |
462 | _fg = TFT_WHITE; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
463 | TFT_print((char *)"Geen hop toevoegingen.", 2, y); |
0 | 464 | } |
465 | y += 16; | |
466 | if (recipe.Whirlpool9) { | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
467 | ShowInteger(2, y, (char *)"Whirlpool 88..100 graden", (char *)" minuten", recipe.Whirlpool9); |
0 | 468 | y += 16; |
469 | } | |
470 | if (recipe.Whirlpool7) { | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
471 | ShowInteger(2, y, (char *)"Whirlpool 71..77 graden", (char *)" minuten", recipe.Whirlpool7); |
0 | 472 | y += 16; |
473 | } | |
474 | if (recipe.Whirlpool6) { | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
475 | ShowInteger(2, y, (char *)"Whirlpool 60..66 graden", (char *)" minuten", recipe.Whirlpool6); |
0 | 476 | y += 16; |
477 | } | |
478 | if (recipe.Whirlpool2) { | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
479 | ShowInteger(2, y, (char *)"Whirlpool koud", (char *)" minuten", recipe.Whirlpool2); |
0 | 480 | y += 16; |
481 | } | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
482 | Buttons_Add( 0, 210, 70, 30, (char *)"Stop" , 0); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
483 | Buttons_Add(250, 210, 70, 30, (char *)"Start" , 1); |
0 | 484 | Buttons[0].dark = true; |
485 | Buttons_Show(); | |
486 | loop = true; | |
487 | while (loop) { | |
488 | switch (Buttons_Scan()) { | |
489 | case 0: loop = false; | |
490 | Main_Screen = MAIN_AUTO_ABORT; | |
491 | break; | |
492 | ||
493 | case 1: loop = false; | |
42 | 494 | Main_Screen = MAIN_AUTO_INIT2; |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
495 | log_msg(TAG, "Brew `%s' on `%s'", recipe.Name, equipment.Name); |
0 | 496 | break; |
497 | ||
498 | default: break; | |
499 | } | |
500 | vTaskDelay(20 / portTICK_PERIOD_MS); | |
501 | } | |
42 | 502 | Buttons_Clear(); |
503 | break; | |
0 | 504 | |
42 | 505 | case MAIN_AUTO_INIT2: |
0 | 506 | _UseHLT = false; |
507 | _bg = TFT_BLACK; | |
508 | TFT_fillScreen(_bg); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
509 | TopMessage((char *)"Maisch water aanwezig?"); |
0 | 510 | Buttons_Clear(); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
511 | Buttons_Add( 40, 100, 80, 40, (char *)"Ja", 0); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
512 | Buttons_Add(200, 100, 80, 40, (char *)"Nee", 1); |
0 | 513 | Buttons_Show(); |
514 | SoundPlay(SOUND_Prompt); | |
515 | loop = true; | |
516 | while (loop) { | |
517 | switch (Buttons_Scan()) { | |
518 | case 0: loop = false; | |
519 | break; | |
520 | ||
521 | case 1: loop = false; | |
522 | Main_Screen = MAIN_AUTO_ABORT; | |
523 | break; | |
524 | ||
525 | default: break; | |
526 | } | |
527 | vTaskDelay(20 / portTICK_PERIOD_MS); | |
528 | } | |
529 | if (Main_Screen == MAIN_AUTO_ABORT) | |
530 | break; | |
531 | ||
532 | if ((equipment.SSR2 == SSR2_HLT_SHARE) || (equipment.SSR2 == SSR2_HLT_IND)) { | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
533 | TopMessage((char *)"Spoelwater aanwezig?"); |
0 | 534 | SoundPlay(SOUND_Prompt); |
535 | loop = true; | |
536 | while (loop) { | |
537 | switch (Buttons_Scan()) { | |
538 | case 0: loop = false; | |
539 | _UseHLT = true; | |
540 | break; | |
541 | ||
542 | case 1: loop = false; | |
543 | break; | |
544 | ||
545 | default: break; | |
546 | } | |
547 | vTaskDelay(20 / portTICK_PERIOD_MS); | |
548 | } | |
549 | runtime.UseHLT = _UseHLT; | |
550 | } else { | |
551 | runtime.UseHLT = _UseHLT = false; | |
552 | } | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
553 | log_msg(TAG, "Use HLT %s", (_UseHLT)?"true":"false"); |
0 | 554 | updateRuntime = true; |
555 | if (_UseHLT) { | |
556 | /* | |
557 | * Calculate HLT setpoint for pre-heat. Substract the | |
558 | * available Mash rest times, asume 0.5 degrees/minute | |
559 | * heat capacity during mash. | |
560 | */ | |
561 | int AvailableTime = 0; | |
562 | for (int i = 1; i < 6; i++) // Only normal Mash steps | |
563 | AvailableTime += recipe.MashStep[i].Resttime; | |
564 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
565 | driver_state->hlt_sp = recipe.SpargeTemp - ((AvailableTime / 2) + 2); | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
566 | log_msg(TAG, "HLT preheat set to %4.2f", driver_state->hlt_sp); |
0 | 567 | xSemaphoreGive(xSemaphoreDriver); |
568 | } | |
569 | } | |
570 | Buttons_Clear(); | |
571 | Main_Screen = MAIN_AUTO_DELAYSTART; | |
572 | break; | |
573 | ||
574 | case MAIN_AUTO_DELAYSTART: | |
575 | Main_Screen = MAIN_AUTO_HEATUP; | |
576 | break; | |
577 | ||
578 | case MAIN_AUTO_HEATUP: | |
579 | if (! runtime.UseHLT) { // Skip if HLT is off | |
580 | Main_Screen = MAIN_AUTO_MASH_IN; | |
581 | break; | |
582 | } | |
583 | ||
584 | MLT_info(71, 26, true); | |
585 | HLT_info(71,150, true, false); | |
586 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
587 | if (driver_state->hlt_pv >= driver_state->hlt_sp) { | |
588 | Main_Screen = MAIN_AUTO_MASH_IN; | |
589 | driver_state->hlt_sp = recipe.SpargeTemp; // Set final setpoint | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
590 | log_msg(TAG, "HLT preheat done"); |
0 | 591 | } |
592 | xSemaphoreGive(xSemaphoreDriver); | |
593 | } | |
594 | break; | |
595 | ||
596 | case MAIN_AUTO_MASH_IN: | |
597 | case MAIN_AUTO_MASH_1: | |
598 | case MAIN_AUTO_MASH_2: | |
599 | case MAIN_AUTO_MASH_3: | |
600 | case MAIN_AUTO_MASH_4: | |
601 | case MAIN_AUTO_MASH_5: | |
602 | case MAIN_AUTO_MASH_6: | |
603 | case MAIN_AUTO_MASH_OUT: | |
604 | temp_MLT = 0.0; | |
605 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
606 | temp_MLT = driver_state->mlt_pv; | |
607 | ||
608 | if (MashState == MASH_ADD || MashState == MASH_REMOVE) { | |
609 | driver_state->pump_run = 0; | |
610 | } else if (MashState != MASH_NONE) { | |
611 | if (Main_Screen == MAIN_AUTO_MASH_IN) { | |
612 | driver_state->pump_run = (equipment.PumpPreMash && ! pumpRest) ? 1 : 0; | |
613 | } else if (Main_Screen == MAIN_AUTO_MASH_OUT) { | |
614 | driver_state->pump_run = (equipment.PumpMashOut && ! pumpRest) ? 1 : 0; | |
615 | } else { | |
616 | driver_state->pump_run = (equipment.PumpOnMash && ! pumpRest) ? 1 : 0; | |
617 | } | |
618 | } | |
619 | xSemaphoreGive(xSemaphoreDriver); | |
620 | } | |
621 | if (MashState == MASH_NONE) { | |
622 | stageTemp = recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN].Temperature; | |
623 | stageTime = recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN].Resttime; | |
624 | TempReached = false; | |
625 | if (stageTime == 0) { | |
626 | ESP_LOGI(TAG, "Mash step %d skipped", Main_Screen - MAIN_AUTO_MASH_IN); | |
627 | Main_Screen++; | |
628 | break; | |
629 | } | |
630 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
631 | driver_state->mlt_sp = stageTemp; | |
632 | driver_state->mlt_mode = MLT_MODE_PID; | |
633 | xSemaphoreGive(xSemaphoreDriver); | |
634 | } | |
42 | 635 | MashState = Sub_Screen = MASH_WAITTEMP; |
56
756d1a63d129
Adjusted more strings for new compiler warnings. There should now be no buffer overflows in the app. Changed the date display on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
636 | snprintf(msg, 255, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
637 | ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
638 | log_msg(TAG, "Mash step %d type: %s time: %d sp: %4.2f sv: %4.3f", |
19 | 639 | Main_Screen - MAIN_AUTO_MASH_IN, mashTypes[recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN].Type], |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
640 | stageTime, stageTemp, temp_MLT); |
0 | 641 | |
642 | if (Main_Screen > MAIN_AUTO_MASH_IN) { | |
643 | // Do not annotate before the log is open. | |
644 | if (Main_Screen == MAIN_AUTO_MASH_OUT) { | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
645 | log_annotation(ANNOTATION_STAGE, (char *)"Uitmaischen"); |
0 | 646 | } else { |
647 | sprintf(logline, "Maisch: %d", Main_Screen - MAIN_AUTO_MASH_IN); | |
648 | log_annotation(ANNOTATION_STAGE, logline); | |
649 | } | |
650 | } | |
651 | ||
652 | if (strlen(recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN].Name)) { | |
653 | TopMessage(recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN].Name); | |
654 | } else { | |
655 | sprintf(temp_buf, "Maisch stap #%d", Main_Screen - MAIN_AUTO_MASH_IN); | |
656 | TopMessage(temp_buf); | |
657 | } | |
19 | 658 | if ((Main_Screen > MAIN_AUTO_MASH_IN) && (Main_Screen < MAIN_AUTO_MASH_OUT) && |
659 | (recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN].Type == MASHTYPE_INFUSION)) { | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
660 | Buttons_Add( 5,120, 60, 40, (char *)"Halt", 0); |
19 | 661 | Buttons[0].dark = true; |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
662 | Buttons_Add(255,120, 60, 40, (char *)"Ok", 1); |
19 | 663 | Buttons_Show(); |
664 | _fg = TFT_WHITE; | |
665 | _bg = TFT_BLACK; | |
666 | TFT_setFont(DEJAVU18_FONT, NULL); | |
667 | sprintf(temp_buf, "Infuse %.1f L/%.1f C", recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN].Infusion_amount, | |
668 | recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN].Infusion_temp); | |
669 | TFT_print(temp_buf, CENTER, 135); | |
670 | SoundPlay(SOUND_Prompt); | |
42 | 671 | MashState = Sub_Screen = MASH_INFUSE; |
56
756d1a63d129
Adjusted more strings for new compiler warnings. There should now be no buffer overflows in the app. Changed the date display on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
672 | snprintf(msg, 255, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"%s\"}", Main_Screen, Sub_Screen, temp_buf); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
673 | ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); |
19 | 674 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { |
675 | // No heating during the infusion. | |
676 | driver_state->mlt_sp = stageTemp; | |
677 | driver_state->mlt_mode = MLT_MODE_OFF; | |
678 | xSemaphoreGive(xSemaphoreDriver); | |
679 | } | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
680 | log_msg(TAG, "Mash infusion prompt"); |
19 | 681 | } else { |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
682 | Buttons_Add( 5, 30, 60, 40, (char *)"+sp", 0); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
683 | Buttons_Add(255, 30, 60, 40, (char *)"-sp", 1); |
19 | 684 | Buttons_Show(); |
685 | } | |
0 | 686 | |
687 | } else if (MashState == MASH_WAITTEMP) { | |
688 | pumpRest = false; | |
689 | if (temp_MLT < stageTemp) { | |
690 | Steady = 0; | |
691 | } | |
692 | if ((temp_MLT >= stageTemp) && (Steady > 10)) { | |
693 | SoundPlay(SOUND_TempReached); | |
694 | TempReached = true; | |
42 | 695 | MashState = Sub_Screen = MASH_REST; |
696 | snprintf(msg, 63, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
697 | ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); |
0 | 698 | if (Main_Screen == MAIN_AUTO_MASH_IN) { |
699 | TimerSet(0); | |
700 | } else { | |
701 | if (Resume && (runtime.StageTimeLeft < stageTime)) | |
702 | TimerSet(runtime.StageTimeLeft * 60); | |
703 | else | |
704 | TimerSet(stageTime * 60); | |
705 | } | |
706 | Resume = false; | |
707 | runtime.StageTimeLeft = TimeLeft / 60; | |
708 | updateRuntime = true; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
709 | log_msg(TAG, "Mash step %d temperature reached, rest time %d", Main_Screen - MAIN_AUTO_MASH_IN, TimeLeft / 60); |
0 | 710 | Buttons_Clear(); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
711 | Buttons_Add( 0, 120, 60, 40, (char *)"+1m", 0); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
712 | Buttons_Add(260, 120, 60, 40, (char *)"-1m", 1); |
0 | 713 | Buttons_Show(); |
714 | } | |
715 | switch (Buttons_Scan()) { | |
716 | case 0: if (stageTemp < MaxMash) { | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
717 | change_sp(true); |
0 | 718 | } |
719 | break; | |
720 | ||
721 | case 1: if (stageTemp > MinMash) { | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
722 | change_sp(false); |
0 | 723 | } |
724 | break; | |
725 | ||
726 | default: | |
727 | break; | |
728 | } | |
729 | if (NewMinute) | |
730 | updateRuntime = true; | |
731 | ||
732 | } else if (MashState == MASH_REST) { | |
733 | /* | |
734 | * Mash step rest time and pump control | |
735 | */ | |
736 | if (((Main_Screen == MAIN_AUTO_MASH_OUT) && equipment.PumpMashOut) || | |
737 | ((Main_Screen != MAIN_AUTO_MASH_OUT) && equipment.PumpOnMash)) { | |
738 | float DeltaTemp = equipment.PumpRest * stageTemp / 120; // Maximum temperature drop before heating again. | |
739 | if (pumpTime >= (equipment.PumpCycle + equipment.PumpRest) || ((stageTemp - temp_MLT) > DeltaTemp)) { | |
740 | pumpTime = 0; | |
741 | } | |
742 | if (pumpTime >= equipment.PumpCycle) { | |
743 | if (! pumpRest) { | |
744 | pumpRest = true; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
745 | log_msg(TAG, "Pump rest"); |
0 | 746 | } |
747 | } else { | |
748 | if (pumpRest) { | |
749 | pumpRest = false; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
750 | log_msg(TAG, "Pump start"); |
0 | 751 | } |
752 | } | |
753 | } | |
754 | if (TimeLeft) { | |
755 | switch (Buttons_Scan()) { | |
756 | case 0: TimeLeft += 60; | |
757 | runtime.StageTimeLeft = TimeLeft / 60; | |
758 | updateRuntime = true; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
759 | log_msg(TAG, "Changed resttime to %d", runtime.StageTimeLeft); |
0 | 760 | break; |
761 | ||
762 | case 1: if (TimeLeft < 60) | |
763 | TimeLeft = 0; | |
764 | else | |
765 | TimeLeft -= 60; | |
766 | runtime.StageTimeLeft = TimeLeft / 60; | |
767 | updateRuntime = true; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
768 | log_msg(TAG, "Changed resttime to %d", runtime.StageTimeLeft); |
0 | 769 | break; |
770 | ||
771 | default: break; | |
772 | } | |
773 | } | |
774 | ||
775 | if (TimeLeft == 0) { | |
776 | runtime.StageTimeLeft = TimeLeft / 60; | |
777 | updateRuntime = true; | |
778 | if ((Main_Screen == MAIN_AUTO_MASH_IN) && config.AskAdd) { | |
779 | /* | |
780 | * Add Mash prompt. | |
781 | */ | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
782 | log_annotation(ANNOTATION_EVENT, (char *)"Mout storten"); |
0 | 783 | Buttons_Clear(); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
784 | Buttons_Add( 5,120, 60, 40, (char *)"Halt", 0); |
0 | 785 | Buttons[0].dark = true; |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
786 | Buttons_Add(255,120, 60, 40, (char *)"Ok", 1); |
0 | 787 | Buttons_Show(); |
788 | _fg = TFT_WHITE; | |
789 | _bg = TFT_BLACK; | |
790 | TFT_setFont(DEJAVU24_FONT, NULL); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
791 | TFT_print((char *)"Mout storten?", CENTER, 135); |
0 | 792 | SoundPlay(SOUND_Prompt); |
42 | 793 | MashState = Sub_Screen = MASH_ADD; |
794 | snprintf(msg, 63, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"Mout storten?\"}", Main_Screen, Sub_Screen); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
795 | ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
796 | log_msg(TAG, "Mash add prompt"); |
0 | 797 | break; |
798 | } | |
799 | if (((Main_Screen - MAIN_AUTO_MASH_IN) == LastMashStep) && config.AskIodine) { | |
800 | /* | |
801 | * Iodone test prompt. | |
802 | */ | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
803 | log_annotation(ANNOTATION_EVENT, (char *)"Jodium test"); |
0 | 804 | TFT_fillRect(0, 120, 320, 50, TFT_BLACK); |
805 | Buttons_Clear(); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
806 | Buttons_Add( 5,120, 60, 40, (char *)"Halt", 0); |
0 | 807 | Buttons[0].dark = true; |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
808 | Buttons_Add(255,120, 60, 40, (char *)"Ok", 1); |
0 | 809 | Buttons_Show(); |
810 | _fg = TFT_WHITE; | |
811 | _bg = TFT_BLACK; | |
812 | TFT_setFont(DEJAVU24_FONT, NULL); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
813 | TFT_print((char *)"Jodium test?", CENTER, 127); |
0 | 814 | SoundPlay(SOUND_Prompt); |
815 | beeped = false; | |
816 | TimerSet(config.IodineTime * 60); | |
42 | 817 | MashState = Sub_Screen = MASH_IODINE; |
818 | snprintf(msg, 63, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"Jodium test?\"}", Main_Screen, Sub_Screen); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
819 | ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
820 | log_msg(TAG, "Mash iodine test prompt"); |
0 | 821 | break; |
822 | } | |
823 | if ((Main_Screen == MAIN_AUTO_MASH_OUT) && config.AskRemove) { | |
824 | /* | |
825 | * Mash remove prompt. | |
826 | */ | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
827 | log_annotation(ANNOTATION_EVENT, (char *)"Mout verwijderen"); |
0 | 828 | TFT_fillRect(0, 120, 320, 50, TFT_BLACK); |
829 | Buttons_Clear(); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
830 | Buttons_Add( 5,120, 60, 40, (char *)"Halt", 0); |
0 | 831 | Buttons[0].dark = true; |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
832 | Buttons_Add(255,120, 60, 40, (char *)"Ok", 1); |
0 | 833 | Buttons_Show(); |
834 | _fg = TFT_WHITE; | |
835 | _bg = TFT_BLACK; | |
836 | TFT_setFont(DEJAVU18_FONT, NULL); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
837 | TFT_print((char *)"Mout verwijderen?", CENTER, 135); |
0 | 838 | SoundPlay(SOUND_Prompt); |
42 | 839 | MashState = Sub_Screen = MASH_REMOVE; |
840 | snprintf(msg, 63, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"Mout verwijderen?\"}", Main_Screen, Sub_Screen); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
841 | ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
842 | log_msg(TAG, "Mash remove prompt"); |
0 | 843 | break; |
844 | } | |
845 | if (Main_Screen != MAIN_AUTO_ABORT) | |
846 | Main_Screen++; | |
847 | TempReached = false; | |
848 | } else { | |
849 | TimerShow(TimeLeft, 65, 122); | |
850 | if (NewMinute) { | |
851 | runtime.StageTimeLeft = TimeLeft / 60; | |
852 | updateRuntime = true; | |
853 | } | |
854 | } | |
855 | } else if (MashState == MASH_ADD) { | |
856 | switch (Buttons_Scan()) { | |
857 | case 0: Main_Screen = MAIN_AUTO_ABORT; | |
858 | break; | |
859 | case 1: Main_Screen++; | |
860 | break; | |
861 | default: break; | |
862 | } | |
863 | } else if (MashState == MASH_IODINE) { | |
864 | if (TimeSpent % 45 == 0) { | |
865 | if (! beeped) { | |
866 | SoundPlay(SOUND_Warn); | |
867 | beeped = true; | |
868 | } | |
869 | } else { | |
870 | beeped = false; | |
871 | } | |
872 | switch (Buttons_Scan()) { | |
873 | case 0: Main_Screen = MAIN_AUTO_ABORT; | |
874 | break; | |
875 | case 1: Main_Screen++; | |
876 | break; | |
877 | default: break; | |
878 | } | |
879 | if (TimeLeft == 0) { | |
880 | Main_Screen++; | |
881 | } | |
882 | } else if (MashState == MASH_REMOVE) { | |
883 | switch (Buttons_Scan()) { | |
884 | case 0: Main_Screen = MAIN_AUTO_ABORT; | |
885 | break; | |
886 | case 1: Main_Screen++; | |
887 | break; | |
888 | default: break; | |
889 | } | |
19 | 890 | } else if (MashState == MASH_INFUSE) { |
891 | switch (Buttons_Scan()) { | |
892 | case 0: Main_Screen = MAIN_AUTO_ABORT; | |
893 | break; | |
42 | 894 | case 1: MashState = Sub_Screen = MASH_WAITTEMP; |
895 | snprintf(msg, 63, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
896 | ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); |
19 | 897 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { |
898 | // Start PID again. | |
899 | driver_state->mlt_sp = stageTemp; | |
900 | driver_state->mlt_mode = MLT_MODE_PID; | |
901 | xSemaphoreGive(xSemaphoreDriver); | |
902 | } | |
903 | Buttons_Clear(); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
904 | Buttons_Add( 5, 30, 60, 40, (char *)"+sp", 0); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
905 | Buttons_Add(255, 30, 60, 40, (char *)"-sp", 1); |
19 | 906 | Buttons_Show(); |
907 | TFT_fillRect(65, 120, 190, 40, TFT_BLACK); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
908 | log_annotation(ANNOTATION_EVENT, (char *)"Eind infusie"); |
19 | 909 | break; |
910 | default: break; | |
911 | } | |
0 | 912 | } /* MashState */ |
913 | MLT_info(71, 26, true); | |
914 | if (_UseHLT) { | |
915 | HLT_info(71, 170, true, true); | |
916 | } | |
917 | break; | |
918 | ||
919 | case MAIN_AUTO_TOBOIL: | |
920 | Output = 255; | |
921 | /* | |
922 | * Go to the boil temperature and wait until it is steady. | |
923 | */ | |
924 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
925 | if (driver_state->mlt_pv < stageTemp) { | |
926 | Steady = 0; | |
927 | } else { | |
928 | if (Steady > 10) { | |
929 | Main_Screen = MAIN_AUTO_BOILING; | |
930 | TempReached = true; | |
931 | } | |
932 | } | |
933 | driver_state->pump_run = (equipment.PumpOnBoil && (driver_state->mlt_pv < equipment.PumpMaxTemp)) ? 1 : 0; | |
934 | xSemaphoreGive(xSemaphoreDriver); | |
935 | } | |
936 | ||
937 | MLT_info(71, 26, true); | |
938 | switch (Buttons_Scan()) { | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
939 | case 0: if (stageTemp < 105) { |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
940 | change_sp(true); |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
941 | } |
0 | 942 | break; |
943 | ||
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
944 | case 1: if (stageTemp > 80) { |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
945 | change_sp(false); |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
946 | } |
0 | 947 | break; |
948 | ||
949 | default: break; | |
950 | } | |
951 | if (Resume) | |
952 | Resume = false; | |
953 | break; | |
954 | ||
955 | case MAIN_AUTO_BOILING: | |
956 | if (Resume) | |
957 | Resume = false; | |
958 | if (NewMinute) { | |
959 | if ((runtime.HopAddition < recipe.Additions) && (TimeLeft <= ((recipe.Addition[runtime.HopAddition].Time * 60) + 60))) { | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
960 | log_msg(TAG, "Hop addition %d at %d minutes", runtime.HopAddition + 1, recipe.Addition[runtime.HopAddition].Time); |
0 | 961 | TopMessage(recipe.Addition[runtime.HopAddition].Name); |
26
373a33699605
Graph title includes beer code. Hop additions now only display the additions themselfes.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
962 | log_annotation(ANNOTATION_EVENT, recipe.Addition[runtime.HopAddition].Name); |
0 | 963 | SoundPlay(SOUND_AddHop); |
964 | runtime.HopAddition++; | |
965 | } else { | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
966 | TopMessage((char *)"Koken"); |
0 | 967 | } |
968 | runtime.StageTimeLeft = TimeLeft / 60; | |
969 | updateRuntime = true; | |
970 | } | |
971 | if (TimeLeft < 60) { | |
972 | if (Output) { | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
973 | log_annotation(ANNOTATION_STAGE, (char *)"Vlamuit"); |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
974 | log_msg(TAG, "Boil flame off"); |
0 | 975 | } |
976 | // Flameout | |
977 | Output = 0; | |
978 | } else if (driver_state->mlt_pv >= stageTemp) { | |
979 | Output = (int)((BoilPower * 255.0) / 100.0); | |
980 | if (Buttons[4].x == -1) { | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
981 | Buttons_Add( 3,110, 60, 40, (char *)"+%", 4); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
982 | Buttons_Add(257,110, 60, 40, (char *)"-%", 5); |
0 | 983 | Buttons_Show(); |
984 | } | |
985 | } else { | |
986 | Output = 255; | |
987 | if (Buttons[4].x != -1) { | |
988 | Buttons[4].x = Buttons[5].x = -1; | |
989 | Buttons_Show(); | |
990 | TFT_fillRect( 3,110, 60, 40, TFT_BLACK); | |
991 | TFT_fillRect(257,110, 60, 40, TFT_BLACK); | |
992 | } | |
993 | } | |
994 | ||
995 | MLT_info(71, 26, true); | |
996 | TimerShow(TimeLeft, 65, 190); | |
997 | ||
998 | switch (Buttons_Scan()) { | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
999 | case 0: if (stageTemp < 105) { |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
1000 | change_sp(true); |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
1001 | } |
0 | 1002 | break; |
1003 | ||
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
1004 | case 1: if (stageTemp > 80) { |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
1005 | change_sp(false); |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
1006 | } |
0 | 1007 | break; |
1008 | ||
1009 | case 2: TimeLeft += 60; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
1010 | log_msg(TAG, "Increase boiltime to %d minutes", TimeLeft / 60); |
0 | 1011 | break; |
1012 | ||
1013 | case 3: if (TimeLeft > 60) | |
1014 | TimeLeft -= 60; | |
1015 | else | |
1016 | TimeLeft = 0; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
1017 | log_msg(TAG, "Decrease boiltime to %d minutes", TimeLeft / 60); |
0 | 1018 | break; |
1019 | ||
1020 | case 4: if (BoilPower < 100) | |
1021 | BoilPower++; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
1022 | log_msg(TAG, "Increase boilpower to %d%%", BoilPower); |
0 | 1023 | break; |
1024 | ||
1025 | case 5: if (BoilPower > 0) | |
1026 | BoilPower--; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
1027 | log_msg(TAG, "Decrease boilpower to %d%%", BoilPower); |
0 | 1028 | break; |
1029 | ||
1030 | default: break; | |
1031 | } | |
1032 | ||
1033 | if (TimeLeft == 0) { | |
1034 | Main_Screen = MAIN_AUTO_WHIRLPOOL9; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
1035 | log_msg(TAG, "Boil is ready"); |
0 | 1036 | } |
1037 | break; | |
1038 | ||
1039 | case MAIN_AUTO_COOLING_H: | |
1040 | case MAIN_AUTO_COOLING_M: | |
1041 | case MAIN_AUTO_COOLING_C: | |
1042 | if (_Prompt) { | |
1043 | /* | |
1044 | * Prompt mode | |
1045 | */ | |
1046 | switch (Buttons_Scan()) { | |
1047 | case 0: _Prompt = false; | |
1048 | Buttons_Clear(); | |
1049 | break; | |
1050 | case 1: Main_Screen = MAIN_AUTO_DONE; | |
1051 | Buttons_Clear(); | |
1052 | return true; //goto startover; | |
1053 | break; | |
1054 | default: | |
1055 | break; | |
1056 | } | |
1057 | ||
1058 | if (! _Prompt) { | |
1059 | /* | |
1060 | * Starting cooling, setup the screen. | |
1061 | */ | |
1062 | Buttons_Clear(); | |
1063 | TFT_fillScreen(_bg); | |
42 | 1064 | Sub_Screen = 1; |
0 | 1065 | if (Main_Screen == MAIN_AUTO_COOLING_H) { |
1066 | stageTemp = 77.0; | |
1067 | } else if (Main_Screen == MAIN_AUTO_COOLING_M) { | |
1068 | stageTemp = 66.0; | |
1069 | } else { | |
1070 | stageTemp = recipe.CoolTemp; | |
1071 | } | |
42 | 1072 | snprintf(msg, 63, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1073 | ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); |
0 | 1074 | CoolBeep = false; |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
1075 | log_msg(TAG, "Start cooling from %6.2f to %4.1f", ds18b20_state->mlt_temperature, stageTemp); |
0 | 1076 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { |
1077 | driver_state->mlt_mode = MLT_MODE_OFF; | |
1078 | driver_state->mlt_sp = stageTemp; | |
1079 | xSemaphoreGive(xSemaphoreDriver); | |
1080 | } | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1081 | log_annotation(ANNOTATION_STAGE, (char *)"Koelen"); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1082 | TopMessage((char *)"Koelen"); |
0 | 1083 | MLT_info(71, 26, false); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1084 | Buttons_Add( 5, 200, 60, 40, (char *)"Stop", 0); |
0 | 1085 | Buttons[0].dark = true; |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1086 | Buttons_Add( 5, 26, 60, 40, (char *)"+1", 1); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1087 | Buttons_Add(255, 26, 60, 40, (char *)"-1", 2); |
0 | 1088 | /* |
1089 | * The next key is not a mistake, but we need a key entry which | |
1090 | * will later become the pump key. The keyscan routine will find | |
1091 | * the original key if pressed. | |
1092 | */ | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1093 | Buttons_Add(255, 26, 60, 40, (char *)"-1", 3); |
0 | 1094 | Buttons_Show(); |
1095 | } | |
1096 | } else { | |
1097 | /* | |
1098 | * Not in prompt mode. | |
1099 | */ | |
1100 | #ifdef CONFIG_TEMP_SENSORS_SIMULATOR | |
1101 | if (Fake_MLT > 12.0) { | |
1102 | if (driver_state->pump_run) | |
1103 | Fake_MLT -= 0.00025 * (Fake_MLT - 12.0); | |
1104 | else | |
1105 | Fake_MLT -= 0.00015 * (Fake_MLT - 12.0); | |
1106 | } | |
1107 | if (xSemaphoreTake(xSemaphoreDS18B20, 10) == pdTRUE) { | |
1108 | ds18b20_state->mlt_temperature = ((int)(Fake_MLT * 16)) / 16.0; | |
1109 | xSemaphoreGive(xSemaphoreDS18B20); | |
1110 | } | |
1111 | #endif | |
1112 | MLT_info(71, 26, true); | |
1113 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
1114 | /* | |
1115 | * If the pump safe temperature is reached, add the control button. | |
1116 | * Redefine key number 3 if it is at the position of key 2. | |
1117 | */ | |
1118 | if ((driver_state->mlt_pv < equipment.PumpMaxTemp) && (Buttons[3].x == Buttons[2].x) &&(Buttons[3].y == Buttons[2].y)) { | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1119 | Buttons_Add(255, 200, 60, 40, (char *)"Pomp", 3); |
0 | 1120 | Buttons_Show(); |
1121 | } | |
1122 | xSemaphoreGive(xSemaphoreDriver); | |
1123 | } | |
1124 | switch (Buttons_Scan()) { | |
1125 | case 1: if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
1126 | if (Main_Screen == MAIN_AUTO_COOLING_H) { | |
1127 | if (driver_state->mlt_sp < 77.0) | |
1128 | driver_state->mlt_sp += 1.0; | |
1129 | } else if (Main_Screen == MAIN_AUTO_COOLING_M) { | |
1130 | if (driver_state->mlt_sp < 66.0) | |
1131 | driver_state->mlt_sp += 1.0; | |
1132 | } else if (Main_Screen == MAIN_AUTO_COOLING_C) { | |
1133 | if (driver_state->mlt_sp < 30.0) | |
1134 | driver_state->mlt_sp += 1.0; | |
1135 | } | |
1136 | xSemaphoreGive(xSemaphoreDriver); | |
1137 | } | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
1138 | log_msg(TAG, "Increase sp to %.2f", driver_state->mlt_sp); |
0 | 1139 | break; |
1140 | ||
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1141 | case 0: Buttons_Add( 60, 150, 90, 40, (char *)"Stoppen", 4); |
0 | 1142 | Buttons[4].dark = true; |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1143 | Buttons_Add(170, 150, 90, 40, (char *)"Sorry", 5); |
0 | 1144 | Buttons_Show(); |
1145 | break; | |
1146 | ||
1147 | case 2: if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
1148 | if (Main_Screen == MAIN_AUTO_COOLING_H) { | |
1149 | if (driver_state->mlt_sp > 71.0) | |
1150 | driver_state->mlt_sp -= 1.0; | |
1151 | } else if (Main_Screen == MAIN_AUTO_COOLING_M) { | |
1152 | if (driver_state->mlt_sp > 60.0) | |
1153 | driver_state->mlt_sp -= 1.0; | |
1154 | } else if (Main_Screen == MAIN_AUTO_COOLING_C) { | |
1155 | if (driver_state->mlt_sp > 10.0) | |
1156 | driver_state->mlt_sp -= 1.0; | |
1157 | } | |
1158 | xSemaphoreGive(xSemaphoreDriver); | |
1159 | } | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
1160 | log_msg(TAG, "Decrease sp to %.2f", driver_state->mlt_sp); |
0 | 1161 | break; |
1162 | ||
1163 | case 3: if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
1164 | if (driver_state->mlt_pv < equipment.PumpMaxTemp) { | |
1165 | if (driver_state->pump_run) | |
1166 | driver_state->pump_run = 0; | |
1167 | else | |
1168 | driver_state->pump_run = 1; | |
1169 | } else { | |
1170 | driver_state->pump_run = 0; | |
1171 | } | |
1172 | runtime.PumpCooling = driver_state->pump_run; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
1173 | log_msg(TAG, "Pump turned %s", (driver_state->pump_run)?"on":"off"); |
0 | 1174 | updateRuntime = true; |
1175 | xSemaphoreGive(xSemaphoreDriver); | |
1176 | } | |
1177 | break; | |
1178 | ||
1179 | case 4: Main_Screen++; | |
1180 | break; | |
1181 | ||
1182 | case 5: Buttons[4].x = Buttons[5].x = -1; | |
1183 | TFT_fillRect(60, 150, 200, 40, TFT_BLACK); | |
1184 | break; | |
1185 | ||
1186 | default: | |
1187 | break; | |
1188 | } | |
1189 | ||
1190 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
1191 | if (! CoolBeep && (driver_state->mlt_pv < (driver_state->mlt_sp + 2.0))) { | |
1192 | SoundPlay(SOUND_Warn); | |
1193 | CoolBeep = true; | |
1194 | } | |
1195 | if (driver_state->mlt_pv <= driver_state->mlt_sp) { | |
1196 | SoundPlay(SOUND_TempReached); | |
1197 | Main_Screen++; | |
42 | 1198 | Sub_Screen = 0; |
0 | 1199 | } |
1200 | xSemaphoreGive(xSemaphoreDriver); | |
1201 | } | |
1202 | } | |
1203 | break; | |
1204 | ||
1205 | case MAIN_AUTO_WHIRLPOOL9: | |
1206 | case MAIN_AUTO_WHIRLPOOL7: | |
1207 | case MAIN_AUTO_WHIRLPOOL6: | |
1208 | case MAIN_AUTO_WHIRLPOOL2: | |
1209 | if (_Prompt) { | |
1210 | ||
1211 | switch (Buttons_Scan()) { | |
1212 | case 0: _Prompt = false; | |
1213 | break; | |
1214 | case 1: if (Main_Screen == MAIN_AUTO_WHIRLPOOL2) { | |
1215 | Main_Screen = MAIN_AUTO_DONE; | |
1216 | } else { | |
1217 | Main_Screen++; | |
1218 | } | |
1219 | Buttons_Clear(); | |
1220 | return true; //goto startover; | |
1221 | break; | |
1222 | default: | |
1223 | break; | |
1224 | } | |
1225 | ||
1226 | if (! _Prompt) { | |
1227 | /* | |
1228 | * Prepare the screen for the actual whirpool. | |
1229 | */ | |
1230 | Buttons_Clear(); | |
1231 | TFT_fillScreen(_bg); | |
42 | 1232 | Sub_Screen = 1; |
1233 | snprintf(msg, 63, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1234 | ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); |
0 | 1235 | if (Main_Screen == MAIN_AUTO_WHIRLPOOL9) { |
1236 | TimeWhirlPool = recipe.Whirlpool9; | |
1237 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
1238 | driver_state->mlt_sp = 93.0; | |
1239 | driver_state->mlt_mode = MLT_MODE_PID; | |
1240 | xSemaphoreGive(xSemaphoreDriver); | |
1241 | } | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1242 | TopMessage((char *)"Whirlpool 88..100"); |
0 | 1243 | } else if (Main_Screen == MAIN_AUTO_WHIRLPOOL7) { |
1244 | TimeWhirlPool = recipe.Whirlpool7; | |
1245 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
1246 | driver_state->mlt_sp = 74.0; | |
1247 | driver_state->mlt_mode = MLT_MODE_PID; | |
1248 | xSemaphoreGive(xSemaphoreDriver); | |
1249 | } | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1250 | TopMessage((char *)"Whirlpool 71..77"); |
0 | 1251 | } else if (Main_Screen == MAIN_AUTO_WHIRLPOOL6) { |
1252 | TimeWhirlPool = recipe.Whirlpool6; | |
1253 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
1254 | driver_state->mlt_sp = 63.0; | |
1255 | driver_state->mlt_mode = MLT_MODE_PID; | |
1256 | xSemaphoreGive(xSemaphoreDriver); | |
1257 | } | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1258 | TopMessage((char *)"Whirlpool 60..66"); |
0 | 1259 | } else { |
1260 | TimeWhirlPool = recipe.Whirlpool2; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1261 | TopMessage((char *)"Koude whirlpool"); |
0 | 1262 | } |
1263 | if (Resume) { | |
1264 | TimeWhirlPool = runtime.StageTimeLeft; | |
1265 | } | |
1266 | ||
1267 | /* | |
1268 | * If the pump is allowed at the current temperature, turn it on. | |
1269 | */ | |
1270 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
1271 | driver_state->pump_run = (driver_state->mlt_pv < equipment.PumpMaxTemp) ? 1 : 0; | |
1272 | xSemaphoreGive(xSemaphoreDriver); | |
1273 | } | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1274 | log_annotation(ANNOTATION_STAGE, (char *)"Whirlpool"); |
0 | 1275 | |
1276 | TimerSet(TimeWhirlPool * 60); | |
1277 | runtime.StageTimeLeft = TimeWhirlPool; | |
1278 | updateRuntime = true; | |
1279 | MLT_info(71, 26, false); | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
1280 | log_msg(TAG, "Whirlpool %d minutes, sp %4.1f", TimeWhirlPool, driver_state->mlt_sp); |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1281 | Buttons_Add(255, 120, 60, 40, (char *)"+1m", 0); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1282 | Buttons_Add( 5, 120, 60, 40, (char *)"-1m", 1); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
43
diff
changeset
|
1283 | Buttons_Add(255, 200, 60, 40, (char *)"Pomp", 2); |
0 | 1284 | Buttons_Show(); |
1285 | } | |
1286 | } else { | |
1287 | /* | |
1288 | * Not running in prompt mode, do the whirlpool. | |
1289 | */ | |
1290 | if (TimeLeft == 120) { | |
1291 | /* | |
1292 | * Drop the temperature when whirlpool is almost ready. | |
1293 | * If we are lucky the heater element will cool down so | |
1294 | * the next cooling stage will not wast too much energy. | |
1295 | */ | |
1296 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
1297 | if (Main_Screen == MAIN_AUTO_WHIRLPOOL9) | |
1298 | driver_state->mlt_sp = 88.0; | |
1299 | if (Main_Screen == MAIN_AUTO_WHIRLPOOL7) | |
1300 | driver_state->mlt_sp = 71.0; | |
1301 | if (Main_Screen == MAIN_AUTO_WHIRLPOOL6) | |
1302 | driver_state->mlt_sp = 60.0; | |
1303 | xSemaphoreGive(xSemaphoreDriver); | |
1304 | } | |
1305 | } | |
1306 | ||
1307 | MLT_info(71, 26, true); | |
1308 | TimerShow(TimeLeft, 65, 122); | |
1309 | switch (Buttons_Scan()) { | |
1310 | case 0: TimeLeft += 60; | |
1311 | break; | |
1312 | case 1: if (TimeLeft > 60) | |
1313 | TimeLeft -= 60; | |
1314 | else | |
1315 | TimeLeft = 0; | |
1316 | break; | |
1317 | case 2: if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
1318 | if (driver_state->mlt_pv < equipment.PumpMaxTemp) { | |
1319 | if (driver_state->pump_run) | |
1320 | driver_state->pump_run = 0; | |
1321 | else | |
1322 | driver_state->pump_run = 1; | |
1323 | } else { | |
1324 | driver_state->pump_run = 0; | |
1325 | } | |
1326 | xSemaphoreGive(xSemaphoreDriver); | |
1327 | } | |
1328 | } | |
1329 | ||
1330 | if (NewMinute) { | |
1331 | runtime.StageTimeLeft = TimeLeft / 60; | |
1332 | updateRuntime = true; | |
1333 | } | |
1334 | ||
1335 | if ((TimeLeft == 0)) { | |
1336 | if (Main_Screen == MAIN_AUTO_WHIRLPOOL9) { | |
1337 | Main_Screen = MAIN_AUTO_COOLING_H; | |
1338 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
1339 | driver_state->pump_run = runtime.PumpCooling; | |
1340 | xSemaphoreGive(xSemaphoreDriver); | |
1341 | } | |
1342 | } else if (Main_Screen == MAIN_AUTO_WHIRLPOOL7) { | |
1343 | Main_Screen = MAIN_AUTO_COOLING_M; | |
1344 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
1345 | driver_state->pump_run = runtime.PumpCooling; | |
1346 | xSemaphoreGive(xSemaphoreDriver); | |
1347 | } | |
1348 | } else if (Main_Screen == MAIN_AUTO_WHIRLPOOL6) { | |
1349 | Main_Screen = MAIN_AUTO_COOLING_C; | |
1350 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
1351 | driver_state->pump_run = runtime.PumpCooling; | |
1352 | xSemaphoreGive(xSemaphoreDriver); | |
1353 | } | |
1354 | } else if (Main_Screen == MAIN_AUTO_WHIRLPOOL2) { | |
1355 | Main_Screen = MAIN_AUTO_DONE; | |
1356 | } | |
1357 | } | |
1358 | } | |
1359 | break; | |
1360 | ||
1361 | case MAIN_AUTO_DONE: | |
1362 | case MAIN_AUTO_ABORT: | |
1363 | if (Buttons_Scan() == 0) | |
1364 | Main_Screen = MAIN_MODE_FREE; | |
1365 | break; | |
1366 | ||
1367 | default: | |
1368 | break; | |
1369 | } | |
1370 | ||
1371 | return false; | |
1372 | } | |
1373 | ||
1374 |