4 Commits
1.2.1 ... 1.2.2

Author SHA1 Message Date
56058fecc5 Bump library to 1.2.2 version. 2015-10-12 18:39:28 -07:00
d71288af17 Merge branch 'jmdana-master' 2015-10-12 18:38:58 -07:00
ce3190f65c Switch back to integer division in array indexing. 2015-10-12 18:37:54 -07:00
5bc0a5c796 Divisions turned into multiplications
As correctly stated by Mausy5043, the division is quite slow in most
microcontrollers, so I have replaced them with multiplications.
2015-10-06 23:42:19 +01:00
2 changed files with 5 additions and 5 deletions

View File

@ -46,7 +46,7 @@ float DHT::readTemperature(bool S, bool force) {
f = data[2] & 0x7F; f = data[2] & 0x7F;
f *= 256; f *= 256;
f += data[3]; f += data[3];
f /= 10; f *= 0.1;
if (data[2] & 0x80) { if (data[2] & 0x80) {
f *= -1; f *= -1;
} }
@ -60,11 +60,11 @@ float DHT::readTemperature(bool S, bool force) {
} }
float DHT::convertCtoF(float c) { float DHT::convertCtoF(float c) {
return c * 9 / 5 + 32; return c * 1.8 + 32;
} }
float DHT::convertFtoC(float f) { float DHT::convertFtoC(float f) {
return (f - 32) * 5 / 9; return (f - 32) * 0.55555;
} }
float DHT::readHumidity(bool force) { float DHT::readHumidity(bool force) {
@ -79,7 +79,7 @@ float DHT::readHumidity(bool force) {
f = data[0]; f = data[0];
f *= 256; f *= 256;
f += data[1]; f += data[1];
f /= 10; f *= 0.1;
break; break;
} }
} }

View File

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