MSS
/
test_MPL3115A2
test program for MPL3115A2
Revision 1:4870f310b921, committed 2017-05-18
- 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
diff -r 27799234e2ed -r 4870f310b921 MPL3115A2.lib --- 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
diff -r 27799234e2ed -r 4870f310b921 main.cpp --- 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) ; } }
diff -r 27799234e2ed -r 4870f310b921 mbed.bld --- 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