sdsd
VL6180.h@0:f23c00f688b2, 2015-10-19 (annotated)
- Committer:
- sburg
- Date:
- Mon Oct 19 16:19:05 2015 +0000
- Revision:
- 0:f23c00f688b2
- Child:
- 1:1b46b69895f9
VL6180 first revision.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sburg | 0:f23c00f688b2 | 1 | #ifndef MBED_VL6180_H |
sburg | 0:f23c00f688b2 | 2 | #define MBED_VL6180_H |
sburg | 0:f23c00f688b2 | 3 | |
sburg | 0:f23c00f688b2 | 4 | #include "mbed.h" |
sburg | 0:f23c00f688b2 | 5 | |
sburg | 0:f23c00f688b2 | 6 | class VL6180 { |
sburg | 0:f23c00f688b2 | 7 | public: |
sburg | 0:f23c00f688b2 | 8 | /** Create a VL6180 object at I2C address 0x29 (7 bit). |
sburg | 0:f23c00f688b2 | 9 | * |
sburg | 0:f23c00f688b2 | 10 | * @param sda I2C sda pin number |
sburg | 0:f23c00f688b2 | 11 | * @param scl I2C scl pin number |
sburg | 0:f23c00f688b2 | 12 | */ |
sburg | 0:f23c00f688b2 | 13 | VL6180(PinName sda, PinName scl); |
sburg | 0:f23c00f688b2 | 14 | |
sburg | 0:f23c00f688b2 | 15 | /** Make a range reading. |
sburg | 0:f23c00f688b2 | 16 | * |
sburg | 0:f23c00f688b2 | 17 | * @param return Distance to target in cm. Approx 0.0 cm to 20.0 cm. |
sburg | 0:f23c00f688b2 | 18 | */ |
sburg | 0:f23c00f688b2 | 19 | float read(); |
sburg | 0:f23c00f688b2 | 20 | |
sburg | 0:f23c00f688b2 | 21 | /* Float cast is shorthand for read() */ |
sburg | 0:f23c00f688b2 | 22 | operator float(); |
sburg | 0:f23c00f688b2 | 23 | |
sburg | 0:f23c00f688b2 | 24 | private: |
sburg | 0:f23c00f688b2 | 25 | void writeI2C(int reg, char data); |
sburg | 0:f23c00f688b2 | 26 | char readI2C(int reg); |
sburg | 0:f23c00f688b2 | 27 | I2C _i2c; |
sburg | 0:f23c00f688b2 | 28 | int _res; |
sburg | 0:f23c00f688b2 | 29 | static const int _addr = 0x52; |
sburg | 0:f23c00f688b2 | 30 | }; |
sburg | 0:f23c00f688b2 | 31 | |
sburg | 0:f23c00f688b2 | 32 | #endif |