Demo program for the MPL3115A2 library.

Dependencies:   MPL3115A2 mbed

Example program for MPL3115 sensor. Added code for data acquisition using Interrupt.

Revision:
6:07f92b4716b6
Parent:
4:bcf56c80dd2b
Child:
7:97f5edf7d270
--- a/main.cpp	Sun Aug 25 21:48:37 2013 +0000
+++ b/main.cpp	Sun Sep 22 11:18:08 2013 +0000
@@ -24,7 +24,7 @@
     pc.baud( 230400);
     pc.printf("MPL3115A2 Sensor. [%X]\r\n", wigo_sensor1.getDeviceID());
         
-#if 0
+#if 1
     // ***** Data acquisition using Interrupt
     
     // Configure the sensor as Barometer.
@@ -37,7 +37,8 @@
         wait( 1.0);
         pc.printf(".");
     }
-#else
+#endif
+
 #if 0
     // ***** Data acquisition using polling method
     
@@ -64,7 +65,39 @@
         //
         wait( 1.0);
     }
-#else
+#endif
+
+#if 0
+    // ***** Data acquisition using polling method with Max and Min values visualization
+    
+    // Configure the sensor as Barometer.
+    unsigned int mode=1;
+    
+    // Set over sampling value (see MPL3115A2.h for details)
+    wigo_sensor1.Oversample_Ratio( OVERSAMPLE_RATIO_64);
+    // Configure the sensor as Barometer.
+    wigo_sensor1.Barometric_Mode();
+
+    while(1) {
+        //
+        if ( wigo_sensor1.getAllData( &sensor_data[0])) {
+            pc.printf("\tPressure: %f\tTemperature: %f\r\n", sensor_data[0], sensor_data[1]);
+            if ( (mode % 20)==0) {
+                sensor_data[0] = sensor_data[1] = 0.0;
+                wigo_sensor1.getAllMaximumData( &sensor_data[0]);
+                pc.printf("\tMaxPress: %f\tMaxTemp: %f\r\n", sensor_data[0], sensor_data[1]);
+                sensor_data[0] = sensor_data[1] = 0.0;
+                wigo_sensor1.getAllMinimumData( &sensor_data[0]);
+                pc.printf("\tMinPress: %f\tMinTemp: %f\r\n", sensor_data[0], sensor_data[1]);                    
+            }
+            mode++;
+        }
+        //
+        wait( 1.0);
+    }
+#endif
+
+#if 0
     // ***** Data acquisition in RAW mode using polling method
 
     // Create a buffer for raw data
@@ -76,7 +109,7 @@
     wigo_sensor1.Oversample_Ratio( OVERSAMPLE_RATIO_64);
     // Configure the sensor as Barometer.
     wigo_sensor1.Barometric_Mode();
-
+    
     while(1) {
         //
         if ( wigo_sensor1.getAllDataRaw( &raw_data[0])) {
@@ -94,7 +127,7 @@
     }
     
 #endif    
-#endif    
+    
 }
 
 void dataready( void)