vl53l1x: Check data ready and clear interrupt in read().#74
Merged
Conversation
8 tasks
2237105 to
157fed0
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds data-ready checking and interrupt clearing to the VL53L1X time-of-flight sensor's read() method, ensuring fresh measurements instead of stale data. It follows the auto-trigger convention established in issue #44.
Changes:
- Added
start_ranging(),stop_ranging(),_is_data_ready(),_clear_interrupt(), and_ensure_data()methods to the VL53L1X driver - Modified
read()to call_ensure_data()before reading and_clear_interrupt()after, while removing commented-out dead code - Added mock test scenarios for data-ready checking, interrupt clearing, and stop/restart behavior
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/vl53l1x/vl53l1x/device.py | Added ranging control, data-ready polling, interrupt clearing, and integrated them into read() |
| tests/scenarios/vl53l1x.yaml | Added mock registers for new functionality and three new test scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🎉 This PR is included in version 0.0.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #71
Summary
The
read()method now checks for data ready before reading and clears the interrupt after, ensuring fresh measurements instead of stale data.start_ranging()/stop_ranging()— control ranging via SYSTEM__MODE_START (0x0087)_is_data_ready()— checks GPIO__TIO_HV_STATUS (0x0031) bit 0 vs interrupt polarity_clear_interrupt()— writes 0x01 to SYSTEM__INTERRUPT_CLEAR (0x0086)_ensure_data()— starts ranging and polls data ready if no data available (up to 1s)read()calls_ensure_data()before reading and_clear_interrupt()afterFollows the auto-trigger convention from #44.
Test plan
Mock tests (no hardware)
python3 -m pytest tests/ -k "vl53l1x and mock" -vHardware tests (STeaMi board connected)
python3 -m pytest tests/ --port /dev/ttyACM0 -k "vl53l1x and hardware" -s -v