diff --git a/DHT.cpp b/DHT.cpp index ec57de5..86ad91c 100644 --- a/DHT.cpp +++ b/DHT.cpp @@ -11,8 +11,10 @@ written by Adafruit Industries DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) { _pin = pin; _type = type; - _bit = digitalPinToBitMask(pin); - _port = digitalPinToPort(pin); + #ifdef __AVR + _bit = digitalPinToBitMask(pin); + _port = digitalPinToPort(pin); + #endif _maxcycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for // reading pulses from DHT sensor. // Note that count is now ignored as the DHT reading algorithm adjusts itself @@ -95,7 +97,7 @@ float DHT::computeHeatIndex(float temperature, float percentHumidity, bool isFah if (!isFahrenheit) temperature = convertCtoF(temperature); - hi = 0.5 * (temperature + 61.0 + ((temperature - 68.0) * 1.2) + (percentHumidity * 0.094)); + hi = 0.5 * (temperature + 61.0 + ((temperature - 68.0) * 1.2) + (percentHumidity * 0.094)); if (hi > 79) { hi = -42.379 + diff --git a/DHT.h b/DHT.h index 5d92f06..d81f6db 100644 --- a/DHT.h +++ b/DHT.h @@ -48,7 +48,12 @@ class DHT { private: uint8_t data[5]; - uint8_t _pin, _type, _bit, _port; + uint8_t _pin, _type; + #ifdef __AVR + // Use direct GPIO access on an 8-bit AVR so keep track of the port and bitmask + // for the digital pin connected to the DHT. Other platforms will use digitalRead. + uint8_t _bit, _port; + #endif uint32_t _lastreadtime, _maxcycles; bool _lastresult; diff --git a/library.properties b/library.properties index 5c004e5..c85a332 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=DHT sensor library -version=1.2.2 +version=1.2.3 author=Adafruit maintainer=Adafruit sentence=Arduino library for DHT11, DHT22, etc Temp & Humidity Sensors