From 6e74bf3be0d8096eb05301df4278b1a2f8aeeb30 Mon Sep 17 00:00:00 2001 From: BlueFox Date: Mon, 28 Oct 2024 09:23:01 +0000 Subject: [PATCH] Added WelcomeScreen.py with the basic class (copied from micronEC/welcome.py) --- WelcomeScreen.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 WelcomeScreen.py diff --git a/WelcomeScreen.py b/WelcomeScreen.py new file mode 100644 index 0000000..61c320f --- /dev/null +++ b/WelcomeScreen.py @@ -0,0 +1,51 @@ +""" +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 . +""" + +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! " + + for i in range(loops): + line1 = padding + "Starting..." + padding + line2 = " the Program " + for i in range(32): + self.lcd.putstr(line1[0:16]) + self.lcd.move_to(0,1) + self.lcd.putstr(line2[0:16]) + line1 = line1[1:] + + self.lcd.move_to(0,0) + self.lcd.putstr(started_str) + + # now fade down + time.sleep(2) + self.lcd.move_to(0,0) + self.lcd.putstr(padding + started_str) + time.sleep(0.1) + self.lcd.clear()