#Adafruit IS31FL3741 and adafruit_led_animations
1 messages · Page 1 of 1 (latest)
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 ^^^
ah actually the code is wrong since the pixelBuf I instantiate has is not linked to the is31
stupid mistake
but when I try to use https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3741/blob/main/adafruit_is31fl3741/is31fl3741_pixelbuf.py
it requires a "mapping"
and I have no idea of what to pass
@soft shell I think maybe you don't need to use the PixelBuf class. Instead use this one: Adafruit_RGBMatrixQT Initialize it the normal way as shown in the first part of this script: https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3741/blob/main/examples/is31fl3741_rgbswirl.py once initialized give that object to your Animation constructor
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
Looking at this further, the LED animation library uses a pixel buffer. But this buffer isn't exposed in the RGBMatrixQT driver.
😕
There is an example for the glasses that uses an led_animation: https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3741/blob/main/examples/is31fl3741_animation.py and the LED_Glasses class extends IS31FL3741_colorXY the same way that Adafruit_RGBMatrixQT does. I would have assumed it could work the same way as the glasses with animation. I need to pick up one of these devices, I missed the boat on the first run of them but always did want to play with it.
This examples uses the PIxelBuf - https://learn.adafruit.com/adafruit-eyelights-led-glasses-and-driver/displayio-sports-scroller
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'
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))
Indeed I saw those examples but if you have a look at the constructors of the pixel bug a map is passed and I I have no idea about what that tuple means
I will try that in a couple of hours when I can plugged back my laptop. That might works. That being said I believe that being able to extend adafruit_pixelbuf and implement transmit should be the correct way to make all the animations work. And the issue is that mapping I don't know
I got the led glasses and they are definitely fun during end of year and Halloween parties
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.
You might be onto something. I will try with a range and then may be with a concatenation of all the tuples obtained via the method pixel_addrs I saw in the cose
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
You might need to open an issue in the GitHub for assistance on the mapping. https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3741/issues
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)
Indeed I am going to open an issue and ask them for the best way to integrate such changes