This is the SparkFun_VL53L1X_Arduino_Library translated into mbed, with some elements of Ian Kilburn's VL6180x mbed library.

Dependents:   Hug2Go_ver_2 Nucleo_rtos_basic_f103rb

Committer:
jvfausto
Date:
Wed Jul 18 16:47:45 2018 +0000
Revision:
0:03b7e8deb3ee
Child:
1:0d762892f7af
VL53L1X mbed

Who changed what in which revision?

UserRevisionLine numberNew 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 0:03b7e8deb3ee 15 void softReset(); //Reset the sensor via software
jvfausto 0:03b7e8deb3ee 16 void startMeasurement(uint8_t offset = 0); //Write a block of bytes to the sensor to configure it to take a measurement
jvfausto 0:03b7e8deb3ee 17 bool newDataReady(); //Polls the measurement completion bit
jvfausto 0:03b7e8deb3ee 18 uint16_t getDistance(); //Returns the results from the last measurement, distance in mm
jvfausto 0:03b7e8deb3ee 19 uint16_t getSignalRate(); //Returns the results from the last measurement, signal rate
jvfausto 0:03b7e8deb3ee 20 void setDistanceMode(uint8_t mode = 2);//Defaults to long range
jvfausto 0:03b7e8deb3ee 21 uint8_t getDistanceMode();
jvfausto 0:03b7e8deb3ee 22 uint8_t getRangeStatus(); //Returns the results from the last measurement, 0 = valid
jvfausto 0:03b7e8deb3ee 23
jvfausto 0:03b7e8deb3ee 24 uint8_t readRegister(uint16_t addr); //Read a byte from a 16-bit address
jvfausto 0:03b7e8deb3ee 25 uint16_t readRegister16(uint16_t addr); //Read two bytes from a 16-bit address
jvfausto 0:03b7e8deb3ee 26 void writeRegister(uint16_t addr, uint8_t val); //Write a byte to a spot
jvfausto 0:03b7e8deb3ee 27 void writeRegister16(uint16_t addr, uint16_t val); //Write two bytes to a spot
jvfausto 0:03b7e8deb3ee 28
jvfausto 0:03b7e8deb3ee 29 private:
jvfausto 0:03b7e8deb3ee 30 I2C _i2c;
jvfausto 0:03b7e8deb3ee 31
jvfausto 0:03b7e8deb3ee 32 uint8_t _deviceAddress;
jvfausto 0:03b7e8deb3ee 33 uint8_t _distanceMode;// = 0; <--- might cause a problem
jvfausto 0:03b7e8deb3ee 34 };
jvfausto 0:03b7e8deb3ee 35
jvfausto 0:03b7e8deb3ee 36
jvfausto 0:03b7e8deb3ee 37 #endif