[WelcomeScreen.py] Little performance improvement by bundling all the self.lcd.num_column requests

This commit is contained in:
BlueFox 2024-10-28 10:30:27 +00:00
parent 412ea72867
commit c5baa26545

View File

@ -22,20 +22,22 @@ import time
class WelcomeScreen:
def __init__(self, lcd):
self.lcd = lcd
self.columns = self.lcd.num_columns
self.lines = self.lcd.num_lines
def show(self, cycles=1): # loops says how often the Starting text goes through
if cycles < 1: cycles = 1
padding = " " * self.lcd.num_columns # as much spaces as padding as one display line is long
padding = " " * self.columns # as much spaces as padding as one display line is long
starting_str = "Starting..."
started_str = "Started!".center(self.lcd.num_columns)
started_str = "Started!".center(self.columns)
for i in range(cycles):
line1 = padding + starting_str + padding
line2 = "The Program!".center(self.lcd.num_columns)
for i in range(self.lcd.num_columns + len(starting_str)):
self.lcd.putstr(line1[0:self.lcd.num_columns])
line2 = "The Program!".center(self.columns)
for i in range(self.columns + len(starting_str)):
self.lcd.putstr(line1[0:self.columns])
self.lcd.move_to(0,1)
self.lcd.putstr(line2[0:self.lcd.num_columns])
self.lcd.putstr(line2[0:self.columns])
line1 = line1[1:]
self.lcd.move_to(0,0)