aa
This commit is contained in:
17
init.py
17
init.py
@@ -52,6 +52,12 @@ class AlarmClock:
|
||||
currentButtonState = not self.buttonGpio.read()
|
||||
currentTime = time()
|
||||
|
||||
if (self.configMode == "normal"):
|
||||
currentMinute = int((currentTime / 60) % 60)
|
||||
currentHour = int((currentTime / 3600) % 24)
|
||||
|
||||
self.setLcdText(f"Time {currentHour:02d}:{currentMinute:02d} \nAlarm {self.alarmHour:02d}:{self.alarmMinute:02d}")
|
||||
|
||||
# Only process button state change if debounce delay has passed
|
||||
if currentButtonState != self.lastKnownButtonState:
|
||||
if (currentTime - self.lastButtonStateChangeTime) >= self.debounceDelay:
|
||||
@@ -66,16 +72,6 @@ class AlarmClock:
|
||||
self.onLongPress()
|
||||
self.buttonPressStartTime = 0.0 # Reset to prevent repeated triggers
|
||||
|
||||
def setLcdTime(self, hours: int, minutes: int):
|
||||
self.lcd.clear()
|
||||
# write the time on spanning both rows of the LCD
|
||||
timeString = f"{hours:02}:{minutes:02}"
|
||||
self.setLcdText(timeString)
|
||||
|
||||
def generateDualLineTimeString(self, hours: int, minutes: int) -> str:
|
||||
# generate custom characters to display time in dual line format
|
||||
|
||||
|
||||
def onButtonPress(self, button: str, state: bool):
|
||||
print(f"Button '{button}' pressed state: {state}")
|
||||
currentTime = time()
|
||||
@@ -97,7 +93,6 @@ class AlarmClock:
|
||||
if self.configMode == "normal":
|
||||
# Normal mode: toggle relay
|
||||
self.setRelayState(not self.relayGpio.read())
|
||||
self.setLcdText(f"Relay: {'ON' if self.relayGpio.read() else 'OFF'}")
|
||||
elif self.configMode == "set_hour":
|
||||
# Increment hour
|
||||
self.alarmHour = (self.alarmHour + 1) % 24
|
||||
|
||||
Reference in New Issue
Block a user