I2C Temprature Sensor Progemm MPL3115A2
Dependents: I2C_Temprature_raspiboard
Fork of MPL3115A2 by
Diff: Pressure.h
- Revision:
- 3:7c7c1ea6fc33
- Parent:
- 0:beb43bc3d6d4
diff -r 2ebc9c0d4a54 -r 7c7c1ea6fc33 Pressure.h --- a/Pressure.h Wed Apr 02 12:22:45 2014 +0000 +++ b/Pressure.h Wed Apr 02 12:59:44 2014 +0000 @@ -14,11 +14,17 @@ #include "mbed.h" +//! Pressure provides a wrapper around barometric data coming from the sensor. The class handles +//! working with compressed data from the sensor and provides convenient functions for retreiving +//! the data in various units (with room to add more if needed). class Pressure { public: + //! The size of the compressed data buffer from the sensor. Used in an I2C read. static const int size = 3; + + //! The units we support converting the sensor data to. enum unitsType { PASCALS, PSI, INHG, MMHG }; Pressure(); @@ -26,15 +32,19 @@ Pressure(const char* compressed); Pressure(const char msb, const char csb, const char lsb); + //! Allows using the object directly in an I2C read operation. operator char*(void) { return _compressed; } + //! Same as calling pressure with PASCALS as the parameter. operator float(void) { return _pressure; } float pressure(unitsType units = PASCALS); + //! Call to decompress the sensor data after an I2C read. void setPressure(); void setPressure(const char* compressed); void setPressure(const char msb, const char csb, const char lsb); void setPressure(float a, unitsType units = PASCALS); + //! Returns the pressure as a string in the units specified, defaulting to PASCAL if none specified. const char* print(unitsType units = PASCALS); private: