Demo program for the MPL3115A2 library.

Dependencies:   FOCOMETROPRESION mbed

Fork of WIGO_MPL3115A2 by clemente di caprio

Files at this revision

API Documentation at this revision

Comitter:
perezalvarezhi
Date:
Thu Oct 02 21:31:27 2014 +0000
Parent:
7:97f5edf7d270
Commit message:
adfasdf

Changed in this revision

MPL3115A2.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 97f5edf7d270 -r c415332bdea7 MPL3115A2.lib
--- a/MPL3115A2.lib	Tue Sep 24 20:22:57 2013 +0000
+++ b/MPL3115A2.lib	Thu Oct 02 21:31:27 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/clemente/code/MPL3115A2/#82ac06669316
+http://developer.mbed.org/users/perezalvarezhi/code/FOCOMETROPRESION/#39bfad7780a1
diff -r 97f5edf7d270 -r c415332bdea7 main.cpp
--- a/main.cpp	Tue Sep 24 20:22:57 2013 +0000
+++ b/main.cpp	Thu Oct 02 21:31:27 2014 +0000
@@ -2,9 +2,9 @@
 #include "MPL3115A2.h"
 
 #define MPL3115A2_I2C_ADDRESS (0x60<<1)
-
+#define 
 DigitalOut myled(LED1);
-MPL3115A2 wigo_sensor1( PTE0, PTE1, MPL3115A2_I2C_ADDRESS);
+MPL3115A2 wigo_sensor1( PTC9, PTC8, MPL3115A2_I2C_ADDRESS);
 Serial pc(USBTX, USBRX);
 
 /* pos [0] = altimeter or pressure value */
@@ -20,135 +20,32 @@
 float print_TemperatureValue( unsigned char *dt);
 
 int main() {
-    
-    pc.baud( 230400);
+    pc.baud(9600);
     pc.printf("MPL3115A2 Sensor. [%X]\r\n", wigo_sensor1.getDeviceID());
-        
-#if 0
-    // ***** Data acquisition using Interrupt
-    
-    // Configure the sensor as Barometer.
-    wigo_sensor1.Barometric_Mode();
-    // Set callback function and over sampling value (see MPL3115A2.h for details)
-    wigo_sensor1.DataReady( &dataready, OVERSAMPLE_RATIO_64);
-    // just loop...
-    while( 1)
-    {
-        wait( 1.0);
-        pc.printf(".");
-    }
-#endif
-
-#if 0
-    // ***** Data acquisition using polling method
-    
-    // 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])) {
-            if ( mode & 0x0001) {
-                pc.printf("\tPressure: %f\tTemperature: %f\r\n", sensor_data[0], sensor_data[1]);
-                wigo_sensor1.Altimeter_Mode();
-            } else {
-                pc.printf("\tAltitude: %f\tTemperature: %f\r\n", sensor_data[0], sensor_data[1]);
-                wigo_sensor1.Barometric_Mode();            
-            }
-            mode++;
-        }
-        //
-        wait( 1.0);
-    }
-#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 1
     // ***** Data acquisition using polling method and delta values
-
     // Array for the dela values
-    float delta[2];
+    //float delta[2];
     
     // Set over sampling value (see MPL3115A2.h for details)
     wigo_sensor1.Oversample_Ratio( OVERSAMPLE_RATIO_128);
     // Configure the sensor as Barometer.
     wigo_sensor1.Barometric_Mode();
-
+    int i =0;
     while(1) {
         //
-        if ( wigo_sensor1.getAllData( &sensor_data[0], &delta[0])) {
+        if ( wigo_sensor1.getAllData( &sensor_data[0]) ) {
             pc.printf("\tPressure: %f\tTemperature: %f\r\n", sensor_data[0], sensor_data[1]);
-            pc.printf("\tDelatPress: %f\tDeltaTemp: %f\r\n", delta[0], delta[1]);
+            //pc.printf("\tDelatPress: %f\tDeltaTemp: %f\r\n", delta[0], delta[1]);
+        }else{
+            pc.printf("Not reading any more");
         }
+        pc.printf("Measurement# %d",i);
+        i++;
         //
         wait( 1.0);
     }
-#endif
 
-#if 0
-    // ***** Data acquisition in RAW mode using polling method
-
-    // Create a buffer for raw data
-    unsigned char raw_data[5];
-    // 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.getAllDataRaw( &raw_data[0])) {
-            if ( mode & 0x0001) {
-                pc.printf("\tPressure: %f\tTemperature: %f\r\n", print_PressureValue( &raw_data[0]), print_TemperatureValue( &raw_data[3]));
-                wigo_sensor1.Altimeter_Mode();
-            } else {
-                pc.printf("\tAltitude: %f\tTemperature: %f\r\n", print_AltimiterValue( &raw_data[0]), print_TemperatureValue( &raw_data[3]));
-                wigo_sensor1.Barometric_Mode();            
-            }
-            mode++;
-        }
-        //
-        wait( 1.0);
-    }
-    
-#endif    
     
 }