main/task_temp.h

Sun, 10 Sep 2023 17:29:15 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 10 Sep 2023 17:29:15 +0200
changeset 37
50dbb626fbab
parent 32
84e54b14e7db
permissions
-rw-r--r--

Version 0.4.3. Attempt to fix the sunlight overflow of the APDS9930 sensor in the private part of the esp-idf-lib. Removed some error checks from functions that always return OK. Store light sensor registers in the state record and report the values in the json result string.

32
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * @file task_temp.h
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 * @brief The FreeRTOS task to query the chip temperature sensor.
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * The task will update the sensor state structures.
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 */
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 #ifndef _TASK_TEMP_H
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 #define _TASK_TEMP_H
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 /*
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * Error codes in this task
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 */
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 #define TEMP_ERR_NONE 0 ///< No errors
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 #define TEMP_ERR_READ 1
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 /**
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * @brief Structure containing the variables for the TEMP task.
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 */
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 typedef struct {
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 bool valid; ///< Valid measurement
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 float temperature; ///< Temperature in celsius
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 int error; ///< Error result
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 } TEMP_State;
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 /**
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 * @brief Request a new measurement from the temperature sensor.
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 */
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 void request_temp(void);
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 /**
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 * @brief Check if results are ready
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 * @return true of results are ready, else false.
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 */
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 bool ready_temp(void);
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 /**
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 * @brief The FreeRTOS task to update the temperature on request.
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 * @param pvParameters Parameters for the task.
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 */
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 void task_temp(void *pvParameters);
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 #endif
84e54b14e7db Version 0.4.1 Measure internal chip temperature, range -10 to 80. Result available in mqtt json payload.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49

mercurial