use new OnDiskBitmap init API
This commit is contained in:
parent
7c055d2286
commit
841e39e3ee
6 changed files with 57 additions and 65 deletions
12
README.rst
12
README.rst
|
|
@ -103,16 +103,8 @@ Usage Example
|
||||||
|
|
||||||
g = displayio.Group()
|
g = displayio.Group()
|
||||||
|
|
||||||
# CircuitPython 6 & 7 compatible
|
pic = displayio.OnDiskBitmap("/display-ruler.bmp")
|
||||||
f = open("/display-ruler.bmp", "rb")
|
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
|
||||||
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)
|
|
||||||
|
|
||||||
g.append(t)
|
g.append(t)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,25 +42,25 @@ display = adafruit_ssd1680.SSD1680(
|
||||||
|
|
||||||
g = displayio.Group()
|
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)
|
print("refreshed")
|
||||||
# Always refresh a little longer. It's not a problem to refresh
|
|
||||||
# a few seconds more, but it's terrible to refresh too early
|
time.sleep(display.time_to_refresh + 5)
|
||||||
# (the display will throw an exception when if the refresh
|
# Always refresh a little longer. It's not a problem to refresh
|
||||||
# is too soon)
|
# a few seconds more, but it's terrible to refresh too early
|
||||||
print("waited correct time")
|
# (the display will throw an exception when if the refresh
|
||||||
|
# is too soon)
|
||||||
|
print("waited correct time")
|
||||||
|
|
||||||
|
|
||||||
# Keep the display the same
|
# Keep the display the same
|
||||||
|
|
|
||||||
|
|
@ -49,23 +49,23 @@ display = adafruit_ssd1680.SSD1680(
|
||||||
|
|
||||||
g = displayio.Group()
|
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)
|
print("refreshed")
|
||||||
# Always refresh a little longer. It's not a problem to refresh
|
|
||||||
# a few seconds more, but it's terrible to refresh too early
|
time.sleep(display.time_to_refresh + 5)
|
||||||
# (the display will throw an exception when if the refresh
|
# Always refresh a little longer. It's not a problem to refresh
|
||||||
# is too soon)
|
# a few seconds more, but it's terrible to refresh too early
|
||||||
print("waited correct time")
|
# (the display will throw an exception when if the refresh
|
||||||
|
# is too soon)
|
||||||
|
print("waited correct time")
|
||||||
|
|
||||||
|
|
||||||
# Keep the display the same
|
# Keep the display the same
|
||||||
|
|
|
||||||
|
|
@ -41,17 +41,17 @@ display = adafruit_ssd1680.SSD1680(
|
||||||
|
|
||||||
g = displayio.Group()
|
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)
|
||||||
|
|
|
||||||
|
|
@ -41,17 +41,17 @@ display = adafruit_ssd1680.SSD1680(
|
||||||
|
|
||||||
g = displayio.Group()
|
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)
|
||||||
|
|
|
||||||
|
|
@ -51,23 +51,23 @@ display = adafruit_ssd1680.SSD1680(
|
||||||
g = displayio.Group()
|
g = displayio.Group()
|
||||||
|
|
||||||
# Note: Check the name of the file. Sometimes the dash is changed to an underscore
|
# 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)
|
print("refreshed")
|
||||||
# Always refresh a little longer. It's not a problem to refresh
|
|
||||||
# a few seconds more, but it's terrible to refresh too early
|
time.sleep(display.time_to_refresh + 5)
|
||||||
# (the display will throw an exception when if the refresh
|
# Always refresh a little longer. It's not a problem to refresh
|
||||||
# is too soon)
|
# a few seconds more, but it's terrible to refresh too early
|
||||||
print("waited correct time")
|
# (the display will throw an exception when if the refresh
|
||||||
|
# is too soon)
|
||||||
|
print("waited correct time")
|
||||||
|
|
||||||
|
|
||||||
# Keep the display the same
|
# Keep the display the same
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue