ScrollHat.Display (scroll_hat v0.2.1) View Source
Ensure you start the display to initialize the driver manually or in your supervision tree:
{:ok, _pid} = ScrollHat.Display.start_link()
The draw/1
and marquee/2
accept a string of text or 2D 7x17 canvas matrix
where each value represents the LED at that location starting from top-left.
Values must be a positive integer, 0-255, where 0
disables the LED and any value
greater than 0 sets the brightness to that level.
When using marquee/2
, a canvas larger than 7x17 can be supplied in which
the display will attempt to scroll through, left -> right, moving one LED
column at a time.
Use set_font/1
to change the font of the display to one of the supporting
fonts. Note: Fonts are still in development and may not support every
character which might fail trying to convert a text to a canvas
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Clear the display
Draw a canvas matrix or text on the display
Draw a canvas or text and then scroll it to the left.
Set the brightness for all active LEDs for the current canvas
Start the GenServer to manage the Scroll HAT's display
Link to this section Types
Specs
canvas() :: [[non_neg_integer()], ...] | String.t()
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Specs
clear() :: IS31FL3731.result()
Clear the display
This sets all LED's to the off state.
Specs
draw(canvas()) :: IS31FL3731.result() | {:error, :invalid_canvas}
Draw a canvas matrix or text on the display
The canvas matrix is expected to be a 2D 7x17 matrix where each value is an integer between 0-255. The value represents the brightness of the LED at that location and any value > 0 signifies that the LED is on.
If the canvas is a binary, it will be transposed to a matrix based
on the font set with set_font/1
Specs
marquee(canvas(), non_neg_integer()) :: IS31FL3731.result() | {:error, :invalid_canvas}
Draw a canvas or text and then scroll it to the left.
step_time
is the number of milliseconds to wait between each step
See draw/1
for details about canvas
.
Specs
set_brightness(0..255) :: IS31FL3731.result()
Set the brightness for all active LEDs for the current canvas
Specs
start_link(keyword()) :: GenServer.on_start()
Start the GenServer to manage the Scroll HAT's display
This is a singleton GenServer.
Options:
:bus
- the I2C bus going to the Scroll HAT (defaults to"i2c-1"
)