ScrollHat.Display (scroll_hat v0.1.0) 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/2
and marquee/3
accept a 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.
The frame
argument is the frame (0-7) to write for the LED driver. The default
is the first frame 0
. However, this rarely needs to be used as it is mainly
intended as a memory store on the LED driver chip and is mainly provided for
convenience. The state of the display is instead kept in ScrollHat.Display
When using marquee/3
, 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.
A ScrollHat.Font
has been provided as a convenience to transform text into
a canvas for display:
canvas = ScrollHat.Font.graph("howdy")
ScrollHat.Display.draw(canvas)
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Clear the specified frame of the display
Draw a canvas matrix on the display
Draw a canvas and then scroll it to the left
Link to this section Types
Specs
canvas() :: [[non_neg_integer()], ...]
Specs
frame() :: 0..7
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Specs
clear(frame()) :: IS31FL3731.result()
Clear the specified frame of the display
This sets all LED's of that frame to the off state.
Specs
draw(canvas(), frame()) :: IS31FL3731.result()
Draw a canvas matrix on the display
The canvas 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.
Specs
marquee(canvas(), non_neg_integer(), frame()) :: IS31FL3731.result()
Draw a canvas and then scroll it to the left
step_time
is the number of milliseconds to wait between each step