Fix string identifier format
This commit is contained in:
@@ -36,6 +36,7 @@ class SerialReader:
|
||||
while self._run_event.is_set():
|
||||
line = self.serial.readline()
|
||||
if line:
|
||||
print("Generic method")
|
||||
data = line.decode('utf-8', errors='ignore')
|
||||
self._notify(data)
|
||||
|
||||
@@ -47,4 +48,4 @@ if __name__ == "__main__":
|
||||
|
||||
reader = SerialReader("/dev/ttyUSB1", 57600)
|
||||
reader.subscribe(callback)
|
||||
reader.start()
|
||||
reader.start()
|
||||
|
||||
@@ -21,7 +21,7 @@ class LoraLightSensorReader(SerialReader):
|
||||
match = self.json_pattern.search(line)
|
||||
if match:
|
||||
try:
|
||||
data = json.loads(match.group())
|
||||
data = match.group()
|
||||
self._notify(str(data))
|
||||
except json.JSONDecodeError:
|
||||
print("Received invalid JSON:", match.group())
|
||||
print("Received invalid JSON:", match.group())
|
||||
|
||||
56
rpi/main.py
56
rpi/main.py
@@ -57,59 +57,3 @@ if __name__ == "__main__":
|
||||
except Exception as e:
|
||||
print(e)
|
||||
exit_app()
|
||||
|
||||
"""
|
||||
def get_move(prompt, move_queue):
|
||||
while True:
|
||||
move = input(prompt)
|
||||
move_queue.put(move)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
config = Configuration(host="http://192.168.15.120:8000")
|
||||
setRGB(255, 255, 255)
|
||||
controller = ApiController(config)
|
||||
|
||||
white_name = input("White Name: ")
|
||||
black_name = input("Black Name: ")
|
||||
time_value = int(input("Time value: "))
|
||||
increment = int(input("Increment: "))
|
||||
|
||||
white_clock = Clock(time_value, increment)
|
||||
black_clock = Clock(time_value, increment)
|
||||
|
||||
print("Creating the party...")
|
||||
game_id = controller.create_party(white_name, black_name, time_value, increment)
|
||||
if game_id is None:
|
||||
print("An error occurred while creating the party. Exiting...")
|
||||
exit()
|
||||
|
||||
print("Party Created!")
|
||||
|
||||
currentPlayer = 0
|
||||
white_clock.start()
|
||||
|
||||
move_queue = queue.Queue()
|
||||
input_thread = threading.Thread(target=get_move, args=("", move_queue), daemon=True)
|
||||
input_thread.start()
|
||||
|
||||
while True:
|
||||
setText(f"W {white_clock.clock_to_str()}\n B {black_clock.clock_to_str()}")
|
||||
|
||||
try:
|
||||
move = move_queue.get_nowait()
|
||||
message = "White to play" if currentPlayer == 0 else "Black to play"
|
||||
controller.add_move(game_id, move)
|
||||
|
||||
if currentPlayer == 0:
|
||||
currentPlayer = 1
|
||||
white_clock.start()
|
||||
black_clock.stop()
|
||||
else:
|
||||
currentPlayer = 0
|
||||
black_clock.start()
|
||||
white_clock.stop()
|
||||
except queue.Empty:
|
||||
pass
|
||||
|
||||
time.sleep(1)"""
|
||||
|
||||
Reference in New Issue
Block a user