Peng Jing Xuan
/
VL53L1X-MAX
VL53L1X-MAX
Embed:
(wiki syntax)
Show/hide line numbers
VL53L1X.h
00001 #ifndef VL53L1X_H 00002 #define VL53L1X_H 00003 00004 #include "mbed.h" 00005 00006 #include "VL53L1X_register_map.h" 00007 00008 #define I2C_BUFFER_LENGTH 32 00009 00010 const char defaultAddress_VL53L1X = 0x29; 00011 //const char defaultAddress_VL53L1X = 0x52; 00012 00013 class VL53L1X { 00014 public: 00015 VL53L1X(PinName SDA, PinName SCL); 00016 bool begin(); 00017 void softReset(); //Reset the sensor via software 00018 void startMeasurement(uint8_t offset = 0); //Write a block of bytes to the sensor to configure it to take a measurement 00019 bool newDataReady(); //Polls the measurement completion bit 00020 uint16_t getDistance(); //Returns the results from the last measurement, distance in mm 00021 uint16_t getSignalRate(); //Returns the results from the last measurement, signal rate 00022 void setDistanceMode(uint8_t mode = 2);//Defaults to long range 00023 uint8_t getDistanceMode(); 00024 uint8_t getRangeStatus(); //Returns the results from the last measurement, 0 = valid 00025 00026 uint8_t readRegister(uint16_t addr); //Read a byte from a 16-bit address 00027 uint16_t readRegister16(uint16_t addr); //Read two bytes from a 16-bit address 00028 void writeRegister(uint16_t addr, uint8_t val); //Write a byte to a spot 00029 void writeRegister16(uint16_t addr, uint16_t val); //Write two bytes to a spot 00030 00031 private: 00032 I2C _i2c; 00033 00034 uint8_t _deviceAddress; 00035 uint8_t _distanceMode;// = 0; <--- might cause a problem 00036 }; 00037 00038 00039 #endif 00040 00041
Generated on Tue Aug 2 2022 20:27:10 by 1.7.2