Skip to content
Merged
Show file tree
Hide file tree
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
Binary file modified Matrix_Portal_Tip_Jar/bmps.zip
100755 → 100644
Binary file not shown.
25 changes: 16 additions & 9 deletions Matrix_Portal_Tip_Jar/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

# --- Display setup ---
matrix = Matrix(bit_depth=4)
sprite_group = displayio.Group(max_size=1)
sprite_group = displayio.Group()
matrix.display.show(sprite_group)

# --- Button setup ---
Expand Down Expand Up @@ -68,23 +68,30 @@ def load_image():
while sprite_group:
sprite_group.pop()

bitmap = displayio.OnDiskBitmap(
open(SPRITESHEET_FOLDER + "/" + file_list[CURRENT_IMAGE], "rb")
)

FRAME_COUNT = int(bitmap.height / matrix.display.height)
FRAME_DURATION = DEFAULT_FRAME_DURATION
filename = SPRITESHEET_FOLDER + "/" + file_list[CURRENT_IMAGE]

# CircuitPython 6 & 7 compatible
bitmap = displayio.OnDiskBitmap(open(filename, "rb"))
sprite = displayio.TileGrid(
bitmap,
pixel_shader=getattr(bitmap, 'pixel_shader', displayio.ColorConverter()),
width=1,
height=1,
tile_width=bitmap.width,
tile_height=matrix.display.height,
)

# # CircuitPython 7+ compatible
# bitmap = displayio.OnDiskBitmap(filename)
# sprite = displayio.TileGrid(
# bitmap,
# pixel_shader=bitmap.pixel_shader,
# tile_width=bitmap.width,
# tile_height=matrix.display.height,
# )

sprite_group.append(sprite)

FRAME_COUNT = int(bitmap.height / matrix.display.height)
FRAME_DURATION = DEFAULT_FRAME_DURATION
CURRENT_FRAME = 0
CURRENT_LOOP = 0

Expand Down