#Eduardo Rojas Rodriguez
# Grupo: 602-A
from machine import SPI, Pin
import time
spi = SPI(0, 500000, sck = Pin(6), mosi = Pin(7),miso = Pin(4) )
cs = Pin(5, Pin.OUT)
cs.value(1)
def Send(RegNum, data):
buff = [RegNum, data]
cs.value(0)
spi.write(bytearray(buff))
cs.value(1)
def Configure():
Send(0x09, 0)
Send(0x0A, 8)
Send(0x0B, 7)
Send(0x0C, 1)
def Paint(Data_out):
for i in range(0, 8):
Send(i + 1, Data_out[i])
Cuadro1 = [0x10, 0x38, 0x7C, 0xFE, 0x10, 0x10, 0x10, 0x00] # Flecha hacia arriba
Cuadro2 = [0x08, 0x0C, 0x0E, 0xFF, 0xFF, 0x0E, 0x0C, 0x08] # Flecha hacia izquierda
Cuadro3 = [0x00, 0x00, 0x7E, 0x42, 0x42, 0x7E, 0x00, 0x00] # rectangulo en el centro
Cuadro4 = [0x00, 0x18, 0x3C, 0x7E, 0x7E, 0x3C, 0x18, 0x00] # circulo con relleno
Cuadro5 = [0x7E, 0x81, 0xBD, 0xA5, 0xA5, 0xBD, 0x81, 0x7E] # 2 cuadrados
Cuadro6 = [0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81] # una X
Cuadro7 = [0x3C, 0x42, 0x81, 0x81, 0x81, 0x81, 0x42, 0x3C] # Un circulo sin relleno
Cuadro8 = [0x00, 0x18, 0x24, 0x42, 0x42, 0x24, 0x18, 0x00] # Un circulo pequeño
# Lista de imágenes para la animacion
imagenes = [Cuadro1, Cuadro2, Cuadro3, Cuadro4, Cuadro5, Cuadro6, Cuadro7, Cuadro8]
Configure()
while True:
for imagen in imagenes:
Paint(imagen)
time.sleep_ms(300)