Trinket M0, TLC59711 and CircuitPython 7.1

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
tomeskenazi
 
Posts: 3
Joined: Sat Jan 01, 2022 12:41 pm

Trinket M0, TLC59711 and CircuitPython 7.1

Post by tomeskenazi »

Hi!

I'm trying to control a TLC59711 with a Trinket M0. I had no problem doing so with the CircuitPython version shipped with the Trinket M0.
However, after upgrading CircuitPython to 7.1 and using the related TLC59711 library, I cannot make the example "tlc59711_simpletest.py" program run without errors.
I tried the following scenarios and no luck so far.

> pixels = adafruit_tlc59711.TLC59711(spi, pixel_count=16)
generates MemoryError: memory allocation failed, allocating 184 bytes

If I change to 4 leds instead:
> pixels = adafruit_tlc59711.TLC59711(spi, pixel_count=4)
generates OverflowError: small int overflow

If I change to 3 leads instead:
> pixels = adafruit_tlc59711.TLC59711(spi, pixel_count=4)
It works, but then writing to one led:
> pixels.r0 = 100
generates RuntimeError: Buffer too small

Would anyone have any tip?

User avatar
deepSparse2
 
Posts: 2
Joined: Sun Jan 02, 2022 11:15 am

Re: Trinket M0, TLC59711 and CircuitPython 7.1

Post by deepSparse2 »

Hi!
I ran into the same memory allocation problem using a M0 ItsyBitsy to control the TLC59711 with CircuitPython 7.1. I think this was because the default number of pixels was 16, but I'm not totally sure.

My workaround was to remove as much code as possible from the TLC59711 library to reduce its memory usage, then add this file to the /lib folder of my ItsyBitsy. I've attached the lib file I used (adafruit_tlc59711_brief.py) and the main code (test-leds.py) below. Unfortunately, this only allowed me to use TLC59711.set_channel() to control the LED. The main code turns each LED on then off sequentially.

Other possible solutions:
1. Downgrade both CircuitPython and TLC59711 python library to a previous stable version (maybe version 6.3?)
2. Use Arduino IDE + Arduino library for TLC59711. I tried using the Arduino library, but I ran into a problem where the ItsyBitsy would disconnect from the serial monitor after the sketch was uploaded. Please see this thread for more info: viewtopic.php?f=62&t=186669&p=904531&hi ... 11#p904531

To those at Adafruit:
1. Does someone have insight into a better solution?
2. Should we open a new issue in the TLC59711 github: https://github.com/adafruit/Adafruit_Ci ... 711/issues?
Attachments
test-LEDs.py
(638 Bytes) Downloaded 6 times
adafruit_tlc59711_brief.py
(9.18 KiB) Downloaded 6 times

User avatar
tomeskenazi
 
Posts: 3
Joined: Sat Jan 01, 2022 12:41 pm

Re: Trinket M0, TLC59711 and CircuitPython 7.1

Post by tomeskenazi »

Thanks a lot @deepSpare2, very much appreciated. I will try with Arduino.

I investigated a bit further and it seems the TLC59711 library version for CircuitPython 7.1 may not work with small int boards.
Could we have a confirmation from Adafruit?

I could successfully pass the memory allocation by removing the TLC59711AutoShow class and regenerating the mpy.
However, even with a pixel_count = 4 (minimum for one chip), I cannot pass the TLC59711 class constructor:

Traceback (most recent call last):
File "main.py", line 23, in <module>
File "adafruit_tlc59711.py", line 306, in __init__
File "adafruit_tlc59711.py", line 315, in _init_buffer
File "adafruit_tlc59711.py", line 438, in _chip_set_WriteCommand
File "adafruit_tlc59711.py", line 327, in set_chipheader_bits_in_buffer
OverflowError: small int overflow

I'm afraid my knowledge is a little limited as this is my first time working with Adafruit products. Perhaps someone could help further?

Thank you very much.

User avatar
danhalbert
 
Posts: 4650
Joined: Tue Aug 08, 2017 12:37 pm

Re: Trinket M0, TLC59711 and CircuitPython 7.1

Post by danhalbert »

It does appear that the TLC5971111 driver is assuming it can use 32-bit integers. This is probably fixable, but I don't see an immediate fix. Please open an issue in https://github.com/adafruit/Adafruit_Ci ... 711/issues. In the meantime, if you have another board that is not a small build like the Trinket M0, you could try that. The Trinket and Gemma M0 builds are very skinny and really limit what you can do.

User avatar
tomeskenazi
 
Posts: 3
Joined: Sat Jan 01, 2022 12:41 pm

Re: Trinket M0, TLC59711 and CircuitPython 7.1

Post by tomeskenazi »

Thanks @danalbert for confirming the issue.

I opened a new issue as suggested:
https://github.com/adafruit/Adafruit_Ci ... /issues/21

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”