Add buzzer and led support

This commit is contained in:
2026-01-04 20:42:52 +01:00
parent 16f354ad60
commit b2ce505c27
6 changed files with 44 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
from hardware.buzzer.buzzer import Buzzer
from hardware.led.led import Led
from models.exceptions.ServiceException import ServiceException
from services.clock_service import ClockService
from services.detection_service import DetectionService
@@ -8,11 +10,15 @@ class GameService:
_detection_service : DetectionService
_clock_service : ClockService
_has_started : bool
_led : Led
_buzzer : Buzzer
def __init__(self):
self._detection_service = DetectionService()
self._clock_service = ClockService()
self._has_started = False
self._led = Led(7)
self._buzzer = Buzzer(6)
def start(self, white_name, back_name, time_control : int, increment : int ) -> None:
if self._has_started :
@@ -20,10 +26,12 @@ class GameService:
self._clock_service.start(time_control, increment)
self._clock_service.set_on_terminated(self.stop)
self._has_started = True
self._led.on()
def stop(self):
self._clock_service.stop()
self._detection_service.stop()
self._buzzer.beep()
self._has_started = False
def make_move(self) -> tuple[bytes, str] | None: