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

set_led function

parent e9938303
No related branches found
No related tags found
No related merge requests found
...@@ -107,3 +107,20 @@ class matrix: ...@@ -107,3 +107,20 @@ class matrix:
# Apply the array # Apply the array
np.write() np.write()
def set_led(column, line, color):
# 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")
# Convert the color
color = color_convert(color)
# Set the specific LED to the color
np[line * nb_row + column] = color
# Apply the array
np.write()
...@@ -12,3 +12,9 @@ for i in range(8): ...@@ -12,3 +12,9 @@ for i in range(8):
matrix.set_column(i, color.RED) matrix.set_column(i, color.RED)
time.sleep(0.2) time.sleep(0.2)
matrix.set_column(i, 0) 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment