Documentation ¶
Overview ¶
Package vl53l1x provides a driver for the VL53L1X time-of-flight distance sensor
Datasheet: https://www.st.com/resource/en/datasheet/vl53l1x.pdf This driver was based on the library https://github.com/pololu/vl53l1x-arduino and ST's VL53L1X API (STSW-IMG007) https://www.st.com/content/st_com/en/products/embedded-software/proximity-sensors-software/stsw-img007.html
Index ¶
- Constants
- type Device
- func (d *Device) AmbientRate() int32
- func (d *Device) Configure(use2v8Mode bool) bool
- func (d *Device) Connected() bool
- func (d *Device) Distance() int32
- func (d *Device) GetMeasurementTimingBudget() uint32
- func (d *Device) Read(blocking bool) uint16
- func (d *Device) SetDistanceMode(mode DistanceMode) bool
- func (d *Device) SetMeasurementTimingBudget(budgetMicroseconds uint32) bool
- func (d *Device) SetTimeout(timeout uint32)
- func (d *Device) SignalRate() int32
- func (d *Device) StartContinuous(periodMs uint32)
- func (d *Device) Status() RangeStatus
- func (d *Device) StopContinuous()
- type DistanceMode
- type RangeStatus
Constants ¶
const ( CHIP_ID = 0xEACC SOFT_RESET = 0x0000 OSC_MEASURED_FAST_OSC_FREQUENCY = 0x0006 VHV_CONFIG_TIMEOUT_MACROP_LOOP_BOUND = 0x0008 VHV_CONFIG_INIT = 0x000B ALGO_PART_TO_PART_RANGE_OFFSET_MM = 0x001E MM_CONFIG_OUTER_OFFSET_MM = 0x0022 DSS_CONFIG_TARGET_TOTAL_RATE_MCPS = 0x0024 PAD_I2C_HV_EXTSUP_CONFIG = 0x002E GPIO_TIO_HV_STATUS = 0x0031 SIGMA_ESTIMATOR_EFFECTIVE_PULSE_WIDTH_NS = 0x0036 SIGMA_ESTIMATOR_EFFECTIVE_AMBIENT_WIDTH_NS = 0x0037 ALGO_CROSSTALK_COMPENSATION_VALID_HEIGHT_MM = 0x0039 ALGO_RANGE_MIN_CLIP = 0x003F ALGO_CONSISTENCY_CHECK_TOLERANCE = 0x0040 CAL_CONFIG_VCSEL_START = 0x0047 PHASECAL_CONFIG_TIMEOUT_MACROP = 0x004B PHASECAL_CONFIG_OVERRIDE = 0x004D DSS_CONFIG_ROI_MODE_CONTROL = 0x004F SYSTEM_THRESH_RATE_HIGH = 0x0050 SYSTEM_THRESH_RATE_LOW = 0x0052 DSS_CONFIG_MANUAL_EFFECTIVE_SPADS_SELECT = 0x0054 DSS_CONFIG_APERTURE_ATTENUATION = 0x0057 MM_CONFIG_TIMEOUT_MACROP_A = 0x005A MM_CONFIG_TIMEOUT_MACROP_B = 0x005C RANGE_CONFIG_TIMEOUT_MACROP_A = 0x005E RANGE_CONFIG_VCSEL_PERIOD_A = 0x0060 RANGE_CONFIG_TIMEOUT_MACROP_B = 0x0061 RANGE_CONFIG_VCSEL_PERIOD_B = 0x0063 RANGE_CONFIG_SIGMA_THRESH = 0x0064 RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT_MCPS = 0x0066 RANGE_CONFIG_VALID_PHASE_HIGH = 0x0069 SYSTEM_INTERMEASUREMENT_PERIOD = 0x006C SYSTEM_GROUPED_PARAMETER_HOLD_0 = 0x0071 SYSTEM_SEED_CONFIG = 0x0077 SD_CONFIG_WOI_SD0 = 0x0078 SD_CONFIG_WOI_SD1 = 0x0079 SD_CONFIG_INITIAL_PHASE_SD0 = 0x007A SD_CONFIG_INITIAL_PHASE_SD1 = 0x007B SYSTEM_GROUPED_PARAMETER_HOLD_1 = 0x007C SD_CONFIG_QUANTIFIER = 0x007E SYSTEM_SEQUENCE_CONFIG = 0x0081 SYSTEM_GROUPED_PARAMETER_HOLD = 0x0082 SYSTEM_INTERRUPT_CLEAR = 0x0086 SYSTEM_MODE_START = 0x0087 RESULT_RANGE_STATUS = 0x0089 PHASECAL_RESULT_VCSEL_START = 0x00D8 RESULT_OSC_CALIBRATE_VAL = 0x00DE FIRMWARE_SYSTEM_STATUS = 0x00E5 WHO_AM_I = 0x010F SHADOW_RESULT_FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0_HI = 0x0FBE TIMING_GUARD = 4528 TARGETRATE = 0x0A00 )
Registers
const Address = 0x29 //0x52
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 VHVInit uint8 VHVTimeout uint8 // contains filtered or unexported fields }
Device wraps an I2C connection to a VL53L1X device.
func New ¶
New creates a new VL53L1X connection. The I2C bus must already be configured.
This function only creates the Device object, it does not touch the device.
func (*Device) AmbientRate ¶
AmbientRate returns the ambient rate in count per second (cps)
func (*Device) Connected ¶
Connected returns whether a VL53L1X has been found. It does a "who am I" request and checks the response.
func (*Device) GetMeasurementTimingBudget ¶
GetMeasurementTimingBudget returns the timing budget in microseconds
func (*Device) Read ¶
Read stores in the buffer the values of the sensor and returns the current distance in mm
func (*Device) SetDistanceMode ¶
func (d *Device) SetDistanceMode(mode DistanceMode) bool
SetDistanceMode sets the mode for calculating the distance. Distance mode vs. max. distance SHORT: 136cm (dark) - 135cm (strong ambient light) MEDIUM: 290cm (dark) - 76cm (strong ambient light) LONG: 360cm (dark) - 73cm (strong ambient light) It returns false if an invalid mode is provided
func (*Device) SetMeasurementTimingBudget ¶
SetMeasurementTimingBudget configures the timing budget in microseconds It returns false if an invalid timing budget is provided
func (*Device) SetTimeout ¶
SetTimeout configures the timeout
func (*Device) SignalRate ¶
SignalRate returns the peak signal rate in count per second (cps)
func (*Device) StartContinuous ¶
StartContinuous starts the continuous sensing mode
func (*Device) Status ¶
func (d *Device) Status() RangeStatus
Status returns the status of the sensor
func (*Device) StopContinuous ¶
func (d *Device) StopContinuous()
StopContinuous stops the continuous sensing mode
type RangeStatus ¶
type RangeStatus uint8
const ( RangeValid RangeStatus = iota SigmaFail SignalFail RangeValidMinRangeClipped OutOfBoundsFail HardwareFail RangeValidNoWrapCheckFail WrapTargetFail ProcessingFail XtalkSignalFail SynchronizationInt MergedPulse TargetPresentLackOfSignal MinRangeFail RangeInvalid None RangeStatus = 255 )