Skip to main content

Helper library for the Adafruit MagTag

Project description

Introduction

Documentation Status Discord Build Status Code Style: Ruff

Helper library for the Adafruit MagTag.

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Usage Example

# 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)

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adafruit_circuitpython_magtag-2.2.17.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adafruit_circuitpython_magtag-2.2.17-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file adafruit_circuitpython_magtag-2.2.17.tar.gz.

File metadata

File hashes

Hashes for adafruit_circuitpython_magtag-2.2.17.tar.gz
Algorithm Hash digest
SHA256 9d29c3a317810b9a0894355c51c3d16cff2df3b0e9eeecb147d5c6ccfd351778
MD5 e41057309d8102339852bae5e3ba0a3a
BLAKE2b-256 8bf612648773bb95f91381ff27e893ff2db94fc5319bab20578e8563f8fbdea7

See more details on using hashes here.

File details

Details for the file adafruit_circuitpython_magtag-2.2.17-py3-none-any.whl.

File metadata

File hashes

Hashes for adafruit_circuitpython_magtag-2.2.17-py3-none-any.whl
Algorithm Hash digest
SHA256 87cb3d75e742e0e8e92a4354bd9b8ee158b6862aafd7919a9d592f648eee60b9
MD5 055ccd53b14c988c2125b0ceba8dd27c
BLAKE2b-256 0db1833479eba97bb1afb5b9adf5c2b66479f9017f3271fc68f90abf6b0a9e65

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page