[WelcomeScreen.py] Added

This commit is contained in:
BlueFox 2024-10-28 17:00:17 +00:00
parent cc29f158b4
commit 359c96aacc

View File

@ -20,6 +20,11 @@ import time
class WelcomeScreen:
# __init__() - the constructor
# lcd: an object of I2C_LCD (from the PCF8574T library - https://git.privacynerd.de/BlueFox/micropython-libraries/src/branch/main/PCF8574T)
# subtitle: the text shown below the cycling text (e.g. the device's name, ...) (Lorem ipsum. by default)
# starting_msg: the text shown while cycling (default: Starting...)
# started_msg: the text shown while cycling (default: Started!)
def __init__(self, lcd, subtitle="Lorem ipsum.", starting_msg="Starting...", started_msg="Started!"):
self.lcd = lcd
self.columns = self.lcd.num_columns
@ -28,6 +33,7 @@ class WelcomeScreen:
self.starting_msg = starting_msg
self.started_msg = started_msg
# show() - Display the actual message
# ---
# cycles says how often the Starting text goes through
@ -83,13 +89,13 @@ class WelcomeScreen:
wait_after = fade_down["wait_after"]
else:
wait_after = 0.3
#if self.lines == 4:
# current_display = padding_hyphen + self.started_msg.center(16) + self.subtitle.center(self.columns) + padding_hyphen
#else:
# current_display = self.started_msg.center(16) + self.subtitle.center(self.columns)
self.lcd.move_to(0,y_offset)
self.lcd.putstr(padding + self.started_msg.center(16))
time.sleep(wait_between)
self.lcd.clear()
time.sleep(wait_after)
if self.lines == 4:
old_display = padding_hyphen + self.started_msg.center(16) + self.subtitle.center(self.columns) + padding_hyphen
else:
old_display = self.started_msg.center(16) + self.subtitle.center(self.columns)
self.lcd.move_to(0,0) # move to the start of the lcd
while old_display != "":
old_display = old_display[:-self.columns]
lines_before = " " * (self.columns*self.lines-len(old_display))
self.lcd.putstr(lines_before + old_display)