From 646ddad4cdc0ef61d38a64b5161dc8f156e52437 Mon Sep 17 00:00:00 2001 From: Jason Jackson Date: Fri, 3 Mar 2023 07:51:36 -0500 Subject: [PATCH] Added splash screen --- src/code.py | 23 +++++++++++++++++++++-- src/weather/weather_display.py | 7 ++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/code.py b/src/code.py index cb41bfd..846c894 100644 --- a/src/code.py +++ b/src/code.py @@ -21,6 +21,7 @@ from weather.weather_factory import Factory from weather.weather_display import WeatherDisplay +icon_spritesheet = "/images/weather-icons.bmp" time_format_flag = 0 # 12 or 24 (0 or 1) hour display. bit_depth_value = 1 base_width = 64 @@ -53,14 +54,32 @@ # Associate the RGB matrix with a Display so that we can use displayio features display = framebufferio.FramebufferDisplay(matrix, auto_refresh=True) -network = WifiNetwork() # TODO: catch exception and do something meaninful with it. +#display a splash screen to hide the random text that appears. +icons = displayio.OnDiskBitmap(open(icon_spritesheet, "rb")) +splash = displayio.Group() +splash.x = 24 +splash.y = 8 +bg = displayio.TileGrid( + icons, + pixel_shader=getattr(icons, 'pixel_shader', displayio.ColorConverter()), + tile_width=16, + tile_height=16 +) +splash.append(bg) +display.show(splash) +try: + network = WifiNetwork() # TODO: catch exception and do something meaninful with it. +except Exception as e: + print('Network exception?', e) + datetime = DateTimeProcessing(time_format_flag, network) showSystem = DisplaySubsystem(display, datetime) light_sensor = LightSensor(display) key_input = KeyProcessing(light_sensor, datetime) -weather_display = WeatherDisplay(display) +weather_display = WeatherDisplay(display, icons) + try: if os.getenv('TEMPEST_ENABLE'): weather = Factory('TEMPEST', weather_display, datetime, network) diff --git a/src/weather/weather_display.py b/src/weather/weather_display.py index 2729b09..2577ef0 100644 --- a/src/weather/weather_display.py +++ b/src/weather/weather_display.py @@ -6,12 +6,10 @@ from adafruit_display_shapes.circle import Circle class WeatherDisplay(displayio.Group): - def __init__(self, display) -> None: + def __init__(self, display, icons) -> None: super().__init__() self._display = display - icon_spritesheet = "/images/weather-icons.bmp" small_font = "/fonts/helvB12.bdf" - #small_font = "/fonts/SteelfishRg-Regular-9.bdf" glyphs = b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-,.: " self._current_label = None #index of current label @@ -21,10 +19,9 @@ def __init__(self, display) -> None: self._small_font.load_glyphs(glyphs) self._small_font.load_glyphs(("°",)) - icons = displayio.OnDiskBitmap(open(icon_spritesheet, "rb")) icon_width = 16 icon_height = 16 - + self.scroll_delay = 0.03 self._current_icon = None self._scroll_array = []