适用于I2C的Garmin LIDAR Lite传感器的CircuitPython & Python库。
项目描述
简介
适用于I2C的Garmin LIDAR Lite传感器的CircuitPython & Python库
目前不支持Lidar Lite v4,无法确定何时添加 - 欢迎提交PR!
依赖项
此驱动程序依赖于
请确保所有依赖项都可在CircuitPython文件系统中使用。这可以通过下载 Adafruit库和驱动程序包 来轻松实现。
从PyPI安装
在支持GNU/Linux系统(如Raspberry Pi)上,您可以从PyPI 本地安装驱动程序。为当前用户安装
pip3 install adafruit-circuitpython-lidarlite
要全局安装(在某些情况下可能需要)
sudo pip3 install adafruit-circuitpython-lidarlite
在当前项目中安装虚拟环境
mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-lidarlite
使用示例
V3示例
import time
import board
import busio
import adafruit_lidarlite
# Create library object using our Bus I2C port
i2c = busio.I2C(board.SCL, board.SDA)
# Default configuration, with only i2c wires
sensor = adafruit_lidarlite.LIDARLite(i2c)
while True:
try:
# We print tuples so you can plot with Mu Plotter
print((sensor.distance,))
except RuntimeError as e:
# If we get a reading error, just print it and keep truckin'
print(e)
time.sleep(0.01) # you can remove this for ultra-fast measurements!
V3 HP示例
import time
import busio
import board
import adafruit_lidarlite
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_lidarlite.LIDARLite(i2c, sensor_type=adafruit_lidarlite.TYPE_V3HP)
while True:
try:
print(f"Sensor ID#: {sensor.unit_id}")
print(f"Distance = {sensor.distance}")
print(f" Strength: {sensor.signal_strength}")
except RuntimeError as e:
print(e)
try:
print(f"Status: 0b{sensor.status:b}")
print(f" Busy: {bool(sensor.status & adafruit_lidarlite.STATUS_BUSY_V3HP)}")
print(f" Overflow: {bool(sensor.status & adafruit_lidarlite.STATUS_SIGNAL_OVERFLOW_V3HP)}")
print(f" Health: 0b{sensor.health_status:b}")
print(f" Power Control: 0b{sensor.power_control:b}")
print(f" I2C Config: 0b{sensor.i2c_config:b}")
print(f" Test Command: 0b{sensor.test_command:b}")
print(f" Correlation: 0b{sensor.correlation_data}")
except RuntimeError as e:
print(e)
print()
time.sleep(1)
文档
此库的API文档可以在 Read the Docs 上找到。
有关构建库文档的信息,请参阅 本指南。
贡献
欢迎贡献!请在贡献之前阅读我们的行为准则,以帮助本项目保持欢迎的氛围。
项目详情
关闭
哈希 对 adafruit_circuitpython_lidarlite-1.3.7-py3-none-any.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 2a6d6c40c4070211eda1535e0d8277f88393e8e106e55dac03aebfca85242221 |
|
MD5 | c214aa86d5dcfa2a3e6384dc398d390a |
|
BLAKE2b-256 | e4106647f7b3b1acb37026632a1c0f70050673da01f8ba78531c9e131b700fe8 |