Skip to content

Commit 054722d

Browse files
committed
python/ledris: Draw on led matrix
Draws on all that are connected. Signed-off-by: Daniel Schaefer <[email protected]>
1 parent 5ee59e0 commit 054722d

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

python/ledris.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
import random
66
import time
77

8+
from inputmodule import cli
9+
from inputmodule.gui.ledmatrix import show_string
10+
from inputmodule.inputmodule import ledmatrix
11+
812
# Initialize pygame
913
pygame.init()
1014

@@ -49,8 +53,19 @@ def get_board_state(board, current_shape, current_pos):
4953
temp_board[off_y + y][off_x + x] = 1
5054
return temp_board
5155

56+
def draw_ledmatrix(board, devices):
57+
for dev in devices:
58+
matrix = [[0 for _ in range(34)] for _ in range(9)]
59+
for y in range(rows):
60+
for x in range(cols):
61+
matrix[x][y] = board[y][x]
62+
ledmatrix.render_matrix(dev, matrix)
63+
#vals = [0 for _ in range(39)]
64+
#send_command(dev, CommandVals.Draw, vals)
65+
5266
# Function to draw the game based on the board state
5367
def draw_board(board, devices):
68+
draw_ledmatrix(board, devices)
5469
screen.fill(white)
5570
for y in range(rows):
5671
for x in range(cols):
@@ -189,9 +204,14 @@ def gameLoop(devices):
189204

190205
# Flash the screen twice before waiting for restart
191206
for _ in range(2):
207+
for dev in devices:
208+
ledmatrix.percentage(dev, 0)
192209
screen.fill(black)
193210
pygame.display.update()
194211
time.sleep(0.3)
212+
213+
for dev in devices:
214+
ledmatrix.percentage(dev, 100)
195215
screen.fill(white)
196216
pygame.display.update()
197217
time.sleep(0.3)
@@ -217,4 +237,8 @@ def gameLoop(devices):
217237
pygame.quit()
218238
quit()
219239

220-
gameLoop(devices)
240+
if __name__ == "__main__":
241+
devices = cli.find_devs()
242+
for dev in devices:
243+
show_string(dev, 'YAY')
244+
gameLoop(devices)

0 commit comments

Comments
 (0)