Qwiic_VL53L1X_Py  packaging_test0-1-gc769ef3
Python for SFE Qwiic VL53L1X
Loading...
Searching...
No Matches
qwiic_vl53l1x.QwiicVL53L1X Class Reference
Inheritance diagram for qwiic_vl53l1x.QwiicVL53L1X:

Public Member Functions

def __init__ (self, address=None, debug=None, i2c_driver=None)
 This method initializes the class object. More...
 
def get_distance (self)
 This function returns the distance measured by the sensor in mm. More...
 
def init_sensor (self, address)
 Initialize the sensor with default values. More...
 
def get_sw_version (self)
 This function returns the SW driver version. More...
 
def set_i2c_address (self, new_address)
 This function sets the sensor I2C address used in case multiple devices application, default address 0x29 (0x52 >> 1) More...
 
def sensor_init (self)
 This function loads the 135 bytes default values to initialize the sensor. More...
 
def clear_interrupt (self)
 This function clears the interrupt, to be called after a ranging data reading to arm the interrupt for the next data ready event. More...
 
def set_interrupt_polarity (self, NewPolarity)
 This function programs the interrupt polarity. More...
 
def get_interrupt_polarity (self)
 This function returns the current interrupt polarity. More...
 
def start_ranging (self)
 This function starts the ranging distance operation The ranging operation is continuous. More...
 
def stop_ranging (self)
 This function stops the ranging. More...
 
def check_for_data_ready (self)
 This function checks if the new ranging data is available by polling the dedicated register. More...
 
def set_timing_budget_in_ms (self, TimingBudgetInMs)
 This function programs the timing budget in ms. More...
 
def get_timing_budget_in_ms (self)
 This function returns the current timing budget in ms. More...
 
def set_distance_mode (self, DM)
 This function programs the distance mode (1=short, 2=long(default)). More...
 
def get_distance_mode (self)
 This function returns the current distance mode (1=short, 2=long). More...
 
def set_inter_measurement_in_ms (self, InterMeasMs)
 This function programs the Intermeasurement period in ms. More...
 
def get_inter_measurement_in_ms (self)
 This function returns the Intermeasurement period in ms. More...
 
def boot_state (self)
 This function returns the boot state of the device (1:booted, 0:not booted) More...
 
def get_sensor_id (self)
 This function returns the sensor id, sensor Id must be 0xEEAC. More...
 
def get_signal_per_spad (self)
 This function returns the returned signal per SPAD in kcps/SPAD (kcps stands for Kilo Count Per Second). More...
 
def get_ambient_per_spad (self)
 This function returns the ambient per SPAD in kcps/SPAD. More...
 
def get_signal_rate (self)
 This function returns the returned signal in kcps. More...
 
def get_spad_nb (self)
 This function returns the current number of enabled SPADs. More...
 
def get_ambient_rate (self)
 This function returns the ambient rate in kcps. More...
 
def get_range_status (self)
 This function returns the ranging status error. More...
 
def set_offset (self, OffsetValue)
 This function programs the offset correction in mm. More...
 
def get_offset (self)
 This function returns the programmed offset correction value in mm. More...
 
def set_xtalk (self, XtalkValue)
 This function programs the xtalk correction value in cps (Count Per Second). More...
 
def get_xtalk (self)
 This function returns the current programmed xtalk correction value in cps. More...
 
def set_distance_threshold (self, ThreshLow, ThreshHigh, Window, IntOnNoTarget)
 This function programs the threshold detection mode. More...
 
def get_distance_threshold_window (self)
 This function returns the window detection mode (0=below 1=above 2=out 3=in) More...
 
def get_distance_threshold_low (self)
 This function returns the low threshold in mm. More...
 
def get_distance_threshold_high (self)
 This function returns the high threshold in mm. More...
 
def set_roi (self, X, Y, OpticalCenter=199)
 This function programs the ROI (Region of Interest). More...
 
def get_roi_xy (self)
 This function returns width X and height Y. More...
 
def set_signal_threshold (self, Signal)
 This function programs a new signal threshold in kcps (default=1024 kcps) More...
 
def get_signal_threshold (self)
 This function returns the current signal threshold in kcps. More...
 
