Skip to content

Commit fb70bf1

Browse files
authored
Merge pull request #1655 from lesamouraipourpre/eink-quickstart
EInk CircuitPython QuickStart: Update for CP7
2 parents 0225ceb + 462b39f commit fb70bf1

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

EInk_CircuitPython_Quickstart/213_tricolor_eink_fw_badge.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,27 @@
6767
g.append(bg_sprite)
6868

6969
# Display a picture from the root directory of the CIRCUITPY drive
70-
# Picture should be HEIGHTxHEIGHT square idealy for a portrait
70+
# Picture should be HEIGHTxHEIGHT square ideally for a portrait
7171
# But could be the entire WIDTHxHEIGHT for a non-portrait
72-
f = open("/picture.bmp", "rb")
72+
filename = "/picture.bmp"
7373

74-
pic = displayio.OnDiskBitmap(f)
7574
# Create a Tilegrid with the bitmap and put in the displayio group
76-
t = displayio.TileGrid(pic, pixel_shader=getattr(pic, 'pixel_shader', displayio.ColorConverter()))
75+
76+
# CircuitPython 6 & 7 compatible
77+
pic = displayio.OnDiskBitmap(open(filename, "rb"))
78+
t = displayio.TileGrid(
79+
pic, pixel_shader=getattr(pic, 'pixel_shader', displayio.ColorConverter())
80+
)
7781
g.append(t)
7882

83+
# # CircuitPython 7+ compatible
84+
# pic = displayio.OnDiskBitmap(filename)
85+
# t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
86+
# g.append(t)
87+
7988
# Draw simple text using the built-in font into a displayio group
8089
# For smaller text, change scale=2 to scale=1
81-
text_group = displayio.Group(max_size=10, scale=2,
90+
text_group = displayio.Group(scale=2,
8291
x=DISPLAY_HEIGHT + 10,
8392
y=int(DISPLAY_HEIGHT/2) - 13)
8493
first_name = "Limor"
@@ -88,7 +97,7 @@
8897
g.append(text_group)
8998

9099
# Draw simple text using the built-in font into a displayio group
91-
text_group = displayio.Group(max_size=10, scale=2,
100+
text_group = displayio.Group(scale=2,
92101
x=DISPLAY_HEIGHT + 10,
93102
y=int(DISPLAY_HEIGHT/2) + 13)
94103
last_name = "Ladyada"

EInk_CircuitPython_Quickstart/213_tricolor_eink_fw_text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
highlight_color=0xff0000)
5555

5656
# Create a display group for our screen objects
57-
g = displayio.Group(max_size=10)
57+
g = displayio.Group()
5858

5959
# Set a background
6060
background_bitmap = displayio.Bitmap(DISPLAY_WIDTH, DISPLAY_HEIGHT, 1)
@@ -67,7 +67,7 @@
6767
g.append(t)
6868

6969
# Draw simple text using the built-in font into a displayio group
70-
text_group = displayio.Group(max_size=10, scale=2, x=20, y=40)
70+
text_group = displayio.Group(scale=2, x=20, y=40)
7171
text = "Hello World!"
7272
text_area = label.Label(terminalio.FONT, text=text, color=FOREGROUND_COLOR)
7373
text_group.append(text_area) # Add this text to the text group

EInk_CircuitPython_Quickstart/27_tricolor_eink_shield_badge.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
highlight_color=0xff0000, rotation=90)
4848

4949
# Create a display group for our screen objects
50-
g = displayio.Group(max_size=10)
50+
g = displayio.Group()
5151

5252
# Set a background
5353
background_bitmap = displayio.Bitmap(DISPLAY_WIDTH, DISPLAY_HEIGHT, 1)
@@ -63,19 +63,28 @@
6363
g.append(bg_sprite)
6464

6565
# Display a picture from the root directory of the CIRCUITPY drive
66-
# Picture should be HEIGHTxHEIGHT square idealy for a portrait
66+
# Picture should be HEIGHTxHEIGHT square ideally for a portrait
6767
# But could be the entire WIDTHxHEIGHT for a non-portrait
68-
f = open("/picture.bmp", "rb")
68+
filename = "/picture.bmp"
6969

70-
pic = displayio.OnDiskBitmap(f)
7170
# Create a Tilegrid with the bitmap and put in the displayio group
72-
t = displayio.TileGrid(pic, pixel_shader=getattr(pic, 'pixel_shader', displayio.ColorConverter()))
71+
72+
# CircuitPython 6 & 7 compatible
73+
pic = displayio.OnDiskBitmap(open(filename, "rb"))
74+
t = displayio.TileGrid(
75+
pic, pixel_shader=getattr(pic, 'pixel_shader', displayio.ColorConverter())
76+
)
7377
g.append(t)
7478

79+
# # CircuitPython 7+ compatible
80+
# pic = displayio.OnDiskBitmap(filename)
81+
# t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
82+
# g.append(t)
83+
7584
# Draw simple text using the built-in font into a displayio group
7685
# For smaller text, change scale=2 to scale=1 as scale 2 doesn't
7786
# allow for much text but the text is bigger.
78-
text_group = displayio.Group(max_size=10, scale=2,
87+
text_group = displayio.Group(scale=2,
7988
x=DISPLAY_HEIGHT + 5,
8089
y=int(DISPLAY_HEIGHT/2) - 13)
8190
first_name = "Limor"
@@ -87,7 +96,7 @@
8796
# Draw simple text using the built-in font into a displayio group
8897
# For smaller text, change scale=2 to scale=1 as scale 2 doesn't
8998
# allow for much text but the text is bigger.
90-
text_group = displayio.Group(max_size=10, scale=2,
99+
text_group = displayio.Group(scale=2,
91100
x=DISPLAY_HEIGHT + 5,
92101
y=int(DISPLAY_HEIGHT/2) + 13)
93102
last_name = "Fried"

EInk_CircuitPython_Quickstart/27_tricolor_eink_shield_text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
highlight_color=0xff0000, rotation=90)
4949

5050
# Create a display group for our screen objects
51-
g = displayio.Group(max_size=10)
51+
g = displayio.Group()
5252

5353
# Set a white background
5454
background_bitmap = displayio.Bitmap(DISPLAY_WIDTH, DISPLAY_HEIGHT, 1)
@@ -61,7 +61,7 @@
6161
g.append(t)
6262

6363
# Draw simple text using the built-in font into a displayio group
64-
text_group = displayio.Group(max_size=10, scale=2, x=40, y=40)
64+
text_group = displayio.Group(scale=2, x=40, y=40)
6565
text = "Hello World!"
6666
text_area = label.Label(terminalio.FONT, text=text, color=FOREGROUND_COLOR)
6767
text_group.append(text_area) # Add this text to the text group

0 commit comments

Comments
 (0)