Saltar al contenido principal

ojosmatriz

La clase EyesMatrix controla la matriz de LED NeoPixel (los ojos de Eliobot): 2 matrices de 8×8 para un total de 128 LED.

Diseño físico

        Œil droit (indices 0–63)          Œil gauche (indices 64–127)
[ 0][ 1][ 2][ 3][ 4][ 5][ 6][ 7] [ 64][ 65][ 66][ 67][ 68][ 69][ 70][ 71]
[ 8][ 9][ 10][ 11][ 12][ 13][ 14][ 15] [ 72][ 73][ 74][ 75][ 76][ 77][ 78][ 79]
[ 16][ 17][ 18][ 19][ 20][ 21][ 22][ 23] [ 80][ 81][ 82][ 83][ 84][ 85][ 86][ 87]
[ 24][ 25][ 26][ 27][ 28][ 29][ 30][ 31] [ 88][ 89][ 90][ 91][ 92][ 93][ 94][ 95]
[ 32][ 33][ 34][ 35][ 36][ 37][ 38][ 39] [ 96][ 97][ 98][ 99][100][101][102][103]
[ 40][ 41][ 42][ 43][ 44][ 45][ 46][ 47] [104][105][106][107][108][109][110][111]
[ 48][ 49][ 50][ 51][ 52][ 53][ 54][ 55] [112][113][114][115][116][117][118][119]
[ 56][ 57][ 58][ 59][ 60][ 61][ 62][ 63] [120][121][122][123][124][125][126][127]

Inicialización

import board
from elio import EyesMatrix

eyes = EyesMatrix(board.IO2, brightness=0.05)
ParamètreTypeDéfautDescription
pinPinPin de la matrice NeoPixel
brightnessfloat0.05Luminosité (0.0 à 1.0)

Métodos de visualización

set_matrix_colors(led_colors)

Define el color de cada LED de una lista de 128 tuplas RGB.

colors = [(255, 0, 0)] * 64 + [(0, 0, 255)] * 64  # Œil droit rouge, gauche bleu
eyes.set_matrix_colors(colors)

clear_matrix()

Apaga todos los LED.

eyes.clear_matrix()

set_matrix_logo(logo, color)

Muestra un logotipo (lista de 128 booleanos) con un color determinado.

eyes.set_matrix_logo(eyes.emotionHappy, (255, 200, 0))

Emociones predefinidas

La clase incluye logotipos ya preparados que representan emociones:

AttributDescription
emotionHappyContent
emotionSadTriste
emotionAngryEn colère
emotionNeutralNeutre
emotionThrilledEnthousiaste
emotionTiredFatigué
emotionAmazedÉtonné
emotionDizzyÉtourdi
emotionConfusedConfus
emotionLoveAmour
emotionKOKO
emotionMusicMusique
eyes.set_matrix_logo(eyes.emotionHappy, (255, 200, 0))   # Yeux jaunes contents
eyes.set_matrix_logo(eyes.emotionSad, (0, 100, 255)) # Yeux bleus tristes

Flechas predefinidas

AttributDescription
arrowRightFlèche droite
arrowLeftFlèche gauche
arrowUpFlèche haut
arrowDownFlèche bas
eyes.set_matrix_logo(eyes.arrowRight, (0, 255, 0))

Desplazamiento de texto

scroll_matrix_text_both_eyes(text, color, speed=0.1)

Desplaza el texto sobre ambos ojos de derecha a izquierda.

ParamètreTypeDéfautDescription
textstrTexte à afficher
colortupleCouleur RGB
speedfloat0.1Délai entre chaque frame (secondes)
eyes.scroll_matrix_text_both_eyes("Eliobot!", (255, 255, 0), speed=0.08)

scroll_matrix_text_eye(text, color, eye=0, speed=0.1)

Desplaza el texto en un ojo.

ParamètreTypeDéfautDescription
textstrTexte à afficher
colortupleCouleur RGB
eyeint ou str00 ou "right" = œil droit, 1 ou "left" = œil gauche
speedfloat0.1Délai entre chaque frame (secondes)
eyes.scroll_matrix_text_eye("Hello", (0, 255, 0), eye="left", speed=0.1)
eyes.scroll_matrix_text_eye("42", (255, 0, 0), eye=0)

Personajes soportados

El desplazamiento admite letras (mayúsculas y minúsculas), números y símbolos comunes: ? ! , . - _ / \ ( ) [ ] @ # $ = + * ^ & % | : ; ' < >

Ejemplo completo

import board
import time
from elio import EyesMatrix

eyes = EyesMatrix(board.IO2, brightness=0.05)

# Afficher une émotion
eyes.set_matrix_logo(eyes.emotionHappy, (255, 200, 0))
time.sleep(2)

# Faire défiler du texte
eyes.scroll_matrix_text_both_eyes("Bonjour!", (0, 200, 255), speed=0.08)

# Éteindre
eyes.clear_matrix()