Skip to content

Commit

Permalink
python/ledris: Draw on led matrix
Browse files Browse the repository at this point in the history
Draws on all that are connected.

Signed-off-by: Daniel Schaefer <[email protected]>
  • Loading branch information
JohnAZoidberg committed Nov 22, 2024
1 parent 5ee59e0 commit 054722d
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion python/ledris.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import random
import time

from inputmodule import cli
from inputmodule.gui.ledmatrix import show_string
from inputmodule.inputmodule import ledmatrix

# Initialize pygame
pygame.init()

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

def draw_ledmatrix(board, devices):
for dev in devices:
matrix = [[0 for _ in range(34)] for _ in range(9)]
for y in range(rows):
for x in range(cols):
matrix[x][y] = board[y][x]
ledmatrix.render_matrix(dev, matrix)
#vals = [0 for _ in range(39)]
#send_command(dev, CommandVals.Draw, vals)

# Function to draw the game based on the board state
def draw_board(board, devices):
draw_ledmatrix(board, devices)
screen.fill(white)
for y in range(rows):
for x in range(cols):
Expand Down Expand Up @@ -189,9 +204,14 @@ def gameLoop(devices):

# Flash the screen twice before waiting for restart
for _ in range(2):
for dev in devices:
ledmatrix.percentage(dev, 0)
screen.fill(black)
pygame.display.update()
time.sleep(0.3)

for dev in devices:
ledmatrix.percentage(dev, 100)
screen.fill(white)
pygame.display.update()
time.sleep(0.3)
Expand All @@ -217,4 +237,8 @@ def gameLoop(devices):
pygame.quit()
quit()

gameLoop(devices)
if __name__ == "__main__":
devices = cli.find_devs()
for dev in devices:
show_string(dev, 'YAY')
gameLoop(devices)

0 comments on commit 054722d

Please sign in to comment.