From eec2195b423f8c70863cf22d9c6379c9f8bd5546 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Fri, 27 Jun 2025 11:11:42 -0500 Subject: [PATCH] use new OnDiskBitmap API --- README.rst | 26 ++++++++++----------- examples/il0373_1.54_color.py | 21 +++++++---------- examples/il0373_2.13_color.py | 24 ++++++------------- examples/il0373_2.9_color.py | 24 ++++++------------- examples/il0373_2.9_grayscale.py | 21 ++++++----------- examples/il0373_flexible_2.13_monochrome.py | 19 ++++++--------- examples/il0373_flexible_2.9_monochrome.py | 19 ++++++--------- examples/il0373_simpletest.py | 21 ++++++----------- 8 files changed, 62 insertions(+), 113 deletions(-) diff --git a/README.rst b/README.rst index e27a557..41e7d16 100644 --- a/README.rst +++ b/README.rst @@ -59,17 +59,21 @@ Usage Example .. code-block: python + # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries + # SPDX-License-Identifier: MIT + """Simple test script for 2.13" 212x104 tri-color featherwing. Supported products: * Adafruit 2.13" Tri-Color FeatherWing * https://www.adafruit.com/product/4128 - """ - + """ import time + import board import displayio import fourwire + import adafruit_il0373 displayio.release_displays() @@ -80,20 +84,14 @@ Usage Example display_bus = fourwire.FourWire(board.SPI(), command=epd_dc, chip_select=epd_cs, baudrate=1000000) time.sleep(1) - display = adafruit_il0373.IL0373(display_bus, width=212, height=104, rotation=90, - highlight_color=0xff0000) + display = adafruit_il0373.IL0373( + display_bus, width=212, height=104, rotation=90, highlight_color=0xFF0000 + ) g = displayio.Group() - f = open("/display-ruler.bmp", "rb") - - pic = displayio.OnDiskBitmap(f) - # 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) + pic = displayio.OnDiskBitmap("/display-ruler.bmp") + t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) g.append(t) display.root_group = g @@ -101,9 +99,9 @@ Usage Example display.refresh() print("refreshed") - time.sleep(120) + Documentation ============= diff --git a/examples/il0373_1.54_color.py b/examples/il0373_1.54_color.py index 8a53b1e..cd268c3 100644 --- a/examples/il0373_1.54_color.py +++ b/examples/il0373_1.54_color.py @@ -41,20 +41,15 @@ g = displayio.Group() -with open("/display-ruler.bmp", "rb") as f: - pic = displayio.OnDiskBitmap(f) - # 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) - display.root_group = g +pic = displayio.OnDiskBitmap("/display-ruler.bmp") +t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) +g.append(t) - display.refresh() +display.root_group = g - print("refreshed") +display.refresh() - time.sleep(120) +print("refreshed") + +time.sleep(120) diff --git a/examples/il0373_2.13_color.py b/examples/il0373_2.13_color.py index eaa0c7c..79a1db4 100755 --- a/examples/il0373_2.13_color.py +++ b/examples/il0373_2.13_color.py @@ -47,23 +47,13 @@ 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") +t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) +g.append(t) - # Place the display group on the screen - display.root_group = g +display.root_group = g - # Refresh the display to have it actually show the image - # NOTE: Do not refresh eInk displays sooner than 180 seconds - display.refresh() - print("refreshed") +display.refresh() - time.sleep(180) +print("refreshed") +time.sleep(180) diff --git a/examples/il0373_2.9_color.py b/examples/il0373_2.9_color.py index 53c1a04..fd6c62b 100644 --- a/examples/il0373_2.9_color.py +++ b/examples/il0373_2.9_color.py @@ -46,23 +46,13 @@ 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") +t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) +g.append(t) - # Place the display group on the screen - display.root_group = g +display.root_group = g - # Refresh the display to have it actually show the image - # NOTE: Do not refresh eInk displays sooner than 180 seconds - display.refresh() - print("refreshed") +display.refresh() - time.sleep(180) +print("refreshed") +time.sleep(180) diff --git a/examples/il0373_2.9_grayscale.py b/examples/il0373_2.9_grayscale.py index 0c11cb6..dcd3944 100644 --- a/examples/il0373_2.9_grayscale.py +++ b/examples/il0373_2.9_grayscale.py @@ -40,20 +40,13 @@ g = displayio.Group() -with open("/display-ruler.bmp", "rb") as f: - pic = displayio.OnDiskBitmap(f) - # 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") +t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) +g.append(t) - display.root_group = g +display.root_group = g - display.refresh() +display.refresh() - print("refreshed") - - time.sleep(120) +print("refreshed") +time.sleep(120) diff --git a/examples/il0373_flexible_2.13_monochrome.py b/examples/il0373_flexible_2.13_monochrome.py index fd45bc6..79e2dd3 100644 --- a/examples/il0373_flexible_2.13_monochrome.py +++ b/examples/il0373_flexible_2.13_monochrome.py @@ -36,18 +36,13 @@ g = displayio.Group() -with open("/display-ruler.bmp", "rb") as f: - pic = displayio.OnDiskBitmap(f) - # 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") +t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) +g.append(t) - display.root_group = g +display.root_group = g - display.refresh() +display.refresh() - time.sleep(120) +print("refreshed") +time.sleep(180) diff --git a/examples/il0373_flexible_2.9_monochrome.py b/examples/il0373_flexible_2.9_monochrome.py index fb15f86..5a76028 100644 --- a/examples/il0373_flexible_2.9_monochrome.py +++ b/examples/il0373_flexible_2.9_monochrome.py @@ -36,18 +36,13 @@ g = displayio.Group() -with open("/display-ruler.bmp", "rb") as f: - pic = displayio.OnDiskBitmap(f) - # 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") +t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) +g.append(t) - display.root_group = g +display.root_group = g - display.refresh() +display.refresh() - time.sleep(120) +print("refreshed") +time.sleep(120) diff --git a/examples/il0373_simpletest.py b/examples/il0373_simpletest.py index 48d3cff..2df18b2 100644 --- a/examples/il0373_simpletest.py +++ b/examples/il0373_simpletest.py @@ -30,20 +30,13 @@ g = displayio.Group() -with open("/display-ruler.bmp", "rb") as f: - pic = displayio.OnDiskBitmap(f) - # 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") +t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) +g.append(t) - display.root_group = g +display.root_group = g - display.refresh() +display.refresh() - print("refreshed") - - time.sleep(120) +print("refreshed") +time.sleep(120)