Sun, 07 Jun 2020 22:30:07 +0200
Default PID init adjusted.
0 | 1 | /** |
2 | * @file config.h | |
3 | * @brief The BrewBoard configuration data. These are stored in the | |
4 | * spiffs filesystem in a flash partition. | |
5 | */ | |
6 | ||
7 | #ifndef _CONFIG_H | |
8 | #define _CONFIG_H | |
9 | ||
10 | // Global includes for the project | |
11 | ||
12 | #include <stdio.h> | |
13 | #include <stdlib.h> | |
14 | #include <string.h> | |
15 | #include <stdbool.h> | |
16 | #include <time.h> | |
17 | #include <errno.h> | |
18 | #include <sys/unistd.h> | |
19 | #include <sys/fcntl.h> | |
20 | #include <sys/time.h> | |
21 | ||
22 | #include "freertos/FreeRTOS.h" | |
23 | #include "freertos/task.h" | |
24 | #include "freertos/semphr.h" | |
25 | #include "freertos/event_groups.h" | |
26 | #include "freertos/queue.h" | |
27 | #include "driver/i2c.h" | |
28 | #include "esp_log.h" | |
29 | #include "esp_spiffs.h" | |
70
d6838a268020
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.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
30 | #include "esp_event.h" |
0 | 31 | #include "esp_wifi.h" |
32 | #include "esp_wifi_types.h" | |
33 | #include "esp_system.h" | |
34 | ||
35 | #include "esp_ota_ops.h" | |
36 | #include "esp_http_client.h" | |
37 | #include "esp_https_ota.h" | |
38 | ||
39 | #include "esp_vfs.h" | |
40 | #include "esp_vfs_fat.h" | |
41 | #include "nvs.h" | |
42 | #include "nvs_flash.h" | |
34
5c92103c5e72
Version 0.2.10. Fixed spelling error in websocket component. Updated esp-idf to v4.0-dev-459-gba1ff1692 and adjusted several sources for changed headers. Finalized keeping the AP running at all times. Increased websocket server stack depth from 6000 to 7000.
Michiel Broek <mbroek@mbse.eu>
parents:
32
diff
changeset
|
43 | #include "esp32/rom/crc.h" |
0 | 44 | #include "mdns.h" |
45 | #include "lwip/sockets.h" | |
46 | #include "lwip/api.h" | |
47 | #include "lwip/err.h" | |
48 | #include "lwip/netdb.h" | |
49 | #include "lwip/dns.h" | |
50 | #include "lwip/opt.h" | |
51 | #include "lwip/memp.h" | |
52 | #include "lwip/ip.h" | |
53 | #include "lwip/raw.h" | |
54 | #include "lwip/udp.h" | |
55 | #include "sdkconfig.h" | |
56 | #include "lwip/apps/sntp.h" | |
57 | #include "expat.h" | |
58 | ||
59 | #include "tftspi.h" | |
60 | #include "tft.h" | |
61 | #include "PID_v1.h" | |
62 | #include "websocket_server.h" | |
63 | ||
64 | #include "buttons.h" | |
65 | #include "calibration.h" | |
66 | #include "automation.h" | |
67 | #include "manual.h" | |
68 | #include "setup.h" | |
69 | #include "recipes.h" | |
70 | #include "files.h" | |
71 | #include "updates.h" | |
72 | ||
73 | #include "task_tft.h" | |
74 | #include "task_ds18b20.h" | |
75 | #include "task_sdcard.h" | |
76 | #include "task_driver.h" | |
77 | #include "task_wifi.h" | |
78 | #include "task_sound.h" | |
79 | #include "task_http.h" | |
80 | ||
81 | ||
19 | 82 | |
0 | 83 | /** |
84 | * @brief Main mode different screens | |
85 | */ | |
86 | typedef enum | |
87 | { | |
88 | MAIN_MODE_UNKNOWN = -1, ///< During system startup | |
89 | MAIN_MODE_FREE = 0, ///< Main menu, do nothing | |
90 | MAIN_MODE_CALIBRATION, ///< TFT calibration | |
91 | MAIN_INFO, ///< Info/about screen | |
92 | MAIN_TOOLS, ///< Main tools screen | |
93 | MAIN_TOOLS_SETUP, ///< Main setup screen | |
94 | MAIN_TOOLS_SETUP_CONFIG, ///< Main setup configuration | |
95 | MAIN_TOOLS_SETUP_CO_EDIT, ///< Main setup confguration editor | |
96 | MAIN_TOOLS_SETUP_EQUIPMENT, ///< Main setup equipment | |
97 | MAIN_TOOLS_SETUP_EQ_EDIT, ///< Main setup edit equipment | |
98 | MAIN_TOOLS_SETUP_WIFI, ///< Main setup WiFi | |
99 | MAIN_TOOLS_SETUP_WIFI_CUR, ///< Main setup WiFi current connection. | |
100 | MAIN_TOOLS_SETUP_WIFI_CON, ///< Main setup WiFi connect. | |
101 | MAIN_TOOLS_SETUP_WIFI_NEW, ///< Main setup WiFi new connection. | |
102 | MAIN_TOOLS_SETUP_CALIBRATION, ///< Main setup TFT calibration | |
103 | MAIN_TOOLS_RECIPE, ///< Main recipes screen. | |
104 | MAIN_TOOLS_RECIPE_EDIT, ///< Main recipes editor. | |
105 | MAIN_TOOLS_FILES, ///< Main files. | |
2
7a03d81c0e0d
Added database backup and restore.
Michiel Broek <mbroek@mbse.eu>
parents:
1
diff
changeset
|
106 | MAIN_TOOLS_FILES_DIR, ///< Main files directory listings. |
7a03d81c0e0d
Added database backup and restore.
Michiel Broek <mbroek@mbse.eu>
parents:
1
diff
changeset
|
107 | MAIN_TOOLS_FILES_RESTORE, ///< Main files restore. |
7a03d81c0e0d
Added database backup and restore.
Michiel Broek <mbroek@mbse.eu>
parents:
1
diff
changeset
|
108 | MAIN_TOOLS_FILES_BACKUP, ///< Main files backup. |
0 | 109 | MAIN_TOOLS_UPDATES, ///< Main Updates. |
42 | 110 | MAIN_AUTO_INIT1 = 96, ///< Automatic start part 1 |
111 | MAIN_AUTO_INIT2, ///< Automatic start part 2 | |
0 | 112 | MAIN_AUTO_DELAYSTART, ///< Delayed start |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
113 | MAIN_AUTO_HEATUP, ///< Heatup the HLT |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
114 | MAIN_AUTO_MASH = 100, ///< Mash steps |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
115 | MAIN_AUTO_TOBOIL = 120, ///< Going to boil |
0 | 116 | MAIN_AUTO_BOILING, ///< Boiling |
117 | MAIN_AUTO_WHIRLPOOL9, ///< Whirlpool | |
118 | MAIN_AUTO_COOLING_H, ///< Cooling hot type | |
119 | MAIN_AUTO_WHIRLPOOL7, ///< Whirlpool | |
120 | MAIN_AUTO_COOLING_M, ///< Cooling medium type | |
121 | MAIN_AUTO_WHIRLPOOL6, ///< Whirlpool | |
122 | MAIN_AUTO_COOLING_C, ///< Cooling cold type | |
123 | MAIN_AUTO_WHIRLPOOL2, ///< Whirlpool | |
124 | MAIN_AUTO_DONE, ///< Finished | |
125 | MAIN_AUTO_ABORT, ///< Aborted | |
126 | MAIN_MANUAL_INIT = 200, ///< Manual control init | |
127 | MAIN_MANUAL_MAIN, ///< Manual control main menu | |
128 | } MAIN_MODE; | |
129 | ||
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
130 | /** |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
131 | * @brief The differents stages in the mash steps. |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
132 | */ |
0 | 133 | typedef enum { |
134 | MASH_NONE = 0, ///< Initial Mash state | |
135 | MASH_WAITTEMP, ///< Wait to reach temperature. | |
136 | MASH_REST, ///< Mash rest | |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
137 | MASH_ADD, ///< Wait add mash |
0 | 138 | MASH_IODINE, ///< Wait iodine test |
139 | MASH_REMOVE, ///< Wait mash remove | |
19 | 140 | MASH_INFUSE, ///< Wait infusion prompt |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
141 | MASH_DECOCT, ///< Wait decoction prompt |
0 | 142 | } MASH_TYPE; |
143 | ||
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
144 | /** |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
145 | * @brief The working mode of the second heater SSR. |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
146 | */ |
0 | 147 | typedef enum { |
148 | SSR2_OFF = 0, ///< SSR2 not used. | |
149 | SSR2_HLT_SHARE, ///< SSR2 for HLT shared with MLT | |
150 | SSR2_HLT_IND, ///< SSR2 for HLT independend. | |
151 | SSR2_ON_IDLE, ///< SSR2 on when NLT is idle. | |
152 | } SSR2_TYPE; | |
153 | ||
154 | ||
155 | ||
156 | /** | |
157 | * @brief Global configuration. File /spiffs/config.conf | |
158 | */ | |
159 | struct strConfig { | |
160 | uint8_t Version; ///< Record version number for updates. | |
161 | uint8_t Unit; ///< Celsius or Farenheit (not used yet). | |
162 | float BoilTemperature; ///< The temperature when water boils. | |
163 | bool AskAdd; ///< Ask to add the mash. | |
164 | bool AskRemove; ///< Ask to remove the mash. | |
165 | bool AskIodine; ///< Ask to confirm the iodine test. | |
166 | uint8_t IodineTime; ///< Continue after this time if not confirmed. | |
167 | int EquipmentRec; ///< Equipment record number. | |
49
4ec04c6f1551
SNTP uses a callback function to mark the system time is valid. SNTP is started after we received a DHCP ip address. Added an config option to set a preffered NTP server name, most likely on your most used LAN. It will always fal back to pool.ntp.org.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
168 | char ntp_server[32]; ///< Preffered NTP server. |
0 | 169 | char hostname[32]; ///< Our hostname. |
170 | char ap_ssid[32]; ///< AP SSID. | |
171 | char ap_pwd[64]; ///< AP password. | |
172 | uint8_t ap_channel; ///< AP channel. | |
173 | uint8_t ap_ssid_hidden; ///< AP SSID hidden. | |
174 | wifi_bandwidth_t ap_bandwidth; ///< AP channel bandwidth. | |
175 | uint16_t ts_xleft; ///< TS calibration X left. | |
176 | uint16_t ts_xright; ///< TS calibration X right. | |
177 | uint16_t ts_ytop; ///< TS calibration Y top. | |
178 | uint16_t ts_ybottom; ///< TS calibration Y bottom. | |
179 | int RecipeRec; ///< Current recipe record. | |
180 | char uuid[37]; ///< Sort of uuid code. | |
181 | char lastSSID[32]; ///< Last connected station. | |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
182 | } config; ///< Config record. |
0 | 183 | |
184 | /** | |
185 | * @brief Write configuration to disk. | |
186 | */ | |
187 | void write_config(void); | |
188 | ||
189 | /** @brief Read configuration file. If it doesn't exist create and | |
190 | * write a new configuration file with sane defaults. | |
191 | */ | |
192 | void read_config(void); | |
193 | ||
194 | ||
195 | ||
196 | /** | |
197 | * @brief Equipment configuration. File /spiffs/equipments.conf | |
198 | */ | |
199 | struct strEquipment { | |
200 | int Version; ///< Record version number for updates. | |
201 | int Record; ///< Record number. | |
202 | char Name[32]; ///< Equipment name. | |
203 | int BoilPower; ///< The power percentage needed to keep the wort boiling. | |
204 | int MashPower; ///< The power percentage needed to heat during mash. | |
205 | int PumpCycle; ///< Minutes to run the pump during mash rest. | |
206 | int PumpRest; ///< Minutes to pause the pump during mash rests. | |
207 | bool PumpPreMash; ///< Pump on before mash-in. | |
208 | bool PumpOnMash; ///< Pump on during mashing. | |
209 | bool PumpMashOut; ///< Pump on during mash remove. | |
210 | bool PumpOnBoil; ///< Pump on during the boil. | |
211 | int PumpMaxTemp; ///< Turn pump off above this temperature. | |
212 | bool PIDPipe; ///< Run PID during mash removal. | |
213 | int SSR2; ///< Use second SSR (HLT) or not. | |
214 | float TempHLT; ///< The temperature of the sparge water. | |
215 | double PID_kP; ///< PID P setting. | |
216 | double PID_kI; ///< PID I setting. | |
217 | double PID_kD; ///< PID D setting. | |
82 | 218 | bool xPID_POn; |
0 | 219 | int SampleTime; ///< PID sample time in seconds. |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
220 | } equipment; ///< Equipment record. |
0 | 221 | |
222 | /** | |
223 | * @brief Append equipments record to disk. | |
224 | */ | |
225 | void append_equipment(void); | |
226 | ||
227 | /** | |
228 | * @brief Read equipments file. If it doesn't exist create and | |
229 | * write a new equipment file with sane defaults. | |
230 | * This is then the first and default brew equipment. | |
231 | * @param RecNo Read the record with Record is RecNo. Start at 1. | |
232 | */ | |
233 | void read_equipment(int RecNo); | |
234 | ||
235 | /** | |
236 | * @brief Write rquipment record. It should exist. | |
237 | * @param RecNo The equipment record in memory to write at record. Records start at 1. | |
238 | */ | |
239 | void write_equipment(int RecNo); | |
240 | ||
241 | /** | |
242 | * @brief Delete equipment record, renumber remaining records. | |
243 | * @param RecNo The record to remove. | |
244 | */ | |
245 | void delete_equipment(int RecNo); | |
246 | ||
247 | ||
248 | ||
249 | /** | |
250 | * @brief Records with WiFi stations we have succesfully connected. | |
251 | */ | |
252 | struct strStations { | |
253 | char SSID[32]; ///< Station SSID | |
254 | char Password[64]; ///< Station password | |
255 | bool hide; ///< Hide from AP scan. | |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
256 | } wifiStation; ///< Station record. |
0 | 257 | |
258 | /** | |
259 | * @brief Add a new station record. | |
260 | * @param SSID The SSID | |
261 | * @param Password The password for this SSID | |
262 | * @return The record number, or -1 if error. | |
263 | */ | |
264 | int add_station(uint8_t *SSID, uint8_t *Password); | |
265 | ||
266 | /** | |
267 | * @brief Read station info record. | |
268 | * @param SSID Search for the SSID and load the record if found. | |
269 | * @return Return -1 if not found, else the record number and the wifiStation record is filled. | |
270 | */ | |
271 | int read_station(uint8_t *SSID); | |
272 | ||
273 | /** | |
274 | * @brief Remove station record. | |
275 | * @param SSID The SSID to remove. | |
276 | */ | |
277 | void remove_station(uint8_t *SSID); | |
278 | ||
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
279 | /** |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
280 | * @brief Blacklist station SSID |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
281 | * @param SSID The SSID to blacklist. |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
282 | * @return -1 if error, else the record number. |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
283 | */ |
0 | 284 | int blacklist_station(uint8_t *SSID); |
285 | ||
286 | ||
287 | ||
288 | /** | |
289 | * @brief Runtime configuration. File /spiffs/runtime.conf | |
290 | */ | |
291 | struct strRuntime { | |
292 | uint8_t Version; ///< Record version number for updates. | |
293 | bool AutoModeStarted; ///< Running automode. | |
294 | int StageResume; ///< Current Resume Stage. | |
295 | int StageTimeLeft; ///< Current Stage Time left. | |
296 | uint8_t HopAddition; ///< Current Hop Addition. | |
297 | float ManualMLT; ///< Last used MLT temperature. | |
298 | float ManualHLT; ///< Last used HLT temperature. | |
299 | time_t BrewStart; ///< Brew start time. | |
300 | char Logfile[64]; ///< Brew logfile. | |
301 | bool UseHLT; ///< Use HLT during brew. | |
302 | bool PumpCooling; ///< Pump during cooling. | |
303 | uint32_t TimeBrewing; ///< Time we are brewing. | |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
304 | uint8_t MashStep; ///< Current mash step. |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
305 | bool MaltAdded; ///< If malt was added. |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
306 | } runtime; ///< Runtime record. |
0 | 307 | |
308 | ||
309 | /** | |
310 | * @brief Write runtime information to disk. | |
311 | */ | |
312 | void write_runtime(void); | |
313 | ||
314 | /** | |
315 | * @brief Read runtime information file. If it doesn't exist create and | |
316 | * write a new runtime file with sane defaults. | |
317 | */ | |
318 | void read_runtime(void); | |
319 | ||
320 | ||
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
321 | |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
322 | #define RECIPE_VERSION 2 ///< Recipe file version |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
323 | #define MASH_MAX 16 ///< Maximum 16 mash steps |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
324 | #define ADDITION_MAX 20 ///< Maximum 20 additions |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
325 | |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
326 | /** |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
327 | * @brief Mash step types |
15
34b1eb93e71a
Added extra mash step fields for infusion steps. Added these fields in recipe import too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
328 | */ |
34b1eb93e71a
Added extra mash step fields for infusion steps. Added these fields in recipe import too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
329 | typedef enum { |
34b1eb93e71a
Added extra mash step fields for infusion steps. Added these fields in recipe import too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
330 | MASHTYPE_INFUSION = 0, |
34b1eb93e71a
Added extra mash step fields for infusion steps. Added these fields in recipe import too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
331 | MASHTYPE_TEMPERATURE, |
34b1eb93e71a
Added extra mash step fields for infusion steps. Added these fields in recipe import too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
332 | MASHTYPE_DECOCTION, |
34b1eb93e71a
Added extra mash step fields for infusion steps. Added these fields in recipe import too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
333 | } MASHSTEP_TYPE; |
34b1eb93e71a
Added extra mash step fields for infusion steps. Added these fields in recipe import too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
334 | |
34b1eb93e71a
Added extra mash step fields for infusion steps. Added these fields in recipe import too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
335 | /** |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
336 | * @brief Addition types |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
337 | */ |
0 | 338 | typedef enum { |
339 | ADDITION_HOP = 0, | |
340 | ADDITION_FERMENTABLE = 1, | |
341 | ADDITION_SPICE = 2, | |
342 | ADDITION_FINING = 3, | |
343 | ADDITION_WATER_AGENT = 4, | |
344 | ADDITION_HERB = 5, | |
345 | ADDITION_FLAVOR = 6, | |
346 | ADDITION_OTHER = 7, | |
347 | } ADDITION_TYPE; | |
348 | ||
349 | /** | |
350 | * @brief Mash steps | |
351 | */ | |
352 | typedef struct strMashStep { | |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
353 | char Name[32]; ///< Step name. |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
354 | uint8_t Type; ///< Step Type. |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
355 | float Step_temp; ///< Step start temperature. |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
356 | uint16_t Step_time; ///< Step rest time. |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
357 | uint16_t Ramp_time; ///< Step time to reach temp. |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
358 | float End_temp; ///< Step end temperature. |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
359 | float Infuse_amount; ///< Infuse/decoct amount in liters. |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
360 | float Infuse_temp; ///< Infuse temperature. |
0 | 361 | } mashstep_t; |
362 | ||
363 | /** | |
364 | * @brief Hop and other additions | |
365 | */ | |
366 | typedef struct strAddition { | |
367 | uint16_t Time; ///< Time for addition. | |
368 | uint8_t Type; ///< Addition type, Hop, Syrop ... | |
369 | char Name[64]; ///< Addition name. | |
370 | } addition_t; | |
371 | ||
372 | /** | |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
373 | * @brief Recipes database. Starts with a header block for future upgrades, |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
374 | * followed by the actual recpie records. |
0 | 375 | */ |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
376 | struct hdrRecipe { |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
377 | uint32_t version; ///< Structure version. |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
378 | uint32_t hdrsize; ///< Size of this header. |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
379 | uint32_t recsize; ///< Size of a record. |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
380 | uint8_t mashmax; ///< Maximum mash steps. |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
381 | uint8_t additionmax; ///< Maximum additions. |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
382 | } recipe_hdr; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
383 | |
0 | 384 | struct strRecipe { |
385 | char Name[128]; ///< Recipe name. | |
386 | char Code[32]; ///< Recipe code. | |
387 | uint16_t BoilTime; ///< Boil time. | |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
388 | uint8_t Mashsteps; ///< Number of mashsteps. |
0 | 389 | uint8_t Additions; ///< Number of additions. |
390 | float CoolTemp; ///< Cool temperature. | |
391 | uint16_t Whirlpool9; ///< Zero or the Hot Whirlpool time 88..100 ° | |
392 | uint16_t Whirlpool7; ///< Zero or the Sub Isomerization Whirlpool time 71..77 ° | |
393 | uint16_t Whirlpool6; ///< Zero or the "Tepid" Whirlpool time 60..66 ° | |
394 | uint16_t Whirlpool2; ///< Zero or the Cold Whirlpool time < 30 ° | |
395 | float SpargeTemp; ///< Sparge water temperature. | |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
396 | mashstep_t MashStep[MASH_MAX]; ///< Mash steps. |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
397 | addition_t Addition[ADDITION_MAX]; ///< Additions. |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
398 | } recipe; ///< Recipe record. |
0 | 399 | |
400 | /** | |
401 | * @brief Append a recipe record. Create file if it doesn't exist. | |
402 | */ | |
403 | void append_recipe(void); | |
404 | ||
405 | /** | |
406 | * @brief Write current recipe | |
407 | * @param RecNo Record number starting at 1. | |
408 | */ | |
409 | void write_recipe(int RecNo); | |
410 | ||
411 | /** | |
412 | * @brief Read current recipe | |
413 | * @param RecNo The record to read, start at 1. | |
414 | */ | |
415 | void read_recipe(int RecNo); | |
416 | ||
417 | /** | |
418 | * @brief Delete recipe record, renumber remaining records. | |
419 | * @param RecNo The record to remove. | |
420 | */ | |
421 | void delete_recipe(int RecNo); | |
422 | ||
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
423 | |
0 | 424 | #endif |