Merge pull request #4 from FoamyGuy/odb_api_update

use new OnDiskBitmap API
This commit is contained in:
Dan Halbert 2025-06-27 12:14:03 -04:00 committed by GitHub
commit 5c04b518d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 40 deletions

View file

@ -92,9 +92,11 @@ Usage Example
.. code-block:: python
import time
import board
import displayio
import fourwire
from fourwire import FourWire
import adafruit_ek79686
# Used to ensure the display is free in CircuitPython
@ -108,9 +110,7 @@ Usage Example
epd_busy = board.D6
# Create the displayio connection to the display pins
display_bus = fourwire.FourWire(
spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
)
display_bus = FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000)
time.sleep(1) # Wait a bit
# Create the display object - the third color is red (0xff0000)
@ -128,28 +128,23 @@ Usage Example
# Display a ruler graphic from the root directory of the CIRCUITPY drive
with open("/display-ruler.bmp", "rb") as f:
pic = displayio.OnDiskBitmap(f)
# Create a Tilegrid with the bitmap and put in the displayio group
# CircuitPython 6 & 7 compatible
t = displayio.TileGrid(
pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
)
# CircuitPython 7 compatible only
# t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
g.append(t)
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
# Create a Tilegrid with the bitmap and put in the displayio group
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
g.append(t)
# Place the display group on the screen (does not refresh)
display.show(g)
# Place the display group on the screen (does not refresh)
display.root_group = g
# Show the image on the display
display.refresh()
# Show the image on the display
display.refresh()
print("refreshed")
print("refreshed")
# Do Not refresh the screen more often than every 180 seconds
# for eInk displays! Rapid refreshes will damage the panel.
time.sleep(180)
# Do Not refresh the screen more often than every 180 seconds
# for eInk displays! Rapid refreshes will damage the panel.
time.sleep(180)
Documentation

View file

@ -49,25 +49,19 @@ g = displayio.Group()
# Display a ruler graphic from the root directory of the CIRCUITPY drive
with open("/display-ruler.bmp", "rb") as f:
pic = displayio.OnDiskBitmap(f)
# Create a Tilegrid with the bitmap and put in the displayio group
# CircuitPython 6 & 7 compatible
t = displayio.TileGrid(
pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
)
# CircuitPython 7 compatible only
# t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
g.append(t)
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
# Create a Tilegrid with the bitmap and put in the displayio group
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
g.append(t)
# Place the display group on the screen (does not refresh)
display.root_group = g
# Place the display group on the screen (does not refresh)
display.root_group = g
# Show the image on the display
display.refresh()
# Show the image on the display
display.refresh()
print("refreshed")
print("refreshed")
# Do Not refresh the screen more often than every 180 seconds
# for eInk displays! Rapid refreshes will damage the panel.
time.sleep(180)
# Do Not refresh the screen more often than every 180 seconds
# for eInk displays! Rapid refreshes will damage the panel.
time.sleep(180)