def set_sigma_threshold (self, Sigma)
 This function programs a new sigma threshold in mm (default=15 mm) More...
 
def get_sigma_threshold (self)
 This function returns the current sigma threshold in mm. More...
 
def start_temperature_update (self)
 This function performs the temperature calibration. More...
 
def calibrate_offset (self, TargetDistInMm)
 This function performs the offset calibration. More...
 
def calibrate_xtalk (self, TargetDistInMm)
 This function performs the xtalk calibration. More...
 

Public Attributes

 address
 
 debug
 
 status
 

Static Public Attributes

int VL53L1X_IMPLEMENTATION_VER_MAJOR = 1
 
int VL53L1X_IMPLEMENTATION_VER_MINOR = 0
 
int VL53L1X_IMPLEMENTATION_VER_SUB = 1
 
int VL53L1X_IMPLEMENTATION_VER_REVISION = 0000
 
 device_name = _DEFAULT_NAME
 
 available_addresses = _AVAILABLE_I2C_ADDRESS
 

Constructor & Destructor Documentation

◆ __init__()

def qwiic_vl53l1x.QwiicVL53L1X.__init__ (   self,
  address = None,
  debug = None,
  i2c_driver = None 
)

This method initializes the class object.

If no 'address' or 'i2c_driver' are inputed or 'None' is specified, the method will use the defaults.

Parameters
addressThe I2C address to use for the device. If not provided, the method will default to the first address in the 'available_addresses' list. Default = 0x29
debugDesignated whether or not to print debug statements. 0- Don't print debug statements 1- Print debug statements
i2c_driverAn existing i2c driver object. If not provided a driver object is created from the 'qwiic_i2c' I2C driver of the SparkFun Qwiic library.

Member Function Documentation

◆ boot_state()

def qwiic_vl53l1x.QwiicVL53L1X.boot_state (   self)

This function returns the boot state of the device (1:booted, 0:not booted)

Returns
Integer Boot state
  • 1- booted
  • 0- not booted

◆ calibrate_offset()

def qwiic_vl53l1x.QwiicVL53L1X.calibrate_offset (   self,
  TargetDistInMm 
)

This function performs the offset calibration.

The function returns the offset value found and programs the offset compensation into the device.

Parameters
TargetDistInMm* Target distance in mm, ST recommended 100 mm
  • Target reflectance = grey17%
Returns
int status: 0 if no error, other if error

◆ calibrate_xtalk()

def qwiic_vl53l1x.QwiicVL53L1X.calibrate_xtalk (   self,
  TargetDistInMm 
)

This function performs the xtalk calibration.

The function returns the xtalk value found and programs the xtalk compensation to the device

Parameters
TargetDistInMmTarget distance in mm
  • The target distance is the distance where the sensor start to "under range" due to the influence of the photons reflected back from the cover glass becoming strong (also called the inflection point).
  • Target reflectance = grey 17%
Returns
int status: 0 if no error, other if error

◆ check_for_data_ready()

def qwiic_vl53l1x.QwiicVL53L1X.check_for_data_ready (   self)

This function checks if the new ranging data is available by polling the dedicated register.

Returns
Integer 1 if new data is ready, 0 if not

◆ clear_interrupt()

def qwiic_vl53l1x.QwiicVL53L1X.clear_interrupt (   self)

This function clears the interrupt, to be called after a ranging data reading to arm the interrupt for the next data ready event.

◆ get_ambient_per_spad()

def qwiic_vl53l1x.QwiicVL53L1X.get_ambient_per_spad (   self)

This function returns the ambient per SPAD in kcps/SPAD.

Returns
Ambient per SPAD

◆ get_ambient_rate()

def qwiic_vl53l1x.QwiicVL53L1X.get_ambient_rate (   self)

This function returns the ambient rate in kcps.

Returns
Ambient rate in kcps

◆ get_distance()

def qwiic_vl53l1x.QwiicVL53L1X.get_distance (   self)

This function returns the distance measured by the sensor in mm.

Returns
Integer Distance measured by the sensor in mm

◆ get_distance_mode()

