Skip to content

Commit 43f1184

Browse files
Remove max_size usage with displayio.Group
Update OnDiskBitmap filename string usage for CP7
1 parent bd7536a commit 43f1184

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

Matrix_Sprite_Animation_Player/matrix_sprite_animation_player.py

+18-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
# --- Display setup ---
1919
matrix = Matrix(bit_depth=4)
20-
sprite_group = displayio.Group(max_size=1)
20+
sprite_group = displayio.Group()
2121
matrix.display.show(sprite_group)
2222

2323
# --- Button setup ---
@@ -57,27 +57,34 @@ def load_image():
5757
while sprite_group:
5858
sprite_group.pop()
5959

60-
bitmap = displayio.OnDiskBitmap(
61-
open(SPRITESHEET_FOLDER + "/" + file_list[current_image], "rb")
62-
)
63-
64-
frame_count = int(bitmap.height / matrix.display.height)
65-
frame_duration = DEFAULT_FRAME_DURATION
66-
if file_list[current_image] in FRAME_DURATION_OVERRIDES:
67-
frame_duration = FRAME_DURATION_OVERRIDES[file_list[current_image]]
60+
filename = SPRITESHEET_FOLDER + "/" + file_list[current_image]
6861

62+
# CircuitPython 6 & 7 compatible
63+
bitmap = displayio.OnDiskBitmap(open(filename, "rb"))
6964
sprite = displayio.TileGrid(
7065
bitmap,
7166
pixel_shader=getattr(bitmap, 'pixel_shader', displayio.ColorConverter()),
72-
width=1,
73-
height=1,
7467
tile_width=bitmap.width,
7568
tile_height=matrix.display.height,
7669
)
7770

71+
# # CircuitPython 7+ compatible
72+
# bitmap = displayio.OnDiskBitmap(filename)
73+
# sprite = displayio.TileGrid(
74+
# bitmap,
75+
# pixel_shader=bitmap.pixel_shader,
76+
# tile_width=bitmap.width,
77+
# tile_height=matrix.display.height,
78+
# )
79+
7880
sprite_group.append(sprite)
81+
7982
current_frame = 0
8083
current_loop = 0
84+
frame_count = int(bitmap.height / matrix.display.height)
85+
frame_duration = DEFAULT_FRAME_DURATION
86+
if file_list[current_image] in FRAME_DURATION_OVERRIDES:
87+
frame_duration = FRAME_DURATION_OVERRIDES[file_list[current_image]]
8188

8289

8390
def advance_image():

0 commit comments

Comments
 (0)