5
5
import random
6
6
import time
7
7
8
+ from inputmodule import cli
9
+ from inputmodule .gui .ledmatrix import show_string
10
+ from inputmodule .inputmodule import ledmatrix
11
+
8
12
# Initialize pygame
9
13
pygame .init ()
10
14
@@ -49,8 +53,19 @@ def get_board_state(board, current_shape, current_pos):
49
53
temp_board [off_y + y ][off_x + x ] = 1
50
54
return temp_board
51
55
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
+
52
66
# Function to draw the game based on the board state
53
67
def draw_board (board , devices ):
68
+ draw_ledmatrix (board , devices )
54
69
screen .fill (white )
55
70
for y in range (rows ):
56
71
for x in range (cols ):
@@ -189,9 +204,14 @@ def gameLoop(devices):
189
204
190
205
# Flash the screen twice before waiting for restart
191
206
for _ in range (2 ):
207
+ for dev in devices :
208
+ ledmatrix .percentage (dev , 0 )
192
209
screen .fill (black )
193
210
pygame .display .update ()
194
211
time .sleep (0.3 )
212
+
213
+ for dev in devices :
214
+ ledmatrix .percentage (dev , 100 )
195
215
screen .fill (white )
196
216
pygame .display .update ()
197
217
time .sleep (0.3 )
@@ -217,4 +237,8 @@ def gameLoop(devices):
217
237
pygame .quit ()
218
238
quit ()
219
239
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