Merge pull request #61 from 7eggert/master

Save 66 bytes by using integer arithmetric
This commit is contained in:
Paint Your Dragon 2019-01-11 16:05:29 -08:00 committed by GitHub
commit 5550a040c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,9 +45,7 @@ float DHT::readTemperature(bool S, bool force) {
break; break;
case DHT22: case DHT22:
case DHT21: case DHT21:
f = data[2] & 0x7F; f = ((word)(data[2] & 0x7F)) << 8 | data[3];
f *= 256;
f += data[3];
f *= 0.1; f *= 0.1;
if (data[2] & 0x80) { if (data[2] & 0x80) {
f *= -1; f *= -1;
@ -78,9 +76,7 @@ float DHT::readHumidity(bool force) {
break; break;
case DHT22: case DHT22:
case DHT21: case DHT21:
f = data[0]; f = ((word)data[0]) << 8 | data[1];
f *= 256;
f += data[1];
f *= 0.1; f *= 0.1;
break; break;
} }