Skip to content

Commit 9d1ef27

Browse files
authored
Merge pull request #1749 from lesamouraipourpre/circuitpython-displayio
CircuitPython_displayio: Update for CP7 I embedded the GitHub code and removed the inline code for the examples
2 parents a7e6892 + 3d51a5b commit 9d1ef27

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

CircuitPython_displayio/displayio_ondiskbitmap.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33

44
display = board.DISPLAY
55

6+
# Current method valid for CircuitPython 6 & 7
7+
68
# Open the file
79
with open("/purple.bmp", "rb") as bitmap_file:
810

911
# Setup the file as the bitmap data source
1012
bitmap = displayio.OnDiskBitmap(bitmap_file)
1113

1214
# Create a TileGrid to hold the bitmap
13-
tile_grid = displayio.TileGrid(bitmap, pixel_shader=getattr(bitmap, 'pixel_shader', displayio.ColorConverter()))
15+
tile_grid = displayio.TileGrid(
16+
bitmap,
17+
pixel_shader=getattr(bitmap, 'pixel_shader', displayio.ColorConverter())
18+
)
1419

1520
# Create a Group to hold the TileGrid
1621
group = displayio.Group()
@@ -24,3 +29,25 @@
2429
# Loop forever so you can enjoy your image
2530
while True:
2631
pass
32+
33+
34+
# Future method for CircuitPython 7 onwards
35+
36+
# Setup the file as the bitmap data source
37+
bitmap = displayio.OnDiskBitmap("/purple.bmp")
38+
39+
# Create a TileGrid to hold the bitmap
40+
tile_grid = displayio.TileGrid(bitmap, pixel_shader=bitmap.pixel_shader)
41+
42+
# Create a Group to hold the TileGrid
43+
group = displayio.Group()
44+
45+
# Add the TileGrid to the Group
46+
group.append(tile_grid)
47+
48+
# Add the Group to the Display
49+
display.show(group)
50+
51+
# Loop forever so you can enjoy your image
52+
while True:
53+
pass

CircuitPython_displayio/displayio_text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
font = terminalio.FONT
1010
color = 0x0000FF
1111

12-
# Create the tet label
13-
text_area = label.Label(font, text="HELLO WORLD", color=0x00FF00)
12+
# Create the text label
13+
text_area = label.Label(font, text=text, color=color)
1414

1515
# Set the location
1616
text_area.x = 100

0 commit comments

Comments
 (0)