From 60eb340fdb289ad34dcba2bcc1a50991374ad74b Mon Sep 17 00:00:00 2001
From: "michael.divia" <michael.divia@etu.hesge.ch>
Date: Mon, 17 Jun 2024 17:08:08 +0200
Subject: [PATCH] First try at Matrix function

---
 1 - Code/color.py  |  7 +++++++
 1 - Code/main.py   | 13 +++----------
 1 - Code/matrix.py | 11 +++++++++++
 3 files changed, 21 insertions(+), 10 deletions(-)
 create mode 100644 1 - Code/color.py
 create mode 100644 1 - Code/matrix.py

diff --git a/1 - Code/color.py b/1 - Code/color.py
new file mode 100644
index 0000000..5c9c42c
--- /dev/null
+++ b/1 - Code/color.py	
@@ -0,0 +1,7 @@
+class Color:
+    BLACK = (0, 0, 0)
+    BLUE = (0, 0, 255)
+    CYAN = (0, 255, 255)
+    GREEN = (0, 255, 0)
+    MAGENTA = (255, 0, 255)
+    RED = (255, 0, 0)
\ No newline at end of file
diff --git a/1 - Code/main.py b/1 - Code/main.py
index 9a5fbc1..864173b 100644
--- a/1 - Code/main.py	
+++ b/1 - Code/main.py	
@@ -1,17 +1,10 @@
 from machine import Pin
 from neopixel import NeoPixel
-import time
+from matrix import matrix
+from color import color
 
 pin = Pin(0, Pin.OUT)   # set GPIO0 to output to drive NeoPixels
 np = NeoPixel(pin, 64)   # create NeoPixel driver on GPIO0 for 64 pixels
 
 while True:
-    for j in range(3):
-        for i in range(0,64):
-            if j == 0:
-                np[i] = (255, 0, 0)
-            elif j == 1:
-                np[i] = (0, 255, 0)
-            elif j == 2:
-                np[i] = (0, 0, 255)
-            np.write()
\ No newline at end of file
+    matrix.clear(color.RED)
\ No newline at end of file
diff --git a/1 - Code/matrix.py b/1 - Code/matrix.py
new file mode 100644
index 0000000..345e78e
--- /dev/null
+++ b/1 - Code/matrix.py	
@@ -0,0 +1,11 @@
+from machine import Pin
+from neopixel import NeoPixel
+from color import color
+
+pin = Pin(0, Pin.OUT)   # set GPIO0 to output to drive NeoPixels
+np = NeoPixel(pin, 64)   # create NeoPixel driver on GPIO0 for 64 pixels
+
+class matrix:
+    def clear(self, color):
+        for i in range(0,64):
+            np[i] = color
\ No newline at end of file
-- 
GitLab