code.py
1 # SPDX-FileCopyrightText: 2020 Jeff Epler for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 import os 6 import time 7 8 import board 9 import displayio 10 11 display = board.DISPLAY 12 13 # The bmp files on the sd card will be shown in alphabetical order 14 bmpfiles = sorted("/sd/" + fn for fn in os.listdir("/sd") if fn.lower().endswith("bmp")) 15 16 while True: 17 if len(bmpfiles) == 0: 18 print("No BMP files found") 19 break 20 21 for filename in bmpfiles: 22 print("showing", filename) 23 24 # CircuitPython 6 & 7 compatible 25 bitmap_file = open(filename, "rb") 26 bitmap = displayio.OnDiskBitmap(bitmap_file) 27 tile_grid = displayio.TileGrid( 28 bitmap, 29 pixel_shader=getattr(bitmap, 'pixel_shader', displayio.ColorConverter()) 30 ) 31 32 # # CircuitPython 7+ compatible 33 # bitmap = displayio.OnDiskBitmap(filename) 34 # tile_grid = displayio.TileGrid(bitmap, pixel_shader=bitmap.pixel_shader) 35 36 group = displayio.Group() 37 group.append(tile_grid) 38 display.show(group) 39 40 # Show the image for 10 seconds 41 time.sleep(10)