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

get_led Function

parent 8530450a
No related branches found
No related tags found
No related merge requests found
......@@ -124,3 +124,19 @@ class matrix:
# Apply the array
np.write()
def get_led(column, line):
# Check bounds
if line < 0 or line >= nb_line:
raise ValueError("Line is out of bound")
if column < 0 or column >= nb_row:
raise ValueError("Column is out of bound")
# Get the color of the specific LED
r, g, b = np[line * nb_row + column]
# Convert to hexadecimal
hex_color = (r << 16) | (g << 8) | b
return hex_color
......@@ -3,14 +3,17 @@ import time
matrix.clear(0)
matrix.set_led(5, 5, color.GREEN)
print(matrix.get_led(5,5))
for i in range(8):
matrix.set_line(i, color.RED)
time.sleep(0.2)
time.sleep(0.1)
matrix.set_line(i, 0)
for i in range(8):
matrix.set_column(i, color.RED)
time.sleep(0.2)
time.sleep(0.1)
matrix.set_column(i, 0)
for i in range(8):
......
......@@ -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 aussi profité d'implémenter toute les couleurs que nous devions implémentées d'après la documentation. J'ai ensuite enchaîné avec l'ajout de la fonction `set_line`,`set_column`, `set_led`.
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. J'ai ensuite enchaîné avec l'ajout de la fonction `set_line`,`set_column`, `set_led`, `get_led`.
# Creators
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment