BMP180用ライブラリ
Dependents: 2017_11_1768 2017_11_1768 201803_oshima_jodan 201803_oshima_gedan
Fork of BMP180 by
Diff: BMP180.h
- Revision:
- 2:5230f93e755b
- Parent:
- 1:072073c79cfd
diff -r 072073c79cfd -r 5230f93e755b BMP180.h --- a/BMP180.h Mon Mar 17 20:42:23 2014 +0000 +++ b/BMP180.h Mon Nov 21 15:20:42 2016 +0000 @@ -1,18 +1,4 @@ -/* - @file BMP180.h - - @brief Barometric Pressure and Temperature Sensor BMP180 Breakout I2C Library - @Author spiridion (http://mailme.spiridion.net) - - Tested on LPC1768 and FRDM-KL25Z - - Copyright (c) 2014 spiridion - Released under the MIT License (see http://mbed.org/license/mit) - - Documentation regarding the BMP180 can be found here: - http://mbed.org/media/uploads/spiridion/bst-bmp180-ds000-09.pdf -*/ #ifndef BMP180_H #define BMP180_H @@ -31,108 +17,22 @@ #define UNSET_BMP180_PRESSURE_VALUE 0.F #define UNSET_BMP180_TEMPERATURE_VALUE -273.15F // absolute zero -/** BMP180 class. - * Read Pressure and temperature from the BMP180 Breakout I2C sensor - * - * Example: - * @code - * #include "mbed.h" - * #include "BMP180.h" - * - * #if defined(TARGET_LPC1768) - * #define PIN_SDA p9 - * #define PIN_SCL p10 - * #elif defined(TARGET_KL25Z) // watch out for the PTE0/PTE1 mixed up in the KL25Z doc - * #define PIN_SDA PTE0 - * #define PIN_SCL PTE1 - * #endif - * - * int main() - * { - * BMP180 bmp180(PIN_SDA, PIN_SCL); - * float pressure, temperature; - * - * // bmp180.Initialize(); // no altitude compensation and normal oversampling - * bmp180.Initialize(64, BMP180_OSS_ULTRA_LOW_POWER); // 64m altitude compensation and low power oversampling - * - * while(1) - * { - * if (bmp180.ReadData(&pressure, &temperature)) - * printf("Pressure(hPa): %8.2f \t Temperature(C): %8.2f\n", pressure, temperature); - * wait(1); - * } - * } - * @endcode - */ class BMP180 { public: - - /** Create a BMP180 instance - * @param sda pin - * @param scl pin - * @param address: I2C slave address - */ BMP180(PinName sda, PinName scl, int address = BMP180_I2C_ADDRESS); - - /** Create a BMP180 instance - * @param i2c object - * @param address: I2C slave address - */ BMP180(I2C& i2c, int address = BMP180_I2C_ADDRESS); - - /** Initialization: set member values and read BMP180 calibration parameters - * @param altitude (in meter) - * @param overSamplingSetting - */ int Initialize(float altitude = 0.F, int overSamplingSetting = BMP180_OSS_NORMAL); - - /** Read pressure and temperature from the BMP180. - * @param pressure (hPa) - * @param temperature (C) - * @returns - * 1 on success, - * 0 on error - */ int ReadData(float* pTemperature = NULL, float* pPressure = NULL); - - /** Get temperature from a previous measurement - * - * @returns - * temperature (C) - */ float GetTemperature() {return m_temperature;}; - - /** Get pressure from a previous measurement - * - * @returns - * pressure (hPa) - */ float GetPressure() {return m_pressure;}; protected: - /** Perform temperature measurement - * - * @returns - * temperature (C) - */ int ReadRawTemperature(long* pUt); - - /** Perform pressure measurement - * - * @returns - * temperature (C) - */ int ReadRawPressure(long* pUp); - - /** Calculation of the temperature from the digital output - */ float TrueTemperature(long ut); - - /** Calculation of the pressure from the digital output - */ float TruePressure(long up); int m_oss;