test program for MPL3115A2

Dependencies:   C12832 LM75B MPL3115A2 mbed

Fork of test_MPL3115A2 by MSS

Revision:
0:27799234e2ed
Child:
1:4870f310b921
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Apr 28 04:31:47 2017 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+#include "MSS.h"
+#include "MPL3115A2.h"
+#define MPL3115A2_I2C_ADDRESS (0x60)
+
+int main() {
+    uint32_t alt, bar,  tmp ;
+    uint16_t sample_time ;
+    MPL3115A2 mpl(PIN_SDA, PIN_SCL, MPL3115A2_I2C_ADDRESS) ;
+    
+    printf("=== test MPL3115A2 for %s (%s) ===\n",BOARD_NAME, __DATE__) ;
+    printf("Altitude, Pressure,   Temperature\n") ;
+    
+    while(1) {
+        mpl.modeAlt() ;
+        sample_time = mpl.OneShot() ;
+        wait(((double)sample_time)/1000.0) ;
+        alt = mpl.getAltitude() ;
+        mpl.modeBar() ;
+        sample_time = mpl.OneShot() ;
+        wait(((double)sample_time)/1000.0) ;
+        bar = mpl.getPressure() ;
+        tmp = mpl.getTemperature() ;
+        printf("%6d,   %6d, %6d\n",
+            (alt >> 16)&0xFFFF,
+            (bar >> 6),
+            (tmp >> 8) ) ; 
+        wait(1) ;
+    }
+}