Added the WelcomeScreen library

This commit is contained in:
2024-10-28 21:09:23 +01:00
parent bd396913fe
commit 355821a6a9
3 changed files with 137 additions and 37 deletions

View File

@@ -27,37 +27,3 @@ def log(log_level: int, message: str):
elif cfg.LOG_LEVEL >= log_level: # if log level is valid
print(f"[{log_mapping[log_level]}] {message}")
"""
Simple function that displays a startup "welcome" screen
Configurable in config.py
"""
def show_welcome(): # cycles says how often the startup text goes through
cycles = cfg.STARTUP_WELCOME_CYCLES
if cycles < 1:
cycles = 1
padding = " "*cfg.LCD_I2C_NUM_COLS
started_str = cfg.STARTUP_MESSAGE_FINISHED
starting_str = cfg.STARTUP_MESSAGE_STARTING
# slide the first line over the display (animated from right to left)
for i in range(cycles):
line1 = padding + starting_str + padding
line2 = cfg.STARTUP_PROJECT_NAME
for i in range(cfg.LCD_I2C_NUM_COLS + len(starting_str)):
cfg.LCD.putstr(line1[0:16])
cfg.LCD.move_to(0,1)
cfg.LCD.putstr(line2[0:16])
line1 = line1[1:]
cfg.LCD.move_to(0,0)
cfg.LCD.putstr(started_str)
# now fade down
sleep(2)
cfg.LCD.move_to(0,0)
cfg.LCD.putstr(padding + started_str)
sleep(0.1)
cfg.LCD.clear()