adafruit_matrixportal.fakerequests

Helper library for the Adafruit RGB Matrix Shield + Metro M4 Airlift Lite.

  • Author(s): Melissa LeBlanc-Williams

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_matrixportal.fakerequests.Fake_Requests(filename)

For faking ‘requests’ using a local file instead of the network.

json()

json parsed version for local requests.

text

raw text version for local requests.

adafruit_matrixportal.matrix

Helper library for the Adafruit RGB Matrix Shield + Metro M4 Airlift Lite.

  • Author(s): Melissa LeBlanc-Williams

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_matrixportal.matrix.Matrix(*, width=64, height=32, bit_depth=2, alt_addr_pins=None, color_order='RGB')

Class representing the Adafruit RGB Matrix. This is used to automatically initialize the display.

Parameters:
  • width (int) – The width of the display in Pixels. Defaults to 64.
  • height (int) – The height of the display in Pixels. Defaults to 32.
  • bit_depth (int) – The number of bits per color channel. Defaults to 2.
  • alt_addr_pins (list) – An alternate set of address pins to use. Defaults to None
  • color_order (string) – A string containing the letter “R”, “G”, and “B” in the order you want. Defaults to “RGB”

adafruit_matrixportal.graphics

Helper library for the Adafruit RGB Matrix Shield + Metro M4 Airlift Lite.

  • Author(s): Melissa LeBlanc-Williams

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_matrixportal.graphics.Graphics(*, default_bg=0, width=64, height=32, bit_depth=2, alt_addr_pins=None, color_order='RGB', debug=False)

Graphics Helper Class for the MatrixPortal Library

Parameters:
  • default_bg – The path to your default background image file or a hex color. Defaults to 0x000000.
  • width (int) – The width of the display in Pixels. Defaults to 64.
  • height (int) – The height of the display in Pixels. Defaults to 32.
  • bit_depth (int) – The number of bits per color channel. Defaults to 2.
  • alt_addr_pins (list) – An alternate set of address pins to use. Defaults to None
  • color_order (string) – A string containing the letter “R”, “G”, and “B” in the order you want. Defaults to “RGB”
  • debug – Turn on debug print outs. Defaults to False.
set_background(file_or_color, position=None)

The background image to a bitmap file.

Parameters:file_or_color – The filename of the chosen background image, or a hex color.

adafruit_matrixportal.matrixportal

Helper library for the Adafruit RGB Matrix Shield + Metro M4 Airlift Lite.

  • Author(s): Melissa LeBlanc-Williams

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_matrixportal.matrixportal.MatrixPortal(*, url=None, headers=None, json_path=None, regexp_path=None, default_bg=0, status_neopixel=None, json_transform=None, esp=None, external_spi=None, bit_depth=2, alt_addr_pins=None, color_order='RGB', debug=False, width=64, height=32)

Class representing the Adafruit RGB Matrix Portal.

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 to None, not the status LED
  • json_transform – A function or a list of functions to call with the parsed JSON. Changes and additions are permitted for the dict object.
  • esp – A passed ESP32 object, Can be used in cases where the ESP32 chip needs to be used before calling the pyportal class. Defaults to None.
  • external_spi (busio.SPI) – A previously declared spi object. Defaults to None.
  • bit_depth (int) – The number of bits per color channel. Defaults to 2.
  • alt_addr_pins (list) – An alternate set of address pins to use. Defaults to None
  • color_order (string) – A string containing the letter “R”, “G”, and “B” in the order you want. Defaults to “RGB”
  • debug – Turn on debug print outs. Defaults to False.
add_text(text_position=None, text_font=<fontio.BuiltinFont object>, text_color=8421504, text_wrap=False, text_maxlen=0, text_transform=None, text_scale=1, scrolling=False, line_spacing=1.25)

Add text labels with settings

Parameters:
  • text_font (str) – The path to your font file for your data text display.
  • text_position – The position of your extracted text on the display in an (x, y) tuple. Can be a list of tuples for when there’s a list of json_paths, for example.
  • text_color – The color of the text, in 0xRRGGBB format. Can be a list of colors for when there’s multiple texts. Defaults to None.
  • text_wrap – Whether or not to wrap text (for long text data chunks). Defaults to False, no wrapping.
  • text_maxlen – The max length of the text for text wrapping. Defaults to 0.
  • text_transform – A function that will be called on the text before display
  • text_scale (int) – The factor to scale the default size of the text by
  • scrolling (bool) – If true, text is placed offscreen and the scroll() function is used to scroll text on a pixel-by-pixel basis. Multiple text labels with the scrolling set to True will be cycled through.
fetch(refresh_url=None, timeout=10)

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

get_io_data(feed_key)

Return all values from the Adafruit IO Feed Data that matches the feed key

Parameters:feed_key (str) – Name of feed key to receive data from.
get_io_feed(feed_key, detailed=False)

Return the Adafruit IO Feed that matches the feed key

Parameters:
  • feed_key (str) – Name of feed key to match.
  • detailed (bool) – Whether to return additional detailed information
get_io_group(group_key)

Return the Adafruit IO Group that matches the group key

Parameters:group_key (str) – Name of group key to match.
get_local_time(location=None)

Accessor function for get_local_time()

static html_color_convert(color)

Convert an HTML color code to an integer

