main/task_sdcard.h

changeset 0
b74b0e4902c3
child 1
ad2c8b13eb88
equal deleted inserted replaced
-1:000000000000 0:b74b0e4902c3
1 #ifndef _TASK_SDCARD_H
2 #define _TASK_SDCARD_H
3
4 /**
5 * @file task_sdcard.h
6 * @brief The interface to the FreeRTOS SD/MMC card task.
7 */
8
9
10 typedef enum
11 {
12 ANNOTATION_STAGE = 0, ///< Annotate stage event
13 ANNOTATION_EVENT, ///< Annotate an event
14 ANNOTATION_SYSTEM, ///< Annotate a system event.
15 } ANNOTATION_TYPES;
16
17 /**
18 * @brief Structure containing the information of the SD cards task.
19 */
20 typedef struct {
21 bool host_ok; ///< SPI host is Ok.
22 bool card_present; ///< If card is present in the slot.
23 char logfile[32]; ///< Current logfile name.
24 } SDCARD_State;
25
26 /**
27 * @brief JSON log data
28 */
29 typedef struct {
30 char time[9]; ///< Time in the brew.
31 float mlt_sp; ///< MLT setpoint.
32 float mlt_pv; ///< MLT temperature.
33 int mlt_power; ///< MLT power in %
34 int mlt_tempreached; ///< MLT temperature reached (0 or 1).
35 int pump_run; ///< Pump run (0 or 1).
36 float hlt_sp; ///< HLT setpoint.
37 float hlt_pv; ///< HLT temperature.
38 int hlt_power; ///< HLT power in %.
39 char event[64]; ///< Event message.
40 } JSON_log;
41
42 /**
43 * @brief Begin a new logfile. The logfile is created and written to on
44 * the spiffs filesystem.
45 * @param t The time in seconds since the Epoch, to create the filename.
46 */
47 void log_begin(time_t t);
48
49 /**
50 * @brief Close an open logfile. The logfile is moved to the SD card if
51 * the card is present and mounted. Then, the temporary logfile
52 * is removed.
53 */
54 void log_close(void);
55
56 /**
57 * @brief Clean logfile directory /spiffs/log/
58 */
59 void log_clean(void);
60
61 /**
62 * @brief Log to JSON logfile.
63 */
64 void log_json(void);
65
66 /**
67 * @brief Log annotations for the chart. These are stored in a temporary
68 * file and later when the logfile is closed they are merged in
69 * the main json logfile.
70 * @param annotation_type The type of annotation, stage/event/system.
71 * @param label The label text that will be seen in the chart.
72 */
73 void log_annotation(int annotation_type, char *label);
74
75 /**
76 * @brief FreeRTOS sd card task.
77 */
78 void task_sdcard(void *);
79
80 #endif

mercurial