test program for MPL3115A2

Dependencies:   MPL3115A2 mbed

Files at this revision

API Documentation at this revision

Comitter:
Rhyme
Date:
Thu May 18 06:32:59 2017 +0000
Parent:
0:27799234e2ed
Commit message:
library was modified to return double value in usual measure, m, hPa, and degree Celsius. And print format etc has been modified to reflect the change(s).

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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/MPL3115A2.lib	Fri Apr 28 04:31:47 2017 +0000
+++ b/MPL3115A2.lib	Thu May 18 06:32:59 2017 +0000
@@ -1,1 +1,1 @@
-https://mbed.org/teams/MSS/code/MPL3115A2/#752c9dbed2fa
+https://mbed.org/teams/MSS/code/MPL3115A2/#6fdcf150410e
--- a/main.cpp	Fri Apr 28 04:31:47 2017 +0000
+++ b/main.cpp	Thu May 18 06:32:59 2017 +0000
@@ -4,27 +4,17 @@
 #define MPL3115A2_I2C_ADDRESS (0x60)
 
 int main() {
-    uint32_t alt, bar,  tmp ;
-    uint16_t sample_time ;
+    double alt, bar, temp ;
     MPL3115A2 mpl(PIN_SDA, PIN_SCL, MPL3115A2_I2C_ADDRESS) ;
     
     printf("=== test MPL3115A2 for %s (%s) ===\n",BOARD_NAME, __DATE__) ;
-    printf("Altitude, Pressure,   Temperature\n") ;
+    printf("Altitude(m), Pressure(hPa),   Temperature(c)\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) ) ; 
+        temp = mpl.getTemperature() ;
+        printf("%6.2f,   %6.2f, %6.2f\n",alt, bar, temp) ;
         wait(1) ;
     }
 }
--- a/mbed.bld	Fri Apr 28 04:31:47 2017 +0000
+++ b/mbed.bld	Thu May 18 06:32:59 2017 +0000
@@ -1,1 +1,1 @@
-https://mbed.org/users/mbed_official/code/mbed/builds/97feb9bacc10
\ No newline at end of file
+https://mbed.org/users/mbed_official/code/mbed/builds/4eea097334d6
\ No newline at end of file