Skip to content

Commit f6fdf96

Browse files
committed
Added use example for v3 HP
1 parent 79eaad2 commit f6fdf96

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

README.rst

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ To install in a virtual environment in your current project:
5353
source .env/bin/activate
5454
pip3 install adafruit-circuitpython-lidarlite
5555
56-
Usage Example
57-
=============
56+
Usage Examples
57+
==============
58+
59+
V3 Example
60+
----------
5861

5962
.. code-block:: python
6063
@@ -78,6 +81,43 @@ Usage Example
7881
print(e)
7982
time.sleep(0.01) # you can remove this for ultra-fast measurements!
8083
84+
85+
V3 HP Example
86+
-------------
87+
88+
.. code-block:: python
89+
90+
import time
91+
import busio
92+
import board
93+
import adafruit_lidarlite
94+
95+
i2c = busio.I2C(board.SCL, board.SDA)
96+
97+
sensor = adafruit_lidarlite.LIDARLite(i2c, sensor_type=adafruit_lidarlite.TYPE_V3HP)
98+
99+
while True:
100+
try:
101+
print(f"Sensor ID#: {sensor.unit_id}")
102+
print(f"Distance = {sensor.distance}")
103+
print(f" Strength: {sensor.signal_strength}")
104+
except RuntimeError as e:
105+
print(e)
106+
try:
107+
print(f"Status: 0b{sensor.status:b}")
108+
print(f" Busy: {bool(sensor.status & adafruit_lidarlite.STATUS_BUSY_V3HP)}")
109+
print(f" Overflow: {bool(sensor.status & adafruit_lidarlite.STATUS_SIGNAL_OVERFLOW_V3HP)}")
110+
print(f" Health: 0b{sensor.health_status:b}")
111+
print(f" Power Control: 0b{sensor.power_control:b}")
112+
print(f" I2C Config: 0b{sensor.i2c_config:b}")
113+
print(f" Test Command: 0b{sensor.test_command:b}")
114+
print(f" Correlation: 0b{sensor.correlation_data}")
115+
except RuntimeError as e:
116+
print(e)
117+
118+
print()
119+
time.sleep(1)
120+
81121
Documentation
82122
=============
83123

0 commit comments

Comments
 (0)