Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wants : change for three distance modes #11

Open
halcyon1945 opened this issue Oct 14, 2022 · 4 comments
Open

wants : change for three distance modes #11

halcyon1945 opened this issue Oct 14, 2022 · 4 comments
Assignees

Comments

@halcyon1945
Copy link

halcyon1945 commented Oct 14, 2022

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.

@property
def distance_mode(self):
"""The distance mode. 1=short, 2=long."""
mode = self._read_register(_PHASECAL_CONFIG__TIMEOUT_MACROP)[0]
if mode == 0x14:
return 1 # short distance
if mode == 0x0A:
return 2 # long distance
return None # unknown
@distance_mode.setter
def distance_mode(self, mode):
if mode == 1:
# short distance
self._write_register(_PHASECAL_CONFIG__TIMEOUT_MACROP, b"\x14")
self._write_register(_RANGE_CONFIG__VCSEL_PERIOD_A, b"\x07")
self._write_register(_RANGE_CONFIG__VCSEL_PERIOD_B, b"\x05")
self._write_register(_RANGE_CONFIG__VALID_PHASE_HIGH, b"\x38")
self._write_register(_SD_CONFIG__WOI_SD0, b"\x07\x05")
self._write_register(_SD_CONFIG__INITIAL_PHASE_SD0, b"\x06\x06")
elif mode == 2:
# long distance
self._write_register(_PHASECAL_CONFIG__TIMEOUT_MACROP, b"\x0A")
self._write_register(_RANGE_CONFIG__VCSEL_PERIOD_A, b"\x0F")
self._write_register(_RANGE_CONFIG__VCSEL_PERIOD_B, b"\x0D")
self._write_register(_RANGE_CONFIG__VALID_PHASE_HIGH, b"\xB8")
self._write_register(_SD_CONFIG__WOI_SD0, b"\x0F\x0D")
self._write_register(_SD_CONFIG__INITIAL_PHASE_SD0, b"\x0E\x0E")
else:
raise ValueError("Unsupported mode.")

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
Copy link
Collaborator

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
Copy link
Author

halcyon1945 commented Oct 14, 2022

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
Copy link
Collaborator

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.

@caternuson caternuson self-assigned this Oct 14, 2022
@halcyon1945
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants