Fix #44 by conditionally excluding unused port and bitmask state on non-AVR platforms.

This commit is contained in:
Tony DiCola 2015-10-12 21:30:01 -07:00
parent 56058fecc5
commit 15020aa891
3 changed files with 12 additions and 5 deletions

View File

@ -11,8 +11,10 @@ written by Adafruit Industries
DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) {
_pin = pin;
_type = type;
#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

7
DHT.h
View File

@ -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;

View File

@ -1,5 +1,5 @@
name=DHT sensor library
version=1.2.2
version=1.2.3
author=Adafruit
maintainer=Adafruit <info@adafruit.com>
sentence=Arduino library for DHT11, DHT22, etc Temp & Humidity Sensors