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 use4as a standard. The 64x64 panels that we stock use5address 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 theOrientationconstants. 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_planescan 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. -
map- A pixel/lanes mapping list. For Active3 configurations usesimple_multilane_mapper(width, height, n_addr_lines, n_lanes). For single matrix bonnet/HAT this can be omitted.
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 theColorspaceconstants. 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.RGB565andColorspace.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 thePinoutconstantsPinout.AdafruitMatrixBonnet,Pinout.AdafruitMatrixBonnetBGR,Pinout.AdafruitMatrixHat, orPinout.AdafruitMatrixHatBGR. For the active3/Triple Matrix Bonnet usePinout.Active3orPinout.Active3BGR -
framebuffer- Anumpy.arraybuffer as noted above. -
geometry- AGeometryinstance 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)
Triple Matrix Bonnet:
pixelmap = simple_multilane_mapper(width, height, n_addr_lines, n_lanes)
geometry = piomatter.Geometry(width=width, height=height, n_addr_lines=n_addr_lines, n_planes=10, n_temporal_planes=4, map=pixelmap, n_lanes=n_lanes)
framebuffer = np.asarray(canvas) + 0 # Make a mutable copy
matrix = piomatter.PioMatter(colorspace=piomatter.Colorspace.RGB888Packed,
pinout=piomatter.Pinout.Active3,
framebuffer=framebuffer,
geometry=geometry)
Page last edited July 15, 2025
Text editor powered by tinymce.