test program for MPL3115A2
Dependencies: C12832 LM75B MPL3115A2 mbed
main.cpp
- Committer:
- Rhyme
- Date:
- 2017-04-28
- Revision:
- 0:27799234e2ed
- Child:
- 1:4870f310b921
File content as of revision 0:27799234e2ed:
#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) ;
}
}