mirror of
https://github.com/adafruit/DHT-sensor-library.git
synced 2023-10-23 22:20:38 +03:00
Merge pull request #52 from Spacefish/master
Use MIN_INTERVAL define instead of hardcoded value
This commit is contained in:
commit
dc71b006b6
4
DHT.cpp
4
DHT.cpp
@ -27,7 +27,7 @@ void DHT::begin(void) {
|
|||||||
// Using this value makes sure that millis() - lastreadtime will be
|
// Using this value makes sure that millis() - lastreadtime will be
|
||||||
// >= MIN_INTERVAL right away. Note that this assignment wraps around,
|
// >= MIN_INTERVAL right away. Note that this assignment wraps around,
|
||||||
// but so will the subtraction.
|
// but so will the subtraction.
|
||||||
_lastreadtime = -MIN_INTERVAL;
|
_lastreadtime = millis()-MIN_INTERVAL;
|
||||||
DEBUG_PRINT("Max clock cycles: "); DEBUG_PRINTLN(_maxcycles, DEC);
|
DEBUG_PRINT("Max clock cycles: "); DEBUG_PRINTLN(_maxcycles, DEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ boolean DHT::read(bool force) {
|
|||||||
// Check if sensor was read less than two seconds ago and return early
|
// Check if sensor was read less than two seconds ago and return early
|
||||||
// to use last reading.
|
// to use last reading.
|
||||||
uint32_t currenttime = millis();
|
uint32_t currenttime = millis();
|
||||||
if (!force && ((currenttime - _lastreadtime) < 2000)) {
|
if (!force && ((currenttime - _lastreadtime) < MIN_INTERVAL)) {
|
||||||
return _lastresult; // return last correct measurement
|
return _lastresult; // return last correct measurement
|
||||||
}
|
}
|
||||||
_lastreadtime = currenttime;
|
_lastreadtime = currenttime;
|
||||||
|
Loading…
Reference in New Issue
Block a user