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=16777215, auto_refresh=True, rotation=270, debug=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, *, qr_size=1, x=0, y=0, qr_color=0)¶
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=None, headers=None, json_path=None, regexp_path=None, default_bg=16777215, status_neopixel=None, json_transform=None, rotation=270, debug=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)¶
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)¶
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.
- Parameters
sleep_time (float) – The amount of time to sleep in seconds
- fetch(refresh_url=None, timeout=10, auto_refresh=True)¶
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
- refresh()¶
Refresh the display
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=None, extract_values=True, debug=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.
- property enabled¶
Get or Set whether the WiFi is enabled
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
- property any_button_pressed¶
Return whether any button is pressed
- property battery¶
Return the voltage of the battery
- property button_a_pressed¶
Return whether Button A is pressed
- property button_b_pressed¶
Return whether Button B is pressed
- property button_c_pressed¶
Return whether Button C is pressed
- property button_d_pressed¶
Return whether Button D is pressed
- deinit()¶
Call deinit on all resources to free them
- property light¶
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)
- property neopixel_disable¶
Enable or disable the neopixels for power savings
- play_tone(frequency, duration)¶
Automatically Enable/Disable the speaker and play a tone at the specified frequency for the specified duration It will attempt to play the sound up to 3 times in the case of an error.
- property speaker_disable¶
Enable or disable the speaker for power savings