Many small changes to WelcomeScreen.py
Changed a parameter name from loops to cycles (for clarity); Improved the fading down animation in the end of the startup screen; Made the class more flexible (should now work on 4x20 LCDs also);
This commit is contained in:
parent
6e74bf3be0
commit
412ea72867
@ -18,34 +18,34 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import time
|
||||
|
||||
"""
|
||||
WelcomeScreen:
|
||||
provide a simple welcome/startup screen
|
||||
"""
|
||||
|
||||
class WelcomeScreen:
|
||||
def __init__(self, lcd):
|
||||
self.lcd = lcd
|
||||
|
||||
def show_welcome(self, loops=1): # loops says how often the Starting text goes through
|
||||
if loops < 1: loops = 1
|
||||
padding = " " # 16 spaces
|
||||
started_str = " Started! "
|
||||
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
|
||||
starting_str = "Starting..."
|
||||
started_str = "Started!".center(self.lcd.num_columns)
|
||||
|
||||
for i in range(loops):
|
||||
line1 = padding + "Starting..." + padding
|
||||
line2 = " the Program "
|
||||
for i in range(32):
|
||||
self.lcd.putstr(line1[0:16])
|
||||
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])
|
||||
self.lcd.move_to(0,1)
|
||||
self.lcd.putstr(line2[0:16])
|
||||
self.lcd.putstr(line2[0:self.lcd.num_columns])
|
||||
line1 = line1[1:]
|
||||
|
||||
self.lcd.move_to(0,0)
|
||||
self.lcd.putstr(started_str)
|
||||
|
||||
|
||||
# now fade down
|
||||
time.sleep(2)
|
||||
time.sleep(1)
|
||||
self.lcd.move_to(0,0)
|
||||
self.lcd.putstr(padding + started_str)
|
||||
time.sleep(0.1)
|
||||
self.lcd.clear()
|
||||
time.sleep(0.3)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user