Skip to content
Snippets Groups Projects
Commit d14be82c authored by michael.divia's avatar michael.divia
Browse files

function set_line working

parent 326e830d
No related branches found
No related tags found
No related merge requests found
from machine import Pin
from neopixel import NeoPixel
np_led = 64
nb_line = 8
nb_row = 8
gpio_neopixel = 0
class Color:
np = NeoPixel(Pin(gpio_neopixel, Pin.OUT), nb_line*nb_row)
class color:
BLACK = (0, 0, 0)
BLUE = (0, 0, 255)
CYAN = (0, 255, 255)
......@@ -39,13 +42,26 @@ class Color:
ORANGE = (255, 128, 0)
ORANGE_YELLOW = (255, 204, 0)
def init_neopixel():
return NeoPixel(Pin(gpio_neopixel, Pin.OUT), np_led)
def col(r, g, b):
return (r, g, b)
class matrix:
def clear(color):
np = init_neopixel()
for i in range(np_led):
# Handle hex an 0
if isinstance(color, int):
if color == 0:
color = (0, 0, 0)
else:
color = ((color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF)
# Handle RGB tuple
elif isinstance(color, tuple) and len(color) == 3:
pass
# Error
else:
raise ValueError("Color must be an RGB tuple, a hex value, 0 or a valide color from the color class")
for i in range(nb_line*nb_row):
np[i] = color
np.write()
\ No newline at end of file
......@@ -42,7 +42,7 @@ J'ai ensuite pris du temps afin de souder des pin à la matrice de LED afin de f
## Mardi, 18 Juin 2024
J'ai commencé par créer `hl3.py` afin d'avoir un fichier librairie avec toutes les fonctions que nous allons implémentées. Je me suis ensuite attelé à la finalisation de la fonction `matrix`.
J'ai commencé par créer `hl3.py` afin d'avoir un fichier librairie avec toutes les fonctions que nous allons implémentées. Je me suis ensuite attelé à la finalisation de la fonction `matrix`. J'ai aussi profité d'implémenter toute les couleurs que nous devions implémentées d'après la documentation.
# Creators
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment