1
Revision 1:2df36c637051, committed 2019-10-01
- Comitter:
- 3874313
- Date:
- Tue Oct 01 15:01:46 2019 +0000
- Parent:
- 0:9b5b3200688f
- Commit message:
- utilisation de float;
Changed in this revision
DHT.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9b5b3200688f -r 2df36c637051 DHT.cpp --- a/DHT.cpp Mon Jul 09 19:47:43 2012 +0000 +++ b/DHT.cpp Tue Oct 01 15:01:46 2019 +0000 @@ -148,7 +148,7 @@ } float DHT::CalcTemperature() { - int v; + float v; switch (_DHTtype) { case DHT11: @@ -156,9 +156,9 @@ return float(v); case DHT22: v = DHT_data[2] & 0x7F; - v *= 256; + v *= 256.0f; v += DHT_data[3]; - v /= 10; + v /= 10.0f; if (DHT_data[2] & 0x80) v *= -1; return float(v); @@ -214,7 +214,7 @@ } float DHT::CalcHumidity() { - int v; + float v; switch (_DHTtype) { case DHT11: @@ -222,9 +222,9 @@ return float(v); case DHT22: v = DHT_data[0]; - v *= 256; + v *= 256.0f; v += DHT_data[1]; - v /= 10; + v /= 10.0f; return float(v); } return 0;