2024-10-28 09:23:01 +00:00
|
|
|
"""
|
|
|
|
WelcomeScreen: A simple library providing a customizable welcome screen fading over an LCD
|
|
|
|
Copyright (C) 2024 Benjamin Burkhardt
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
2024-10-28 10:27:00 +00:00
|
|
|
|
2024-10-28 09:23:01 +00:00
|
|
|
class WelcomeScreen:
|
|
|
|
def __init__(self, lcd):
|
|
|
|
self.lcd = lcd
|
2024-10-28 10:30:27 +00:00
|
|
|
self.columns = self.lcd.num_columns
|
|
|
|
self.lines = self.lcd.num_lines
|
2024-10-28 09:23:01 +00:00
|
|
|
|
2024-10-28 10:27:00 +00:00
|
|
|
def show(self, cycles=1): # loops says how often the Starting text goes through
|
|
|
|
if cycles < 1: cycles = 1
|
2024-10-28 10:30:27 +00:00
|
|
|
padding = " " * self.columns # as much spaces as padding as one display line is long
|
2024-10-28 10:27:00 +00:00
|
|
|
starting_str = "Starting..."
|
2024-10-28 10:30:27 +00:00
|
|
|
started_str = "Started!".center(self.columns)
|
2024-10-28 09:23:01 +00:00
|
|
|
|
2024-10-28 10:27:00 +00:00
|
|
|
for i in range(cycles):
|
|
|
|
line1 = padding + starting_str + padding
|
2024-10-28 10:30:27 +00:00
|
|
|
line2 = "The Program!".center(self.columns)
|
|
|
|
for i in range(self.columns + len(starting_str)):
|
|
|
|
self.lcd.putstr(line1[0:self.columns])
|
2024-10-28 09:23:01 +00:00
|
|
|
self.lcd.move_to(0,1)
|
2024-10-28 10:30:27 +00:00
|
|
|
self.lcd.putstr(line2[0:self.columns])
|
2024-10-28 09:23:01 +00:00
|
|
|
line1 = line1[1:]
|
|
|
|
|
|
|
|
self.lcd.move_to(0,0)
|
|
|
|
self.lcd.putstr(started_str)
|
2024-10-28 10:27:00 +00:00
|
|
|
|
2024-10-28 09:23:01 +00:00
|
|
|
# now fade down
|
2024-10-28 10:27:00 +00:00
|
|
|
time.sleep(1)
|
2024-10-28 09:23:01 +00:00
|
|
|
self.lcd.move_to(0,0)
|
|
|
|
self.lcd.putstr(padding + started_str)
|
|
|
|
time.sleep(0.1)
|
|
|
|
self.lcd.clear()
|
2024-10-28 10:27:00 +00:00
|
|
|
time.sleep(0.3)
|
|
|
|
|