Skip to main content

Helper library for the Adafruit MagTag

Project description

Introduction

Documentation Status Discord Build Status Code Style: Black

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.6.tar.gz (30.3 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file adafruit-circuitpython-magtag-2.2.6.tar.gz.

File metadata

File hashes

Hashes for adafruit-circuitpython-magtag-2.2.6.tar.gz
Algorithm Hash digest
SHA256 95ca55af33964d9627fa10ce4e4d275cc4ddf2faacdbe49437758eeaed03a02f
MD5 1d65e41b3fad553fdb1c6048127eb3a0
BLAKE2b-256 bc40ebe060a30dd4e4540908fedd84d3695d218c7718fcaeb7e115bf583ff730

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adafruit_circuitpython_magtag-2.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d1e59d4acb9de45307698c9095ceed57893d6f94ff2b996b70436221b326eadc
MD5 76fb14a72f33c97ba7c80d8bf272b680
BLAKE2b-256 9a6ed850624a61e4a1403ee3a778c969f0b0f75a3f1ceef7c383afebd76473bf

See more details on using hashes here.

Supported by

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