Helper library for the Adafruit MagTag
Project description
Introduction
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file adafruit-circuitpython-magtag-2.2.7.tar.gz
.
File metadata
- Download URL: adafruit-circuitpython-magtag-2.2.7.tar.gz
- Upload date:
- Size: 30.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c53606c2a82cb986d08d284fa5b910c1bf833699f05cedf521b5588632311ca0 |
|
MD5 | 73c4dd83574fe29dadaf8debc1b1f5d0 |
|
BLAKE2b-256 | 3dcf76877f47f957abf762c8edbea0d951abeffef422684d5bda445e751946d7 |
File details
Details for the file adafruit_circuitpython_magtag-2.2.7-py3-none-any.whl
.
File metadata
- Download URL: adafruit_circuitpython_magtag-2.2.7-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7062d5668aa000e8a7786dd49d73fec587fdf8f316c071ff698bf0edc99e553c |
|
MD5 | 5bd20d376cb434719ceddbb77c367cb0 |
|
BLAKE2b-256 | 0e4cbba7ba522497a829d02b813afdb5a1986c90e370b55650f4d6daec8ac69f |