Skip to content

Commit

Permalink
Merge pull request #19 from jake1164/splash
Browse files Browse the repository at this point in the history
Added splash screen
  • Loading branch information
jake1164 authored Mar 3, 2023
2 parents 0919fed + 646ddad commit 9075ef1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
23 changes: 21 additions & 2 deletions src/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,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
Expand Down Expand Up @@ -52,14 +53,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)
Expand Down
6 changes: 2 additions & 4 deletions src/weather/weather_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
#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"
glyphs = b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-,.: "
self._current_label = None #index of current label
Expand All @@ -21,10 +20,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 = []
Expand Down

0 comments on commit 9075ef1

Please sign in to comment.