I2C Temprature Sensor Progemm MPL3115A2

Dependents:   I2C_Temprature_raspiboard

Fork of MPL3115A2 by Michael Lange

Revision:
0:beb43bc3d6d4
Child:
3:7c7c1ea6fc33
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Temperature.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 temperature reading from the sensor.
+ 
+ */
+ 
+ 
+#ifndef TEMPERATURE_H
+#define TEMPERATURE_H
+
+#include "mbed.h"
+
+class Temperature
+{
+public:
+
+    static const int size = 2;
+    enum unitsType { CELSIUS, FAHRENHEIT, KELVIN };
+
+    Temperature();
+    Temperature(float a, unitsType units = FAHRENHEIT);
+    Temperature(const char* compressed);
+    Temperature(const char msb, const char lsb);
+
+    operator char*(void) { return _compressed; }
+    operator float(void) { return _temperature; }
+
+    float temperature(unitsType units = FAHRENHEIT);
+    void setTemperature();
+    void setTemperature(const char* compressed);
+    void setTemperature(const char msb, const char lsb);
+    void setTemperature(float a, unitsType units = FAHRENHEIT);
+
+    const char* print(unitsType units = FAHRENHEIT);
+    
+private:
+    float _temperature;
+    char  _compressed[2];
+    char  _printBuffer[9];
+};
+
+#endif // TEMPERATURE_H
\ No newline at end of file