Fixed temp calculations (thanks sanelss)

This commit is contained in:
Kevin Townsend committed 2012-12-27 17:08:11 +01:00
1 parent f4f02f46eb
commit 4802c1b8d3
1 file changed
+7 -8
+7 -8
View File
@@ -130,10 +130,9 @@ int32_t Adafruit_BMP085::readPressure(void) {
#endif
// do temperature calculations
X1 = ((UT - (int32_t)ac6) * (int32_t)ac5) >> 15;
X2 = ((int32_t)mc << 11) - (X1 + md)/2; // round up
X2 /= (X1 + md);
B5 = X1 + X2;
X1=(UT-(int32_t)(ac6))*((int32_t)(ac5))/pow(2,15);
X2=((int32_t)mc*pow(2,11))/(X1+(int32_t)md);
B5=X1 + X2;
#if BMP085_DEBUG == 1
Serial.print("X1 = "); Serial.println(X1);
@@ -207,12 +206,12 @@ float Adafruit_BMP085::readTemperature(void) {
#endif
// step 1
X1 = ((UT - (int32_t)ac6) * (int32_t)ac5) >> 15;
X2 = ((int32_t)mc << 11) / (X1 + (int32_t)md);
X1 = (UT - (int32_t)ac6) * ((int32_t)ac5) / pow(2,15);
X2 = ((int32_t)mc * pow(2,11)) / (X1+(int32_t)md);
B5 = X1 + X2;
temp = (B5 + 8) >> 4;
temp = (B5+8)/pow(2,4);
temp /= 10;
return temp;
}