adafruit_magtag.graphics
¶
Helper Library for the Adafruit MagTag.
Author(s): Melissa LeBlanc-Williams
Implementation Notes¶
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
Adafruit’s PortalBase library: https://github.com/adafruit/Adafruit_CircuitPython_PortalBase
- class adafruit_magtag.graphics.Graphics(*, default_bg: str | int = 16777215, auto_refresh: bool = True, rotation: int = 270, debug: bool = False)¶
Graphics Helper Class for the MagTag Library
- Parameters:
default_bg – The path to your default background image file or a hex color. Defaults to 0xFFFFFF.
auto_refresh (bool) – Automatically refresh the eInk after writing to displayio. Defaults to True.
rotation – Default rotation is landscape (270) but can be 0, 90, 180 for portrait/rotated
debug – Turn on debug print outs. Defaults to False.
- qrcode(qr_data: bytes | str, *, qr_size: int = 1, x: int = 0, y: int = 0, qr_color: int = 0) None ¶
Display a QR code on the eInk
- Parameters:
qr_data – The data for the QR code.
qr_size (int) – The scale of the QR code.
x – The x position of upper left corner of the QR code on the display.
y – The y position of upper left corner of the QR code on the display.
adafruit_magtag.magtag
¶
Helper library for the Adafruit MagTag.
Author(s): Melissa LeBlanc-Williams
Implementation Notes¶
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
Adafruit’s PortalBase library: https://github.com/adafruit/Adafruit_CircuitPython_PortalBase
- class adafruit_magtag.magtag.MagTag(*, url: str | None = None, headers: Dict[str, str] | None = None, json_path: Sequence[Any] | None = None, regexp_path: Sequence[str] | None = None, default_bg: str | int = 16777215, status_neopixel: Pin | NeoPixel | None = None, json_transform: Sequence[Callable] | Callable = None, rotation: int = 270, debug: bool = False)¶
Class representing the Adafruit MagTag.
- Parameters:
url – The URL of your data source. Defaults to
None
.headers – The headers for authentication, typically used by Azure API’s.
json_path – The list of json traversal to get data out of. Can be list of lists for multiple data points. Defaults to
None
to not use json.regexp_path – The list of regexp strings to get data out (use a single regexp group). Can be list of regexps for multiple data points. Defaults to
None
to not use regexp.default_bg – The path to your default background image file or a hex color. Defaults to 0x000000.
status_neopixel – The pin for the status NeoPixel. Use
board.NEOPIXEL
for the on-board NeoPixel. Defaults toNone
, to not use the status LEDjson_transform – A function or a list of functions to call with the parsed JSON. Changes and additions are permitted for the
dict
object.rotation – Default rotation is landscape (270) but can be 0, 90, or 180 for portrait/rotated
debug – Turn on debug print outs. Defaults to False.
- enter_light_sleep(sleep_time: float) None ¶
Enter light sleep and resume the program after a certain period of time.
See https://circuitpython.readthedocs.io/en/latest/shared-bindings/alarm/index.html for more details.
- Parameters:
sleep_time (float) – The amount of time to sleep in seconds
- exit_and_deep_sleep(sleep_time: float) None ¶
Stops the current program and enters deep sleep. The program is restarted from the beginning after a certain period of time.
See https://circuitpython.readthedocs.io/en/latest/shared-bindings/alarm/index.html for more details.
Note: This function is for time based deep sleep only. If you want to use a PinAlarm to wake up from deep sleep you need to deinit() the pins and use the alarm module directly.
- Parameters:
sleep_time (float) – The amount of time to sleep in seconds
- fetch(refresh_url: str | None = None, timeout: int = 10, auto_refresh: bool = True) Any ¶
Fetch data from the url we initialized with, perfom any parsing, and display text or graphics. This function does pretty much everything Optionally update the URL
adafruit_magtag.network
¶
Helper library for the Adafruit MagTag.
Author(s): Melissa LeBlanc-Williams
Implementation Notes¶
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
Adafruit’s PortalBase library: https://github.com/adafruit/Adafruit_CircuitPython_PortalBase
- class adafruit_magtag.network.Network(*, status_neopixel: Pin | NeoPixel | None = None, extract_values: bool = True, debug: bool = False)¶
Class representing the Adafruit MagTag.
- Parameters:
status_neopixel – The pin for the status NeoPixel. Use
board.NEOPIXEL
for the on-board NeoPixel. Defaults toNone
, not the status LEDextract_values (bool) – If true, single-length fetched values are automatically extracted from lists and tuples. Defaults to
True
.debug – Turn on debug print outs. Defaults to False.
adafruit_magtag.peripherals
¶
Helper Library for the Adafruit MagTag.
Author(s): Melissa LeBlanc-Williams
Implementation Notes¶
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
Adafruit’s PortalBase library: https://github.com/adafruit/Adafruit_CircuitPython_PortalBase
- class adafruit_magtag.peripherals.Peripherals¶
Peripherals Helper Class for the MagTag Library
- deinit() None ¶
Call deinit to free all resources used by peripherals. You must call this function before you can use the peripheral pins for other purposes like PinAlarm with deep sleep.
- property light: int¶
Return the value of the light sensor. The neopixel_disable property must be false to get a value.
import time from adafruit_magtag.magtag import MagTag magtag = MagTag() while True: print(magtag.peripherals.light) time.sleep(0.01)