Christian Benitez
/
VL53L1X__
No range status update (error 255)
Fork of VL53L1X by
VL53L1X.h@4:a9362bc0597a, 2018-07-24 (annotated)
- Committer:
- cpbenite
- Date:
- Tue Jul 24 17:41:28 2018 +0000
- Revision:
- 4:a9362bc0597a
- Parent:
- 1:0d762892f7af
No range status update
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jvfausto | 0:03b7e8deb3ee | 1 | #ifndef VL53L1X_H |
jvfausto | 0:03b7e8deb3ee | 2 | #define VL53L1X_H |
jvfausto | 0:03b7e8deb3ee | 3 | |
jvfausto | 0:03b7e8deb3ee | 4 | #include "mbed.h" |
jvfausto | 0:03b7e8deb3ee | 5 | |
jvfausto | 0:03b7e8deb3ee | 6 | #include "VL53L1X_register_map.h" |
jvfausto | 0:03b7e8deb3ee | 7 | |
jvfausto | 0:03b7e8deb3ee | 8 | #define I2C_BUFFER_LENGTH 32 |
jvfausto | 0:03b7e8deb3ee | 9 | |
jvfausto | 0:03b7e8deb3ee | 10 | const char defaultAddress_VL53L1X = 0x29; |
jvfausto | 0:03b7e8deb3ee | 11 | |
jvfausto | 0:03b7e8deb3ee | 12 | class VL53L1X { |
jvfausto | 0:03b7e8deb3ee | 13 | public: |
jvfausto | 0:03b7e8deb3ee | 14 | VL53L1X(PinName SDA, PinName SCL); |
jvfausto | 1:0d762892f7af | 15 | bool begin(); |
jvfausto | 0:03b7e8deb3ee | 16 | void softReset(); //Reset the sensor via software |
jvfausto | 0:03b7e8deb3ee | 17 | void startMeasurement(uint8_t offset = 0); //Write a block of bytes to the sensor to configure it to take a measurement |
jvfausto | 0:03b7e8deb3ee | 18 | bool newDataReady(); //Polls the measurement completion bit |
jvfausto | 0:03b7e8deb3ee | 19 | uint16_t getDistance(); //Returns the results from the last measurement, distance in mm |
jvfausto | 0:03b7e8deb3ee | 20 | uint16_t getSignalRate(); //Returns the results from the last measurement, signal rate |
jvfausto | 0:03b7e8deb3ee | 21 | void setDistanceMode(uint8_t mode = 2);//Defaults to long range |
jvfausto | 0:03b7e8deb3ee | 22 | uint8_t getDistanceMode(); |
jvfausto | 0:03b7e8deb3ee | 23 | uint8_t getRangeStatus(); //Returns the results from the last measurement, 0 = valid |
jvfausto | 0:03b7e8deb3ee | 24 | |
cpbenite | 4:a9362bc0597a | 25 | uint8_t readRegister(uint16_t registerAddr); //Read a byte from a 16-bit address |
cpbenite | 4:a9362bc0597a | 26 | uint16_t readRegister16(uint16_t registerAddr); //Read two bytes from a 16-bit address |
cpbenite | 4:a9362bc0597a | 27 | void writeRegister(uint16_t registerAddr, uint8_t data); //Write a byte to a spot |
cpbenite | 4:a9362bc0597a | 28 | void writeRegister16(uint16_t registerAddr, uint16_t data); //Write two bytes to a spot |
jvfausto | 0:03b7e8deb3ee | 29 | |
jvfausto | 0:03b7e8deb3ee | 30 | private: |
jvfausto | 0:03b7e8deb3ee | 31 | I2C _i2c; |
jvfausto | 0:03b7e8deb3ee | 32 | |
jvfausto | 0:03b7e8deb3ee | 33 | uint8_t _deviceAddress; |
jvfausto | 0:03b7e8deb3ee | 34 | uint8_t _distanceMode;// = 0; <--- might cause a problem |
jvfausto | 0:03b7e8deb3ee | 35 | }; |
jvfausto | 0:03b7e8deb3ee | 36 | |
jvfausto | 0:03b7e8deb3ee | 37 | |
jvfausto | 0:03b7e8deb3ee | 38 | #endif |