跳转到主要内容

CircuitPython库,用于HT16K33 LED矩阵和段式显示屏。

项目描述

简介

Documentation Status Discord Build Status Code Style: Black

这是一个用于使用基于I²C的LED矩阵和HT16K33芯片的库。它支持16x8和8x8矩阵,以及7段和14段显示。

  • 注意事项

    1. 此库旨在与Adafruit CircuitPython的API兼容。对于与MicroPython机器API兼容的库,请参阅此

    2. 此库不适用于Trellis 4x4 LED+键盘板。对于该产品,请使用: CircuitPython Trellis库

依赖项

此驱动程序依赖于

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

从PyPI安装

在支持GNU/Linux的系统上,如树莓派,您可以从PyPI本地安装驱动程序。要为当前用户安装

pip3 install adafruit-circuitpython-ht16k33

要全局安装(在某些情况下可能需要)

sudo pip3 install adafruit-circuitpython-ht16k33

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

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

使用示例

# Import all board pins and bus interface.
import board
import busio

# Import the HT16K33 LED matrix module.
from adafruit_ht16k33 import matrix

# Create the I2C interface.
i2c = busio.I2C(board.SCL, board.SDA)

# Create the matrix class.
# This creates a 16x8 matrix:
matrix = matrix.Matrix16x8(i2c)
# Or this creates a 8x8 matrix:
#matrix = matrix.Matrix8x8(i2c)
# Or this creates a 8x8 bicolor matrix:
#matrix = matrix.Matrix8x8x2
# Finally you can optionally specify a custom I2C address of the HT16k33 like:
#matrix = matrix.Matrix16x8(i2c, address=0x70)

# Clear the matrix.
matrix.fill(0)

# Set a pixel in the origin 0,0 position.
matrix[0, 0] = 1
# Set a pixel in the middle 8, 4 position.
matrix[8, 4] = 1
# Set a pixel in the opposite 15, 7 position.
matrix[15, 7] = 1
matrix.show()

# Change the brightness
matrix.brightness = 8

# Set the blink rate
matrix.blink_rate = 2

文档

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

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

贡献

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

项目详情


下载文件

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

源分布

adafruit-circuitpython-ht16k33-4.6.9.tar.gz (38.9 kB 查看哈希值)

上传时间

构建分布

adafruit_circuitpython_ht16k33-4.6.9-py3-none-any.whl (16.4 kB 查看哈希值)

上传时间 Python 3

支持者

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