Sun, 24 Nov 2019 16:44:00 +0100
Version 0.3.7. The WiFi task uses the new event handlers. Cooling temperature top is now 45 instead of 30 degreees for pitching Kveik. One extra cosmetic message during OTA update.
0 | 1 | #ifndef _TASK_SDCARD_H |
2 | #define _TASK_SDCARD_H | |
3 | ||
4 | /** | |
5 | * @file task_sdcard.h | |
4 | 6 | * @brief SD/MMC driver. This driver is for a slot for the user on |
7 | * the front panel. It will detect an inserted card and then | |
8 | * mount it. It also detects the removal of the card and then | |
9 | * unmounts it. Be carefull, only do this in the main menu. | |
10 | * Also, brew logging is handled here and finished brewlogs | |
11 | * are copied to the SD card if it is mounted. | |
12 | * Recipes to import must go into the /sdcard/recipe folder | |
13 | * and have extension .xml and the contents be a beerxml file. | |
14 | * Backup and restore is also done to this card. | |
0 | 15 | */ |
16 | ||
17 | ||
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
18 | /** |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
19 | * @brief Annotation types for the log graph. |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
20 | */ |
0 | 21 | typedef enum |
22 | { | |
23 | ANNOTATION_STAGE = 0, ///< Annotate stage event | |
24 | ANNOTATION_EVENT, ///< Annotate an event | |
25 | ANNOTATION_SYSTEM, ///< Annotate a system event. | |
26 | } ANNOTATION_TYPES; | |
27 | ||
28 | /** | |
29 | * @brief Structure containing the information of the SD cards task. | |
30 | */ | |
31 | typedef struct { | |
32 | bool host_ok; ///< SPI host is Ok. | |
33 | bool card_present; ///< If card is present in the slot. | |
34 | char logfile[32]; ///< Current logfile name. | |
35 | } SDCARD_State; | |
36 | ||
37 | /** | |
38 | * @brief JSON log data | |
39 | */ | |
40 | typedef struct { | |
54
7b134c27fadb
Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents:
4
diff
changeset
|
41 | char time[12]; ///< Time in the brew. |
0 | 42 | float mlt_sp; ///< MLT setpoint. |
43 | float mlt_pv; ///< MLT temperature. | |
44 | int mlt_power; ///< MLT power in % | |
45 | int mlt_tempreached; ///< MLT temperature reached (0 or 1). | |
46 | int pump_run; ///< Pump run (0 or 1). | |
47 | float hlt_sp; ///< HLT setpoint. | |
48 | float hlt_pv; ///< HLT temperature. | |
49 | int hlt_power; ///< HLT power in %. | |
50 | char event[64]; ///< Event message. | |
51 | } JSON_log; | |
52 | ||
62
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
53 | |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
54 | /** |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
55 | * @brief Write application messages to a logfile on the sdcard. The |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
56 | * logfile is /sdcard/log/sysyyymmdd.log and is only used |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
57 | * when the time is set from NTP and a card is mounted. |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
58 | * Log messages are always copied to ESP_LOGI() too. |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
59 | * @param tag is the log tag just as in ESP_LOGx(). |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
60 | * @param * is the formatted string. |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
61 | */ |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
62 | void log_msg(const char *tag, const char *, ...); |
2e90ada37476
Added syslog like logging on the sdcard for the manual and automatic processes.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
63 | |
0 | 64 | /** |
65 | * @brief Begin a new logfile. The logfile is created and written to on | |
66 | * the spiffs filesystem. | |
67 | * @param t The time in seconds since the Epoch, to create the filename. | |
68 | */ | |
69 | void log_begin(time_t t); | |
70 | ||
71 | /** | |
72 | * @brief Close an open logfile. The logfile is moved to the SD card if | |
73 | * the card is present and mounted. Then, the temporary logfile | |
74 | * is removed. | |
75 | */ | |
76 | void log_close(void); | |
77 | ||
78 | /** | |
79 | * @brief Clean logfile directory /spiffs/log/ | |
80 | */ | |
81 | void log_clean(void); | |
82 | ||
83 | /** | |
84 | * @brief Log to JSON logfile. | |
85 | */ | |
86 | void log_json(void); | |
87 | ||
88 | /** | |
89 | * @brief Log annotations for the chart. These are stored in a temporary | |
90 | * file and later when the logfile is closed they are merged in | |
91 | * the main json logfile. | |
92 | * @param annotation_type The type of annotation, stage/event/system. | |
93 | * @param label The label text that will be seen in the chart. | |
94 | */ | |
95 | void log_annotation(int annotation_type, char *label); | |
96 | ||
97 | /** | |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
98 | * @brief Copy one file. |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
99 | * @param ff The from filename |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
100 | * @param tf The to filename |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
101 | * @return 0 if success. |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
102 | */ |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
103 | int FileCopy(char *ff, char *tf); |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
104 | |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
105 | /** |
0 | 106 | * @brief FreeRTOS sd card task. |
107 | */ | |
108 | void task_sdcard(void *); | |
109 | ||
110 | #endif |