fix issue with delayMicroseconds > 16000

This commit is contained in:
RobTillaart 2017-03-06 21:10:50 +01:00
parent 4a301a8804
commit 02cc2c5420
4 changed files with 9 additions and 15 deletions

View File

@ -1,11 +1,12 @@
//
// FILE: dht.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.21
// VERSION: 0.1.22
// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino
// URL: http://arduino.cc/playground/Main/DHTLib
//
// HISTORY:
// 0.1.22 undo delayMicroseconds() for wakeups larger than 8
// 0.1.21 replace delay with delayMicroseconds() + small fix
// 0.1.20 Reduce footprint by using uint8_t as error codes. (thanks to chaveiro)
// 0.1.19 masking error for DHT11 - FIXED (thanks Richard for noticing)
@ -123,7 +124,8 @@ int8_t dht::_readSensor(uint8_t pin, uint8_t wakeupDelay, uint8_t leadingZeroBit
// REQUEST SAMPLE
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW); // T-be
delayMicroseconds(wakeupDelay * 1000UL);
if (wakeupDelay > 8) delay(wakeupDelay);
else delayMicroseconds(wakeupDelay * 1000UL);
digitalWrite(pin, HIGH); // T-go
pinMode(pin, INPUT);
@ -196,4 +198,4 @@ int8_t dht::_readSensor(uint8_t pin, uint8_t wakeupDelay, uint8_t leadingZeroBit
}
//
// END OF FILE
//
//

View File

@ -1,7 +1,7 @@
//
// FILE: dht.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.21
// VERSION: 0.1.22
// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino
// URL: http://arduino.cc/playground/Main/DHTLib
//
@ -19,7 +19,7 @@
#include <Arduino.h>
#endif
#define DHT_LIB_VERSION "0.1.21"
#define DHT_LIB_VERSION "0.1.22"
#define DHTLIB_OK 0
#define DHTLIB_ERROR_CHECKSUM -1

View File

@ -2,21 +2,13 @@
"name": "DHTlib",
"keywords": "DHT11 DHT22 DHT33 DHT44 AM2301 AM2302 AM2303",
"description": "Optimized Library for DHT Temperature & Humidity Sensor on AVR only.",
"authors":
[
{
"name": "Rob Tillaart",
"email": "Rob.Tillaart@gmail.com",
"maintainer": true
}
],
"repository":
{
"type": "git",
"url": "https://github.com/RobTillaart/Arduino.git"
},
"frameworks": "arduino",
"platforms": "atmelavr",
"platforms": "*",
"export": {
"include": "libraries/DHTlib"
}

View File

@ -1,5 +1,5 @@
name=DHTlib
version=0.1.21
version=0.1.22
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Optimized Library for DHT Temperature & Humidity Sensor on AVR only.