Parameters:color – The color value to be converted
json_path

Get or set the list of json traversal to get data out of. Can be list of lists for multiple data points.

preload_font(glyphs=None, index=0)

Preload font.

Parameters:glyphs – The font glyphs to load. Defaults to None, uses alphanumeric glyphs if None.
push_to_io(feed_key, data)

Push data to an adafruit.io feed

Parameters:
  • feed_key (str) – Name of feed key to push data to.
  • data – data to send to feed
scroll()

Scroll any text that needs scrolling by a single frame. We also we want to queue up multiple lines one after another. To get simultaneous lines, we can simply use a line break.

scroll_text(frame_delay=0.02)

Scroll the entire text all the way across. We also we want to queue up multiple lines one after another. To get simultaneous lines, we can simply use a line break.

set_background(file_or_color, position=None)

The background image to a bitmap file.

Parameters:file_or_color – The filename of the chosen background image, or a hex color.
set_headers(headers)

Set the headers used by fetch().

Parameters:headers – The new header dictionary
set_text(val, index=0)

Display text, with indexing into our list of text boxes.

Parameters:
  • val (str) – The text to be displayed
  • index – Defaults to 0.
set_text_color(color, index=0)

Update the text color, with indexing into our list of text boxes.

Parameters:
  • color (int) – The color value to be used
  • index – Defaults to 0.
url

Get or set the URL of your data source.

static wrap_nicely(string, max_chars)

A helper that will return a list of lines with word-break wrapping.

Parameters:
  • string (str) – The text to be wrapped.
  • max_chars (int) – The maximum number of characters on a line before wrapping.

adafruit_matrixportal.network

Helper library for the Adafruit RGB Matrix Shield + Metro M4 Airlift Lite.

  • Author(s): Melissa LeBlanc-Williams

Implementation Notes

Hardware:

Software and Dependencies:

exception adafruit_matrixportal.network.HttpError

HTTP Specific Error

class adafruit_matrixportal.network.Network(*, status_neopixel=None, esp=None, external_spi=None, extract_values=True, debug=False)

Class representing the Adafruit RGB Matrix Portal.

Parameters:
  • status_neopixel – The pin for the status NeoPixel. Use board.NEOPIXEL for the on-board NeoPixel. Defaults to None, not the status LED
  • esp – A passed ESP32 object, Can be used in cases where the ESP32 chip needs to be used before calling the pyportal class. Defaults to None.
  • external_spi (busio.SPI) – A previously declared spi object. Defaults to None.
  • extract_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.
add_json_transform(json_transform)

Add a function that is applied to JSON data when data is fetched

Parameters:json_transform – A function or a list of functions to call with the parsed JSON. Changes and additions are permitted for the dict object.
connect()

Connect to WiFi using the settings found in secrets.py

fetch(url, *, headers=None, timeout=10)

Fetch data from the specified url and return a response object

fetch_data(url, *, headers=None, json_path=None, regexp_path=None, timeout=10)

Fetch data from the specified url and perfom any parsing

get_io_data(feed_key)

Return all values from Adafruit IO Feed Data that matches the feed key

Parameters:feed_key (str) – Name of feed key to receive data from.
get_io_feed(feed_key, detailed=False)

Return the Adafruit IO Feed that matches the feed key

Parameters:
  • feed_key (str) – Name of feed key to match.
  • detailed (bool) – Whether to return additional detailed information
get_io_group(group_key)

Return the Adafruit IO Group that matches the group key

Parameters:group_key (str) – Name of group key to match.
get_local_time(location=None)

Fetch and “set” the local time of this microcontroller to the local time at the location, using an internet time API.

Parameters:location (str) – Your city and country, e.g. "New York, US".
ip_address

Return the IP Address nicely formatted

static json_traverse(json, path)

Traverse down the specified JSON path and return the value or values

Parameters:
  • json – JSON data to traverse
  • path (list) – The path that we want to follow
neo_status(value)

The status NeoPixel.

Parameters:value – The color to change the NeoPixel.
push_to_io(feed_key, data)

Push data to an adafruit.io feed

Parameters:
  • feed_key (str) – Name of feed key to push data to.
  • data – data to send to feed
wget(url, filename, *, chunk_size=12000)

Download a url and save to filename location, like the command wget.

Parameters:
  • url – The URL from which to obtain the data.
  • filename – The name of the file to save the data to.
  • chunk_size – how much data to read/write at a time.

adafruit_matrixportal.wifi

Helper library for the Adafruit RGB Matrix Shield + Metro M4 Airlift Lite.

  • Author(s): Melissa LeBlanc-Williams

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_matrixportal.wifi.WiFi(*, status_neopixel=None, esp=None, external_spi=None)

Class representing the ESP.

Parameters:
  • status_neopixel – The pin for the status NeoPixel. Use board.NEOPIXEL for the on-board NeoPixel. Defaults to None, not the status LED
  • esp – A passed ESP32 object, Can be used in cases where the ESP32 chip needs to be used before calling the pyportal class. Defaults to None.
  • external_spi (busio.SPI) – A previously declared spi object. Defaults to None.
manager(secrets)

Initialize the WiFi Manager if it hasn’t been cached and return it

neo_status(value)

The status NeoPixel.

Parameters:value – The color to change the NeoPixel.