From 200fecd4b1ed8e184712f74a420f5d8232527be5 Mon Sep 17 00:00:00 2001
From: "michael.divia" <michael.divia@etu.hesge.ch>
Date: Tue, 18 Jun 2024 11:00:04 +0200
Subject: [PATCH] get_led Function

---
 1 - Code/hl3.py              | 16 ++++++++++++++++
 1 - Code/main.py             |  9 ++++++---
 2 - Reports/Michael_Divia.md |  2 +-
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/1 - Code/hl3.py b/1 - Code/hl3.py
index e73af30..a187bff 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 0f428f2..b105a46 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 733c4f3..c6f7e94 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
 
-- 
GitLab