Wed, 24 Oct 2018 11:55:39 +0200
Removed old logfiles
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 { | |
41 | char time[9]; ///< Time in the brew. | |
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 | ||
53 | /** | |
54 | * @brief Begin a new logfile. The logfile is created and written to on | |
55 | * the spiffs filesystem. | |
56 | * @param t The time in seconds since the Epoch, to create the filename. | |
57 | */ | |
58 | void log_begin(time_t t); | |
59 | ||
60 | /** | |
61 | * @brief Close an open logfile. The logfile is moved to the SD card if | |
62 | * the card is present and mounted. Then, the temporary logfile | |
63 | * is removed. | |
64 | */ | |
65 | void log_close(void); | |
66 | ||
67 | /** | |
68 | * @brief Clean logfile directory /spiffs/log/ | |
69 | */ | |
70 | void log_clean(void); | |
71 | ||
72 | /** | |
73 | * @brief Log to JSON logfile. | |
74 | */ | |
75 | void log_json(void); | |
76 | ||
77 | /** | |
78 | * @brief Log annotations for the chart. These are stored in a temporary | |
79 | * file and later when the logfile is closed they are merged in | |
80 | * the main json logfile. | |
81 | * @param annotation_type The type of annotation, stage/event/system. | |
82 | * @param label The label text that will be seen in the chart. | |
83 | */ | |
84 | void log_annotation(int annotation_type, char *label); | |
85 | ||
86 | /** | |
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
87 | * @brief Copy one file. |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
88 | * @param ff The from filename |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
89 | * @param tf The to filename |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
90 | * @return 0 if success. |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
91 | */ |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
92 | int FileCopy(char *ff, char *tf); |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
93 | |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
94 | /** |
0 | 95 | * @brief FreeRTOS sd card task. |
96 | */ | |
97 | void task_sdcard(void *); | |
98 | ||
99 | #endif |