Documentation ¶
Overview ¶
Package vl6180x provides a driver for the VL6180X time-of-flight distance sensor
Datasheet: https://www.st.com/resource/en/datasheet/vl6180x.pdf This driver was based on the library https://github.com/adafruit/Adafruit_VL6180X and document 'AN4545 VL6180X basic ranging application note': https://www.st.com/resource/en/application_note/an4545-vl6180x-basic-ranging-application-note-stmicroelectronics.pdf
Index ¶
- Constants
- type Device
- func (d *Device) Configure(use2v8Mode bool) bool
- func (d *Device) Connected() bool
- func (d *Device) GetAddress() uint8
- func (d *Device) IsRangeComplete() bool
- func (d *Device) Read() uint16
- func (d *Device) ReadLux(gain uint8) (lux uint32)
- func (d *Device) ReadStatus() uint8
- func (d *Device) SetAddress(address uint8)
- func (d *Device) SetOffset(offset uint8)
- func (d *Device) StartRangeContinuous(periodInMs uint16)
- func (d *Device) StopRangeContinuous()
- type VL6180XError
Constants ¶
const ( CHIP_ID = 0xB4 WHO_AM_I = 0x0000 SYSTEM_INTERRUPT_CONFIG = 0x0014 SYSTEM_INTERRUPT_CLEAR = 0x0015 SYSTEM_FRESH_OUT_OF_RESET = 0x0016 SYSRANGE_START = 0x0018 SYSRANGE_PART_TO_PART_RANGE_OFFSET = 0x0024 SYSALS_START = 0x0038 SYSALS_ANALOGUE_GAIN = 0x003F SYSALS_INTEGRATION_PERIOD_HI = 0x0040 SYSALS_INTEGRATION_PERIOD_LO = 0x0041 RESULT_RANGE_STATUS = 0x004d RESULT_INTERRUPT_STATUS_GPIO = 0x004f RESULT_ALS_VAL = 0x0050 RESULT_RANGE_VAL = 0x0062 I2C_SLAVE_DEVICE_ADDRESS = 0x0212 RANGING_INTERMEASUREMENT_PERIOD = 0x001b ALS_INTERMEASUREMENT_PERIOD = 0x003e ALS_GAIN_1 = 0x06 ///< 1x gain ALS_GAIN_1_25 = 0x05 ///< 1.25x gain ALS_GAIN_1_67 = 0x04 ///< 1.67x gain ALS_GAIN_2_5 = 0x03 ///< 2.5x gain ALS_GAIN_5 = 0x02 ///< 5x gain ALS_GAIN_10 = 0x01 ///< 10x gain ALS_GAIN_20 = 0x00 ///< 20x gain ALS_GAIN_40 = 0x07 ///< 40x gain )
Registers
const Address = 0x29
The I2C address which this device listens to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct { Address uint16 // contains filtered or unexported fields }
Device wraps an I2C connection to a VL6180X device.
func New ¶
New creates a new VL6180X connection. The I2C bus must already be configured.
This function only creates the Device object, it does not touch the device.
func (*Device) Connected ¶
Connected returns whether a VL6180X has been found. It does a "who am I" request and checks the response.
func (*Device) GetAddress ¶
GetAddress returns the I2C address which this device listens to.
func (*Device) IsRangeComplete ¶
IsRangeComplete return true when the reading is complete
func (*Device) ReadStatus ¶
ReadStatus returns the current status of the sensor
func (*Device) SetAddress ¶
SetAddress sets the I2C address which this device listens to.
func (*Device) StartRangeContinuous ¶
StartRangeContinuous starts the continuous reading mode
func (*Device) StopRangeContinuous ¶
func (d *Device) StopRangeContinuous()
StopRangeContinuous stops the continuous reading mode
type VL6180XError ¶
type VL6180XError uint8
const ( NONE VL6180XError = iota SYSERR_1 SYSERR_5 ECEFAIL NOCONVERGE RANGEIGNORE SNR RAWUFLOW RAWOFLOW RANGEUFLOW RANGEOFLOW )