Skip to content

Commit 5bd7ac9

Browse files
committed
main entry point
1 parent 28a425a commit 5bd7ac9

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

main.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
1+
from pyqt.qt import Window, RuntimeData
12
from game.game import Game
23
from colorama import Fore
34
import pygame as pg
5+
import struct
6+
47
import serial
58

69

710
def main():
8-
game: Game = Game(octaves_to_diplay=3)
11+
launcher: Window = Window()
12+
runtime_data: RuntimeData = launcher.run()
13+
14+
mcu_port: str = runtime_data.mcu_port
15+
try:
16+
serial_port: serial.Serial = serial.Serial(mcu_port, 115200, timeout=1)
17+
except serial.SerialException as error:
18+
print(f"{Fore.RED}Invalid MCU port: {error}")
19+
return
20+
21+
game: Game = Game(octaves_to_diplay=runtime_data.octaves)
922
while game.is_running:
10-
print(game.run())
23+
played_frequency: float = game.run()
24+
packed_data = struct.pack("<f", played_frequency)
25+
serial_port.write(packed_data)
26+
print(played_frequency)
1127
pg.quit()
1228

1329

0 commit comments

Comments
 (0)