Files
pi-visualizer/test.py
2026-02-15 17:12:23 -07:00

45 lines
1.3 KiB
Python

#!/usr/bin/python3
# SPDX-FileCopyrightText: 2025 Tim Cocks for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
Display a simple test pattern of 3 shapes on a single 64x32 matrix panel.
Run like this:
$ python simpletest.py
"""
import numpy as np
from PIL import Image, ImageDraw
import adafruit_blinka_raspberry_pi5_piomatter as piomatter
width = 192
height = 64
geometry = piomatter.Geometry(width=width, height=height, n_addr_lines=5,
rotation=piomatter.Orientation.Normal, n_planes=6, n_temporal_planes=4)
canvas = Image.new('RGB', (width, height), (0, 0, 0))
draw = ImageDraw.Draw(canvas)
framebuffer = np.asarray(canvas) + 0 # Make a mutable copy
matrix = piomatter.PioMatter(colorspace=piomatter.Colorspace.RGB888Packed,
pinout=piomatter.Pinout.AdafruitMatrixBonnet,
framebuffer=framebuffer,
geometry=geometry)
# draw.rectangle((0, 0, 192, 64), fill=0x008800)
# draw.circle((18, 6), 4, fill=0x880000)
# draw.polygon([(28, 2), (32, 10), (24, 10)], fill=0x000088)
draw.rectangle((0,0,1,64), fill=0x008800)
draw.rectangle((1,0,1,64), fill=0x880000)
framebuffer[:] = np.asarray(canvas)
matrix.show()
input("Press enter to exit")