Skip to content

Commit 5c04b51

Browse files
authored
Merge pull request #4 from FoamyGuy/odb_api_update
use new OnDiskBitmap API
2 parents d38b4c6 + 8dc962f commit 5c04b51

File tree

2 files changed

+33
-44
lines changed

2 files changed

+33
-44
lines changed

README.rst

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ Usage Example
9292
.. code-block:: python
9393
9494
import time
95+
9596
import board
9697
import displayio
97-
import fourwire
98+
from fourwire import FourWire
99+
98100
import adafruit_ek79686
99101
100102
# Used to ensure the display is free in CircuitPython
@@ -108,9 +110,7 @@ Usage Example
108110
epd_busy = board.D6
109111
110112
# Create the displayio connection to the display pins
111-
display_bus = fourwire.FourWire(
112-
spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
113-
)
113+
display_bus = FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000)
114114
time.sleep(1) # Wait a bit
115115
116116
# Create the display object - the third color is red (0xff0000)
@@ -128,28 +128,23 @@ Usage Example
128128
129129
130130
# Display a ruler graphic from the root directory of the CIRCUITPY drive
131-
with open("/display-ruler.bmp", "rb") as f:
132-
pic = displayio.OnDiskBitmap(f)
133-
# Create a Tilegrid with the bitmap and put in the displayio group
134-
# CircuitPython 6 & 7 compatible
135-
t = displayio.TileGrid(
136-
pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
137-
)
138-
# CircuitPython 7 compatible only
139-
# t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
140-
g.append(t)
141-
142-
# Place the display group on the screen (does not refresh)
143-
display.show(g)
144-
145-
# Show the image on the display
146-
display.refresh()
147-
148-
print("refreshed")
149-
150-
# Do Not refresh the screen more often than every 180 seconds
151-
# for eInk displays! Rapid refreshes will damage the panel.
152-
time.sleep(180)
131+
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
132+
# Create a Tilegrid with the bitmap and put in the displayio group
133+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
134+
g.append(t)
135+
136+
# Place the display group on the screen (does not refresh)
137+
display.root_group = g
138+
139+
# Show the image on the display
140+
display.refresh()
141+
142+
print("refreshed")
143+
144+
# Do Not refresh the screen more often than every 180 seconds
145+
# for eInk displays! Rapid refreshes will damage the panel.
146+
time.sleep(180)
147+
153148
154149
155150
Documentation

examples/ek79686_simpletest.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,19 @@
4949

5050

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

63-
# Place the display group on the screen (does not refresh)
64-
display.root_group = g
57+
# Place the display group on the screen (does not refresh)
58+
display.root_group = g
6559

66-
# Show the image on the display
67-
display.refresh()
60+
# Show the image on the display
61+
display.refresh()
6862

69-
print("refreshed")
63+
print("refreshed")
7064

71-
# Do Not refresh the screen more often than every 180 seconds
72-
# for eInk displays! Rapid refreshes will damage the panel.
73-
time.sleep(180)
65+
# Do Not refresh the screen more often than every 180 seconds
66+
# for eInk displays! Rapid refreshes will damage the panel.
67+
time.sleep(180)

0 commit comments

Comments
 (0)