Line data Source code
1 :
2 : #ifndef SENSOR_READ_HPP
3 : #define SENSOR_READ_HPP
4 :
5 : #include "IRTOS.hpp"
6 : #include "ISensor.hpp"
7 : #include "appDefines.hpp"
8 :
9 : namespace FreeRTOS_Cpp
10 : {
11 : #define LOG_SENSOR(buf, label, val, unit) \
12 : App_FormatSensorMsg((buf), (uint32_t)sizeof(buf), (label), (val), (unit))
13 :
14 : class appSensorRead{
15 :
16 : public:
17 : appSensorRead(IRTOS* rtos, ISensor* tempSensor,
18 : ISensor* humiditySensor, void* sysEvents, void* wdgEvents);
19 :
20 : uint8_t appSensorRead_Init(void);
21 : static void vSensorReadTask(void *pvParameters);
22 :
23 : uint32_t getTempSensorID(void);
24 : uint32_t getHumiditySensorID(void);
25 :
26 1 : float getCurrentTemp(void){return _currentTemp;};
27 1 : float getCurrentHumidity(void){return _currentHumidity;};
28 :
29 0 : void enableTemperatureLogging(void){bEnableTemperatureLogging = true;}
30 0 : void enableHumidityLogging(void){bEnableHumidityLogging = true;}
31 0 : void disableTemperatureLogging(void){bEnableTemperatureLogging = false;}
32 0 : void disableHumidityLogging(void){bEnableHumidityLogging = false;}
33 :
34 : PRIVATE_FOR_TEST:
35 : bool bEnableTemperatureLogging{false};
36 : bool bEnableHumidityLogging{false};
37 : IRTOS* _rtos;
38 : ISensor* _tempSensor; // Hardware Abstracted
39 : ISensor* _humiditySensor; // Hardware Abstracted
40 : float _currentTemp;
41 : float _currentHumidity;
42 : void* _sysEvents;
43 : void* _wdgEvents;
44 : static constexpr uint32_t appSENSOR_TEMPERATURE = (1u << 0); // Bit 0
45 : static constexpr uint32_t appSENSOR_HUMIDITY = (1u << 1); // Bit 1
46 :
47 : void App_FormatSensorMsg(char *pDest, uint32_t destLen, const char *pLabel,
48 : float val, const char *pUnit);
49 :
50 : };
51 : }
52 : #endif //SENSOR_READ_H
|