Closed rlake closed 6 years ago
yah - just tried it and you're right! but we're not sure exactly where the math error is. we adapted the code from pololu's non-API-based library... do you want to try the arduino version and see if that's also slow (thus bug in both) or if its correct (thus bug is in our port)? https://github.com/pololu/vl53l0x-arduino
Interesting! In Arduino mode both Pololu and Adafruit VL53L0X example sketches are very responsive.
are you feeling up to investigating the circuitpython lib to see where it might be miscalculating?
You bet! I think I might have spotted the problem from comparing the code side by side. In the reference function VL53L0X::setMeasurementTimingBudget it calls timeoutMicrosecondsToMclks to set final_range_timeout_mclks. In the circuitpython function it calls _timeout_mclks_to_microseconds(so the reverse!). I'd bet that's the problem, just need to get back into circuitpython mode from sketch.
amazing ! thanks- we're debugging some other libraries today but if you have a pull req we can test tonite!
Please see note in pull request. I hit some snags building/testing but hopefully that should do the trick.
ok thanx i will test and report back
I have a Trinket M0 with the module connected to gpio pins 0/2 and gpio pin 3 as a pwm output for an LED (through a transistor). Circuitpython bundle build is 3.x dated 20180809 with the 3.0.0 uf2 firmware.
For some reason with the default configuration the sensor is taking approximately 2 seconds to take a reading:
sensor distance 8191mm, time 2.08398 sensor distance 257mm, time 2.08203 sensor distance 190mm, time 2.08203 sensor distance 294mm, time 2.08179
Dropping the timing budget to 20ms helps by roughly 300ms and in both modes there is the occasional fast read:
sensor distance 8191mm, time 1.76489 sensor distance 8190mm, time 0.0290527 sensor distance 8190mm, time 1.76611 sensor distance 149mm, time 1.76904 sensor distance 212mm, time 1.76587 sensor distance 296mm, time 1.76392 sensor distance 8190mm, time 1.76611
Any idea what would cause such a delay?