Skip to content

Commit 42143b1

Browse files
authored
Merge pull request #34 from FoamyGuy/odb_api_update
use new OnDiskBitmap API
2 parents eb297a8 + eec2195 commit 42143b1

8 files changed

+62
-113
lines changed

README.rst

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,21 @@ Usage Example
5959

6060
.. code-block: python
6161
62+
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
63+
# SPDX-License-Identifier: MIT
64+
6265
"""Simple test script for 2.13" 212x104 tri-color featherwing.
6366
6467
Supported products:
6568
* Adafruit 2.13" Tri-Color FeatherWing
6669
* https://www.adafruit.com/product/4128
67-
"""
68-
70+
"""
6971
import time
72+
7073
import board
7174
import displayio
7275
import fourwire
76+
7377
import adafruit_il0373
7478
7579
displayio.release_displays()
@@ -80,30 +84,24 @@ Usage Example
8084
display_bus = fourwire.FourWire(board.SPI(), command=epd_dc, chip_select=epd_cs, baudrate=1000000)
8185
time.sleep(1)
8286
83-
display = adafruit_il0373.IL0373(display_bus, width=212, height=104, rotation=90,
84-
highlight_color=0xff0000)
87+
display = adafruit_il0373.IL0373(
88+
display_bus, width=212, height=104, rotation=90, highlight_color=0xFF0000
89+
)
8590
8691
g = displayio.Group()
8792
88-
f = open("/display-ruler.bmp", "rb")
89-
90-
pic = displayio.OnDiskBitmap(f)
91-
# CircuitPython 6 & 7 compatible
92-
t = displayio.TileGrid(
93-
pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
94-
)
95-
# CircuitPython 7 compatible only
96-
# t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
93+
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
94+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
9795
g.append(t)
9896
9997
display.root_group = g
10098
10199
display.refresh()
102100
103101
print("refreshed")
104-
105102
time.sleep(120)
106103
104+
107105
Documentation
108106
=============
109107

examples/il0373_1.54_color.py

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

4242
g = displayio.Group()
4343

44-
with open("/display-ruler.bmp", "rb") as f:
45-
pic = displayio.OnDiskBitmap(f)
46-
# CircuitPython 6 & 7 compatible
47-
t = displayio.TileGrid(
48-
pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
49-
)
50-
# CircuitPython 7 compatible only
51-
# t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
52-
g.append(t)
5344

54-
display.root_group = g
45+
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
46+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
47+
g.append(t)
5548

56-
display.refresh()
49+
display.root_group = g
5750

58-
print("refreshed")
51+
display.refresh()
5952

60-
time.sleep(120)
53+
print("refreshed")
54+
55+
time.sleep(120)

examples/il0373_2.13_color.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,13 @@
4747
g = displayio.Group()
4848

4949
# Display a ruler graphic from the root directory of the CIRCUITPY drive
50-
with open("/display-ruler.bmp", "rb") as f:
51-
pic = displayio.OnDiskBitmap(f)
52-
# Create a Tilegrid with the bitmap and put in the displayio group
53-
# CircuitPython 6 & 7 compatible
54-
t = displayio.TileGrid(
55-
pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
56-
)
57-
# CircuitPython 7 compatible only
58-
# t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
59-
g.append(t)
50+
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
51+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
52+
g.append(t)
6053

61-
# Place the display group on the screen
62-
display.root_group = g
54+
display.root_group = g
6355

64-
# Refresh the display to have it actually show the image
65-
# NOTE: Do not refresh eInk displays sooner than 180 seconds
66-
display.refresh()
67-
print("refreshed")
56+
display.refresh()
6857

69-
time.sleep(180)
58+
print("refreshed")
59+
time.sleep(180)

examples/il0373_2.9_color.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,13 @@
4646
g = displayio.Group()
4747

4848
# Display a ruler graphic from the root directory of the CIRCUITPY drive
49-
with open("/display-ruler.bmp", "rb") as f:
50-
pic = displayio.OnDiskBitmap(f)
51-
# Create a Tilegrid with the bitmap and put in the displayio group
52-
# CircuitPython 6 & 7 compatible
53-
t = displayio.TileGrid(
54-
pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
55-
)
56-
# CircuitPython 7 compatible only
57-
# t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
58-
g.append(t)
49+
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
50+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
51+
g.append(t)
5952

60-
# Place the display group on the screen
61-
display.root_group = g
53+
display.root_group = g
6254

63-
# Refresh the display to have it actually show the image
64-
# NOTE: Do not refresh eInk displays sooner than 180 seconds
65-
display.refresh()
66-
print("refreshed")
55+
display.refresh()
6756

68-
time.sleep(180)
57+
print("refreshed")
58+
time.sleep(180)

examples/il0373_2.9_grayscale.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,13 @@
4040

4141
g = displayio.Group()
4242

43-
with open("/display-ruler.bmp", "rb") as f:
44-
pic = displayio.OnDiskBitmap(f)
45-
# CircuitPython 6 & 7 compatible
46-
t = displayio.TileGrid(
47-
pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
48-
)
49-
# CircuitPython 7 compatible only
50-
# t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
51-
g.append(t)
43+
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
44+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
45+
g.append(t)
5246

53-
display.root_group = g
47+
display.root_group = g
5448

55-
display.refresh()
49+
display.refresh()
5650

57-
print("refreshed")
58-
59-
time.sleep(120)
51+
print("refreshed")
52+
time.sleep(120)

examples/il0373_flexible_2.13_monochrome.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,13 @@
3636

3737
g = displayio.Group()
3838

39-
with open("/display-ruler.bmp", "rb") as f:
40-
pic = displayio.OnDiskBitmap(f)
41-
# CircuitPython 6 & 7 compatible
42-
t = displayio.TileGrid(
43-
pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
44-
)
45-
# CircuitPython 7 compatible only
46-
# t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
47-
g.append(t)
39+
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
40+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
41+
g.append(t)
4842

49-
display.root_group = g
43+
display.root_group = g
5044

51-
display.refresh()
45+
display.refresh()
5246

53-
time.sleep(120)
47+
print("refreshed")
48+
time.sleep(180)

examples/il0373_flexible_2.9_monochrome.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,13 @@
3636

3737
g = displayio.Group()
3838

39-
with open("/display-ruler.bmp", "rb") as f:
40-
pic = displayio.OnDiskBitmap(f)
41-
# CircuitPython 6 & 7 compatible
42-
t = displayio.TileGrid(
43-
pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
44-
)
45-
# CircuitPython 7 compatible only
46-
# t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
47-
g.append(t)
39+
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
40+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
41+
g.append(t)
4842

49-
display.root_group = g
43+
display.root_group = g
5044

51-
display.refresh()
45+
display.refresh()
5246

53-
time.sleep(120)
47+
print("refreshed")
48+
time.sleep(120)

examples/il0373_simpletest.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,13 @@
3030

3131
g = displayio.Group()
3232

33-
with open("/display-ruler.bmp", "rb") as f:
34-
pic = displayio.OnDiskBitmap(f)
35-
# CircuitPython 6 & 7 compatible
36-
t = displayio.TileGrid(
37-
pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
38-
)
39-
# CircuitPython 7 compatible only
40-
# t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
41-
g.append(t)
33+
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
34+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
35+
g.append(t)
4236

43-
display.root_group = g
37+
display.root_group = g
4438

45-
display.refresh()
39+
display.refresh()
4640

47-
print("refreshed")
48-
49-
time.sleep(120)
41+
print("refreshed")
42+
time.sleep(120)

0 commit comments

Comments
 (0)