API Reference

adafruit_dash_display

CircuitPython library for creating Adafruit IO dashboards.

  • Author(s): Eva Herrada

Implementation Notes

Hardware:

  • This library currently only officially supports the Adafruit Funhouse but other boards are coming soon.

Software and Dependencies:

class adafruit_dash_display.Feed(key: str, default_text: str, formatted_text: str, callback: Callable | None, color: int | None, pub: Callable | None, index: int)

Feed object to make getting and setting different feed properties easier

Parameters:
  • key (str) – The Adafruit IO key.

  • default_text (str) – Text to display before data has been pulled from Adafruit IO.

  • formatted_text (str) – String with formatting placeholders within it ready to have data formatted into it.

  • callback (Callable) – A function to call when the feed is fetched.

  • color (int) – Hex color code for the feed text.

  • pub (Callable) – a function to call when data is published to the feed.

property key: str

Getter for feed key. Will give the value of the feed key

property text: str

Getter for text ready to be formatted. Will give the feed text

property callback: Callable | None

Getter for callback function. Returns the feed callback

property color: int

Getter for text color callback function. Will return the color for the feed

property pub: Callable | None

Getter for publish function, called when a new value is published by this library.

property last_val: str | None

Getter for the last value received

class adafruit_dash_display.Hub(display: BusDisplay, io_mqtt: IO_MQTT, nav: Tuple[digitalio.DigitalInOut, ...])

Object that lets you make an IOT dashboard

Parameters:
  • display (busdisplay.BusDisplay) – The display for the dashboard.

  • io_mqtt (IO_MQTT) – MQTT communications object.

  • nav (Tuple[DigitalInOut, ...]) – The navigation pushbuttons.

simple_text_callback(client: IO_MQTT, feed_id: str, message: str) str

Default callback function that uses the text in the Feed object and the color callback to set the text

Parameters:
  • client (IO_MQTT) – The MQTT client to use.

  • feed_id (str) – The Adafruit IO feed ID.

  • message (str) – The text to display.

Returns:

A string with data formatted into it.

update_text(client: IO_MQTT, feed_id: str, message: str) None

Updates the text on the display

Parameters:
  • client (IO_MQTT) – The MQTT client to use.

  • feed_id (str) – The Adafruit IO feed ID.

  • message (str) – The text to display.

base_pub(var: Any) None

Default function called when a feed is published to

add_device(feed_key: str, default_text: str | None = None, formatted_text: str | None = None, color_callback: int | None = None, callback: Callable | None = None, pub_method: Callable | None = None)

Adds a feed/device to the UI

Parameters:
  • feed_key – The Adafruit IO feed key.

  • default_text (str) – The default text for the device.

  • formatted_text (str) – The formatted text for the device.

  • color_callback (int) – The color to use for the device

  • callback (Callable) – The callback function to be called when data is fetched.

  • pub_method (Callable) – The pub_method to be called when data is published.

get() None

Gets all the subscribed feeds

static connected(client: IO_MQTT) None

Callback for when the device is connected to Adafruit IO

Parameters:

client (IO_MQTT) – The MQTT client to use.

static subscribe(client: IO_MQTT, userdata: Any, topic: str, granted_qos: str) None

Callback for when a new feed is subscribed to

Parameters:
  • client (IO_MQTT) – The MQTT client to use.

  • userdata (str) – The userdata to subscribe to.

  • topic (str) – The topic to subscribe to.

  • granted_qos (str) – The QoS level.

static disconnected(client: IO_MQTT) None

Callback for when the device disconnects from Adafruit IO

Parameters:

client (IO_MQTT) – The MQTT client to use.

message(client: IO_MQTT, feed_id: str, message: str) None

Callback for whenever a new message is received

Parameters:
  • client (IO_MQTT) – The MQTT client to use.

  • feed_id (str) – The Adafruit IO feed ID.

  • message (str) – The message received.

publish(feed: Feed, message: str) None

Callback for publishing a message

Parameters:
  • feed (Feed) – The feed to publish to.

  • message (str) – The message to publish.

loop() None

Loops Adafruit IO and also checks to see if any buttons have been pressed