adafruit / Adafruit_CircuitPython_VL53L1X

CircuitPython module for interacting with the VL53L1X distance sensor.
MIT License
8 stars 11 forks source link

wants : change for three distance modes #11

Open halcyon1945 opened 2 years ago

halcyon1945 commented 2 years ago

Hi, this issue is feature request .

VL53L1X chip datasheet say distance_mode has three enums. short,middle and long. but this library set only two. short and long.

https://github.com/adafruit/Adafruit_CircuitPython_VL53L1X/blob/434cb7e129f798554e3fa7ee6fed676edd95b09e/adafruit_vl53l1x.py#L265-L294

could your change for three mode?

see this datasheet and section 2.5.1 Distance mode. https://www.st.com/resource/en/datasheet/vl53l1x.pdf

thanks.

caternuson commented 2 years ago

Unfortunately, ST does not provide register details in their datasheet. This CircuitPython library was written based on ST's Arduino library here: https://github.com/stm32duino/VL53L1X and that library only has code for setting two distance modes: https://github.com/stm32duino/VL53L1X/blob/5aa46e743913186c448aaf86dd0f12071fddc0a2/src/vl53l1x_class.cpp#L420-L451

If you have a source for more information on how the Medium distance mode can be set, please link here and we can take a look.

halcyon1945 commented 2 years ago

i got it.

i did download and unzip ST official API called "VL53L1X Full API " https://www.st.com/en/embedded-software/stsw-img007.html

and checked API/core/src/vl53l1_api.c around L:996 function is similar.

VL53L1_Error VL53L1_SetDistanceMode(VL53L1_DEV Dev,
        VL53L1_DistanceModes DistanceMode)

VL53L1_DistanceModes definition.

/** @defgroup VL53L1_define_DistanceModes_group Defines Distance modes
 *  Defines all possible Distance modes for the device
 *  @{
 */
typedef uint8_t VL53L1_DistanceModes;

#define VL53L1_DISTANCEMODE_SHORT             ((VL53L1_DistanceModes)  1)
#define VL53L1_DISTANCEMODE_MEDIUM            ((VL53L1_DistanceModes)  2)
#define VL53L1_DISTANCEMODE_LONG              ((VL53L1_DistanceModes)  3)
/** @} VL53L1_define_DistanceModes_group */

and another way .... it seems pololu deal with this issue. https://github.com/pololu/vl53l1x-arduino/blob/8f21d608af00b42dc8776cfdf5ce935b45d2387d/VL53L1X.cpp#L272

caternuson commented 2 years ago

Ugh. They require email validation to access the "full" API.

Will take a look at the pololu code. The timing budget settings are affected by distance mode. So will need to verify what is needed there for "medium" mode.

halcyon1945 commented 2 years ago

memo : Current (tag 1.1.6) lib can be set to short and long . It just doesn't have medium , which I don't use much. I thought it was short and medium because the enum is 1 and 2. (ST doc said 1 as short, 2 as medium ,3 as long)