Permalink
Browse files

sign fix

  • Loading branch information...
1 parent cc425e9 commit 219c1ae925fe25702bb342b2efbdc9f110fe6389 @ladyada ladyada committed Jun 15, 2012
Showing with 10 additions and 5 deletions.
  1. +10 −5 Adafruit_MAX31855.cpp
View
@@ -54,7 +54,7 @@ double Adafruit_MAX31855::readInternal(void) {
double Adafruit_MAX31855::readCelsius(void) {
- uint32_t v;
+ int32_t v;
v = spiread32();
@@ -78,13 +78,18 @@ double Adafruit_MAX31855::readCelsius(void) {
//Serial.println(v, HEX);
// pull the bottom 13 bits off
- double temp = v & 0x1FFF;
+ int16_t temp = v & 0x3FFF;
+
// check sign bit
if (v & 0x2000)
- temp *= -1;
+ temp |= 0xC000;
+ //Serial.println(temp);
+
+ double centigrade = v;
+
// LSB = 0.25 degrees C
- temp *= 0.25;
- return temp;
+ centigrade *= 0.25;
+ return centigrade;
}
uint8_t Adafruit_MAX31855::readError() {

0 comments on commit 219c1ae

Please sign in to comment.