Library for the VL6180 time of flight range finder.

Dependents:   VL6180_Hello_World STM32F103C8T6_VL6180 BLE_Sensor_VL6180 BLE_Sensor_VL6180_window

VL6180.h

Committer:
sburg
Date:
2015-10-19
Revision:
1:1b46b69895f9
Parent:
0:f23c00f688b2
Child:
2:595673e4c505

File content as of revision 1:1b46b69895f9:

#ifndef MBED_VL6180_H
#define MBED_VL6180_H

#include "mbed.h"

class VL6180 {
public:
    /** Create a VL6180 object at I2C address 0x29 (7 bit).
     * 
     * @param sda I2C sda pin number
     * @param scl I2C scl pin number
     */
    VL6180(PinName sda, PinName scl);
    
    /** Make a range reading.
     * 
     * @param return Distance to target in cm. Approx 0.0 cm to 20.0 cm.
     */
    float read();
    
    /** Float cast is shorthand for read() */
    operator float();
    
private:
    void writeI2C(int reg, char data);
    char readI2C(int reg);
    I2C _i2c;
    int _res;
    static const int _addr = 0x52;
};

#endif