""" uv-belichter-software - Some utilities for better customization and modularization 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 config as cfg from time import sleep """ Very simple logging function Overall log level can be specified in config.py """ def log(log_level: int, message: str): log_mapping = {0: "WARN", 1: "INFO", 2: "DEBUG"} log_level = int(log_level) # make sure log_level is an integer if log_level not in [0, 1, 2]: print(f"[LOGGER] Got a message of unknown log level ({log_level}). Original message is printed below.") print(f"{message}") 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()