Merge pull request #3 from kunosee/master

add another function, which will return seaLevelPressure for a given height
This commit is contained in:
Kevin Townsend
2014-02-27 13:35:06 +08:00
2 changed files with 17 additions and 0 deletions

View File

@@ -364,6 +364,22 @@ float Adafruit_BMP085_Unified::pressureToAltitude(float seaLevel, float atmosphe
* (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

View File

@@ -99,6 +99,7 @@ class Adafruit_BMP085_Unified : public Adafruit_Sensor
void getTemperature(float *temp);
void getPressure(float *pressure);
float pressureToAltitude(float seaLevel, float atmospheric, float temp);
float seaLevelForAltitude(float altitude, float atmospheric, float temp);
void getEvent(sensors_event_t*);
void getSensor(sensor_t*);