Update librairies
This commit is contained in:
@@ -20,7 +20,13 @@
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
#include <Wire.h>
|
||||
#ifdef __AVR_ATtiny85__
|
||||
#include "TinyWireM.h"
|
||||
#define Wire TinyWireM
|
||||
#else
|
||||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
@@ -206,6 +212,18 @@ static void readRawPressure(int32_t *pressure)
|
||||
#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
|
||||
***************************************************************************/
|
||||
@@ -272,9 +290,7 @@ void Adafruit_BMP085_Unified::getPressure(float *pressure)
|
||||
readRawPressure(&up);
|
||||
|
||||
/* Temperature compensation */
|
||||
x1 = (ut - (int32_t)(_bmp085_coeffs.ac6))*((int32_t)(_bmp085_coeffs.ac5))/pow(2,15);
|
||||
x2 = ((int32_t)(_bmp085_coeffs.mc*pow(2,11)))/(x1+(int32_t)(_bmp085_coeffs.md));
|
||||
b5 = x1 + x2;
|
||||
b5 = computeB5(ut);
|
||||
|
||||
/* Pressure compensation */
|
||||
b6 = b5 - 4000;
|
||||
@@ -327,11 +343,8 @@ void Adafruit_BMP085_Unified::getTemperature(float *temp)
|
||||
_bmp085_coeffs.md = 2868;
|
||||
#endif
|
||||
|
||||
// step 1
|
||||
X1 = (UT - (int32_t)_bmp085_coeffs.ac6) * ((int32_t)_bmp085_coeffs.ac5) / pow(2,15);
|
||||
X2 = ((int32_t)_bmp085_coeffs.mc * pow(2,11)) / (X1+(int32_t)_bmp085_coeffs.md);
|
||||
B5 = X1 + X2;
|
||||
t = (B5+8)/pow(2,4);
|
||||
B5 = computeB5(UT);
|
||||
t = (B5+8) >> 4;
|
||||
t /= 10;
|
||||
|
||||
*temp = t;
|
||||
@@ -340,7 +353,7 @@ void Adafruit_BMP085_Unified::getTemperature(float *temp)
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
Calculates the altitude (in meters) from the specified atmospheric
|
||||
pressure (in hPa), sea-level pressure (in hPa), and temperature (in <20>C)
|
||||
pressure (in hPa), sea-level pressure (in hPa), and temperature (in <20>C)
|
||||
|
||||
@param seaLevel Sea-level pressure in hPa
|
||||
@param atmospheric Atmospheric pressure in hPa
|
||||
@@ -358,12 +371,28 @@ float Adafruit_BMP085_Unified::pressureToAltitude(float seaLevel, float atmosphe
|
||||
/* where: h = height (in meters) */
|
||||
/* P0 = sea-level pressure (in hPa) */
|
||||
/* P = atmospheric pressure (in hPa) */
|
||||
/* T = temperature (in <20>C) */
|
||||
/* T = temperature (in <20>C) */
|
||||
|
||||
return (((float)pow((seaLevel/atmospheric), 0.190223F) - 1.0F)
|
||||
* (temp + 273.15F)) / 0.0065F;
|
||||
}
|
||||
|
||||
float Adafruit_BMP085_Unified::seaLevelForAltitude(float altitude, float atmospheric, float temp)
|
||||
{
|
||||
/* Hyposometric formula: */
|
||||
/* */
|
||||
/* P0=((((h*0.0065)/(temp + 273.15F))+1)^(^/0.190223F))*P */
|
||||
/* */
|
||||
/* where: h = height (in meters) */
|
||||
/* P0 = sea-level pressure (in hPa) */
|
||||
/* P = atmospheric pressure (in hPa) */
|
||||
/* T = temperature (in <20>C) */
|
||||
|
||||
return (float)pow((((altitude*0.0065)/(temp + 273.15F))+1), (1.0/0.190223F))*atmospheric;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Provides the sensor_t data for this sensor
|
||||
@@ -403,5 +432,5 @@ void Adafruit_BMP085_Unified::getEvent(sensors_event_t *event)
|
||||
event->type = SENSOR_TYPE_PRESSURE;
|
||||
event->timestamp = 0;
|
||||
getPressure(&pressure_kPa);
|
||||
event->pressure = pressure_kPa / 100.0F; /* kPa to hPa */
|
||||
event->pressure = pressure_kPa / 100.0F;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user