Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 11 additions & 2 deletions CircuitPython_RGBMatrix/fruit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@
# This bitmap contains the emoji we're going to use. It is assumed
# to contain 20 icons, each 20x24 pixels. This fits nicely on the 64x32
# RGB matrix display.
bitmap_file = open("emoji.bmp", 'rb')

filename = "emoji.bmp"

# CircuitPython 6 & 7 compatible
bitmap_file = open(filename, 'rb')
bitmap = displayio.OnDiskBitmap(bitmap_file)
pixel_shader = getattr(bitmap, 'pixel_shader', displayio.ColorConverter())

# # CircuitPython 7+ compatible
# bitmap = displayio.OnDiskBitmap(filename)
# pixel_shader = bitmap.pixel_shader

# Each wheel can be in one of three states:
STOPPED, RUNNING, BRAKING = range(3)
Expand All @@ -35,7 +44,7 @@ def shuffled(seq):
class Wheel(displayio.TileGrid):
def __init__(self):
# Portions of up to 3 tiles are visible.
super().__init__(bitmap=bitmap, pixel_shader=getattr(bitmap, 'pixel_shader', displayio.ColorConverter()),
super().__init__(bitmap=bitmap, pixel_shader=pixel_shader,
width=1, height=3, tile_width=20, tile_height=24)
self.order = shuffled(range(20))
self.state = STOPPED
Expand Down
25 changes: 19 additions & 6 deletions CircuitPython_RGBMatrix/tiled.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,28 @@
rotation=0)

# Load BMP image, create Group and TileGrid to hold it
BITMAP = displayio.OnDiskBitmap(open('wales.bmp', 'rb'))
GROUP = displayio.Group()
GROUP.append(displayio.TileGrid(
FILENAME = "wales.bmp"

# CircuitPython 6 & 7 compatible
BITMAP = displayio.OnDiskBitmap(open(FILENAME, "rb"))
TILEGRID = displayio.TileGrid(
BITMAP,
pixel_shader=getattr(BITMAP, 'pixel_shader', displayio.ColorConverter()),
width=1,
height=1,
tile_width=BITMAP.width,
tile_height=BITMAP.height))
tile_height=BITMAP.height
)

# # CircuitPython 7+ compatible
# BITMAP = displayio.OnDiskBitmap(FILENAME)
# TILEGRID = displayio.TileGrid(
# BITMAP,
# pixel_shader=BITMAP.pixel_shader,
# tile_width=BITMAP.width,
# tile_height=BITMAP.height
# )

GROUP = displayio.Group()
GROUP.append(TILEGRID)
DISPLAY.show(GROUP)
DISPLAY.refresh()

Expand Down