Demo program for the MPL3115A2 library.

Dependencies:   FOCOMETROPRESION mbed

Fork of WIGO_MPL3115A2 by clemente di caprio

Revision:
0:5d92b48edaff
Child:
1:5ea71ebc0d82
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 23 06:46:16 2013 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+#include "MPL3115A2.h"
+
+#define MPL3115A2_I2C_ADDRESS (0x60<<1)
+
+DigitalOut myled(LED1);
+MPL3115A2 wigo_sensor1( PTE0, PTE1, MPL3115A2_I2C_ADDRESS);
+Serial pc(USBTX, USBRX);
+
+/* pos [0] = altimeter or pressure value */
+/* pos [1] = temperature value */
+float sensor_data[2];
+
+int main() {
+    
+    unsigned int mode=1;
+    
+    pc.baud( 230400);
+    pc.printf("MPL3115A2 Barometric mode. [%d]\r\n", wigo_sensor1.getDeviceID());
+    
+    wigo_sensor1.Oversample_Ratio( OVERSAMPLE_RATIO_32);
+    wigo_sensor1.Barometric_Mode();
+    
+    while(1) {
+        //
+        if ( wigo_sensor1.isDataAvailable()) {
+            wigo_sensor1.getAllData( &sensor_data[0]);
+            if ( mode & 0x0001) {
+                pc.printf("\tPressure: %f\tTemperature: %f\r\n", sensor_data[0], sensor_data[1]);
+                wigo_sensor1.Altimeter_Mode();
+            } else {
+                pc.printf("\Altitude: %f\tTemperature: %f\r\n", sensor_data[0], sensor_data[1]);
+                wigo_sensor1.Barometric_Mode();            
+            }
+            mode++;
+        }
+        //
+        wait( 0.001);
+    }
+}