a
This commit is contained in:
4
init.py
4
init.py
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user