from machine import Pin, SPI
from max7219 import Matrix8x8
from time import sleep
#Spremenljivke za glavni program
delay = 0.5
#Naslavljanje Max7219-stk
spi = SPI (1, baudrate = 10000000, polarity = 0, phase = 0, sck = (Pin(4, Pin.OUT)), mosi = (Pin(16, Pin.OUT)))
ss = Pin (17, Pin.OUT)
matrix = Matrix8x8 (spi, ss, 8)
#Simboli
heart = [
"00000000",
"00100100",
"01111110",
"01111110",
"01111110",
"00111100",
"00011000",
"00000000"
]
#Podprogrami
#Prikaz 8x8 simbola, seznam = vrednost svetlobnost LED, repeat = število simbolov, ki se bodo pokazali
def Print8x8(sez: list, repeat: int):
for i in range(repeat + 1):
stev = 0
for y in range(0, 8):
for x in range(i*8 - 8, i*8):
matrix.pixel(x, y, sez[stev])
stev += 1
matrix.show()
#Razdelitev seznama str števil svetlobnosti v seznam vseh vrednosti posebaj
def SymbolToBrightness (sez:list) -> list:
rez = []
for row in sez:
for bright in row:
rez.append(int(bright))
return rez
#Glavni program
Heart = SymbolToBrightness(heart)
Print8x8(Heart, 8)