from machine import Pin, SPI
import max7219
import matrixes
from time import sleep
spi = SPI(0,sck=Pin(2),mosi=Pin(3))
cs = Pin(5, Pin.OUT)
display = max7219.Matrix8x8(spi, cs, 11)
display.brightness(10)
def draw(matrix, offset, flipped=False):
size = len(matrix)
if flipped:
for j, line in enumerate(matrix):
for i in range(0,size):
if(matrix[j] & (1 << i)):
display.pixel((size + offset * 8) - (j + 1), i, 1)
else:
for j, line in enumerate(matrix):
for i in range(0,size):
if(matrix[j] & (1 << i)):
display.pixel(j + offset * 8, i, 1)
while True:
display.fill(0)
#display.text('12' ,0*8,0,1)
draw(matrixes.eyes[0],0)
#display.text('45' ,3*8,0,1)
draw(matrixes.eyes[0],3,True)
#display.text('3' ,2*8,0,1)
draw(matrixes.nose[0],2)
#display.text('678',5*8,0,1)
draw(matrixes.mouth[0],5)
#display.text('90a',8*8,0,1)
draw(matrixes.mouth[0],8,True)
display.show()
sleep(100)