Skip to content

Commit bdd2756

Browse files
Fix computeHeatIndex declaration, check F_CPU in expectPulse
1 parent 07da1cd commit bdd2756

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

DHT.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,15 @@ float DHT::readHumidity(bool force) {
9292
}
9393

9494
//boolean isFahrenheit: True == Fahrenheit; False == Celcius
95-
float DHT::computeHeatIndex(isFahrenheit) {
96-
float hi = self.computeHeatIndex(self.readTemperature(isFahrenheit), self.readHumidity(), isFahrenheit);
95+
float DHT::computeHeatIndex(bool isFahrenheit) {
96+
float hi = computeHeatIndex(readTemperature(isFahrenheit), readHumidity(),
97+
isFahrenheit);
9798
return isFahrenheit ? hi : convertFtoC(hi);
9899
}
99100

100101
//boolean isFahrenheit: True == Fahrenheit; False == Celcius
101-
float DHT::computeHeatIndex(float temperature, floast percentHumidity, bool isFahrenheit) {
102+
float DHT::computeHeatIndex(float temperature, float percentHumidity,
103+
bool isFahrenheit) {
102104
// Using both Rothfusz and Steadman's equations
103105
// http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
104106
float hi;
@@ -243,7 +245,11 @@ bool DHT::read(bool force) {
243245
// in the very latest IDE versions):
244246
// https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring_pulse.c
245247
uint32_t DHT::expectPulse(bool level) {
246-
uint16_t count = 0;
248+
#if (F_CPU > 16000000L)
249+
uint32_t count = 0;
250+
#else
251+
uint16_t count = 0; // To work fast enough on slower AVR boards
252+
#endif
247253
// On AVR platforms use direct GPIO port access as it's much faster and better
248254
// for catching pulses that are 10's of microseconds in length:
249255
#ifdef __AVR

0 commit comments

Comments
 (0)