aa
This commit is contained in:
13
init.py
13
init.py
@@ -117,9 +117,20 @@ class AlarmClock:
|
||||
self.setLcdText(f"Saved: {self.alarmHour:02d}:{self.alarmMinute:02d}")
|
||||
print(f"Alarm time saved: {self.alarmHour:02d}:{self.alarmMinute:02d}")
|
||||
|
||||
lastLcdText: str = ""
|
||||
def setLcdText(self, text: str):
|
||||
if text == self.lastLcdText:
|
||||
return
|
||||
self.lastLcdText = text
|
||||
self.lcd.clear()
|
||||
self.lcd.write(" "+text)
|
||||
rows = text.split("\n")
|
||||
for i, row in enumerate(rows):
|
||||
if i == 0:
|
||||
self.lcd.setCursor(0, 0)
|
||||
self.lcd.write(row)
|
||||
elif i == 1:
|
||||
self.lcd.setCursor(0, 1)
|
||||
self.lcd.write(row)
|
||||
print(f"LCD: {text}")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user