Documentation ¶
Index ¶
- Constants
- type RangeSpec
- type RegBytePair
- type SequenceStepEnables
- type SequenceStepTimeouts
- type SpadInfo
- type SpeedAccuracySpec
- type VcselPeriodType
- type Vl53l0x
- func (v *Vl53l0x) Config(i2c *machine.I2C, rng RangeSpec, speed SpeedAccuracySpec) error
- func (v *Vl53l0x) GetProductMinorRevision(i2c *machine.I2C) (byte, error)
- func (v *Vl53l0x) GetSignalRateLimit(i2c *machine.I2C) (float32, error)
- func (v *Vl53l0x) Init(i2c *machine.I2C) error
- func (v *Vl53l0x) ReadRangeContinuousMillimeters(i2c *machine.I2C) (uint16, error)
- func (v *Vl53l0x) ReadRangeSingleMillimeters(i2c *machine.I2C) (uint16, error)
- func (v *Vl53l0x) Reset(i2c *machine.I2C) error
- func (v *Vl53l0x) SetAddress(i2cRef *machine.I2C, newAddr byte) error
- func (v *Vl53l0x) SetMeasurementTimingBudget(i2c *machine.I2C, budgetUsec uint32) error
- func (v *Vl53l0x) SetSignalRateLimit(i2c *machine.I2C, limitMcps float32) error
- func (v *Vl53l0x) SetVcselPulsePeriod(i2c *machine.I2C, tpe VcselPeriodType, periodPclks uint8) error
- func (v *Vl53l0x) StartContinuous(i2c *machine.I2C, periodMs uint32) error
- func (v *Vl53l0x) StopContinuous(i2c *machine.I2C) error
Constants ¶
const ( SYSRANGE_START = 0x00 SYSTEM_THRESH_HIGH = 0x0C SYSTEM_THRESH_LOW = 0x0E SYSTEM_SEQUENCE_CONFIG = 0x01 SYSTEM_RANGE_CONFIG = 0x09 SYSTEM_INTERMEASUREMENT_PERIOD = 0x04 SYSTEM_INTERRUPT_CONFIG_GPIO = 0x0A GPIO_HV_MUX_ACTIVE_HIGH = 0x84 SYSTEM_INTERRUPT_CLEAR = 0x0B RESULT_INTERRUPT_STATUS = 0x13 RESULT_RANGE_STATUS = 0x14 RESULT_CORE_AMBIENT_WINDOW_EVENTS_RTN = 0xBC RESULT_CORE_RANGING_TOTAL_EVENTS_RTN = 0xC0 RESULT_CORE_AMBIENT_WINDOW_EVENTS_REF = 0xD0 RESULT_CORE_RANGING_TOTAL_EVENTS_REF = 0xD4 RESULT_PEAK_SIGNAL_RATE_REF = 0xB6 ALGO_PART_TO_PART_RANGE_OFFSET_MM = 0x28 I2C_SLAVE_DEVICE_ADDRESS = 0x8A MSRC_CONFIG_CONTROL = 0x60 PRE_RANGE_CONFIG_MIN_SNR = 0x27 PRE_RANGE_CONFIG_VALID_PHASE_LOW = 0x56 PRE_RANGE_CONFIG_VALID_PHASE_HIGH = 0x57 PRE_RANGE_MIN_COUNT_RATE_RTN_LIMIT = 0x64 FINAL_RANGE_CONFIG_MIN_SNR = 0x67 FINAL_RANGE_CONFIG_VALID_PHASE_LOW = 0x47 FINAL_RANGE_CONFIG_VALID_PHASE_HIGH = 0x48 FINAL_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT = 0x44 PRE_RANGE_CONFIG_SIGMA_THRESH_HI = 0x61 PRE_RANGE_CONFIG_SIGMA_THRESH_LO = 0x62 PRE_RANGE_CONFIG_VCSEL_PERIOD = 0x50 PRE_RANGE_CONFIG_TIMEOUT_MACROP_HI = 0x51 PRE_RANGE_CONFIG_TIMEOUT_MACROP_LO = 0x29 SYSTEM_HISTOGRAM_BIN = 0x81 HISTOGRAM_CONFIG_INITIAL_PHASE_SELECT = 0x33 HISTOGRAM_CONFIG_READOUT_CTRL = 0x55 FINAL_RANGE_CONFIG_VCSEL_PERIOD = 0x70 FINAL_RANGE_CONFIG_TIMEOUT_MACROP_HI = 0x71 FINAL_RANGE_CONFIG_TIMEOUT_MACROP_LO = 0x72 CROSSTALK_COMPENSATION_PEAK_RATE_MCPS = 0x20 MSRC_CONFIG_TIMEOUT_MACROP = 0x46 SOFT_RESET_GO2_SOFT_RESET_N = 0xBF IDENTIFICATION_MODEL_ID = 0xC0 IDENTIFICATION_REVISION_ID = 0xC2 OSC_CALIBRATE_VAL = 0xF8 GLOBAL_CONFIG_VCSEL_WIDTH = 0x32 GLOBAL_CONFIG_SPAD_ENABLES_REF_0 = 0xB0 GLOBAL_CONFIG_SPAD_ENABLES_REF_1 = 0xB1 GLOBAL_CONFIG_SPAD_ENABLES_REF_2 = 0xB2 GLOBAL_CONFIG_SPAD_ENABLES_REF_3 = 0xB3 GLOBAL_CONFIG_SPAD_ENABLES_REF_4 = 0xB4 GLOBAL_CONFIG_SPAD_ENABLES_REF_5 = 0xB5 GLOBAL_CONFIG_REF_EN_START_SELECT = 0xB6 DYNAMIC_SPAD_NUM_REQUESTED_REF_SPAD = 0x4E DYNAMIC_SPAD_REF_EN_START_OFFSET = 0x4F POWER_MANAGEMENT_GO1_POWER_FORCE = 0x80 VHV_CONFIG_PAD_SCL_SDA__EXTSUP_HV = 0x89 ALGO_PHASECAL_LIM = 0x30 ALGO_PHASECAL_CONFIG_TIMEOUT = 0x30 )
Registers from sensor hardware.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RangeSpec ¶
type RangeSpec int
RangeSpec used to configure sensor for expected distance to measure.
const ( // Signal rate limit = 0.25 MCPS, laser pulse periods = (14, 10). RegularRange RangeSpec = iota + 1 // Signal rate limit = 0.10 MCPS, laser pulse periods = (18, 14). // Use "long range" mode only when "regular" can't detect distance // (returned distance value is 8190 mm or more). It's ordinary // happens, when distance exceed something about a meter. LongRange )
type RegBytePair ¶
Keeps pair of register and value to write to. Used as a bunch of registers which should be initialized with corresponding values.
type SequenceStepEnables ¶
TCC: Target CentreCheck MSRC: Minimum Signal Rate Check DSS: Dynamic Spad Selection
type SequenceStepTimeouts ¶
type SpadInfo ¶
SpadInfo keeps information about sensor SPAD (single photon avalanche diode) photodetector structure.
type SpeedAccuracySpec ¶
type SpeedAccuracySpec int
SpeedAccuracySpec used to configure sensor for accuracy/measure time. It's clear that to improve accuracy, you should increase measure time.
const ( // HighSpeed distance measurement takes 20 ms. HighSpeed SpeedAccuracySpec = iota + 1 // RegularAccuracy distance measurement takes 33 ms. RegularAccuracy // GoodAccuracy distance measurement takes 66 ms. GoodAccuracy // HighAccuracy distance measurement takes 100 ms. HighAccuracy // HighestAccuracy distance measurement takes 200 ms. HighestAccuracy )
func (SpeedAccuracySpec) String ¶
func (v SpeedAccuracySpec) String() string
String implement Stringer interface.
type VcselPeriodType ¶
type VcselPeriodType int
VcselPeriodType is a type of VCSEL (vertical cavity surface emitting laser) pulse period.
const ( // pre-range pulse period VcselPeriodPreRange VcselPeriodType = iota + 1 // final range pulse period VcselPeriodFinalRange )
type Vl53l0x ¶
type Vl53l0x struct {
// contains filtered or unexported fields
}
Vl53l0x contains sensor data and corresponding methods.
func (*Vl53l0x) Config ¶
Config configure sensor expected distance range and time to make a measurement.
func (*Vl53l0x) GetProductMinorRevision ¶
GetProductMinorRevision takes revision from sensor hardware. Based on VL53L0X_GetProductRevision.
func (*Vl53l0x) GetSignalRateLimit ¶
GetSignalRateLimit gets the return signal rate limit check value in MCPS.
func (*Vl53l0x) Init ¶
Init initialize sensor using sequence based on VL53L0X_DataInit(), VL53L0X_StaticInit(), and VL53L0X_PerformRefCalibration(). This function does not perform reference SPAD calibration (VL53L0X_PerformRefSpadManagement()), since the API user manual says that it is performed by ST on the bare modules; it seems like that should work well enough unless a cover glass is added.
func (*Vl53l0x) ReadRangeContinuousMillimeters ¶
ReadRangeContinuousMillimeters returns a range reading in millimeters when continuous mode is active (readRangeSingleMillimeters() also calls this function after starting a single-shot range measurement).
func (*Vl53l0x) ReadRangeSingleMillimeters ¶
ReadRangeSingleMillimeters performs a single-shot range measurement and returns the reading in millimeters based on VL53L0X_PerformSingleRangingMeasurement().
func (*Vl53l0x) SetAddress ¶
SetAddress change default address of sensor and reopen I2C-connection.
func (*Vl53l0x) SetMeasurementTimingBudget ¶
SetMeasurementTimingBudget set the measurement timing budget in microseconds, which is the time allowed for one measurement; the ST API and this library take care of splitting the timing budget among the sub-steps in the ranging sequence. A longer timing budget allows for more accurate measurements. Increasing the budget by a factor of N decreases the range measurement standard deviation by a factor of sqrt(N). Defaults to about 33 milliseconds; the minimum is 20 ms. Based on VL53L0X_set_measurement_timing_budget_micro_seconds().
func (*Vl53l0x) SetSignalRateLimit ¶
SetSignalRateLimit set the return signal rate limit check value in units of MCPS (mega counts per second). "This represents the amplitude of the signal reflected from the target and detected by the device"; setting this limit presumably determines the minimum measurement necessary for the sensor to report a valid reading. Setting a lower limit increases the potential range of the sensor but also seems to increase the likelihood of getting an inaccurate reading because of unwanted reflections from objects other than the intended target. Defaults to 0.25 MCPS as initialized by the ST API and this library.
func (*Vl53l0x) SetVcselPulsePeriod ¶
func (v *Vl53l0x) SetVcselPulsePeriod(i2c *machine.I2C, tpe VcselPeriodType, periodPclks uint8) error
SetVcselPulsePeriod set the VCSEL (vertical cavity surface emitting laser) pulse period for the given period type (pre-range or final range) to the given value in PCLKs. Longer periods seem to increase the potential range of the sensor. Valid values are (even numbers only):
pre: 12 to 18 (initialized default: 14), final: 8 to 14 (initialized default: 10).
Based on VL53L0X_set_vcsel_pulse_period().
func (*Vl53l0x) StartContinuous ¶
StartContinuous start continuous ranging measurements. If period_ms (optional) is 0 or not given, continuous back-to-back mode is used (the sensor takes measurements as often as possible); otherwise, continuous timed mode is used, with the given inter-measurement period in milliseconds determining how often the sensor takes a measurement. Based on VL53L0X_StartMeasurement().