test program for MPL3115A2
Dependencies: C12832 LM75B MPL3115A2 mbed
Diff: main.cpp
- Revision:
- 1:4870f310b921
- Parent:
- 0:27799234e2ed
- Child:
- 2:ef315a40af7b
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) ; } }