1- // DHT Temperature & Humidity Unified Sensor Library
2- // Copyright (c) 2014 Adafruit Industries
3- // Author: Tony DiCola
4-
5- // Permission is hereby granted, free of charge, to any person obtaining a copy
6- // of this software and associated documentation files (the "Software"), to deal
7- // in the Software without restriction, including without limitation the rights
8- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9- // copies of the Software, and to permit persons to whom the Software is
10- // furnished to do so, subject to the following conditions:
11-
12- // The above copyright notice and this permission notice shall be included in all
13- // copies or substantial portions of the Software.
14-
15- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21- // SOFTWARE.
1+ /* !
2+ * @file DHT_U.cpp
3+ *
4+ * Temperature & Humidity Unified Sensor Library
5+ *
6+ * This is a library for DHT series of low cost temperature/humidity sensors.
7+ *
8+ * You must have Adafruit Unified Sensor Library library installed to use this
9+ * class.
10+ *
11+ * Adafruit invests time and resources providing this open source code,
12+ * please support Adafruit andopen-source hardware by purchasing products
13+ * from Adafruit!
14+ */
2215#include " DHT_U.h"
2316
17+ /* !
18+ * @brief Instantiates a new DHT_Unified class
19+ * @param pin
20+ * pin number that sensor is connected
21+ * @param type
22+ * type of sensor
23+ * @param count
24+ * number of sensors
25+ * @param tempSensorId
26+ * temperature sensor id
27+ * @param humiditySensorId
28+ * humidity sensor id
29+ */
2430DHT_Unified::DHT_Unified (uint8_t pin, uint8_t type, uint8_t count, int32_t tempSensorId, int32_t humiditySensorId):
2531 _dht(pin, type, count),
2632 _type(type),
2733 _temp(this , tempSensorId),
2834 _humidity(this , humiditySensorId)
2935{}
3036
37+ /* !
38+ * @brief Setup sensor (calls begin on It)
39+ */
3140void DHT_Unified::begin () {
3241 _dht.begin ();
3342}
3443
44+ /* !
45+ * @brief Sets sensor name
46+ * @param sensor
47+ * Sensor that will be set
48+ */
3549void DHT_Unified::setName (sensor_t * sensor) {
3650 switch (_type) {
3751 case DHT11:
@@ -55,6 +69,11 @@ void DHT_Unified::setName(sensor_t* sensor) {
5569 sensor->name [sizeof (sensor->name )- 1 ] = 0 ;
5670}
5771
72+ /* !
73+ * @brief Sets Minimum Delay Value
74+ * @param sensor
75+ * Sensor that will be set
76+ */
5877void DHT_Unified::setMinDelay (sensor_t * sensor) {
5978 switch (_type) {
6079 case DHT11:
@@ -76,11 +95,23 @@ void DHT_Unified::setMinDelay(sensor_t* sensor) {
7695 }
7796}
7897
98+ /* !
99+ * @brief Instantiates a new DHT_Unified Temperature Class
100+ * @param parent
101+ * Parent Sensor
102+ * @param id
103+ * Sensor id
104+ */
79105DHT_Unified::Temperature::Temperature (DHT_Unified* parent, int32_t id):
80106 _parent(parent),
81107 _id(id)
82108{}
83109
110+ /* !
111+ * @brief Reads the sensor and returns the data as a sensors_event_t
112+ * @param event
113+ * @return always returns true
114+ */
84115bool DHT_Unified::Temperature::getEvent (sensors_event_t * event) {
85116 // Clear event definition.
86117 memset (event, 0 , sizeof (sensors_event_t ));
@@ -94,6 +125,10 @@ bool DHT_Unified::Temperature::getEvent(sensors_event_t* event) {
94125 return true ;
95126}
96127
128+ /* !
129+ * @brief Provides the sensor_t data for this sensor
130+ * @param sensor
131+ */
97132void DHT_Unified::Temperature::getSensor (sensor_t * sensor) {
98133 // Clear sensor definition.
99134 memset (sensor, 0 , sizeof (sensor_t ));
@@ -135,11 +170,23 @@ void DHT_Unified::Temperature::getSensor(sensor_t* sensor) {
135170 }
136171}
137172
173+ /* !
174+ * @brief Instantiates a new DHT_Unified Humidity Class
175+ * @param parent
176+ * Parent Sensor
177+ * @param id
178+ * Sensor id
179+ */
138180DHT_Unified::Humidity::Humidity (DHT_Unified* parent, int32_t id):
139181 _parent(parent),
140182 _id(id)
141183{}
142184
185+ /* !
186+ * @brief Reads the sensor and returns the data as a sensors_event_t
187+ * @param event
188+ * @return always returns true
189+ */
143190bool DHT_Unified::Humidity::getEvent (sensors_event_t * event) {
144191 // Clear event definition.
145192 memset (event, 0 , sizeof (sensors_event_t ));
@@ -153,6 +200,10 @@ bool DHT_Unified::Humidity::getEvent(sensors_event_t* event) {
153200 return true ;
154201}
155202
203+ /* !
204+ * @brief Provides the sensor_t data for this sensor
205+ * @param sensor
206+ */
156207void DHT_Unified::Humidity::getSensor (sensor_t * sensor) {
157208 // Clear sensor definition.
158209 memset (sensor, 0 , sizeof (sensor_t ));
0 commit comments