test program for MPL3115A2
Dependencies: C12832 LM75B MPL3115A2 mbed
main.cpp@0:27799234e2ed, 2017-04-28 (annotated)
- Committer:
- Rhyme
- Date:
- Fri Apr 28 04:31:47 2017 +0000
- Revision:
- 0:27799234e2ed
- Child:
- 1:4870f310b921
Program/Project re-created
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:27799234e2ed | 1 | #include "mbed.h" |
Rhyme | 0:27799234e2ed | 2 | #include "MSS.h" |
Rhyme | 0:27799234e2ed | 3 | #include "MPL3115A2.h" |
Rhyme | 0:27799234e2ed | 4 | #define MPL3115A2_I2C_ADDRESS (0x60) |
Rhyme | 0:27799234e2ed | 5 | |
Rhyme | 0:27799234e2ed | 6 | int main() { |
Rhyme | 0:27799234e2ed | 7 | uint32_t alt, bar, tmp ; |
Rhyme | 0:27799234e2ed | 8 | uint16_t sample_time ; |
Rhyme | 0:27799234e2ed | 9 | MPL3115A2 mpl(PIN_SDA, PIN_SCL, MPL3115A2_I2C_ADDRESS) ; |
Rhyme | 0:27799234e2ed | 10 | |
Rhyme | 0:27799234e2ed | 11 | printf("=== test MPL3115A2 for %s (%s) ===\n",BOARD_NAME, __DATE__) ; |
Rhyme | 0:27799234e2ed | 12 | printf("Altitude, Pressure, Temperature\n") ; |
Rhyme | 0:27799234e2ed | 13 | |
Rhyme | 0:27799234e2ed | 14 | while(1) { |
Rhyme | 0:27799234e2ed | 15 | mpl.modeAlt() ; |
Rhyme | 0:27799234e2ed | 16 | sample_time = mpl.OneShot() ; |
Rhyme | 0:27799234e2ed | 17 | wait(((double)sample_time)/1000.0) ; |
Rhyme | 0:27799234e2ed | 18 | alt = mpl.getAltitude() ; |
Rhyme | 0:27799234e2ed | 19 | mpl.modeBar() ; |
Rhyme | 0:27799234e2ed | 20 | sample_time = mpl.OneShot() ; |
Rhyme | 0:27799234e2ed | 21 | wait(((double)sample_time)/1000.0) ; |
Rhyme | 0:27799234e2ed | 22 | bar = mpl.getPressure() ; |
Rhyme | 0:27799234e2ed | 23 | tmp = mpl.getTemperature() ; |
Rhyme | 0:27799234e2ed | 24 | printf("%6d, %6d, %6d\n", |
Rhyme | 0:27799234e2ed | 25 | (alt >> 16)&0xFFFF, |
Rhyme | 0:27799234e2ed | 26 | (bar >> 6), |
Rhyme | 0:27799234e2ed | 27 | (tmp >> 8) ) ; |
Rhyme | 0:27799234e2ed | 28 | wait(1) ; |
Rhyme | 0:27799234e2ed | 29 | } |
Rhyme | 0:27799234e2ed | 30 | } |