#Adafruit IS31FL3741 and adafruit_led_animations

1 messages · Page 1 of 1 (latest)

soft shell
#

and if I use a PixelBuf I get a stack complaining that the method _transmit is not implemented.

Traceback (most recent call last):
  File "asyncio/core.py", line 246, in run_until_complete
  File "check_leds.py", line 24, in run_leds_loop
  File "adafruit_led_animation/animation/__init__.py", line 90, in animate
  File "adafruit_led_animation/animation/__init__.py", line 119, in show
AttributeError: 'PixelBuf' object has no attribute '_transmit'
#

Adafruit IS31FL3741 and adafruit_led_animations

#

@nocturne cypress ^^^

soft shell
#

ah actually the code is wrong since the pixelBuf I instantiate has is not linked to the is31

#

stupid mistake

#

it requires a "mapping"

#

and I have no idea of what to pass

fresh stratus
#

something like this:

import board
from rainbowio import colorwheel

from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT
import adafruit_is31fl3741

i2c = board.I2C()  # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
is31 = Adafruit_RGBMatrixQT(i2c, allocate=adafruit_is31fl3741.PREFER_BUFFER)


is31.enable = True
# print("Enabled? ", is31.enable)
anim3 = ColorCycle(is31, 0.03)

while True:
    anim3.animate()

I don't have real hardware though, I can't actually run it. Might have syntax or other error, but I think it should be close

nocturne cypress
#

Looking at this further, the LED animation library uses a pixel buffer. But this buffer isn't exposed in the RGBMatrixQT driver.

#

😕

fresh stratus
nocturne cypress
soft shell
# fresh stratus something like this: ``` import board from rainbowio import colorwheel from ada...

when I use the instance directly I get the following stack

Traceback (most recent call last):
  File "asyncio/core.py", line 246, in run_until_complete
  File "check_leds.py", line 38, in run_leds_loop
  File "adafruit_led_animation/animation/__init__.py", line 85, in animate
  File "adafruit_led_animation/animation/colorcycle.py", line 52, in draw
  File "adafruit_is31fl3741/__init__.py", line 301, in fill
TypeError: unsupported types for __rshift__: 'tuple', 'int'
fresh stratus
#

Ah, sorry I did see you posted that before but didn't understand that it was output from that.

It looks to me like maybe the color is a tuple instead of hex and that might be throwing it off

#

@soft shell If you try it like this does anything change?

anim3 = ColorCycle(is31, 0.03, colors = (0xff0000, 0x00ff00, 0x0000ff))
soft shell
soft shell
soft shell
fresh stratus
#

I don't know what the proper map would be either unfortunately. Once we get it worked out we can add an example with it.

My gut instinct is for that plain grid it would be something very basic like just a "range" list of indexes from 0 to however many total pixels there are. But it is a complete guess on my part.

soft shell
soft shell
#

So I am trying to initialize a PixelBuf
With the following map

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)
    )
)

I end with the following stack

Traceback (most recent call last):
  File "asyncio/core.py", line 246, in run_until_complete
  File "check_leds.py", line 65, in run_leds_loop
  File "adafruit_led_animation/animation/__init__.py", line 90, in animate
  File "adafruit_led_animation/animation/__init__.py", line 119, in show
  File "adafruit_is31fl3741/is31fl3741_pixelbuf.py", line 156, in _transmit
AttributeError: 'Adafruit_RGBMatrixQT' object has no attribute 'write'

Indeed there is no write method anywhere

nocturne cypress
soft shell
#

First thank you all for your help on that

#

I managed to do it! I implemented an adapter of Adafruit_RGBMatrixQT

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)
soft shell