Skip to content

Commit c1cb589

Browse files
authored
Merge pull request #1750 from lesamouraipourpre/circuitpython-rgbmatrix
CircuitPython RGBMatrix: Update for CP7
2 parents 9d1ef27 + 742ca89 commit c1cb589

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

CircuitPython_RGBMatrix/fruit.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,17 @@
1818
# This bitmap contains the emoji we're going to use. It is assumed
1919
# to contain 20 icons, each 20x24 pixels. This fits nicely on the 64x32
2020
# RGB matrix display.
21-
bitmap_file = open("emoji.bmp", 'rb')
21+
22+
filename = "emoji.bmp"
23+
24+
# CircuitPython 6 & 7 compatible
25+
bitmap_file = open(filename, 'rb')
2226
bitmap = displayio.OnDiskBitmap(bitmap_file)
27+
pixel_shader = getattr(bitmap, 'pixel_shader', displayio.ColorConverter())
28+
29+
# # CircuitPython 7+ compatible
30+
# bitmap = displayio.OnDiskBitmap(filename)
31+
# pixel_shader = bitmap.pixel_shader
2332

2433
# Each wheel can be in one of three states:
2534
STOPPED, RUNNING, BRAKING = range(3)
@@ -35,7 +44,7 @@ def shuffled(seq):
3544
class Wheel(displayio.TileGrid):
3645
def __init__(self):
3746
# Portions of up to 3 tiles are visible.
38-
super().__init__(bitmap=bitmap, pixel_shader=getattr(bitmap, 'pixel_shader', displayio.ColorConverter()),
47+
super().__init__(bitmap=bitmap, pixel_shader=pixel_shader,
3948
width=1, height=3, tile_width=20, tile_height=24)
4049
self.order = shuffled(range(20))
4150
self.state = STOPPED

CircuitPython_RGBMatrix/tiled.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,28 @@
4040
rotation=0)
4141

4242
# Load BMP image, create Group and TileGrid to hold it
43-
BITMAP = displayio.OnDiskBitmap(open('wales.bmp', 'rb'))
44-
GROUP = displayio.Group()
45-
GROUP.append(displayio.TileGrid(
43+
FILENAME = "wales.bmp"
44+
45+
# CircuitPython 6 & 7 compatible
46+
BITMAP = displayio.OnDiskBitmap(open(FILENAME, "rb"))
47+
TILEGRID = displayio.TileGrid(
4648
BITMAP,
4749
pixel_shader=getattr(BITMAP, 'pixel_shader', displayio.ColorConverter()),
48-
width=1,
49-
height=1,
5050
tile_width=BITMAP.width,
51-
tile_height=BITMAP.height))
51+
tile_height=BITMAP.height
52+
)
53+
54+
# # CircuitPython 7+ compatible
55+
# BITMAP = displayio.OnDiskBitmap(FILENAME)
56+
# TILEGRID = displayio.TileGrid(
57+
# BITMAP,
58+
# pixel_shader=BITMAP.pixel_shader,
59+
# tile_width=BITMAP.width,
60+
# tile_height=BITMAP.height
61+
# )
62+
63+
GROUP = displayio.Group()
64+
GROUP.append(TILEGRID)
5265
DISPLAY.show(GROUP)
5366
DISPLAY.refresh()
5467

0 commit comments

Comments
 (0)