Skip to main content

EyesMatrix

The EyesMatrix class controls the NeoPixel LED matrix (Eliobot's eyes): 2 8×8 matrices for a total of 128 LEDs.

Physical layout

        Œ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]

Initialization

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)

Display methods

set_matrix_colors(led_colors)

Defines the color of each LED from a list of 128 RGB tuples.

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

clear_matrix()

Turns off all LEDs.

eyes.clear_matrix()

set_matrix_logo(logo, color)

Displays a logo (list of 128 booleans) with a given color.

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

Predefined emotions

The class includes ready-made logos depicting emotions:

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

Predefined arrows

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

Text scrolling

scroll_matrix_text_both_eyes(text, color, speed=0.1)

Scrolls text over both eyes from right to left.

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)

Scrolls text on one eye.

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)

Supported characters

Scrolling supports letters (upper and lower case), numbers and common symbols: ? ! , . - _ / \ ( ) [ ] @ # $ = + * ^ & % | : ; ' < >

Complete example

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()