|
12 | 12 | get_brightness,
|
13 | 13 | bootloader,
|
14 | 14 | CommandVals,
|
| 15 | + Game, |
| 16 | + GameControlVal |
15 | 17 | )
|
16 | 18 | from inputmodule.gui.games import snake
|
17 | 19 | from inputmodule.gui.games import ledris
|
@@ -107,10 +109,23 @@ def run_gui(devices):
|
107 | 109 | percentage_scale.pack(fill="x", padx=5, pady=5)
|
108 | 110 |
|
109 | 111 | # Games tab
|
110 |
| - games_frame = ttk.LabelFrame(tab_games, text="Games", style="TLabelframe") |
| 112 | + games_frame = ttk.LabelFrame(tab_games, text="Interactive", style="TLabelframe") |
111 | 113 | games_frame.pack(fill="x", padx=10, pady=5)
|
112 | 114 | ttk.Button(games_frame, text="Snake", command=lambda: perform_action(devices, 'game_snake'), style="TButton").pack(side="left", padx=5, pady=5)
|
113 | 115 | ttk.Button(games_frame, text="Ledris", command=lambda: perform_action(devices, 'game_ledris'), style="TButton").pack(side="left", padx=5, pady=5)
|
| 116 | + gol_frame = ttk.LabelFrame(tab_games, text="Game of Life", style="TLabelframe") |
| 117 | + gol_frame.pack(fill="x", padx=10, pady=5) |
| 118 | + animation_buttons = { |
| 119 | + "Current Matrix": "gol_current", |
| 120 | + "Pattern 1": "gol_pattern1", |
| 121 | + "Blinker": "gol_blinker", |
| 122 | + "Toad": "gol_toad", |
| 123 | + "Beacon": "gol_beacon", |
| 124 | + "Glider": "gol_glider", |
| 125 | + "Stop": "game_stop", |
| 126 | + } |
| 127 | + for text, action in animation_buttons.items(): |
| 128 | + ttk.Button(gol_frame, text=text, command=lambda a=action: perform_action(devices, a), style="TButton").pack(side="left", padx=5, pady=5) |
114 | 129 |
|
115 | 130 | # Countdown Timer
|
116 | 131 | countdown_frame = ttk.LabelFrame(tab2, text="Countdown Timer", style="TLabelframe")
|
@@ -187,6 +202,13 @@ def perform_action(devices, action):
|
187 | 202 | "stop_animation": lambda dev: animate(dev, False),
|
188 | 203 | "start_time": lambda dev: threading.Thread(target=clock, args=(dev,), daemon=True).start(),
|
189 | 204 | "start_eq": lambda dev: threading.Thread(target=random_eq, args=(dev,), daemon=True).start(),
|
| 205 | + "gol_current": lambda dev: send_command(dev, CommandVals.StartGame, [Game.GameOfLife, 0]), |
| 206 | + "gol_pattern1": lambda dev: send_command(dev, CommandVals.StartGame, [Game.GameOfLife, 1]), |
| 207 | + "gol_blinker": lambda dev: send_command(dev, CommandVals.StartGame, [Game.GameOfLife, 2]), |
| 208 | + "gol_toad": lambda dev: send_command(dev, CommandVals.StartGame, [Game.GameOfLife, 3]), |
| 209 | + "gol_beacon": lambda dev: send_command(dev, CommandVals.StartGame, [Game.GameOfLife, 4]), |
| 210 | + "gol_glider": lambda dev: send_command(dev, CommandVals.StartGame, [Game.GameOfLife, 5]), |
| 211 | + "game_stop": lambda dev: send_command(dev, CommandVals.GameControl, [GameControlVal.Quit]), |
190 | 212 | }
|
191 | 213 | selected_devices = get_selected_devices(devices)
|
192 | 214 | for dev in selected_devices:
|
|
0 commit comments