Add LCD display initialization and text setting in AlarmClock class
This commit is contained in:
6
init.py
6
init.py
@@ -4,6 +4,7 @@ from astral.sun import sun
|
|||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
from grove.gpio import GPIO
|
from grove.gpio import GPIO
|
||||||
|
from grove.display.jhd1802 import JHD1802
|
||||||
|
|
||||||
city = LocationInfo("Seinäjoki", "Finland", "Europe/Helsinki", 62.7900, 22.8400)
|
city = LocationInfo("Seinäjoki", "Finland", "Europe/Helsinki", 62.7900, 22.8400)
|
||||||
s = sun(city.observer, date=date.today())
|
s = sun(city.observer, date=date.today())
|
||||||
@@ -21,9 +22,12 @@ class AlarmClock:
|
|||||||
ledGpio: GPIO
|
ledGpio: GPIO
|
||||||
buttonGpio: GPIO
|
buttonGpio: GPIO
|
||||||
lastKnownButtonState: bool = False
|
lastKnownButtonState: bool = False
|
||||||
|
lcd: JHD1802
|
||||||
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)
|
||||||
|
self.lcd = JHD1802()
|
||||||
|
self.setLcdText("AlarmClock Init")
|
||||||
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
@@ -43,6 +47,8 @@ class AlarmClock:
|
|||||||
print(f"Button {button} pressed")
|
print(f"Button {button} pressed")
|
||||||
|
|
||||||
def setLcdText(self, text: str):
|
def setLcdText(self, text: str):
|
||||||
|
self.lcd.clear()
|
||||||
|
self.lcd.write(text)
|
||||||
print(f"LCD: {text}")
|
print(f"LCD: {text}")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user