Forked Changes to Pressure sensor

Dependents:   WiFiDipCortexSensor

Fork of MPL3115A2 by Michael Lange

Revision:
0:beb43bc3d6d4
Child:
3:7c7c1ea6fc33
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Pressure.h	Tue Apr 01 21:35:23 2014 +0000
@@ -0,0 +1,46 @@
+/*
+    MPL3115A2 Barometric Pressure and Tempurature Sensor Library
+    By: Michael Lange
+    Date: March 31, 2014
+    License: This code is public domain.
+ 
+    This class encapsulates a pressure reading from the sensor.
+ 
+ */
+ 
+ 
+#ifndef PRESSURE_H
+#define PRESSURE_H
+
+#include "mbed.h"
+
+class Pressure
+{
+public:
+
+    static const int size = 3;
+    enum unitsType { PASCALS, PSI, INHG, MMHG };
+
+    Pressure();
+    Pressure(float a, unitsType units = PASCALS);
+    Pressure(const char* compressed);
+    Pressure(const char msb, const char csb, const char lsb);
+
+    operator char*(void) { return _compressed; }
+    operator float(void) { return _pressure; }
+
+    float pressure(unitsType units = PASCALS);
+    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);
+
+    const char* print(unitsType units = PASCALS);
+    
+private:
+    float _pressure;
+    char  _compressed[3];
+    char  _printBuffer[9];
+};
+
+#endif // PRESSURE_H
\ No newline at end of file