VL53L1X-MAX

Committer:
peng103617
Date:
Tue Oct 22 05:47:05 2019 +0000
Revision:
0:385e286b830a
MAX

Who changed what in which revision?

UserRevisionLine numberNew contents of line
peng103617 0:385e286b830a 1 #ifndef VL53L1X_H
peng103617 0:385e286b830a 2 #define VL53L1X_H
peng103617 0:385e286b830a 3
peng103617 0:385e286b830a 4 #include "mbed.h"
peng103617 0:385e286b830a 5
peng103617 0:385e286b830a 6 #include "VL53L1X_register_map.h"
peng103617 0:385e286b830a 7
peng103617 0:385e286b830a 8 #define I2C_BUFFER_LENGTH 32
peng103617 0:385e286b830a 9
peng103617 0:385e286b830a 10 const char defaultAddress_VL53L1X = 0x29;
peng103617 0:385e286b830a 11 //const char defaultAddress_VL53L1X = 0x52;
peng103617 0:385e286b830a 12
peng103617 0:385e286b830a 13 class VL53L1X {
peng103617 0:385e286b830a 14 public:
peng103617 0:385e286b830a 15 VL53L1X(PinName SDA, PinName SCL);
peng103617 0:385e286b830a 16 bool begin();
peng103617 0:385e286b830a 17 void softReset(); //Reset the sensor via software
peng103617 0:385e286b830a 18 void startMeasurement(uint8_t offset = 0); //Write a block of bytes to the sensor to configure it to take a measurement
peng103617 0:385e286b830a 19 bool newDataReady(); //Polls the measurement completion bit
peng103617 0:385e286b830a 20 uint16_t getDistance(); //Returns the results from the last measurement, distance in mm
peng103617 0:385e286b830a 21 uint16_t getSignalRate(); //Returns the results from the last measurement, signal rate
peng103617 0:385e286b830a 22 void setDistanceMode(uint8_t mode = 2);//Defaults to long range
peng103617 0:385e286b830a 23 uint8_t getDistanceMode();
peng103617 0:385e286b830a 24 uint8_t getRangeStatus(); //Returns the results from the last measurement, 0 = valid
peng103617 0:385e286b830a 25
peng103617 0:385e286b830a 26 uint8_t readRegister(uint16_t addr); //Read a byte from a 16-bit address
peng103617 0:385e286b830a 27 uint16_t readRegister16(uint16_t addr); //Read two bytes from a 16-bit address
peng103617 0:385e286b830a 28 void writeRegister(uint16_t addr, uint8_t val); //Write a byte to a spot
peng103617 0:385e286b830a 29 void writeRegister16(uint16_t addr, uint16_t val); //Write two bytes to a spot
peng103617 0:385e286b830a 30
peng103617 0:385e286b830a 31 private:
peng103617 0:385e286b830a 32 I2C _i2c;
peng103617 0:385e286b830a 33
peng103617 0:385e286b830a 34 uint8_t _deviceAddress;
peng103617 0:385e286b830a 35 uint8_t _distanceMode;// = 0; <--- might cause a problem
peng103617 0:385e286b830a 36 };
peng103617 0:385e286b830a 37
peng103617 0:385e286b830a 38
peng103617 0:385e286b830a 39 #endif
peng103617 0:385e286b830a 40
peng103617 0:385e286b830a 41