####################### Mr Inglese #######################
# LIBRARY IMPORTS
import max7219
from machine import Pin, SPI
from time import sleep
from emoticon import setOfIcons
#######################
# INITIALISATION
spi = SPI(0, baudrate=10000000, polarity=1, phase=0, sck=Pin(2), mosi=Pin(3))
cs1 = Pin(5, Pin.OUT) # matrix displays - row 1
cs2 = Pin(10, Pin.OUT) # matrix displays - row 2
display = max7219.Matrix8x16(spi,cs1,cs2,2)
display.init()
xres = 16
startingBrightness = 10 # adjust brightness 1 to 15
#######################
# MAIN LOOP
while 1:
for z in range(len(setOfIcons)):
display.fill(0) # Clear the display array
display.show()
icon = setOfIcons[z]
iconName = icon[0]
iconLines = len(icon)-1
print("\nEmoticon",z+1,'"',iconName,'"',"has",iconLines,"lines")
if iconLines != 0:
display.brightness(startingBrightness)
for y in range(iconLines):
pixelRow = y+1
line = icon[pixelRow]
print('line',pixelRow,"{:16b}".format(line))
for x in range(xres):
if (line & (1<<x)):
display.pixel(xres-1-x,y,1)
display.show()
sleep(0.05)
for b in range(startingBrightness,0,-1):
sleep(0.3)
display.brightness(b)
###### end ######