Skip to content

Commit ca258c3

Browse files
authored
Merge pull request #1686 from lesamouraipourpre/tip-jar
Matrix Portal Tip Jar: Update for CP7 Guide changes made
2 parents 52bbb34 + da7d40e commit ca258c3

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

Matrix_Portal_Tip_Jar/bmps.zip

100755100644
-1.24 KB
Binary file not shown.

Matrix_Portal_Tip_Jar/code.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
# --- Display setup ---
3030
matrix = Matrix(bit_depth=4)
31-
sprite_group = displayio.Group(max_size=1)
31+
sprite_group = displayio.Group()
3232
matrix.display.show(sprite_group)
3333

3434
# --- Button setup ---
@@ -68,23 +68,30 @@ def load_image():
6868
while sprite_group:
6969
sprite_group.pop()
7070

71-
bitmap = displayio.OnDiskBitmap(
72-
open(SPRITESHEET_FOLDER + "/" + file_list[CURRENT_IMAGE], "rb")
73-
)
74-
75-
FRAME_COUNT = int(bitmap.height / matrix.display.height)
76-
FRAME_DURATION = DEFAULT_FRAME_DURATION
71+
filename = SPRITESHEET_FOLDER + "/" + file_list[CURRENT_IMAGE]
7772

73+
# CircuitPython 6 & 7 compatible
74+
bitmap = displayio.OnDiskBitmap(open(filename, "rb"))
7875
sprite = displayio.TileGrid(
7976
bitmap,
8077
pixel_shader=getattr(bitmap, 'pixel_shader', displayio.ColorConverter()),
81-
width=1,
82-
height=1,
8378
tile_width=bitmap.width,
8479
tile_height=matrix.display.height,
8580
)
8681

82+
# # CircuitPython 7+ compatible
83+
# bitmap = displayio.OnDiskBitmap(filename)
84+
# sprite = displayio.TileGrid(
85+
# bitmap,
86+
# pixel_shader=bitmap.pixel_shader,
87+
# tile_width=bitmap.width,
88+
# tile_height=matrix.display.height,
89+
# )
90+
8791
sprite_group.append(sprite)
92+
93+
FRAME_COUNT = int(bitmap.height / matrix.display.height)
94+
FRAME_DURATION = DEFAULT_FRAME_DURATION
8895
CURRENT_FRAME = 0
8996
CURRENT_LOOP = 0
9097

0 commit comments

Comments
 (0)