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
29 changes: 18 additions & 11 deletions Matrix_Sprite_Animation_Player/matrix_sprite_animation_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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 @@ -57,27 +57,34 @@ 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
if file_list[current_image] in FRAME_DURATION_OVERRIDES:
frame_duration = FRAME_DURATION_OVERRIDES[file_list[current_image]]
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)

current_frame = 0
current_loop = 0
frame_count = int(bitmap.height / matrix.display.height)
frame_duration = DEFAULT_FRAME_DURATION
if file_list[current_image] in FRAME_DURATION_OVERRIDES:
frame_duration = FRAME_DURATION_OVERRIDES[file_list[current_image]]


def advance_image():
Expand Down