adafruit_pyportal

CircuitPython driver for Adafruit PyPortal.

  • Author(s): Limor Fried, Kevin J. Walters, Melissa LeBlanc-Williams

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_pyportal.PyPortal(*, url=None, headers=None, json_path=None, regexp_path=None, convert_image=True, default_bg=0, status_neopixel=None, text_font=<sphinx.ext.autodoc.importer._MockObject object>, text_position=None, text_color=8421504, text_wrap=False, text_maxlen=0, text_transform=None, text_scale=1, json_transform=None, image_json_path=None, image_resize=None, image_position=None, image_dim_json_path=None, caption_text=None, caption_font=None, caption_position=None, caption_color=8421504, image_url_path=None, success_callback=None, esp=None, external_spi=None, debug=False, secrets_data=None)

Class representing the Adafruit PyPortal.

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.
  • convert_image – Determine whether or not to use the AdafruitIO image converter service. Set as False if your image is already resized. Defaults to True.
  • 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
  • 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
  • json_transform – A function or a list of functions to call with the parsed JSON. Changes and additions are permitted for the dict object.
  • image_json_path – The JSON traversal path for a background image to display. Defaults to None.
  • image_resize – What size to resize the image we got from the json_path, make this a tuple of the width and height you want. Defaults to None.
  • image_position – The position of the image on the display as an (x, y) tuple. Defaults to None.
  • image_dim_json_path – The JSON traversal path for the original dimensions of image tuple. Used with fetch(). Defaults to None.
  • success_callback – A function we’ll call if you like, when we fetch data successfully. Defaults to None.
  • caption_text (str) – The text of your caption, a fixed text not changed by the data we get. Defaults to None.
  • caption_font (str) – The path to the font file for your caption. Defaults to None.
  • caption_position – The position of your caption on the display as an (x, y) tuple. Defaults to None.
  • caption_color – The color of your caption. Must be a hex value, e.g. 0x808000.
  • image_url_path – The HTTP traversal path for a background image to display. Defaults to None.
  • 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.
  • debug – Turn on debug print outs. Defaults to False.
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

set_caption(caption_text, caption_position, caption_color)

A caption. Requires setting caption_font in init!

Parameters:
  • caption_text – The text of the caption.
  • caption_position – The position of the caption text.
  • caption_color – The color of your caption text. Must be a hex value, e.g. 0x808000.

adafruit_pyportal.graphics

CircuitPython driver for Adafruit PyPortal.

  • Author(s): Limor Fried, Kevin J. Walters, Melissa LeBlanc-Williams

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_pyportal.graphics.Graphics(*, default_bg=None, debug=False)

Graphics Helper Class for the PyPortal Library

Parameters:
  • default_bg – The path to your default background image file or a hex color. Defaults to 0x000000.
  • debug – Turn on debug print outs. Defaults to False.
hide_QR()

Clear any QR codes that are currently on the screen

qrcode(qr_data, *, qr_size=1, x=0, y=0, hide_background=False)

Display a QR code

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_pyportal.network

CircuitPython driver for Adafruit PyPortal.

  • Author(s): Limor Fried, Kevin J. Walters, Melissa LeBlanc-Williams

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_pyportal.network.Network(*, status_neopixel=None, esp=None, external_spi=None, extract_values=True, debug=False, convert_image=True, image_url_path=None, image_json_path=None, image_resize=None, image_position=None, image_dim_json_path=None, secrets_data=None)

Class representing the Adafruit PyPortal.

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.
  • convert_image – Determine whether or not to use the AdafruitIO image converter service. Set as False if your image is already resized. Defaults to True.
  • image_url_path – The HTTP traversal path for a background image to display. Defaults to None.
  • image_json_path – The JSON traversal path for a background image to display. Defaults to None.
  • image_resize – What size to resize the image we got from the json_path, make this a tuple of the width and height you want. Defaults to None.
  • image_position – The position of the image on the display as an (x, y) tuple. Defaults to None.
  • image_dim_json_path – The JSON traversal path for the original dimensions of image tuple. Used with fetch(). Defaults to None.
image_converter_url(image_url, width, height, color_depth=16)

Generate a converted image url from the url passed in, with the given width and height. aio_username and aio_key must be set in secrets.

ip_address

Return the IP Address nicely formatted

process_image(json_data, sd_card=False)

Process image content

Parameters:
  • json_data – The JSON data that we can pluck values from
  • sd_card (bool) – Whether or not we have an SD card inserted

adafruit_pyportal.peripherals

CircuitPython driver for Adafruit PyPortal.

  • Author(s): Limor Fried, Kevin J. Walters, Melissa LeBlanc-Williams

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_pyportal.peripherals.Peripherals(spi, display, splash_group, debug=False)

Peripherals Helper Class for the PyPortal Library

play_file(file_name, wait_to_finish=True)

Play a wav file.

Parameters:file_name (str) – The name of the wav file to play on the speaker.
sd_check()

Returns True if there is an SD card preset and False if there is no SD card. The _sdcard value is set in _init

set_backlight(val)

Adjust the TFT backlight.

Parameters:val – The backlight brightness. Use a value between 0 and 1, where 0 is off, and 1 is 100% brightness.
speaker_disable

Enable or disable the speaker for power savings