-
Notifications
You must be signed in to change notification settings - Fork 14
Added support for continuous mode and history buffering #23
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ec6bdcc
Added support for continuous mode and history buffering
JonasSchatz c9851cb
Added support for continuous mode and history buffering
JonasSchatz 4ddb04d
Merge branch 'main' of https://github.com/JonasSchatz/Adafruit_Circui…
JonasSchatz cacf12b
Removed unused import
JonasSchatz f3da49e
Reformatted files for black
JonasSchatz c9b310d
Merge remote-tracking branch 'origin/main' into main
JonasSchatz 044f8f7
Fixed too short title underlines
JonasSchatz a016dc4
Replaced logging with print statements
JonasSchatz 43b0735
Removed typing in history example
JonasSchatz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,48 @@ | ||
Simple test | ||
Simple Test | ||
------------ | ||
|
||
Ensure your device works with this simple test. | ||
|
||
.. literalinclude:: ../examples/vl6180x_simpletest.py | ||
:caption: examples/vl6180x_simpletest.py | ||
:linenos: | ||
|
||
|
||
Calibration Test | ||
----------------- | ||
|
||
Demo of calibrating the part to part range offset per Application Note 4545 for the VL6180X sensor. | ||
|
||
.. literalinclude:: ../examples/vl6180x_calibrationtest.py | ||
:caption: examples/vl6180x_calibrationtest.py | ||
:linenos: | ||
|
||
|
||
Continuous Test | ||
---------------- | ||
|
||
Demo of reading the range from the VL6180x distance sensor in continuous mode. | ||
|
||
.. literalinclude:: ../examples/vl6180x_continuoustest.py | ||
:caption: examples/vl6180x_continuoustest.py | ||
:linenos: | ||
|
||
|
||
History Test | ||
------------- | ||
|
||
Demo of reading the range from the history buffer of the VL6180x distance sensor. | ||
|
||
.. literalinclude:: ../examples/vl6180x_historytest.py | ||
:caption: examples/vl6180x_historytest.py | ||
:linenos: | ||
|
||
|
||
Performance Test | ||
----------------- | ||
|
||
Demo of reading the range from the VL6180x distance sensor in different access modes (single shot, continuous, history). | ||
|
||
.. literalinclude:: ../examples/vl6180x_performancetest.py | ||
:caption: examples/vl6180x_performancetest.py | ||
:linenos: |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# SPDX-FileCopyrightText: 2018 Jonas Schatz | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Demo of reading the range from the VL6180x distance sensor in | ||
# continuous mode | ||
|
||
import time | ||
|
||
import board | ||
import busio | ||
|
||
import adafruit_vl6180x | ||
|
||
|
||
# Create I2C bus. | ||
i2c = busio.I2C(board.SCL, board.SDA) | ||
|
||
# Create sensor instance. | ||
sensor = adafruit_vl6180x.VL6180X(i2c) | ||
|
||
# Starting continuous mode | ||
print("Starting continuous mode") | ||
sensor.start_range_continuous(20) | ||
|
||
# Main loop prints the range and lux every 0.01 seconds | ||
for _ in range(100): | ||
# Read the range in millimeters and print it. | ||
range_mm = sensor.range | ||
print("Range: {0}mm".format(range_mm)) | ||
|
||
# Delay for 10 ms | ||
time.sleep(0.01) | ||
|
||
# Stop continuous mode. This is advised as the sensor | ||
# wouldn't stop measuring after the program has ended | ||
sensor.stop_range_continuous() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# SPDX-FileCopyrightText: 2022 Jonas Schatz | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Demo of reading the range from the history buffer of the VL6180x | ||
# distance sensor | ||
|
||
import time | ||
from typing import List | ||
|
||
import board | ||
import busio | ||
|
||
import adafruit_vl6180x | ||
|
||
|
||
# Create I2C bus. | ||
i2c = busio.I2C(board.SCL, board.SDA) | ||
|
||
# Create sensor instance. | ||
sensor = adafruit_vl6180x.VL6180X(i2c) | ||
|
||
# Starting continuous mode | ||
print("Starting continuous mode") | ||
sensor.start_range_continuous() | ||
|
||
# Main loop prints the ranges every 0.01 seconds for about 5 seconds | ||
# You should see changes 'ripple through' the history array | ||
for _ in range(500): | ||
# Read the range in millimeters and print it. | ||
ranges_mm: List[int] = sensor.ranges_from_history | ||
JonasSchatz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
print(ranges_mm) | ||
|
||
# Delay for 10 ms so that the loop is not too fast | ||
time.sleep(0.01) | ||
|
||
# Stop continuous mode. This is advised as the sensor | ||
# wouldn't stop measuring after the program has ended | ||
sensor.stop_range_continuous() |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.