from machine import Pin, SPI
import max7219
import gc
from utime import sleep
spi = SPI(1, 10_000_000, sck=Pin(14), mosi=Pin(15), miso=Pin(12))
screen = max7219.Max7219(32, 8, spi, Pin(9))
def zfl(s, width):
# Pads the provided string with leading 0's to suit the specified 'chrs' length
# Force # characters, fill with leading 0's
return '{:0>{w}}'.format(s, w=width)
def scroll_text(s,timing):
length = len(s)
column = (length * 8) #Calculate number of columns of the message
for i in range(32,-column,-1):
screen.fill(0)
screen.text(s,i,1,1)
screen.show()
sleep(timing)
while 1:
#Define the scrolling message
msg = "RASPBERRY PI PICO AND MAX7219 -- 8x8 DOT MATRIX SCROLLING DISPLAY"
scroll_text(msg,0.01)
gc.collect()