Initializing matrix panels to display things onto requires 3 main steps:Â
- Create a Geometry object to define the size and shape of the panel(s)
- Create a framebuffer to hold display data
- Create the PioMatter instance.
Geometry
The Geometry
object defines the size and shape of the panel(s) that will serve as the display. There 6 arguments that can be passed to configure it.
-
width
- The total width of the panel(s) in pixels. -
height
- The total height of the panel(s) in pixels. -
n_addr_lines
- The number of connected address lines. The number of pixels in the shift register is automatically computed from these values. Many panels use4
as a standard. The 64x64 panels that we stock use5
address lines. Set this value according to which panels you're using. Note that using 5 addr lines also requires soldering a jumper as described on this guide page. -
serpentine
- Controls the arrangement of multiple panels when they are stacked in rows. If it isTrue
, then each row goes in the opposite direction of the previous row. Default isTrue
. -
rotation
- controls the orientation of the panel(s). Must be one of theOrientation
constants. Default isOrientation.Normal
. Over valid values areOrientation.R180
,Orientation.CW
, andOrientation.CCW
-
n_planes
- Controls the color depth of the panel. This is separate from the framebuffer layout. Decreasingn_planes
can increase FPS at the cost of reduced color fidelity. The default,10
, is the maximum value. -
n_temporal_planes
- Controls the temporal dithering. Valid values are0
,2
, and4
. Cannot be higher thann_planes
. The default is0
. Using larger values can increase the framerate in some cases experiment with your panels and application.
Framebuffer
Next you need a framebuffer
, this is a numpy array that will contain pixel data in the appropriate colorspace. When refreshed the matrix will show the data that is in this framebuffer on the display. Depending on what you're displaying it can be created in a few different ways.
# For displaying an image from PIL, canvas is the PIL.Image instance framebuffer = np.asarray(canvas) + 0 # For displaying arbitrary data, start with zeros framebuffer = np.zeros(shape=(geometry.height, geometry.width, 3), dtype=np.uint8)
PioMatter
Now the PioMatter
instance can be initialized. Aside from the Geometry, and Framebuffer created above, it also accepts arguments for colorspace
and pinout
.
-
colorspace
- Controls the colorspace that will be used for data to be displayed.
It must be one of theColorspace
constants. Which to use depends on what dataÂ
your displaying and how it is processed before copying into the framebuffer. Many of the examples useColorspace.RGB888Packed
. Other valid values areColorspace.RGB565
andColorspace.RGB888
-
pinout
- Defines which pins the panels are wired to. Different pinouts can support different hardware breakouts and panels with different color order. The value must be one of thePinout
constantsPinout.AdafruitMatrixBonnet
,Pinout.AdafruitMatrixBonnetBGR
,Pinout.AdafruitMatrixHat
, orPinout.AdafruitMatrixHatBGR
. -
framebuffer
- Anumpy.array
buffer as noted above. -
geometry
- AGeometry
instance as noted above.
geometry = piomatter.Geometry(width=64, height=32, n_addr_lines=4, rotation=piomatter.Orientation.Normal) matrix_framebuffer = np.zeros(shape=(geometry.height, geometry.width, 3), dtype=np.uint8) matrix = piomatter.PioMatter(colorspace=piomatter.Colorspace.RGB888Packed, pinout=piomatter.Pinout.AdafruitMatrixBonnet, framebuffer=matrix_framebuffer, geometry=geometry)
Page last edited March 11, 2025
Text editor powered by tinymce.