Kaynağa Gözat

Merge pull request #7 from danwahl/temp

fixed sign issue with temperature reading
deanm1278 8 yıl önce
ebeveyn
işleme
847270a9ca
1 değiştirilmiş dosya ile 4 ekleme ve 0 silme
  1. 4 0
      Adafruit_MPL3115A2.cpp

+ 4 - 0
Adafruit_MPL3115A2.cpp

@@ -192,6 +192,10 @@ float Adafruit_MPL3115A2::getTemperature() {
   t <<= 8;
   t |= _i2c->read(); // receive DATA
   t >>= 4;
+  
+  if (t & 0x800) {
+    t |= 0xF000;
+  }
 
   float temp = t;
   temp /= 16.0;