mirror of
https://github.com/adafruit/Adafruit_BMP085_Unified.git
synced 2025-07-31 09:27:15 +02:00
Merge pull request #8 from adafruit/merge_bmp85_fixes
Make temperature & pressure calculation code consistent with non-unified library.
This commit is contained in:
@ -212,6 +212,18 @@ static void readRawPressure(int32_t *pressure)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Compute B5 coefficient used in temperature & pressure calcs.
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
int32_t Adafruit_BMP085_Unified::computeB5(int32_t ut) {
|
||||||
|
int32_t X1 = (ut - (int32_t)_bmp085_coeffs.ac6) * ((int32_t)_bmp085_coeffs.ac5) >> 15;
|
||||||
|
int32_t X2 = ((int32_t)_bmp085_coeffs.mc << 11) / (X1+(int32_t)_bmp085_coeffs.md);
|
||||||
|
return X1 + X2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
CONSTRUCTOR
|
CONSTRUCTOR
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
@ -278,9 +290,7 @@ void Adafruit_BMP085_Unified::getPressure(float *pressure)
|
|||||||
readRawPressure(&up);
|
readRawPressure(&up);
|
||||||
|
|
||||||
/* Temperature compensation */
|
/* Temperature compensation */
|
||||||
x1 = (ut - (int32_t)(_bmp085_coeffs.ac6))*((int32_t)(_bmp085_coeffs.ac5))/pow(2,15);
|
b5 = computeB5(ut);
|
||||||
x2 = ((int32_t)(_bmp085_coeffs.mc*pow(2,11)))/(x1+(int32_t)(_bmp085_coeffs.md));
|
|
||||||
b5 = x1 + x2;
|
|
||||||
|
|
||||||
/* Pressure compensation */
|
/* Pressure compensation */
|
||||||
b6 = b5 - 4000;
|
b6 = b5 - 4000;
|
||||||
@ -333,11 +343,8 @@ void Adafruit_BMP085_Unified::getTemperature(float *temp)
|
|||||||
_bmp085_coeffs.md = 2868;
|
_bmp085_coeffs.md = 2868;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// step 1
|
B5 = computeB5(UT);
|
||||||
X1 = (UT - (int32_t)_bmp085_coeffs.ac6) * ((int32_t)_bmp085_coeffs.ac5) / pow(2,15);
|
t = (B5+8) >> 4;
|
||||||
X2 = ((int32_t)_bmp085_coeffs.mc * pow(2,11)) / (X1+(int32_t)_bmp085_coeffs.md);
|
|
||||||
B5 = X1 + X2;
|
|
||||||
t = (B5+8)/pow(2,4);
|
|
||||||
t /= 10;
|
t /= 10;
|
||||||
|
|
||||||
*temp = t;
|
*temp = t;
|
||||||
|
@ -110,7 +110,8 @@ class Adafruit_BMP085_Unified : public Adafruit_Sensor
|
|||||||
void getSensor(sensor_t*);
|
void getSensor(sensor_t*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32_t _sensorID;
|
int32_t computeB5(int32_t ut);
|
||||||
|
int32_t _sensorID;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user