This commit is contained in:
Aaro Varis
2026-01-15 10:35:43 +02:00
parent 1fd81b90f1
commit c3276e6f78

View File

@@ -23,6 +23,7 @@ class AlarmClock:
buttonGpio: GPIO buttonGpio: GPIO
lastKnownButtonState: bool = False lastKnownButtonState: bool = False
lcd: JHD1802 lcd: JHD1802
lastButtonPressTime: float = 0.0
def __init__(self, pins: dict = {}): def __init__(self, pins: dict = {}):
self.ledGpio = GPIO(pins.get("led", 5), GPIO.OUT) self.ledGpio = GPIO(pins.get("led", 5), GPIO.OUT)
self.buttonGpio = GPIO(pins.get("button", 6), GPIO.IN) self.buttonGpio = GPIO(pins.get("button", 6), GPIO.IN)
@@ -45,6 +46,9 @@ class AlarmClock:
def onButtonPress(self, button: str): def onButtonPress(self, button: str):
print(f"Button {button} pressed") print(f"Button {button} pressed")
if button == "button":
self.lastButtonPressTime = time()
self.setLcdText(self.lastButtonPressTime.__str__())
def setLcdText(self, text: str): def setLcdText(self, text: str):
self.lcd.clear() self.lcd.clear()