import machine
import max7219
# Initialize SPI interface for MAX7219 driver
spi = machine.SPI(1, baudrate=10000000, polarity=0, phase=0)
ss = machine.Pin(15, machine.Pin.OUT)
display = max7219.Matrix8x8(spi, ss, 4) # create a 4-module LED matrix display
# Define a simple graphic pattern
pattern = [
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 0, 1, 0, 0, 1, 0, 0],
[0, 0, 0, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 0, 0, 0],
[0, 0, 1, 0, 0, 1, 0, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[1, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 0],
]
# Display the graphic pattern on the LED matrix
for row in pattern:
for i, value in enumerate(row):
display.pixel(i, len(pattern)-1-row.index(row), value)
display.show()