From 359c96aacc355fd4e9ca9f17ea7a103907eb391d Mon Sep 17 00:00:00 2001 From: BlueFox Date: Mon, 28 Oct 2024 17:00:17 +0000 Subject: [PATCH] [WelcomeScreen.py] Added --- WelcomeScreen.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/WelcomeScreen.py b/WelcomeScreen.py index 52bf389..0ba5d17 100644 --- a/WelcomeScreen.py +++ b/WelcomeScreen.py @@ -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) +