diff --git a/1 - Code/hl3.py b/1 - Code/hl3.py index e73af305c7f14ad4acb1e0c93e09d38ee074b5e3..a187bff9808a88e24f1fe86e55722402f43eddcf 100644 --- a/1 - Code/hl3.py +++ b/1 - Code/hl3.py @@ -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 diff --git a/1 - Code/main.py b/1 - Code/main.py index 0f428f244136ed377f323b3a50c12e34673a56ee..b105a4644da006403104de94e506594b8d739318 100644 --- a/1 - Code/main.py +++ b/1 - Code/main.py @@ -3,18 +3,21 @@ 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): for j in range(8): matrix.set_led(j, i, color.RED) time.sleep(0.1) - matrix.set_led(j, i, 0) \ No newline at end of file + matrix.set_led(j, i, 0) diff --git a/2 - Reports/Michael_Divia.md b/2 - Reports/Michael_Divia.md index 733c4f3ef78ccf01443fd628608ac221b1614ff2..c6f7e946ea3238dd8811eabd4979f06d78d66ae4 100644 --- a/2 - Reports/Michael_Divia.md +++ b/2 - Reports/Michael_Divia.md @@ -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