Fork from Mark Randall MPL3115A2 Altitude/Pressure Sensor. Changed to make it compatible with TiltyQuad TiltyIMU module. By Ian HUA 2014.
Fork of MPL3115A2 by
MPL3115A2.h@1:8e57853ce55b, 2014-05-02 (annotated)
- Committer:
- pHysiX
- Date:
- Fri May 02 17:00:28 2014 +0000
- Revision:
- 1:8e57853ce55b
- Parent:
- 0:67dffed9369b
- Child:
- 3:fb9726aaa41d
Fixed library to work with Tilty. Also rearranged and tidied code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mr63 | 0:67dffed9369b | 1 | #include "mbed.h" |
mr63 | 0:67dffed9369b | 2 | |
pHysiX | 1:8e57853ce55b | 3 | #ifndef _MPL3115A2_H_ |
pHysiX | 1:8e57853ce55b | 4 | #define _MPL3115A2_H_ |
pHysiX | 1:8e57853ce55b | 5 | |
pHysiX | 1:8e57853ce55b | 6 | #define OFFSET 0x00 //Set for location this is the Altitude offset in meters |
mr63 | 0:67dffed9369b | 7 | |
pHysiX | 1:8e57853ce55b | 8 | #define SLAVE_ADDRESS 0xC0 |
pHysiX | 1:8e57853ce55b | 9 | |
pHysiX | 1:8e57853ce55b | 10 | #define STARTING_REGISTER 0x01 |
pHysiX | 1:8e57853ce55b | 11 | |
pHysiX | 1:8e57853ce55b | 12 | class MPL3115A2 |
pHysiX | 1:8e57853ce55b | 13 | { |
mr63 | 0:67dffed9369b | 14 | public: |
pHysiX | 1:8e57853ce55b | 15 | MPL3115A2(PinName pin1, PinName pin2); |
pHysiX | 1:8e57853ce55b | 16 | //MPL3115A2(int SlaveAddress, PinName pin1, PinName pin2, PinName pin3, PinName pin4); |
pHysiX | 1:8e57853ce55b | 17 | |
pHysiX | 1:8e57853ce55b | 18 | bool init (void); |
pHysiX | 1:8e57853ce55b | 19 | |
pHysiX | 1:8e57853ce55b | 20 | bool getInterrupt1(void); |
pHysiX | 1:8e57853ce55b | 21 | bool getInterrupt2(void); |
pHysiX | 1:8e57853ce55b | 22 | |
pHysiX | 1:8e57853ce55b | 23 | float Temp_F(void); |
pHysiX | 1:8e57853ce55b | 24 | float Temp_C(void); |
pHysiX | 1:8e57853ce55b | 25 | |
pHysiX | 1:8e57853ce55b | 26 | float Altitude_ft(void); |
pHysiX | 1:8e57853ce55b | 27 | float Altitude_m(void); |
mr63 | 0:67dffed9369b | 28 | |
mr63 | 0:67dffed9369b | 29 | private: |
pHysiX | 1:8e57853ce55b | 30 | int Write_Register (char regnum, char data); |
pHysiX | 1:8e57853ce55b | 31 | int Read_Altitude_Data(void); |
pHysiX | 1:8e57853ce55b | 32 | |
pHysiX | 1:8e57853ce55b | 33 | char _SensorData[8]; //Char array that holds the current Altitude and Temperature data |
pHysiX | 1:8e57853ce55b | 34 | |
pHysiX | 1:8e57853ce55b | 35 | I2C _i2c; |
pHysiX | 1:8e57853ce55b | 36 | //DigitalIn _pin1; |
pHysiX | 1:8e57853ce55b | 37 | //DigitalIn _pin2; |
mr63 | 0:67dffed9369b | 38 | }; |
mr63 | 0:67dffed9369b | 39 | #endif |