Hi.
That it will be possible is logical. If I look at the Python library, the API for the VL53L1X is written in C. I would like to be able to access the sensor with C++ at the end and ultimately perform exactly the same operations as I do with Python. Has anyone already tested this out? Has anyone already written a program on how to ultimately use the API for this without Python?
I’m admittedly unsure which of the files from the API would even be relevant to me. In fact, I think I would ultimately need all of them.
To test the library there is also the following simple C example:
#include "vl53l1_api.h"
#include "vl53l1_platform.h"
int main(){
return 0;
}
This ultimately gives me the hint that I would not have to import much more.
Let me outline what I’m looking for. If possible, I want to end up working the same way as when I use Python, except that I use C++:
VL53L1X::VL53L1X(){}
void VL53L1X:init()
{
}
void VL53L1X:open()
{
}
void VL53L1X:close()
{
}
void VL53L1X:_configure_i2c_library_functions()
{
}
void VL53L1X:set_user_roi()
{
}
void VL53L1X:start_ranging()
{
}
void VL53L1X:set_distance_mode()
{
}
void VL53L1X:stop_ranging()
{
}
double VL53L1X:get_distance()
{
}
void VL53L1X:set_timing()
{
}
void VL53L1X:set_timing_budget()
{
}
void VL53L1X:set_inter_measurement_period()
{
}
uint VL53L1X:get_timing()
{
}
bool VL53L1X:change_address()
{
}
In Python, yes, multiple shared objects are added:
# Load VL53L1X shared lib
_POSSIBLE_LIBRARY_LOCATIONS = [os.path.dirname(os.path.realpath(__file__))]
try:
_POSSIBLE_LIBRARY_LOCATIONS += site.getsitepackages()
except AttributeError:
pass
try:
_POSSIBLE_LIBRARY_LOCATIONS += [site.getusersitepackages()]
except AttributeError:
pass
for lib_location in _POSSIBLE_LIBRARY_LOCATIONS:
files = glob.glob(lib_location + "/vl53l1x_python*.so")
if len(files) > 0:
lib_file = files[0]
try:
_TOF_LIBRARY = CDLL(lib_file)
# print("Using: " + lib_location + "/vl51l1x_python.so")
break
except OSError:
# print(lib_location + "/vl51l1x_python.so not found")
pass
else:
raise OSError('Could not find vl53l1x_python.so')
In Python, strictly speaking, C is reused or used. I would have to work around this workaround. I would have to be able to access the individual headers directly and then call a function directly instead of using _TOF_LIBRARY.function
.
One question that remains for me at the end: Doesn’t that already exist?
Thanks in advance.