Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions Weather_Display_Matrix/openweather_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(
am_pm=True,
units="imperial"
):
super().__init__(max_size=3)
super().__init__()
self.am_pm = am_pm
if units == "metric":
self.celsius = True
Expand All @@ -42,40 +42,50 @@ def __init__(
self.meters_speed = False
self.display = display

splash = displayio.Group(max_size=1)
splash = displayio.Group()
# CircuitPython 6 & 7 compatible
background = displayio.OnDiskBitmap(open("loading.bmp", "rb"))
bg_sprite = displayio.TileGrid(
background,
pixel_shader=getattr(background, 'pixel_shader', displayio.ColorConverter()),
)
# # CircuitPython 7+ compatible
# background = displayio.OnDiskBitmap("loading.bmp")
# bg_sprite = displayio.TileGrid(background, pixel_shader=background.pixel_shader)

splash.append(bg_sprite)
display.show(splash)

self.root_group = displayio.Group(max_size=15)
self.root_group = displayio.Group()
self.root_group.append(self)
self._icon_group = displayio.Group(max_size=1)
self._icon_group = displayio.Group()
self.append(self._icon_group)
self._text_group = displayio.Group(max_size=5)
self._text_group = displayio.Group()
self.append(self._text_group)
self._scrolling_group = displayio.Group(max_size=1)
self._scrolling_group = displayio.Group()
self.append(self._scrolling_group)

# The label index we're currently scrolling
self._current_label = None

# Load the icon sprite sheet
# CircuitPython 6 & 7 compatible
icons = displayio.OnDiskBitmap(open(icon_spritesheet, "rb"))
self._icon_sprite = displayio.TileGrid(
icons,
pixel_shader=getattr(icons, 'pixel_shader', displayio.ColorConverter()),
width=1,
height=1,
tile_width=icon_width,
tile_height=icon_height,
default_tile=0,
x=0,
y=0,
tile_height=icon_height
)
# # CircuitPython 7+ compatible
# icons = displayio.OnDiskBitmap(icon_spritesheet)
# self._icon_sprite = displayio.TileGrid(
# icons,
# pixel_shader=icons.pixel_shader,
# tile_width=icon_width,
# tile_height=icon_height
# )

self.set_icon(None)
self._scrolling_texts = []

Expand All @@ -88,21 +98,21 @@ def __init__(

self.city_text = None

self.temp_text = Label(self.medium_font, max_glyphs=6)
self.temp_text = Label(self.medium_font)
self.temp_text.x = 20
self.temp_text.y = 7
self.temp_text.color = TEMP_COLOR
self._text_group.append(self.temp_text)

self.description_text = Label(self.small_font, max_glyphs=60)
self.description_text = Label(self.small_font)
self.description_text.color = DESCRIPTION_COLOR
self._scrolling_texts.append(self.description_text)

self.humidity_text = Label(self.small_font, max_glyphs=14)
self.humidity_text = Label(self.small_font)
self.humidity_text.color = HUMIDITY_COLOR #
self._scrolling_texts.append(self.humidity_text)

self.wind_text = Label(self.small_font, max_glyphs=10)
self.wind_text = Label(self.small_font)
self.wind_text.color = WIND_COLOR
self._scrolling_texts.append(self.wind_text)

Expand Down