from machine import Pin, SPI
import max7219
from time import sleep
spi = SPI(0, sck=Pin(2), mosi=Pin(3))
ss = Pin(5, Pin.OUT)
display = max7219.Matrix8x8(spi, ss, 1)
heart = [ #// 출력할 하트 모양의 2차원 리스트
0b00000000, #// 0x00
0b01101100, #// 0x6c
0b11111110, #// 0xfe
0b11111110, #// 0xfe
0b11111110, #// 0xfe
0b01111100, #// 0x7c
0b00111000, #// 0x38
0b00010000 #// 0x10
]
def draw_heart(): #// 하트 출력 함수
for y, row in enumerate(heart): #// y는 요소의 인덱스, row 해당 줄의 데이터
for x in range(8):
pixel = row >> (7 - x) & 0x01 #// 해당값이 '0' 인지 '1'인지 저장
display.pixel(x, y, pixel) #// x,y의 위치에 LED를 on/off 세팅
display.show() #// 실제로 LED가 출력되는 부분
while True:
draw_heart() #// 하트 그리는 함수 호출
sleep(1) #// 1초 대기