From 841e39e3ee37df06cf87b6767029680a565c7d01 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Fri, 27 Jun 2025 09:22:29 -0500 Subject: [PATCH] use new OnDiskBitmap init API --- README.rst | 12 ++-------- examples/ssd1680_2.13_featherwing.py | 26 +++++++++++----------- examples/ssd1680_2.13_mono_eink_bonnet.py | 26 +++++++++++----------- examples/ssd1680_2.13_tricolor_breakout.py | 16 ++++++------- examples/ssd1680_2.9_tricolor_breakout.py | 16 ++++++------- examples/ssd1680_simpletest.py | 26 +++++++++++----------- 6 files changed, 57 insertions(+), 65 deletions(-) diff --git a/README.rst b/README.rst index fdde842..0d67c6d 100644 --- a/README.rst +++ b/README.rst @@ -103,16 +103,8 @@ Usage Example g = displayio.Group() - # CircuitPython 6 & 7 compatible - f = open("/display-ruler.bmp", "rb") - pic = displayio.OnDiskBitmap(f) - t = displayio.TileGrid( - pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter()) - ) - - # # CircuitPython 7 compatible only - # pic = displayio.OnDiskBitmap("/display-ruler.bmp") - # 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) diff --git a/examples/ssd1680_2.13_featherwing.py b/examples/ssd1680_2.13_featherwing.py index aeeb31e..9e9f5ef 100644 --- a/examples/ssd1680_2.13_featherwing.py +++ b/examples/ssd1680_2.13_featherwing.py @@ -42,25 +42,25 @@ g = displayio.Group() -with open("/display-ruler.bmp", "rb") as f: - pic = displayio.OnDiskBitmap(f) - t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) +pic = displayio.OnDiskBitmap("/display-ruler.bmp") - g.append(t) +t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) - display.root_group = g +g.append(t) - display.refresh() +display.root_group = g - print("refreshed") +display.refresh() - time.sleep(display.time_to_refresh + 5) - # Always refresh a little longer. It's not a problem to refresh - # a few seconds more, but it's terrible to refresh too early - # (the display will throw an exception when if the refresh - # is too soon) - print("waited correct time") +print("refreshed") + +time.sleep(display.time_to_refresh + 5) +# Always refresh a little longer. It's not a problem to refresh +# a few seconds more, but it's terrible to refresh too early +# (the display will throw an exception when if the refresh +# is too soon) +print("waited correct time") # Keep the display the same diff --git a/examples/ssd1680_2.13_mono_eink_bonnet.py b/examples/ssd1680_2.13_mono_eink_bonnet.py index 2557df6..ef58241 100644 --- a/examples/ssd1680_2.13_mono_eink_bonnet.py +++ b/examples/ssd1680_2.13_mono_eink_bonnet.py @@ -49,23 +49,23 @@ g = displayio.Group() -with open("display-ruler.bmp", "rb") as f: - pic = displayio.OnDiskBitmap(f) - 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(display.time_to_refresh + 5) - # Always refresh a little longer. It's not a problem to refresh - # a few seconds more, but it's terrible to refresh too early - # (the display will throw an exception when if the refresh - # is too soon) - print("waited correct time") +print("refreshed") + +time.sleep(display.time_to_refresh + 5) +# Always refresh a little longer. It's not a problem to refresh +# a few seconds more, but it's terrible to refresh too early +# (the display will throw an exception when if the refresh +# is too soon) +print("waited correct time") # Keep the display the same diff --git a/examples/ssd1680_2.13_tricolor_breakout.py b/examples/ssd1680_2.13_tricolor_breakout.py index 7329dbc..cf1230f 100644 --- a/examples/ssd1680_2.13_tricolor_breakout.py +++ b/examples/ssd1680_2.13_tricolor_breakout.py @@ -41,17 +41,17 @@ g = displayio.Group() -with open("/display-ruler.bmp", "rb") as f: - pic = displayio.OnDiskBitmap(f) - t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) +pic = displayio.OnDiskBitmap("/display-ruler.bmp") - g.append(t) +t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) - display.root_group = g +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/ssd1680_2.9_tricolor_breakout.py b/examples/ssd1680_2.9_tricolor_breakout.py index 8395f46..922878d 100644 --- a/examples/ssd1680_2.9_tricolor_breakout.py +++ b/examples/ssd1680_2.9_tricolor_breakout.py @@ -41,17 +41,17 @@ g = displayio.Group() -with open("/display-ruler.bmp", "rb") as f: - pic = displayio.OnDiskBitmap(f) - t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) +pic = displayio.OnDiskBitmap("/display-ruler.bmp") - g.append(t) +t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) - display.root_group = g +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/ssd1680_simpletest.py b/examples/ssd1680_simpletest.py index 0613236..8b3bcb9 100644 --- a/examples/ssd1680_simpletest.py +++ b/examples/ssd1680_simpletest.py @@ -51,23 +51,23 @@ g = displayio.Group() # Note: Check the name of the file. Sometimes the dash is changed to an underscore -with open("/display-ruler.bmp", "rb") as f: - pic = displayio.OnDiskBitmap(f) - 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(display.time_to_refresh + 5) - # Always refresh a little longer. It's not a problem to refresh - # a few seconds more, but it's terrible to refresh too early - # (the display will throw an exception when if the refresh - # is too soon) - print("waited correct time") +print("refreshed") + +time.sleep(display.time_to_refresh + 5) +# Always refresh a little longer. It's not a problem to refresh +# a few seconds more, but it's terrible to refresh too early +# (the display will throw an exception when if the refresh +# is too soon) +print("waited correct time") # Keep the display the same