跳转到主要内容

适用于I2C的Garmin LIDAR Lite传感器的CircuitPython & Python库。

项目描述

简介

Documentation Status Discord Build Status Code Style: Black

适用于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.tar.gz (28.3 kB 查看哈希)

上传时间

构建分布

adafruit_circuitpython_lidarlite-1.3.7-py3-none-any.whl (7.2 kB 查看哈希)

上传时间 Python 3

由以下赞助

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面