Skip to content

cannot use Adafruit_RGBMatrixQT with adafruit_led_animation #21

@mraveloarinjaka

Description

@mraveloarinjaka

I wanted to use Adafruit_RGBMatrixQT to display some animations
adafruit_led_animation various animations expect a pixels object.
I wanted to use IS31FL3741_PixelBuf but it was missing the "write" method.
Please find below an adapter I wrote that allows to create a pixels object.
I would like to know:

  • is being able to create an adafruit_pixelbuf.PixelBuf from Adafruit_RGBMatrixQT is a valid need?
  • is an adapter such as the one below a relevant way to address this issue?

Thank you in advance for your feedback.

WIDTH = 13
HEIGHT = 9
LEDS_MAP = tuple(
    (
        address
        for x in range(WIDTH)
        for y in range(HEIGHT)
        for address in Adafruit_RGBMatrixQT.pixel_addrs(x, y)
    )
)


class RGBMatrixQTToPixelBufAdapter(Adafruit_RGBMatrixQT):
    """Additional properties so that Adafruit_RGBMatrixQT can be used with IS31FL3741_PixelBuf."""

    def __init__(
        self,
        i2c,
        allocate,
    ):
        super().__init__(i2c, allocate=allocate)

    def write(self, mapping, buffer):
        temp_buffer = FrameBuffer(
            buffer,
            WIDTH,
            HEIGHT,
            adafruit_framebuf.RGB888,
        )
        self.image(temp_buffer)
        self.show()


i2c = board.STEMMA_I2C()
is31 = RGBMatrixQTToPixelBufAdapter(i2c, allocate=adafruit_is31fl3741.PREFER_BUFFER)
# is31.set_led_scaling(0xFF)
is31.set_led_scaling(1)
is31.global_current = 0xFF
is31.enable = True
pixels = IS31FL3741_PixelBuf(is31, LEDS_MAP, init=False, auto_write=False)

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions