####################### Mr Inglese #######################
# LIBRARY IMPORTS
import max7219
from machine import Pin, SPI
from time import sleep
#######################
# INITIALISATION
spi = SPI(0, baudrate=10000000, polarity=1, phase=0, sck=Pin(2), mosi=Pin(3))
ss = Pin(5, Pin.OUT)
display = max7219.Matrix8x8(spi, ss, 4)
#######################
# SUB ROUTINES
# This routine takes the sentence, and scrolls it across the screen at the given speed
def scroll(sentence,scrollSpeed,howBright):
display.brightness(howBright) # adjust brightness 1 to 15
scrollSpeed = 1/scrollSpeed # convert the frequency to seconds
length = (len(sentence)*8)
for x in range(32, -length, -1):
display.text(sentence ,x,0,1)
display.show()
sleep(scrollSpeed)
display.fill(0)
#######################
# MAIN LOOP
display.fill(0) # Clear the display array
display.show() # Write the array to the display
while True:
# scroll usage: ( Sentence, Speed(Hz), Brightness 1>15 )
scroll('Mr MAKER is the BEST!',10,1)
scroll('Another sentence to display ',100,15)
#######################