Skip to content

Commit 574d690

Browse files
authored
Merge pull request #1753 from lesamouraipourpre/circuitpython-sdcardio-sdioio
CircuitPython sdcardio sdioio: Update for CP7
2 parents c4776f7 + 195e66a commit 574d690

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

CircuitPython_sdcardio_sdioio/show_bitmaps.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,35 @@
22
import time
33

44
import board
5-
import digitalio
65
import displayio
6+
77
import mount_sd
88

99
display = board.DISPLAY
1010

1111
# The bmp files on the sd card will be shown in alphabetical order
12-
bmpfiles = sorted("/sd/" + filename for filename in os.listdir("/sd")
13-
if filename.lower().endswith("bmp"))
12+
bmpfiles = sorted("/sd/" + fn for fn in os.listdir("/sd") if fn.lower().endswith("bmp"))
1413

1514
while True:
15+
if len(bmpfiles) == 0:
16+
print("No BMP files found")
17+
break
18+
1619
for filename in bmpfiles:
1720
print("showing", filename)
1821

22+
# CircuitPython 6 & 7 compatible
1923
bitmap_file = open(filename, "rb")
2024
bitmap = displayio.OnDiskBitmap(bitmap_file)
21-
tile_grid = displayio.TileGrid(bitmap,
22-
pixel_shader=getattr(bitmap, 'pixel_shader', displayio.ColorConverter()))
25+
tile_grid = displayio.TileGrid(
26+
bitmap,
27+
pixel_shader=getattr(bitmap, 'pixel_shader', displayio.ColorConverter())
28+
)
29+
30+
# # CircuitPython 7+ compatible
31+
# bitmap = displayio.OnDiskBitmap(filename)
32+
# tile_grid = displayio.TileGrid(bitmap, pixel_shader=bitmap.pixel_shader)
33+
2334
group = displayio.Group()
2435
group.append(tile_grid)
2536
display.show(group)

0 commit comments

Comments
 (0)