Skip to content

Commit 841e39e

Browse files
committed
use new OnDiskBitmap init API
1 parent 7c055d2 commit 841e39e

6 files changed

+57
-65
lines changed

README.rst

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,8 @@ Usage Example
103103
104104
g = displayio.Group()
105105
106-
# CircuitPython 6 & 7 compatible
107-
f = open("/display-ruler.bmp", "rb")
108-
pic = displayio.OnDiskBitmap(f)
109-
t = displayio.TileGrid(
110-
pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
111-
)
112-
113-
# # CircuitPython 7 compatible only
114-
# pic = displayio.OnDiskBitmap("/display-ruler.bmp")
115-
# t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
106+
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
107+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
116108
117109
g.append(t)
118110

examples/ssd1680_2.13_featherwing.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,25 @@
4242

4343
g = displayio.Group()
4444

45-
with open("/display-ruler.bmp", "rb") as f:
46-
pic = displayio.OnDiskBitmap(f)
4745

48-
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
46+
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
4947

50-
g.append(t)
48+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
5149

52-
display.root_group = g
50+
g.append(t)
5351

54-
display.refresh()
52+
display.root_group = g
5553

56-
print("refreshed")
54+
display.refresh()
5755

58-
time.sleep(display.time_to_refresh + 5)
59-
# Always refresh a little longer. It's not a problem to refresh
60-
# a few seconds more, but it's terrible to refresh too early
61-
# (the display will throw an exception when if the refresh
62-
# is too soon)
63-
print("waited correct time")
56+
print("refreshed")
57+
58+
time.sleep(display.time_to_refresh + 5)
59+
# Always refresh a little longer. It's not a problem to refresh
60+
# a few seconds more, but it's terrible to refresh too early
61+
# (the display will throw an exception when if the refresh
62+
# is too soon)
63+
print("waited correct time")
6464

6565

6666
# Keep the display the same

examples/ssd1680_2.13_mono_eink_bonnet.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,23 @@
4949

5050
g = displayio.Group()
5151

52-
with open("display-ruler.bmp", "rb") as f:
53-
pic = displayio.OnDiskBitmap(f)
54-
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
55-
g.append(t)
5652

57-
display.root_group = g
53+
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
54+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
55+
g.append(t)
5856

59-
display.refresh()
57+
display.root_group = g
6058

61-
print("refreshed")
59+
display.refresh()
6260

63-
time.sleep(display.time_to_refresh + 5)
64-
# Always refresh a little longer. It's not a problem to refresh
65-
# a few seconds more, but it's terrible to refresh too early
66-
# (the display will throw an exception when if the refresh
67-
# is too soon)
68-
print("waited correct time")
61+
print("refreshed")
62+
63+
time.sleep(display.time_to_refresh + 5)
64+
# Always refresh a little longer. It's not a problem to refresh
65+
# a few seconds more, but it's terrible to refresh too early
66+
# (the display will throw an exception when if the refresh
67+
# is too soon)
68+
print("waited correct time")
6969

7070

7171
# Keep the display the same

examples/ssd1680_2.13_tricolor_breakout.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@
4141

4242
g = displayio.Group()
4343

44-
with open("/display-ruler.bmp", "rb") as f:
45-
pic = displayio.OnDiskBitmap(f)
4644

47-
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
45+
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
4846

49-
g.append(t)
47+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
5048

51-
display.root_group = g
49+
g.append(t)
5250

53-
display.refresh()
51+
display.root_group = g
5452

55-
print("refreshed")
53+
display.refresh()
5654

57-
time.sleep(120)
55+
print("refreshed")
56+
57+
time.sleep(120)

examples/ssd1680_2.9_tricolor_breakout.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@
4141

4242
g = displayio.Group()
4343

44-
with open("/display-ruler.bmp", "rb") as f:
45-
pic = displayio.OnDiskBitmap(f)
4644

47-
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
45+
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
4846

49-
g.append(t)
47+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
5048

51-
display.root_group = g
49+
g.append(t)
5250

53-
display.refresh()
51+
display.root_group = g
5452

55-
print("refreshed")
53+
display.refresh()
5654

57-
time.sleep(120)
55+
print("refreshed")
56+
57+
time.sleep(120)

examples/ssd1680_simpletest.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,23 @@
5151
g = displayio.Group()
5252

5353
# Note: Check the name of the file. Sometimes the dash is changed to an underscore
54-
with open("/display-ruler.bmp", "rb") as f:
55-
pic = displayio.OnDiskBitmap(f)
56-
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
57-
g.append(t)
5854

59-
display.root_group = g
55+
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
56+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
57+
g.append(t)
6058

61-
display.refresh()
59+
display.root_group = g
6260

63-
print("refreshed")
61+
display.refresh()
6462

65-
time.sleep(display.time_to_refresh + 5)
66-
# Always refresh a little longer. It's not a problem to refresh
67-
# a few seconds more, but it's terrible to refresh too early
68-
# (the display will throw an exception when if the refresh
69-
# is too soon)
70-
print("waited correct time")
63+
print("refreshed")
64+
65+
time.sleep(display.time_to_refresh + 5)
66+
# Always refresh a little longer. It's not a problem to refresh
67+
# a few seconds more, but it's terrible to refresh too early
68+
# (the display will throw an exception when if the refresh
69+
# is too soon)
70+
print("waited correct time")
7171

7272

7373
# Keep the display the same

0 commit comments

Comments
 (0)