跳转到主要内容

Adafruit MagTag的辅助库

项目描述

简介

Documentation Status Discord Build Status Code Style: Black

Adafruit MagTag的辅助库。

依赖项

此驱动程序依赖于

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

使用示例

# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
import time
import terminalio
from adafruit_magtag.magtag import MagTag

magtag = MagTag()

magtag.add_text(
    text_font=terminalio.FONT,
    text_position=(
        50,
        (magtag.graphics.display.height // 2) - 1,
    ),
    text_scale=3,
)

magtag.set_text("Hello World")

buttons = magtag.peripherals.buttons
button_colors = ((255, 0, 0), (255, 150, 0), (0, 255, 255), (180, 0, 255))
button_tones = (1047, 1318, 1568, 2093)
timestamp = time.monotonic()

while True:
    for i, b in enumerate(buttons):
        if not b.value:
            print("Button %c pressed" % chr((ord("A") + i)))
            magtag.peripherals.neopixel_disable = False
            magtag.peripherals.neopixels.fill(button_colors[i])
            magtag.peripherals.play_tone(button_tones[i], 0.25)
            break
    else:
        magtag.peripherals.neopixel_disable = True
    time.sleep(0.01)

文档

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

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

贡献

欢迎贡献!请在贡献之前阅读我们的行为准则,以帮助本项目保持开放。

项目详情


下载文件

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

源分发

adafruit-circuitpython-magtag-2.2.10.tar.gz (30.3 kB 查看哈希值)

上传时间:

构建分发

adafruit_circuitpython_magtag-2.2.10-py3-none-any.whl (11.0 kB 查看哈希值)

上传时间: Python 3

支持者