Add LCD display initialization and text setting in AlarmClock class

This commit is contained in:
Aaro Varis
2026-01-15 10:34:01 +02:00
parent ef31822653
commit 1fd81b90f1

View File

@@ -4,6 +4,7 @@ from astral.sun import sun
from datetime import date
from grove.gpio import GPIO
from grove.display.jhd1802 import JHD1802
city = LocationInfo("Seinäjoki", "Finland", "Europe/Helsinki", 62.7900, 22.8400)
s = sun(city.observer, date=date.today())
@@ -21,9 +22,12 @@ class AlarmClock:
ledGpio: GPIO
buttonGpio: GPIO
lastKnownButtonState: bool = False
lcd: JHD1802
def __init__(self, pins: dict = {}):
self.ledGpio = GPIO(pins.get("led", 5), GPIO.OUT)
self.buttonGpio = GPIO(pins.get("button", 6), GPIO.IN)
self.lcd = JHD1802()
self.setLcdText("AlarmClock Init")
def start(self):
@@ -43,6 +47,8 @@ class AlarmClock:
print(f"Button {button} pressed")
def setLcdText(self, text: str):
self.lcd.clear()
self.lcd.write(text)
print(f"LCD: {text}")