import machine, neopixel
import time
# --- CONFIGURAÇÕES DO PAINEL (18x4) ---
COLUNAS = 18
LINHAS = 4
NUM_LEDS = 72
pin = machine.Pin(28)
np = neopixel.NeoPixel(pin, NUM_LEDS)
# --- MAPA DE ENDEREÇAMENTO (18x4) ---
# Organizado conforme a sequência de IDs do seu diagram.json
# Cada bloco de 6 colunas segue a lógica de serpente que você criou.
MAPA = [
# Bloco 1 (0-23) # Bloco 2 (24-47) # Bloco 3 (48-71)
[0, 1, 2, 3, 4, 5, 24, 25, 26, 27, 28, 29, 48, 49, 50, 51, 52, 53], # Topo
[23, 18, 17, 12, 11, 6, 47, 42, 41, 36, 35, 30, 71, 66, 65, 60, 59, 54],
[22, 19, 16, 13, 10, 7, 46, 43, 40, 37, 34, 31, 70, 67, 64, 61, 58, 55],
[21, 20, 15, 14, 9, 8, 45, 44, 39, 38, 33, 32, 69, 68, 63, 62, 57, 56] # Base
]
# --- ALFABETO (3x4) ---
LETRAS = {
'A': [0,1,0, 1,0,1, 1,1,1, 1,0,1],
'S': [1,1,1, 1,1,0, 0,1,1, 1,1,1],
'I': [1,1,1, 0,1,0, 0,1,0, 1,1,1],
'D': [1,1,0, 1,0,1, 1,0,1, 1,1,0],
'E': [1,1,1, 1,1,0, 1,0,0, 1,1,1],
'C': [0,1,1, 1,0,0, 1,0,0, 0,1,1],
'O': [1,1,1, 1,0,1, 1,0,1, 1,1,1],
'L': [1,0,0, 1,0,0, 1,0,0, 1,1,1],
'T': [1,1,1, 0,1,0, 0,1,0, 0,1,0],
'V': [1,0,1, 1,0,1, 1,0,1, 0,1,0],
' ': [0,0,0, 0,0,0, 0,0,0, 0,0,0]
}
def exibir_frame(posicao_x, frase, cor):
for i in range(NUM_LEDS): np[i] = (0,0,0)
for char_idx, char in enumerate(frase):
if char not in LETRAS: continue
bitmap = LETRAS[char]
# Espaçamento de 4 colunas (3 da letra + 1 vago)
letra_offset_x = posicao_x + (char_idx * 4)
for i, bit in enumerate(bitmap):
if bit:
l_px = i // 3
c_px = (i % 3) + letra_offset_x
# Renderiza apenas o que está dentro das 18 colunas
if 0 <= c_px < COLUNAS and 0 <= l_px < LINHAS:
id_led = MAPA[l_px][c_px]
np[id_led] = cor
np.write()
# --- LOOP PRINCIPAL ---
FRASE = "A SAIDA E COLETIVA"
COR = (0, 0, 200) # Um branco levemente mais suave
print("Painel 18x4: Iniciando letreiro...")
while True:
# Scroll infinito
for x in range(COLUNAS, -(len(FRASE) * 4), -1):
exibir_frame(x, FRASE, COR)
time.sleep(0.08) # Um pouco mais rápido devido ao tamanho