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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers VL53L1X.h Source File

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 
00012 class VL53L1X {
00013   public:
00014     VL53L1X(PinName SDA, PinName SCL);
00015     bool begin();
00016     void softReset(); //Reset the sensor via software
00017     void startMeasurement(uint8_t offset = 0); //Write a block of bytes to the sensor to configure it to take a measurement
00018     bool newDataReady(); //Polls the measurement completion bit
00019     uint16_t getDistance(); //Returns the results from the last measurement, distance in mm
00020     uint16_t getSignalRate(); //Returns the results from the last measurement, signal rate
00021     void setDistanceMode(uint8_t mode = 2);//Defaults to long range
00022     uint8_t getDistanceMode();
00023     uint8_t getRangeStatus(); //Returns the results from the last measurement, 0 = valid
00024 
00025     uint8_t readRegister(uint16_t addr); //Read a byte from a 16-bit address
00026     uint16_t readRegister16(uint16_t addr); //Read two bytes from a 16-bit address
00027     void writeRegister(uint16_t addr, uint8_t val); //Write a byte to a spot
00028     void writeRegister16(uint16_t addr, uint16_t val); //Write two bytes to a spot
00029     
00030   private:
00031   I2C _i2c;
00032   
00033   uint8_t _deviceAddress;
00034   uint8_t _distanceMode;// = 0; <--- might cause a problem
00035 };
00036 
00037 
00038 #endif