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