Sun, 24 Nov 2019 16:44:00 +0100
Version 0.3.7. The WiFi task uses the new event handlers. Cooling temperature top is now 45 instead of 30 degreees for pitching Kveik. One extra cosmetic message during OTA update.
0 | 1 | /** |
2 | * @file manual.c | |
3 | * @brief Manual control functions. | |
4 | */ | |
5 | ||
6 | #include "config.h" | |
7 | ||
8 | bool _ManualHLT = false; ///< Use Hot Liquer Tank | |
9 | bool _ManualMLT = false; ///< Use Mash/Boil kettle | |
10 | bool loop; | |
11 | ||
12 | extern sButton Buttons[MAXBUTTONS]; | |
13 | extern int Main_Screen; | |
14 | extern DS18B20_State *ds18b20_state; | |
15 | extern DRIVER_State *driver_state; | |
16 | extern SemaphoreHandle_t xSemaphoreDS18B20; | |
17 | extern SemaphoreHandle_t xSemaphoreDriver; | |
18 | ||
19 | #ifdef CONFIG_TEMP_SENSORS_SIMULATOR | |
20 | extern float Fake_MLT; | |
21 | extern float Fake_HLT; | |
22 | #endif | |
23 | ||
24 | static const char *TAG = "manual"; | |
25 | ||
26 | ||
27 | /* | |
28 | * Manual init function that only runs once a new screen | |
29 | * is entered. | |
30 | */ | |
31 | bool Manual_Init(void) | |
32 | { | |
33 | switch (Main_Screen) { | |
34 | case MAIN_MANUAL_INIT: | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
35 | log_msg(TAG, "Start manual mode"); |
0 | 36 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { |
37 | driver_state->enable = true; | |
38 | xSemaphoreGive(xSemaphoreDriver); | |
39 | } | |
40 | break; | |
41 | ||
42 | case MAIN_MANUAL_MAIN: | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
43 | TopMessage((char *)"Handbediening"); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
44 | Buttons_Add( 5, 200, 60, 40, (char *)"Stop", 0); |
0 | 45 | Buttons[0].dark = true; |
46 | uint8_t i = 1; | |
47 | if (_ManualMLT) { | |
48 | 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:
0
diff
changeset
|
49 | Buttons_Add( 5, 26, 60, 40, (char *)"+sp" , i++); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
50 | Buttons_Add(255, 26, 60, 40, (char *)"-sp" , i++); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
51 | Buttons_Add( 5, 76, 60, 40, (char *)"Pomp" , i++); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
52 | Buttons_Add(255, 76, 60, 40, (char *)"Aan" , i++); |
0 | 53 | } |
54 | if (_ManualHLT) { | |
55 | HLT_info(71,150, false, false); | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
56 | Buttons_Add( 5, 150, 60, 40, (char *)"+sp" , i++); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
57 | Buttons_Add(255, 150, 60, 40, (char *)"-sp" , i++); |
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
58 | Buttons_Add(255, 200, 60, 40, (char *)"Aan" , i); |
0 | 59 | } |
60 | Buttons_Show(); | |
61 | break; | |
62 | ||
63 | default: | |
64 | break; | |
65 | } | |
66 | ||
67 | return false; | |
68 | } | |
69 | ||
70 | ||
71 | ||
72 | /* | |
73 | * Manual loop screens, non-blocking. | |
74 | */ | |
75 | bool Manual_Loop(void) | |
76 | { | |
77 | switch (Main_Screen) { | |
78 | case MAIN_MANUAL_INIT: | |
79 | _ManualHLT = _ManualMLT = false; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
80 | 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:
0
diff
changeset
|
81 | Buttons_Add(200, 100, 80, 40, (char *)"Nee", 1); |
0 | 82 | Buttons_Show(); |
83 | ||
84 | 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:
0
diff
changeset
|
85 | TopMessage((char *)"Spoelwater ketel?"); |
0 | 86 | SoundPlay(SOUND_Prompt); |
87 | loop = true; | |
88 | while (loop) { | |
89 | switch (Buttons_Scan()) { | |
90 | case 0: loop = false; | |
91 | _ManualHLT = true; | |
92 | break; | |
93 | ||
94 | case 1: loop = false; | |
95 | _ManualHLT = false; | |
96 | break; | |
97 | ||
98 | default: break; | |
99 | } | |
100 | vTaskDelay(20 / portTICK_PERIOD_MS); | |
101 | } | |
102 | } | |
103 | ||
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
104 | TopMessage((char *)"Maisch/Kook ketel?"); |
0 | 105 | SoundPlay(SOUND_Prompt); |
106 | loop = true; | |
107 | while (loop) { | |
108 | switch (Buttons_Scan()) { | |
109 | case 0: loop = false; | |
110 | _ManualMLT = true; | |
111 | break; | |
112 | ||
113 | case 1: loop = false; | |
114 | _ManualMLT = false; | |
115 | break; | |
116 | ||
117 | default: break; | |
118 | } | |
119 | vTaskDelay(20 / portTICK_PERIOD_MS); | |
120 | } | |
121 | Buttons_Clear(); | |
122 | ||
123 | if (! _ManualHLT && ! _ManualMLT) { | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
124 | log_msg(TAG, "End manual mode"); |
0 | 125 | Main_Screen = MAIN_MODE_FREE; |
126 | break; | |
127 | } | |
128 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
129 | /* Set them all, even if not in use now. */ | |
130 | driver_state->hlt_sp = runtime.ManualHLT; | |
131 | driver_state->mlt_sp = runtime.ManualMLT; | |
132 | xSemaphoreGive(xSemaphoreDriver); | |
133 | } | |
134 | if (_ManualHLT) { | |
135 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
136 | driver_state->hlt_mode = HLT_MODE_OFF; | |
137 | xSemaphoreGive(xSemaphoreDriver); | |
138 | } | |
139 | } | |
140 | if (_ManualMLT) { | |
141 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
142 | driver_state->mlt_mode = MLT_MODE_OFF; | |
143 | xSemaphoreGive(xSemaphoreDriver); | |
144 | } | |
145 | } | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
146 | log_msg(TAG, "HLT:%s MLT:%s", (_ManualHLT)?"true":"false", (_ManualMLT)?"true":"false"); |
0 | 147 | Main_Screen = MAIN_MANUAL_MAIN; |
148 | break; | |
149 | ||
150 | case MAIN_MANUAL_MAIN: | |
151 | if (_ManualMLT) { | |
152 | MLT_info(71, 26, true); | |
153 | } | |
154 | if (_ManualHLT) { | |
155 | HLT_info(71, 150, true, false); | |
156 | } | |
157 | switch (Buttons_Scan()) { | |
158 | case 0: Main_Screen = MAIN_MODE_FREE; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
159 | log_msg(TAG, "End manual mode"); |
0 | 160 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { |
161 | runtime.ManualHLT = driver_state->hlt_sp; | |
162 | runtime.ManualMLT = driver_state->mlt_sp; | |
163 | driver_state->enable = false; | |
164 | driver_state->mlt_mode = MLT_MODE_NONE; | |
165 | driver_state->mlt_sp = 0.0; | |
166 | driver_state->hlt_mode = HLT_MODE_NONE; | |
167 | driver_state->hlt_sp = 0.0; | |
168 | driver_state->pump_run = 0; | |
169 | xSemaphoreGive(xSemaphoreDriver); | |
170 | } | |
171 | write_runtime(); | |
172 | break; | |
173 | ||
174 | case 1: if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
175 | if (_ManualMLT) { | |
176 | driver_state->mlt_sp += 0.25; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
177 | log_msg(TAG, "MLT sp %.2f", driver_state->mlt_sp); |
0 | 178 | } else { |
179 | driver_state->hlt_sp += 0.25; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
180 | log_msg(TAG, "HLT sp %.2f", driver_state->hlt_sp); |
0 | 181 | } |
182 | xSemaphoreGive(xSemaphoreDriver); | |
183 | } | |
184 | break; | |
185 | ||
186 | case 2: if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
187 | if (_ManualMLT) { | |
188 | driver_state->mlt_sp -= 0.25; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
189 | log_msg(TAG, "MLT sp %.2f", driver_state->mlt_sp); |
0 | 190 | } else { |
191 | driver_state->hlt_sp -= 0.25; | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
192 | log_msg(TAG, "HLT sp %.2f", driver_state->hlt_sp); |
0 | 193 | } |
194 | xSemaphoreGive(xSemaphoreDriver); | |
195 | } | |
196 | break; | |
197 | ||
198 | case 3: if (_ManualMLT) { | |
199 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
200 | if (driver_state->pump_run) | |
201 | driver_state->pump_run = 0; | |
202 | else | |
203 | driver_state->pump_run = 1; | |
204 | xSemaphoreGive(xSemaphoreDriver); | |
205 | } | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
206 | log_msg(TAG, "Pump turned %s", driver_state->pump_run?"on":"off"); |
0 | 207 | } else { |
208 | if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
209 | if (driver_state->hlt_mode == HLT_MODE_BANG) { | |
210 | driver_state->hlt_mode = HLT_MODE_OFF; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
211 | Buttons_Add(255, 200, 60, 40, (char *)"Aan" , 3); |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
212 | log_msg(TAG, "HLT turned off"); |
0 | 213 | } else { |
214 | driver_state->hlt_mode = HLT_MODE_BANG; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
215 | Buttons_Add(255, 200, 60, 40, (char *)"Uit" , 3); |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
216 | log_msg(TAG, "HLT turned on sp %.2f", driver_state->hlt_sp); |
0 | 217 | } |
218 | xSemaphoreGive(xSemaphoreDriver); | |
219 | } | |
220 | Buttons_Show(); | |
221 | } | |
222 | break; | |
223 | ||
224 | case 4: if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
225 | if (driver_state->mlt_mode == MLT_MODE_PID) { | |
226 | driver_state->mlt_mode = MLT_MODE_OFF; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
227 | Buttons_Add(255, 76, 60, 40, (char *)"Aan" , 4); |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
228 | log_msg(TAG, "MLT turned off"); |
0 | 229 | } else { |
230 | driver_state->mlt_mode = MLT_MODE_PID; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
231 | Buttons_Add(255, 76, 60, 40, (char *)"Uit" , 4); |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
232 | log_msg(TAG, "MLT turned on sp %.2f", driver_state->mlt_sp); |
0 | 233 | } |
234 | xSemaphoreGive(xSemaphoreDriver); | |
235 | } | |
236 | Buttons_Show(); | |
237 | break; | |
238 | ||
239 | case 5: if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
240 | driver_state->hlt_sp += 0.25; | |
241 | xSemaphoreGive(xSemaphoreDriver); | |
242 | } | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
243 | log_msg(TAG, "HLT sp %.2f", driver_state->hlt_sp); |
0 | 244 | break; |
245 | ||
246 | case 6: if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
247 | driver_state->hlt_sp -= 0.25; | |
248 | xSemaphoreGive(xSemaphoreDriver); | |
249 | } | |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
250 | log_msg(TAG, "HLT sp %.2f", driver_state->hlt_sp); |
0 | 251 | break; |
252 | ||
253 | case 7: if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { | |
254 | if (driver_state->hlt_mode == HLT_MODE_BANG) { | |
255 | driver_state->hlt_mode = HLT_MODE_OFF; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
256 | Buttons_Add(255, 200, 60, 40, (char *)"Aan" , 7); |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
257 | log_msg(TAG, "HLT turned off"); |
0 | 258 | } else { |
259 | driver_state->hlt_mode = HLT_MODE_BANG; | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
260 | Buttons_Add(255, 200, 60, 40, (char *)"Uit" , 7); |
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
261 | log_msg(TAG, "HLT turned on %.2f", driver_state->hlt_sp); |
0 | 262 | } |
263 | xSemaphoreGive(xSemaphoreDriver); | |
264 | } | |
265 | Buttons_Show(); | |
266 | break; | |
267 | ||
268 | default: break; | |
269 | } | |
270 | break; | |
271 | ||
272 | default: | |
273 | break; | |
274 | } | |
275 | ||
276 | return false; | |
277 | } | |
278 |