Skip to content

E-Paper Display OnDiskBitmap drawing order issue #3699

@FoamyGuy

Description

@FoamyGuy

In this code the OnDiskBitmap gets added to the group after a Bitmap, so it should get drawn on top.

import time
import board
import displayio
import adafruit_imageload

display = board.DISPLAY
time.sleep(5)

splash = displayio.Group(max_size=20)
# background

rect = displayio.Bitmap(20,20, 2)
rect_palette = displayio.Palette(3)
rect_palette[0] = 0xFFFFFF
# Create a TileGrid using the Bitmap and Palette
rect_tile_grid = displayio.TileGrid(rect, pixel_shader=rect_palette)
rect_tile_grid.x = 3
rect_tile_grid.y = 5

with open("/thermometer.bmp", "rb") as f:

    thermometer_bitmap = displayio.OnDiskBitmap(f)
    tilegrid = displayio.TileGrid(thermometer_bitmap, pixel_shader=displayio.ColorConverter())

    tilegrid.x = 10
    tilegrid.y = 10

    splash.append(rect_tile_grid)
    splash.append(tilegrid)

    display.show(splash)
    display.refresh()

    print("loop")
    while True:
        time.sleep(1)

But when it runs the Bitmap seems to get drawn on top:
odb_over_bitmap

Using very similar code with adafruit_imageload instead of OnDiskBitmap:

import time
import board
import displayio
import adafruit_imageload

display = board.DISPLAY
time.sleep(5)

splash = displayio.Group(max_size=20)
# background

rect = displayio.Bitmap(20,20, 2)
rect_palette = displayio.Palette(3)
rect_palette[0] = 0xFFFFFF
# Create a TileGrid using the Bitmap and Palette
rect_tile_grid = displayio.TileGrid(rect, pixel_shader=rect_palette)
rect_tile_grid.x = 3
rect_tile_grid.y = 5

image, palette = adafruit_imageload.load(
    "/thermometer.bmp", bitmap=displayio.Bitmap, palette=displayio.Palette
)
tilegrid = displayio.TileGrid(image, pixel_shader=palette)

tilegrid.x = 10
tilegrid.y = 10

splash.append(rect_tile_grid)
splash.append(tilegrid)

display.show(splash)
display.refresh()

print("loop")
while True:
    time.sleep(1)

The image does get drawn on top:
imageload_over_bitmap
The thermometer image being used is here:
thermometer.bmp.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions