From 7674b8a629b2f94fcba4f3076a8f4e44f3b20c1a Mon Sep 17 00:00:00 2001 From: ltruelove Date: Sun, 17 Jul 2022 09:35:48 -0400 Subject: [PATCH 1/2] Add ability to change pin and type after instantion of DHT class --- DHT.cpp | 8 ++++++++ DHT.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/DHT.cpp b/DHT.cpp index a48ac74..a1b55d7 100644 --- a/DHT.cpp +++ b/DHT.cpp @@ -72,6 +72,14 @@ void DHT::begin(uint8_t usec) { pullTime = usec; } +void DHT::setPin(uint8_t newPin){ + _pin = newPin; +} + +void DHT::setType(uint8_t newType){ + _type = newType; +} + /*! * @brief Read temperature * @param S diff --git a/DHT.h b/DHT.h index 95570e1..09fc1d3 100644 --- a/DHT.h +++ b/DHT.h @@ -64,6 +64,8 @@ class DHT { public: DHT(uint8_t pin, uint8_t type, uint8_t count = 6); void begin(uint8_t usec = 55); + void setPin(uint8_t newPin); + void setType(uint8_t newType); float readTemperature(bool S = false, bool force = false); float convertCtoF(float); float convertFtoC(float); From d9f1e4e0593f0a7af9ca91ee96f859109384b227 Mon Sep 17 00:00:00 2001 From: ltruelove Date: Sun, 17 Jul 2022 09:43:59 -0400 Subject: [PATCH 2/2] Add comments to the new methods --- DHT.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/DHT.cpp b/DHT.cpp index a1b55d7..bb770bd 100644 --- a/DHT.cpp +++ b/DHT.cpp @@ -72,10 +72,20 @@ void DHT::begin(uint8_t usec) { pullTime = usec; } +/*! + * @brief Sets the _pin property value + * @param newPin + * pin number that sensor is connected + */ void DHT::setPin(uint8_t newPin){ _pin = newPin; } +/*! + * @brief Sets the _type property value + * @param newType + * type of sensor + */ void DHT::setType(uint8_t newType){ _type = newType; }