inky v1.0.2 Inky View Source

The Inky module provides the public API for interacting with the display.

Link to this section Summary

Types

The Inky process name

Functions

Returns a specification to start this module under a supervisor.

set_pixels sets pixels and draws to the display (or not!), with new pixel data or a painter function.

Shows the internally buffered pixels on the display.

Start an Inky GenServer for a display of type type, with the color accent using the optionally provided options opts.

Stops server.

Link to this section Types

Link to this type

name() View Source
name() :: atom() | {:global, term()} | {:via, module(), term()}

The Inky process name

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

set_pixels(pid, arg, opts \\ %{}) View Source
set_pixels(pid :: pid() | name(), arg :: map() | function(), opts :: map()) ::
  :ok | {:error, :device_busy}

set_pixels sets pixels and draws to the display (or not!), with new pixel data or a painter function.

Returns:

  • :ok - If no push was requested or if it was and it worked, or
  • {:error, :device_busy} - If a push to the device was requested but could not be performed due to the device reporting a busy status.

Parameters

  • pid - A pid or valid name option that can be provided to GenServer.
  • arg - A map of pixels or a painter function.

    • pixels :: map(), a map of pixels to merge into the current state. The map use the structure %{{x, y}: color} to indicate pixel coordinates and a color atom.
    • painter :: (x, y, width, height, pixels), a function that will be invoked to pick a color for all points in the screen, in an undefined order. Should return a color atom.

The color atoms

  • :white
  • :black
  • :accent - The third color for a display. Usually red och yellow.
  • :red - Equivalent to :accent.
  • :yellow - Equivalent to :accent.

Options

  • :border - Atom for the border color.
  • :push - Represents the minimum pixel pushing policy the caller wishes to apply for their request. Valid values are listed and explained below.

    NOTE: the internal state of Inky will still be updated, regardless of which pushing policy is employed.

    • :await - Perform a blocking wait until the display is ready and you can push to it. Clears any previously set timeout. This is the default.
    • :once - Push to the display if it is not busy, otherwise, report that it was busy. :await timeouts are reset if a :once push has failed.
    • {:timeout, :await} - Use genserver timeouts to avoid multiple updates. When the timeout triggers, await device with a blocking wait and then push to the display. If the timeout previously was :once, it is replaced.
    • {:timeout, :once} - Use genserver timeouts to avoid multiple updates. When the timeout triggers, update the display if not busy. Does not downgrade a previously set :await timeout.
    • :skip - Do not push to display. If there has been a timeout previously set, but that has yet to fire, it will remain set.
Link to this function

show(server, opts \\ %{}) View Source

Shows the internally buffered pixels on the display.

If opts[:async] is true, the call will be asynchronous.

Returns :ok.

Link to this function

start_link(type, accent, opts \\ %{}) View Source

Start an Inky GenServer for a display of type type, with the color accent using the optionally provided options opts.

The GenServer deals with the HAL state and pushing pixels to the physical display.

Parameters

  • type - An atom, representing the display type, either :phat or :what
  • accent - An atom, representing the display's third color, one of :black, :red or :yellow.

Options

  • border - Atom for the border color, defaults to :black
  • name - GenServer name option for naming the process

See GenServer.start_link/3 for return values.

Stops server.

Returns :ok.