forked from adafruit/DHT-sensor-library
Implement proper pin number type
This commit is contained in:
2
DHT.cpp
2
DHT.cpp
@ -43,7 +43,7 @@ constexpr const auto MIN_INTERVAL = 2s; /**< min interval value */
|
|||||||
* @param count
|
* @param count
|
||||||
* number of sensors
|
* number of sensors
|
||||||
*/
|
*/
|
||||||
DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) :
|
DHT::DHT(gpio_num_t pin, uint8_t type, uint8_t count) :
|
||||||
_pin{pin},
|
_pin{pin},
|
||||||
_type{type},
|
_type{type},
|
||||||
#ifdef __AVR
|
#ifdef __AVR
|
||||||
|
16
DHT.h
16
DHT.h
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include <espchrono.h>
|
#include <espchrono.h>
|
||||||
|
|
||||||
|
#include <hal/gpio_types.h>
|
||||||
|
|
||||||
/* Uncomment to enable printing out nice debug messages. */
|
/* Uncomment to enable printing out nice debug messages. */
|
||||||
//#define DHT_DEBUG
|
//#define DHT_DEBUG
|
||||||
|
|
||||||
@ -46,11 +48,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define types of sensors. */
|
/* Define types of sensors. */
|
||||||
#define DHT11 11 /**< DHT TYPE 11 */
|
constexpr const uint8_t DHT11 = 11; /**< DHT TYPE 11 */
|
||||||
#define DHT12 12 /**< DHY TYPE 12 */
|
constexpr const uint8_t DHT12 = 12; /**< DHY TYPE 12 */
|
||||||
#define DHT22 22 /**< DHT TYPE 22 */
|
constexpr const uint8_t DHT22 = 22; /**< DHT TYPE 22 */
|
||||||
#define DHT21 21 /**< DHT TYPE 21 */
|
constexpr const uint8_t DHT21 = 21; /**< DHT TYPE 21 */
|
||||||
#define AM2301 21 /**< AM2301 */
|
constexpr const uint8_t AM2301 = 21; /**< AM2301 */
|
||||||
|
|
||||||
#if defined(TARGET_NAME) && (TARGET_NAME == ARDUINO_NANO33BLE)
|
#if defined(TARGET_NAME) && (TARGET_NAME == ARDUINO_NANO33BLE)
|
||||||
#ifndef microsecondsToClockCycles
|
#ifndef microsecondsToClockCycles
|
||||||
@ -67,7 +69,7 @@
|
|||||||
*/
|
*/
|
||||||
class DHT {
|
class DHT {
|
||||||
public:
|
public:
|
||||||
DHT(uint8_t pin, uint8_t type, uint8_t count = 6);
|
DHT(gpio_num_t pin, uint8_t type, uint8_t count = 6);
|
||||||
|
|
||||||
bool begin(uint8_t usec = 55);
|
bool begin(uint8_t usec = 55);
|
||||||
|
|
||||||
@ -87,7 +89,7 @@ public:
|
|||||||
const std::optional<std::array<uint8_t, 5>> &read(bool force = false);
|
const std::optional<std::array<uint8_t, 5>> &read(bool force = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const uint8_t _pin;
|
const gpio_num_t _pin;
|
||||||
const uint8_t _type;
|
const uint8_t _type;
|
||||||
#ifdef __AVR
|
#ifdef __AVR
|
||||||
// Use direct GPIO access on an 8-bit AVR so keep track of the port and
|
// Use direct GPIO access on an 8-bit AVR so keep track of the port and
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
* @param humiditySensorId
|
* @param humiditySensorId
|
||||||
* humidity sensor id
|
* humidity sensor id
|
||||||
*/
|
*/
|
||||||
DHT_Unified::DHT_Unified(uint8_t pin, uint8_t type, uint8_t count,
|
DHT_Unified::DHT_Unified(gpio_num_t pin, uint8_t type, uint8_t count,
|
||||||
int32_t tempSensorId, int32_t humiditySensorId)
|
int32_t tempSensorId, int32_t humiditySensorId)
|
||||||
: _dht(pin, type, count), _type(type), _temp(this, tempSensorId),
|
: _dht(pin, type, count), _type(type), _temp(this, tempSensorId),
|
||||||
_humidity(this, humiditySensorId) {}
|
_humidity(this, humiditySensorId) {}
|
||||||
|
2
DHT_U.h
2
DHT_U.h
@ -44,7 +44,7 @@
|
|||||||
*/
|
*/
|
||||||
class DHT_Unified {
|
class DHT_Unified {
|
||||||
public:
|
public:
|
||||||
DHT_Unified(uint8_t pin, uint8_t type, uint8_t count = 6,
|
DHT_Unified(gpio_num_t pin, uint8_t type, uint8_t count = 6,
|
||||||
int32_t tempSensorId = -1, int32_t humiditySensorId = -1);
|
int32_t tempSensorId = -1, int32_t humiditySensorId = -1);
|
||||||
bool begin();
|
bool begin();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user