DHT_U doxygen

This commit is contained in:
Jan Hoffmann 2019-07-04 17:28:10 +02:00
parent dd455428a0
commit c76d42e280
2 changed files with 80 additions and 21 deletions

View File

@ -1,26 +1,32 @@
// DHT Temperature & Humidity Unified Sensor Library /*!
// Copyright (c) 2014 Adafruit Industries * @file DHT_U.cpp
// Author: Tony DiCola *
* Temperature & Humidity Unified Sensor Library
// Permission is hereby granted, free of charge, to any person obtaining a copy *
// of this software and associated documentation files (the "Software"), to deal * This is a library for DHT series of low cost temperature/humidity sensors.
// in the Software without restriction, including without limitation the rights *
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * You must have Adafruit Unified Sensor Library library installed to use this
// copies of the Software, and to permit persons to whom the Software is * class.
// furnished to do so, subject to the following conditions: *
* Adafruit invests time and resources providing this open source code,
// The above copyright notice and this permission notice shall be included in all * please support Adafruit andopen-source hardware by purchasing products
// copies or substantial portions of the Software. * from Adafruit!
*/
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "DHT_U.h" #include "DHT_U.h"
/*!
* @brief Instantiates a new DHT_Unified class
* @param pin
* pin number that sensor is connected
* @param type
* type of sensor
* @param count
* number of sensors
* @param tempSensorId
* temperature sensor id
* @param humiditySensorId
* humidity sensor id
*/
DHT_Unified::DHT_Unified(uint8_t pin, uint8_t type, uint8_t count, int32_t tempSensorId, int32_t humiditySensorId): DHT_Unified::DHT_Unified(uint8_t pin, uint8_t type, uint8_t count, int32_t tempSensorId, int32_t humiditySensorId):
_dht(pin, type, count), _dht(pin, type, count),
_type(type), _type(type),
@ -28,10 +34,18 @@ DHT_Unified::DHT_Unified(uint8_t pin, uint8_t type, uint8_t count, int32_t tempS
_humidity(this, humiditySensorId) _humidity(this, humiditySensorId)
{} {}
/*!
* @brief Setup sensor (calls begin on It)
*/
void DHT_Unified::begin() { void DHT_Unified::begin() {
_dht.begin(); _dht.begin();
} }
/*!
* @brief Sets sensor name
* @param sensor
* Sensor that will be set
*/
void DHT_Unified::setName(sensor_t* sensor) { void DHT_Unified::setName(sensor_t* sensor) {
switch(_type) { switch(_type) {
case DHT11: case DHT11:
@ -55,6 +69,11 @@ void DHT_Unified::setName(sensor_t* sensor) {
sensor->name[sizeof(sensor->name)- 1] = 0; sensor->name[sizeof(sensor->name)- 1] = 0;
} }
/*!
* @brief Sets Minimum Delay Value
* @param sensor
* Sensor that will be set
*/
void DHT_Unified::setMinDelay(sensor_t* sensor) { void DHT_Unified::setMinDelay(sensor_t* sensor) {
switch(_type) { switch(_type) {
case DHT11: case DHT11:
@ -76,11 +95,23 @@ void DHT_Unified::setMinDelay(sensor_t* sensor) {
} }
} }
/*!
* @brief Instantiates a new DHT_Unified Temperature Class
* @param parent
* Parent Sensor
* @param id
* Sensor id
*/
DHT_Unified::Temperature::Temperature(DHT_Unified* parent, int32_t id): DHT_Unified::Temperature::Temperature(DHT_Unified* parent, int32_t id):
_parent(parent), _parent(parent),
_id(id) _id(id)
{} {}
/*!
* @brief Reads the sensor and returns the data as a sensors_event_t
* @param event
* @return always returns true
*/
bool DHT_Unified::Temperature::getEvent(sensors_event_t* event) { bool DHT_Unified::Temperature::getEvent(sensors_event_t* event) {
// Clear event definition. // Clear event definition.
memset(event, 0, sizeof(sensors_event_t)); memset(event, 0, sizeof(sensors_event_t));
@ -94,6 +125,10 @@ bool DHT_Unified::Temperature::getEvent(sensors_event_t* event) {
return true; return true;
} }
/*!
* @brief Provides the sensor_t data for this sensor
* @param sensor
*/
void DHT_Unified::Temperature::getSensor(sensor_t* sensor) { void DHT_Unified::Temperature::getSensor(sensor_t* sensor) {
// Clear sensor definition. // Clear sensor definition.
memset(sensor, 0, sizeof(sensor_t)); memset(sensor, 0, sizeof(sensor_t));
@ -135,11 +170,23 @@ void DHT_Unified::Temperature::getSensor(sensor_t* sensor) {
} }
} }
/*!
* @brief Instantiates a new DHT_Unified Humidity Class
* @param parent
* Parent Sensor
* @param id
* Sensor id
*/
DHT_Unified::Humidity::Humidity(DHT_Unified* parent, int32_t id): DHT_Unified::Humidity::Humidity(DHT_Unified* parent, int32_t id):
_parent(parent), _parent(parent),
_id(id) _id(id)
{} {}
/*!
* @brief Reads the sensor and returns the data as a sensors_event_t
* @param event
* @return always returns true
*/
bool DHT_Unified::Humidity::getEvent(sensors_event_t* event) { bool DHT_Unified::Humidity::getEvent(sensors_event_t* event) {
// Clear event definition. // Clear event definition.
memset(event, 0, sizeof(sensors_event_t)); memset(event, 0, sizeof(sensors_event_t));
@ -153,6 +200,10 @@ bool DHT_Unified::Humidity::getEvent(sensors_event_t* event) {
return true; return true;
} }
/*!
* @brief Provides the sensor_t data for this sensor
* @param sensor
*/
void DHT_Unified::Humidity::getSensor(sensor_t* sensor) { void DHT_Unified::Humidity::getSensor(sensor_t* sensor) {
// Clear sensor definition. // Clear sensor definition.
memset(sensor, 0, sizeof(sensor_t)); memset(sensor, 0, sizeof(sensor_t));

View File

@ -76,8 +76,16 @@ public:
int32_t _id; int32_t _id;
}; };
/*!
* @brief Returns temperature stored in _temp
* @return Temperature value
*/
Temperature temperature() { return _temp; } Temperature temperature() { return _temp; }
/*!
* @brief Returns humidity stored in _humidity
* @return Humidity value
*/
Humidity humidity() { return _humidity; } Humidity humidity() { return _humidity; }
private: private: