跳转到主要内容

用于与Adafruit AS7341扩展板配合使用的CircuitPython库

项目描述

简介

Documentation Status Discord Build Status Code Style: Black

CircuitPython库,用于与Adafruit AS7341扩展板配合使用。 注意:由于该库的大小,它可能无法在M0(例如Trinket M0)和其他低内存板上运行。

依赖项

此驱动程序依赖于

请确保所有依赖项都在CircuitPython文件系统中可用。这可以通过下载Adafruit库和驱动程序捆绑包轻松实现。

从PyPI安装

在支持GNU/Linux的系统(如Raspberry Pi)上,您可以从PyPI本地安装驱动程序。为当前用户安装

pip3 install adafruit-circuitpython-as7341

要系统范围内安装(在某些情况下可能需要)

sudo pip3 install adafruit-circuitpython-as7341

在当前项目的虚拟环境中安装

mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-as7341

使用示例

from time import sleep
import board
from adafruit_as7341 import AS7341

i2c = board.I2C()  # uses board.SCL and board.SDA
sensor = AS7341(i2c)


def bar_graph(read_value):
    scaled = int(read_value / 1000)
    return "[%5d] " % read_value + (scaled * "*")


while True:

    print("F1 - 415nm/Violet  %s" % bar_graph(sensor.channel_415nm))
    print("F2 - 445nm//Indigo %s" % bar_graph(sensor.channel_445nm))
    print("F3 - 480nm//Blue   %s" % bar_graph(sensor.channel_480nm))
    print("F4 - 515nm//Cyan   %s" % bar_graph(sensor.channel_515nm))
    print("F5 - 555nm/Green   %s" % bar_graph(sensor.channel_555nm))
    print("F6 - 590nm/Yellow  %s" % bar_graph(sensor.channel_590nm))
    print("F7 - 630nm/Orange  %s" % bar_graph(sensor.channel_630nm))
    print("F8 - 680nm/Red     %s" % bar_graph(sensor.channel_680nm))
    print("Clear              %s" % bar_graph(sensor.channel_clear))
    print("Near-IR (NIR)      %s" % bar_graph(sensor.channel_nir))
    print("\n------------------------------------------------")
    sleep(1)

文档

此库的API文档可以在Read the Docs上找到。

有关构建库文档的信息,请参阅本指南

贡献

欢迎贡献!在为此项目做出贡献之前,请阅读我们的行为准则,以帮助保持项目的友好性。

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪一个,请了解有关安装包的更多信息。

源代码分发

adafruit-circuitpython-as7341-1.2.18.tar.gz (33.4 kB 查看哈希值)

上传时间 源代码

构建分发

adafruit_circuitpython_as7341-1.2.18-py3-none-any.whl (10.3 kB 查看哈希值)

上传时间 Python 3

由以下机构支持

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