def qwiic_vl53l1x.QwiicVL53L1X.get_distance_mode (   self)

This function returns the current distance mode (1=short, 2=long).

Returns
Integer Distance Mode
  • 1- Short mode max distance is limited to 1.3 m but better ambient immunity
  • 2- Long mode can range up to 4 m in the dark with 200 ms timing budget (default)

◆ get_distance_threshold_high()

def qwiic_vl53l1x.QwiicVL53L1X.get_distance_threshold_high (   self)

This function returns the high threshold in mm.

Returns
Integer High threshold in mm

◆ get_distance_threshold_low()

def qwiic_vl53l1x.QwiicVL53L1X.get_distance_threshold_low (   self)

This function returns the low threshold in mm.

Returns
Integer Low threshold in mm

◆ get_distance_threshold_window()

def qwiic_vl53l1x.QwiicVL53L1X.get_distance_threshold_window (   self)

This function returns the window detection mode (0=below 1=above 2=out 3=in)

Returns
Integer Window detection mode
  • 0- below
  • 1- above
  • 2- out
  • 3- in

◆ get_inter_measurement_in_ms()

def qwiic_vl53l1x.QwiicVL53L1X.get_inter_measurement_in_ms (   self)

This function returns the Intermeasurement period in ms.

Returns
Integer Intermeasurement period in ms

◆ get_interrupt_polarity()

def qwiic_vl53l1x.QwiicVL53L1X.get_interrupt_polarity (   self)

This function returns the current interrupt polarity.

Returns
Integer 1 = active high (default), 0 = active low

◆ get_offset()

def qwiic_vl53l1x.QwiicVL53L1X.get_offset (   self)

This function returns the programmed offset correction value in mm.

Returns
Integer Offset correction value in mm

◆ get_range_status()

def qwiic_vl53l1x.QwiicVL53L1X.get_range_status (   self)

This function returns the ranging status error.

Returns
Ranging status error
            * 0- no error
            * 1- sigma failed
            * 2- signal failed
            * 7- wrap-around

◆ get_roi_xy()

def qwiic_vl53l1x.QwiicVL53L1X.get_roi_xy (   self)

This function returns width X and height Y.

Returns
List Region of Interest Width (X) and Height (Y)

◆ get_sensor_id()

def qwiic_vl53l1x.QwiicVL53L1X.get_sensor_id (   self)

This function returns the sensor id, sensor Id must be 0xEEAC.

Returns
Integer Sensor ID

◆ get_sigma_threshold()

def qwiic_vl53l1x.QwiicVL53L1X.get_sigma_threshold (   self)

This function returns the current sigma threshold in mm.

Returns
Integer Sigma threshold in mm

◆ get_signal_per_spad()

def qwiic_vl53l1x.QwiicVL53L1X.get_signal_per_spad (   self)

This function returns the returned signal per SPAD in kcps/SPAD (kcps stands for Kilo Count Per Second).

Returns
Signal per SPAD (Kilo Count Per Second/SPAD).

◆ get_signal_rate()

def qwiic_vl53l1x.QwiicVL53L1X.get_signal_rate (   self)

This function returns the returned signal in kcps.

Returns
signal in kcps

◆ get_signal_threshold()

def qwiic_vl53l1x.QwiicVL53L1X.get_signal_threshold (   self)

This function returns the current signal threshold in kcps.

Returns
Signal threshold in kcps

◆ get_spad_nb()

def qwiic_vl53l1x.QwiicVL53L1X.get_spad_nb (   self)

This function returns the current number of enabled SPADs.

Returns
Number of enabled SPADs

◆ get_sw_version()

def qwiic_vl53l1x.QwiicVL53L1X.get_sw_version (   self)

This function returns the SW driver version.

Returns
List [major, minor, build, revision] numbers

◆ get_timing_budget_in_ms()

def qwiic_vl53l1x.QwiicVL53L1X.get_timing_budget_in_ms (   self)

This function returns the current timing budget in ms.

◆ get_xtalk()

def qwiic_vl53l1x.QwiicVL53L1X.get_xtalk (   self)

This function returns the current programmed xtalk correction value in cps.

Returns
xtalk correction value in cps

◆ init_sensor()

def qwiic_vl53l1x.QwiicVL53L1X.init_sensor (   self,
  address 
)

Initialize the sensor with default values.

Parameters
addressDevice address
Returns
0 on Success

◆ sensor_init()

def qwiic_vl53l1x.QwiicVL53L1X.sensor_init (   self)

This function loads the 135 bytes default values to initialize the sensor.

Returns
Integer 0 on success or error code

◆ set_distance_mode()

def qwiic_vl53l1x.QwiicVL53L1X.set_distance_mode (   self,
  DM 
)

This function programs the distance mode (1=short, 2=long(default)).

Parameters
IntegerDM: Distance Mode
  • 1- Short mode max distance is limited to 1.3 m but better ambient immunity
  • 2- Long mode can range up to 4 m in the dark with 200 ms timing budget (default)

◆ set_distance_threshold()

def qwiic_vl53l1x.QwiicVL53L1X.set_distance_threshold (   self,
  ThreshLow,
  ThreshHigh,
  Window,
  IntOnNoTarget 
)

This function programs the threshold detection mode.

Parameters
mmThreshLow: The threshold under which one the device raises an interrupt if Window = 0
mmThreshHigh: The threshold above which one the device raises an interrupt if Window = 1
WindowWindow detection mode:
  • 0- below
  • 1- above
  • 2- out
  • 3- in
IntOnNoTarget1 (No longer used - just set to 1)

Example:

  • self.set_distance_threshold(100,300,0,1): Below 100
  • self.set_distance_threshold(100,300,1,1): Above 300
  • self.set_distance_threshold(100,300,2,1): Out of window
  • self.set_distance_threshold(100,300,3,1): In window

◆ set_i2c_address()

def qwiic_vl53l1x.QwiicVL53L1X.set_i2c_address (   self,
  new_address 
)

This function sets the sensor I2C address used in case multiple devices application, default address 0x29 (0x52 >> 1)

Parameters
new_addressI2C address to change device to

◆ set_inter_measurement_in_ms()

def qwiic_vl53l1x.QwiicVL53L1X.set_inter_measurement_in_ms (   self,
  InterMeasMs 
)

This function programs the Intermeasurement period in ms.

Parameters
InterMeasMsIntermeasurement period must be >/= timing budget. This condition is not checked by the API, the customer has the duty to check the condition. Default = 100 ms

◆ set_interrupt_polarity()

def qwiic_vl53l1x.QwiicVL53L1X.set_interrupt_polarity (   self,
  NewPolarity 
)

This function programs the interrupt polarity.

Parameters
**Integer**NewPolarity: 1 = active high (default), 0 = active low

◆ set_offset()

def qwiic_vl53l1x.QwiicVL53L1X.set_offset (   self,
  OffsetValue 
)

This function programs the offset correction in mm.

Parameters
OffsetValueThe offset correction value to program in mm

◆ set_roi()

def qwiic_vl53l1x.QwiicVL53L1X.set_roi (   self,
  X,
  Y,
  OpticalCenter = 199 
)

This function programs the ROI (Region of Interest).

The height and width of the ROI (X, Y) are set in SPADs; the smallest acceptable ROI size = 4 (4 x 4). The optical center is set based on table below. To set the center, use the pad that is to the right and above (i.e. upper right of) the exact center of the region you'd like to measure as your optical center.

Table of Optical Centers:

128,136,144,152,160,168,176,184,  192,200,208,216,224,232,240,248
129,137,145,153,161,169,177,185,  193,201,209,217,225,233,241,249
130,138,146,154,162,170,178,186,  194,202,210,218,226,234,242,250
131,139,147,155,163,171,179,187,  195,203,211,219,227,235,243,251
132,140,148,156,164,172,180,188,  196,204,212,220,228,236,244,252
133,141,149,157,165,173,181,189,  197,205,213,221,229,237,245,253
134,142,150,158,166,174,182,190,  198,206,214,222,230,238,246,254
135,143,151,159,167,175,183,191,  199,207,215,223,231,239,247,255

127,119,111,103,095,087,079,071,  063,055,047,039,031,023,015,007
126,118,110,102,094,086,078,070,  062,054,046,038,030,022,014,006
125,117,109,101,093,085,077,069,  061,053,045,037,029,021,013,005
124,116,108,100,092,084,076,068,  060,052,044,036,028,020,012,004
123,115,107,099,091,083,075,067,  059,051,043,035,027,019,011,003
122,114,106,098,090,082,074,066,  058,050,042,034,026,018,010,002
121,113,105,097,089,081,073,065,  057,049,041,033,025,017,009,001
120,112,104,096,088,080,072,064,  056,048,040,032,024,016,008,0 Pin 1

(Each SPAD has a number which is not obvious.)
Parameters
XROI Width
YROI Height
OpticalCenterThe pad that is to the upper right of the exact center of the ROI (see table above). (default=199)

◆ set_sigma_threshold()

def qwiic_vl53l1x.QwiicVL53L1X.set_sigma_threshold (   self,
  Sigma 
)

This function programs a new sigma threshold in mm (default=15 mm)

Parameters
SigmaSigma threshold in mm (default=15 mm)

◆ set_signal_threshold()

def qwiic_vl53l1x.QwiicVL53L1X.set_signal_threshold (   self,
  Signal 
)

This function programs a new signal threshold in kcps (default=1024 kcps)

Parameters
SignalSignal threshold in kcps (default=1024 kcps)

◆ set_timing_budget_in_ms()

def qwiic_vl53l1x.QwiicVL53L1X.set_timing_budget_in_ms (   self,
  TimingBudgetInMs 
)

This function programs the timing budget in ms.

Parameters
TimingBudgetInMsPredefined values = 15, 20, 33, 50, 100 (default), 200, 500.

◆ set_xtalk()

def qwiic_vl53l1x.QwiicVL53L1X.set_xtalk (   self,
  XtalkValue 
)

This function programs the xtalk correction value in cps (Count Per Second).

This is the number of photons reflected back from the cover glass in cps.

Parameters
XTalkValuextalk correction value in count per second to avoid float type

◆ start_ranging()

def qwiic_vl53l1x.QwiicVL53L1X.start_ranging (   self)

This function starts the ranging distance operation The ranging operation is continuous.

The clear interrupt has to be done after each get data to allow the interrupt to raise when the next data is ready 1=active high (default), 0=active low, use set_interrupt_polarity() to change the interrupt polarity if required.

◆ start_temperature_update()

def qwiic_vl53l1x.QwiicVL53L1X.start_temperature_update (   self)

This function performs the temperature calibration.

It is recommended to call this function any time the temperature might have changed by more than 8 deg C without sensor ranging activity for an extended period.

◆ stop_ranging()

def qwiic_vl53l1x.QwiicVL53L1X.stop_ranging (   self)

This function stops the ranging.

Member Data Documentation

◆ address

qwiic_vl53l1x.QwiicVL53L1X.address

◆ available_addresses

qwiic_vl53l1x.QwiicVL53L1X.available_addresses = _AVAILABLE_I2C_ADDRESS
static

◆ debug

qwiic_vl53l1x.QwiicVL53L1X.debug

◆ device_name

qwiic_vl53l1x.QwiicVL53L1X.device_name = _DEFAULT_NAME
static

◆ status

qwiic_vl53l1x.QwiicVL53L1X.status

◆ VL53L1X_IMPLEMENTATION_VER_MAJOR

int qwiic_vl53l1x.QwiicVL53L1X.VL53L1X_IMPLEMENTATION_VER_MAJOR = 1
static

◆ VL53L1X_IMPLEMENTATION_VER_MINOR

int qwiic_vl53l1x.QwiicVL53L1X.VL53L1X_IMPLEMENTATION_VER_MINOR = 0
static

◆ VL53L1X_IMPLEMENTATION_VER_REVISION

int qwiic_vl53l1x.QwiicVL53L1X.VL53L1X_IMPLEMENTATION_VER_REVISION = 0000
static

◆ VL53L1X_IMPLEMENTATION_VER_SUB

int qwiic_vl53l1x.QwiicVL53L1X.VL53L1X_IMPLEMENTATION_VER_SUB = 1
static

The documentation for this class was generated from the following file: