75 lines
1.3 KiB
Python
75 lines
1.3 KiB
Python
from machine import Pin, SPI
|
|
import max7219
|
|
from time import sleep
|
|
|
|
print('Loading Max9 + Max7219...')
|
|
|
|
spi = SPI(1, baudrate=10000000)
|
|
screen = max7219.Max7219(8, 32, spi, Pin(15))
|
|
|
|
def cls():
|
|
|
|
screen.fill(0)
|
|
screen.show()
|
|
|
|
def text(msg):
|
|
|
|
screen.fill(0)
|
|
screen.text(msg, 0, 0, 1)
|
|
screen.show()
|
|
|
|
def textscroll(msg):
|
|
|
|
for scrolls in range(32):
|
|
screen.fill(0)
|
|
screen.text(msg,0,scrolls,1)
|
|
screen.show()
|
|
sleep(0.03)
|
|
|
|
def textv(msg):
|
|
|
|
screen.fill(0)
|
|
for counter, letter in enumerate(msg):
|
|
screen.text(letter, 0, counter*8, 1)
|
|
screen.show()
|
|
|
|
def textvscrollup(msg):
|
|
|
|
for scrolls in range(32,0,-1):
|
|
screen.fill(0)
|
|
for counter, letter in enumerate(msg):
|
|
screen.text(letter, 0, scrolls+counter*8, 1)
|
|
screen.show()
|
|
sleep(0.005)
|
|
|
|
def textvscrolleft(msg):
|
|
|
|
for scrolls in range(8,-8,-1):
|
|
screen.fill(0)
|
|
for counter, letter in enumerate(msg):
|
|
screen.text(letter, scrolls, counter*8, 1)
|
|
screen.show()
|
|
sleep(0.005)
|
|
|
|
def textvblink(msg,times,speed):
|
|
|
|
for count in range(times):
|
|
textv(msg)
|
|
screen.show()
|
|
sleep(speed)
|
|
screen.fill(0)
|
|
sleep(1)
|
|
|
|
def demo():
|
|
|
|
textv('Demo')
|
|
sleep(2)
|
|
#textvblink('text',5,0.5)
|
|
textscroll('abcdef')
|
|
textvscrollup('abcdef')
|
|
sleep(1)
|
|
textvscrolleft('abcdef')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
demo() |