![]() |
Qwiic_VL53L5CX_Py
packaging_test1-12-gfe85c0e
Python for SFE Qwiic VL53L5CX
|
Public Member Functions | |
def | __init__ (self, address=None, i2c_driver=None, dataPath="/lib/qwiic_vl53l5cx/vl53l5cx_bin") |
Constructor. More... | |
def | is_connected (self) |
Determines if this device is connected. More... | |
def | check_data_directory (self) |
Checks if the data directory exists and contains the necessary files. More... | |
def | begin (self) |
Initializes this device with default parameters. More... | |
def | swap_buffer (self, buffer, size) |
Used to swap a buffer. More... | |
def | poll_for_answer (self, size, pos, addr, mask, expected_value) |
This function is used to wait for an answer from the VL53L5CX sensor. More... | |
def | send_offset_data (self, resolution) |
This function is used to set the offset data gathered from NVM. More... | |
def | send_xtalk_data (self, resolution) |
This function is used to set the Xtalk data from generic configuration, or user's calibration. More... | |
def | dci_write_data (self, data, index, data_size) |
This function can be used to write 'extra data' to DCI. More... | |
def | dci_read_data (self, data, index, data_size) |
This function can be used to read 'extra data' from DCI. More... | |
def | dci_replace_data (self, data, index, data_size, new_data, new_data_size, new_data_pos) |
This function can be used to replace 'extra data' in DCI. More... | |
def | is_alive (self) |
Check if the device is alive. More... | |
def | set_i2c_address (self, i2c_address) |
Set the I2C address of the device. More... | |
def | get_i2c_address (self) |
Get the I2C address of the device. More... | |
def | set_ranging_frequency_hz (self, frequency_hz) |
This function sets a new ranging frequency in Hz. More... | |
def | get_ranging_frequency_hz (self) |
This function gets the current ranging frequency in Hz. More... | |
def | set_resolution (self, resolution) |
This function sets a new resolution (4x4 or 8x8). More... | |
def | get_resolution (self) |
This function gets the current resolution (4x4 or 8x8). More... | |
def | uint32_list_to_byte_list (self, uint32_list) |
This function converts a list of uint32 values to a list of bytes. More... | |
def | byte_list_to_uint32 (self, byte_list) |
This function converts a list of bytes to a single uint32 value. More... | |
def | byte_list_to_uint32_list (self, byte_list, uint32_list) |
This function converts a list of bytes into uint32 values and places at the start of the uint32 list. More... | |
def | byte_list_to_uint16_list (self, byte_list, uint16_list) |
This function converts a list of bytes to a list of uint16 values and places at the start of the uint16 list. More... | |
def | byte_list_to_int16_list (self, byte_list, int16_list) |
This function converts a list of bytes to a list of int16 values and places at the start of the int16 list. More... | |
def | set_ranging_mode (self, ranging_mode) |
This function is used to set the ranging mode. More... | |
def | get_ranging_mode (self) |
This function is used to get the ranging mode. More... | |
def | start_ranging (self) |
This function starts a ranging session. More... | |
def | stop_ranging (self) |
This function stops a ranging session. More... | |
def | check_data_ready (self) |
This function checks if new data is ready by polling I2C. More... | |
def | get_ranging_data (self) |
This function gets the ranging data, using the selected output and the resolution. More... | |
def | get_power_mode (self) |
This function is used to get the current sensor power mode. More... | |
def | set_power_mode (self, power_mode) |
This function is used to set the sensor in Low Power mode, for example if the sensor is not used during a long time. More... | |
def | get_integration_time_ms (self) |
This function gets the current integration time in ms. More... | |
def | set_integration_time_ms (self, integration_time_ms) |
This function sets a new integration time in ms. More... | |
def | get_sharpener_percent (self) |
This function gets the current sharpener in percent. More... | |
def | set_sharpener_percent (self, sharpener_percent) |
This function sets a new sharpener value in percent. More... | |
def | get_target_order (self) |
This function gets the current target order (closest or strongest). More... | |
def | set_target_order (self, target_order) |
This function sets a new target order. More... | |
def | wr_multi (self, addr, reg, values, chunkSize=30) |
This function writes multiple bytes to a register. More... | |
def | rd_multi (self, addr, reg, numBytes, chunkSize=32) |
This function reads multiple bytes from a register. More... | |
def | wr_byte (self, addr, reg, value) |
This function writes a byte to a register. More... | |
def | rd_byte (self, addr, reg) |
This function reads a single byte from a register. More... | |
def | get_buffer_from_open_file (self, f, startByte=0, endByte=None) |
This function gets the buffer from an open file. More... | |
def | get_absolute_data_path (self, fileName) |
This function gets the absolute path to a data file. More... | |
def | get_buffer_from_file (self, fileName, startByte=0, endByte=None) |
This function gets the buffer from the file. More... | |
def | write_out_large_file (self, reg, fileName, startByte=0, size=0, writeChunkSize=31, readChunkSize=4096) |
This function writes out a large buffer file to i2c bus. More... | |
Public Attributes | |
address | |
offset_data | |
xtalk_data | |
temp_buffer | |
data_read_size | |
stream_count | |
Properties | |
connected = property(is_connected) | |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.__init__ | ( | self, | |
address = None , |
|||
i2c_driver = None , |
|||
dataPath = "/lib/qwiic_vl53l5cx/vl53l5cx_bin" |
|||
) |
Constructor.
int,optional | address: The I2C address to use for the device If not provided, the default address is used |
I2CDriver,optional | i2c_driver: An existing i2c driver object If not provided, a driver object is created |
str | dataPath: The absolute path to the data directory. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.begin | ( | self | ) |
Initializes this device with default parameters.
True
if successful, otherwise False
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.byte_list_to_int16_list | ( | self, | |
byte_list, | |||
int16_list | |||
) |
This function converts a list of bytes to a list of int16 values and places at the start of the int16 list.
list | byte_list: The list of bytes to convert. |
list | int16_list: The list of int16 values to convert. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.byte_list_to_uint16_list | ( | self, | |
byte_list, | |||
uint16_list | |||
) |
This function converts a list of bytes to a list of uint16 values and places at the start of the uint16 list.
list | byte_list: The list of bytes to convert. |
list | uint16_list: The list of uint16 values to convert. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.byte_list_to_uint32 | ( | self, | |
byte_list | |||
) |
This function converts a list of bytes to a single uint32 value.
list | byte_list: The list of bytes to convert. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.byte_list_to_uint32_list | ( | self, | |
byte_list, | |||
uint32_list | |||
) |
This function converts a list of bytes into uint32 values and places at the start of the uint32 list.
list | byte_list: The list of bytes to convert. |
list | uint32_list: The list of uint32 values to convert. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.check_data_directory | ( | self | ) |
Checks if the data directory exists and contains the necessary files.
True
if the data directory exists and contains the necessary files, otherwise False
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.check_data_ready | ( | self | ) |
This function checks if new data is ready by polling I2C.
If new data is ready, a flag will be raised.
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.dci_read_data | ( | self, | |
data, | |||
index, | |||
data_size | |||
) |
This function can be used to read 'extra data' from DCI.
Using a known index, the function fills the casted structure passed in argument.
list | data: This field can be a casted structure, or a simple array. Please note that the FW only accept data of 32 bits. So field data can only have a size of 32, 64, 96, 128, bits .... |
int | index: Index of required value. |
int | data_size: This field must be the structure or array size |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.dci_replace_data | ( | self, | |
data, | |||
index, | |||
data_size, | |||
new_data, | |||
new_data_size, | |||
new_data_pos | |||
) |
This function can be used to replace 'extra data' in DCI.
The data can be simple data, or casted structure.
list | data: This field can be a casted structure, or a simple array. Please note that the FW only accepts data of 32 bits. So field data can only have a size of 32, 64, 96, 128 bits, etc. |
int | index: Index of required value. |
int | data_size: This field must be the structure or array size. |
list | new_data: Contains the new fields. |
int | new_data_size: New data size. |
int | new_data_pos: New data position into the buffer. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.dci_write_data | ( | self, | |
data, | |||
index, | |||
data_size | |||
) |
This function can be used to write 'extra data' to DCI.
The data can be simple data, or casted structure.
list | data: This field can be a casted structure, or a simple array. Please note that the FW only accept data of 32 bits. So field data can only have a size of 32, 64, 96, 128, bits .. |
int | index: Index of required value. |
int | data_size: This field must be the structure or array size |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.get_absolute_data_path | ( | self, | |
fileName | |||
) |
This function gets the absolute path to a data file.
str | fileName: The relative path of the data file to get the absolute path for. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.get_buffer_from_file | ( | self, | |
fileName, | |||
startByte = 0 , |
|||
endByte = None |
|||
) |
This function gets the buffer from the file.
If endByte is None, the function will read until the end of the file. Bytes returned will be [startByte, endByte) (endByte not included)
str | fileName: The name of the file to read from. fileName should be relative to the dataPath set in the constructor. |
int | startByte: The start byte to read from the file. |
int | endByte: The end byte to read from the file. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.get_buffer_from_open_file | ( | self, | |
f, | |||
startByte = 0 , |
|||
endByte = None |
|||
) |
This function gets the buffer from an open file.
If endByte is None, the function will read until the end of the file. Bytes returned will be [startByte, endByte) (endByte not included)
open | binary file f: The file to read from. |
int | startByte: The start byte to read from the file. |
int | endByte: The end byte to read from the file. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.get_i2c_address | ( | self | ) |
Get the I2C address of the device.
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.get_integration_time_ms | ( | self | ) |
This function gets the current integration time in ms.
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.get_power_mode | ( | self | ) |
This function is used to get the current sensor power mode.
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.get_ranging_data | ( | self | ) |
This function gets the ranging data, using the selected output and the resolution.
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.get_ranging_frequency_hz | ( | self | ) |
This function gets the current ranging frequency in Hz.
Ranging frequency corresponds to the time between each measurement.
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.get_ranging_mode | ( | self | ) |
This function is used to get the ranging mode.
Two modes are available using ULD: Continuous and autonomous. The default mode is Autonomous.
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.get_resolution | ( | self | ) |
This function gets the current resolution (4x4 or 8x8).
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.get_sharpener_percent | ( | self | ) |
This function gets the current sharpener in percent.
Sharpener can be changed to blur more or less zones depending on the application.
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.get_target_order | ( | self | ) |
This function gets the current target order (closest or strongest).
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.is_alive | ( | self | ) |
Check if the device is alive.
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.is_connected | ( | self | ) |
Determines if this device is connected.
True
if connected, otherwise False
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.poll_for_answer | ( | self, | |
size, | |||
pos, | |||
addr, | |||
mask, | |||
expected_value | |||
) |
This function is used to wait for an answer from the VL53L5CX sensor.
int | size: The number of bytes to read |
int | pos: The position in the buffer to check against expected_value |
int | address: The address to read from |
int | mask: The mask to apply to the value read (at pos) before comparing to expected_value |
int | expected_value: The value to compare against the value read (at pos) |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.rd_byte | ( | self, | |
addr, | |||
reg | |||
) |
This function reads a single byte from a register.
Enables 16 bit register address reads.
int | reg: The 16-bit register to read from. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.rd_multi | ( | self, | |
addr, | |||
reg, | |||
numBytes, | |||
chunkSize = 32 |
|||
) |
This function reads multiple bytes from a register.
Enables 16 bit register address reads.
int | reg: The 16-bit register to read from. |
int | numBytes: The number of bytes to read from the register. |
int | chunkSize: The max size of the chunks to read at a time. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.send_offset_data | ( | self, | |
resolution | |||
) |
This function is used to set the offset data gathered from NVM.
int | resolution: The resolution of the sensor Allowable values for resolution: - kResolution4x4 - kResolution8x8 |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.send_xtalk_data | ( | self, | |
resolution | |||
) |
This function is used to set the Xtalk data from generic configuration, or user's calibration.
int | resolution: The resolution of the sensor Allowable values for resolution: - kResolution4x4 - kResolution8x8 |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.set_i2c_address | ( | self, | |
i2c_address | |||
) |
Set the I2C address of the device.
int | i2c_address: The new I2C address to use |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.set_integration_time_ms | ( | self, | |
integration_time_ms | |||
) |
This function sets a new integration time in ms.
Integration time must be computed to be lower than the ranging period, for a selected resolution. Please note that this function has no impact on ranging mode continuous.
int | integration_time_ms: Contains the integration time in ms. For all resolutions and frequency, the minimum value is 2ms, and the maximum is 1000ms. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.set_power_mode | ( | self, | |
power_mode | |||
) |
This function is used to set the sensor in Low Power mode, for example if the sensor is not used during a long time.
The macro kPowerModeSleep can be used to enable the low power mode. When user wants to restart the sensor, they can use the macro kPowerModeWakeup. Please ensure that the device is not streaming before calling the function.
int | power_mode: Selected power mode (kPowerModeSleep or kPowerModeWakeup) |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.set_ranging_frequency_hz | ( | self, | |
frequency_hz | |||
) |
This function sets a new ranging frequency in Hz.
Ranging frequency corresponds to the measurements frequency. This setting depends on the resolution, so please select your resolution before using this function.
int | frequency_hz: Contains the ranging frequency in Hz.
|
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.set_ranging_mode | ( | self, | |
ranging_mode | |||
) |
This function is used to set the ranging mode.
Two modes are available using ULD: Continuous and autonomous. The default mode is Autonomous.
int | ranging_mode: Use kRangingModeAutonomous, kRangingModeContinous |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.set_resolution | ( | self, | |
resolution | |||
) |
This function sets a new resolution (4x4 or 8x8).
int | resolution: Use kResolution4x4 or kResolution8x8 to set the resolution. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.set_sharpener_percent | ( | self, | |
sharpener_percent | |||
) |
This function sets a new sharpener value in percent.
Sharpener can be changed to blur more or less zones depending on the application. Min value is 0 (disabled), and max is 99.
int | sharpener_percent: Value between 0 (disabled) and 99%. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.set_target_order | ( | self, | |
target_order | |||
) |
This function sets a new target order.
Please use macros VL53L5CX_TARGET_ORDER_STRONGEST and VL53L5CX_TARGET_ORDER_CLOSEST to define the new output order. By default, the sensor is configured with the strongest output.
int | target_order: Required target order. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.start_ranging | ( | self | ) |
This function starts a ranging session.
When the sensor streams, host cannot change settings 'on-the-fly'.
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.stop_ranging | ( | self | ) |
This function stops a ranging session.
It must be used when the sensor streams, after calling vl53l5cx_start_ranging().
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.swap_buffer | ( | self, | |
buffer, | |||
size | |||
) |
Used to swap a buffer.
The buffer size is always a multiple of 4 (4, 8, 12, 16, ...).
list | buffer: The byte buffer to swap |
int | size: Buffer size to swap |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.uint32_list_to_byte_list | ( | self, | |
uint32_list | |||
) |
This function converts a list of uint32 values to a list of bytes.
list | uint32_list: The list of uint32 values to convert. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.wr_byte | ( | self, | |
addr, | |||
reg, | |||
value | |||
) |
This function writes a byte to a register.
Enables 16 bit register address writes.
int | reg: The 16-bit register to write to. |
int | value: The value to write to the register. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.wr_multi | ( | self, | |
addr, | |||
reg, | |||
values, | |||
chunkSize = 30 |
|||
) |
This function writes multiple bytes to a register.
Enables 16 bit register address writes.
int | reg: The 16-bit register to write to. |
list | values: The values to write to the register. |
def qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.write_out_large_file | ( | self, | |
reg, | |||
fileName, | |||
startByte = 0 , |
|||
size = 0 , |
|||
writeChunkSize = 31 , |
|||
readChunkSize = 4096 |
|||
) |
This function writes out a large buffer file to i2c bus.
The function will write out the file in chunks of chunkSize bytes.
str | fileName: The name of the file to write from fileName should be relative to the dataPath set in the constructor. |
int | startByte: The start byte to write from the file. |
int | size: How many bytes of the file to write. |
int | chunkSize: The size of the chunks to write out. |
qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.address |
|
static |
qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.data_read_size |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.offset_data |
qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.stream_count |
qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.temp_buffer |
qwiic_vl53l5cx.qwiic_vl53l5cx.QwiicVL53L5CX.xtalk_data |
|
static |