vl6180x

package
v0.0.0-...-0087ba1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

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

View Source
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

View Source
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

func New(bus drivers.I2C) Device

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) Configure

func (d *Device) Configure(use2v8Mode bool) bool

Configure sets up the device for communication

func (*Device) Connected

func (d *Device) Connected() bool

Connected returns whether a VL6180X has been found. It does a "who am I" request and checks the response.

func (*Device) GetAddress

func (d *Device) GetAddress() uint8

GetAddress returns the I2C address which this device listens to.

func (*Device) IsRangeComplete

func (d *Device) IsRangeComplete() bool

IsRangeComplete return true when the reading is complete

func (*Device) Read

func (d *Device) Read() uint16

Read returns the proximity of the sensor in mm

func (*Device) ReadLux

func (d *Device) ReadLux(gain uint8) (lux uint32)

ReadLux returns the lux of the sensor

func (*Device) ReadStatus

func (d *Device) ReadStatus() uint8

ReadStatus returns the current status of the sensor

func (*Device) SetAddress

func (d *Device) SetAddress(address uint8)

SetAddress sets the I2C address which this device listens to.

func (*Device) SetOffset

func (d *Device) SetOffset(offset uint8)

SetOffset sets the offset

func (*Device) StartRangeContinuous

func (d *Device) StartRangeContinuous(periodInMs uint16)

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
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL