Skip to content

adding alternative TLC59711Multi driver implementation #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 96 commits into from
Apr 27, 2021

Conversation

s-light
Copy link
Contributor

@s-light s-light commented Jan 6, 2019

adds TLC59711Multi
→ this new Implementation is multi-chip aware.
the API is compatible with FancyLED (similar to the neopixel/dotstar).

It has a bunch of different options to set pixel values - these have different speed results.
i have add a examples/tlc59711_multi_dev.py file with some speed comparisons.
the direct list setter pixels[pixel_index] = color supports float and int as tuple / list with auto conversion and extended error raising (reports what goes wrong and why)
this way its a little slower than the unprotected alternatives:
the fastest one is pixels.set_pixel_16bit_value(pixel_index, value_r, value_g, value_b)

this way the user can use the method that fits his application best..

all tests were done with 128 Pixel (= 32 chips)

pleas let me know what you think about this.

@s-light
Copy link
Contributor Author

s-light commented Dec 19, 2020

@FoamyGuy
i just tested this again with the follwing script:

import board
import busio
import adafruit_tlc59711
spi = busio.SPI(board.SCK, MOSI=board.MOSI)
pixels = adafruit_tlc59711.TLC59711(spi)
print('tlc59711 test - light up 4 pixels.')
pixels[0] = (1000, 200, 10)
pixels[1] = (10, 10, 1000)
pixels[2] = (10, 200, 10)
pixels[3] = (500, 10, 1000)
pixels.show()
print('tlc59711 test - show done.')
print('The End')

unfortunately i did not find my Adafruit TLC59711 Breakoutboard :-(
so i only can check with my own made Boards
these have four TLC5971 on them.
my boards are fixed setup for 5V Power and Logic - so i have a levelshifter between my ItsyBitsy M4 and the boards.

the most significant difference between the two for us here is the Data-Transfer-Speed:
TLC5971 20MHz
TLC59711 10MHz
the protocol itself is identical.
in the multi branch i also do no spi configuration other then in the original lib like this:

self._spi.configure(baudrate=self._spi.frequency, polarity=0, phase=0)

so this should make no difference on the outcome with the given example code.
but maybe the default SPI frequency is different on the different boards?!
but this way with the code the current master branch should also not generate a stabel output...
(i think you used a ESP or similar board in your test-setup?)

for the test i renamed the lib to lib_ so that i am sure there are no other versions used.
So my CircuitPython Disc looks as this:

stefan@stefan-Zen:~$ ls -l /media/stefan/CIRCUITPY/
total 65
-rw-r--r--  1 stefan stefan 39342 Dez 19 12:15 adafruit_tlc59711.py
-rw-r--r--  1 stefan stefan    90 Jan  1  2000 boot_out.txt
drwxr-xr-x 44 stefan stefan 24576 Sep 12 13:28 lib_
-rw-r--r--  1 stefan stefan   337 Dez 19 12:14 main.py

my boot_out.txt:

Adafruit CircuitPython 5.3.0 on 2020-04-29; Adafruit ItsyBitsy M4 Express with samd51g19

here are the two tests results as photos:
Original Master:
P1750872_small
multi branch
P1750874_small
the first chip on the board is Marked U1 (top left in the image)
(the other chips are showing kind of garbage that is passed through...)
and as you can see indeed the pixel order is changed.
other than this both work fine.

i try to find my TLC59711 Adafruit Breakout board tomorrow..
(but can not guarantee to find it in my current project chaos... 🙈 )

i have to think about what it would take to correct the pixel order...
(i think i had tested this and it slowed down quite a bit)

and add file global disables.

(inline disable would not make sens to fix the undefined-variable and 
invalid-name multiple times in my opinion.)
@s-light
Copy link
Contributor Author

s-light commented Dec 19, 2020

hmpf the black formating is failing again.
locally it is failing - but for other files ;-)
and this is again the list comma handling...

so are you planing on upgrading the black in the Build CI test?

@kattni
Copy link
Contributor

kattni commented Jan 4, 2021

@s-light

so are you planing on upgrading the black in the Build CI test?

Yes. But honestly, only because you brought this to my attention. We pinned black=19.10b0 and I do not know the reason for this. Just as I pushed for sticking with the latest Pylint to avoid the massive overhaul needed when we moved from 1.9.2 to 2.x, I am going to push for us to move to using the latest Black as well.

My suggestion for now is to force reinstall black with the pinned version, and re-run it to see if you can get it working properly. If you need help with that, let me know. I really want to see progress on this PR, and I apologise that CI is causing roadblocks.

@s-light
Copy link
Contributor Author

s-light commented Jan 5, 2021

happy new year to you all!!

all fine.
just as reference for others stumbling over this -
with this line you can downgrade / install a specific black version.

pip install black==19.10b0

to later upgrade to the latest version you can use

pip install --upgrade black

(source)

@kattni
Copy link
Contributor

kattni commented Jan 6, 2021

@s-light @FoamyGuy Now that this is passing again, where are we at with it? I don't know the whole story so I don't want to jump in and merge if there are still incoming changes.

@FoamyGuy
Copy link
Contributor

FoamyGuy commented Jan 6, 2021

@s-light this file has .pdf extension but is in the examples folder and seems to contain python code. I think it must have gotten pdf accidentally and needs to be changed to .py

https://github.com/s-light/Adafruit_CircuitPython_TLC59711/blob/multi/examples/tlc59711_fancyled.pdf

@kattni I was not able to get the examples to run successfully with the new version of the library. Looks like s-light has custom breakouts that may be a bit different than the Adafruit ones perhaps, that is the only guess I have as to the difference in behavior between them and myself. I wonder if it may be possible to get one of the Adafruit breakouts into s-light's hands so they could try these changes out directly on that device.

I've got my circuit still put together stashed away so I can pull it out to re-test any time. But I don't really have any other ideas for troubleshooting at this time.

@kattni
Copy link
Contributor

kattni commented Jan 6, 2021

@s-light Please email me at kattni@adafruit.com. Thanks!

@s-light
Copy link
Contributor Author

s-light commented Jan 7, 2021

the pdf should be py - sorry... (fixed)

i have extended my search for my adafruit breakout board. and luckily i found it :-)
😄

so i have done a second test here.

testsetup

hw

P1760016_small

code i used

import board
import busio
import adafruit_tlc59711

spi = busio.SPI(board.SCK, MOSI=board.MOSI)
pixels = adafruit_tlc59711.TLC59711(spi)

print("tlc59711 test - light up 4 pixels.")

pixels[0] = (30000, 200, 200)
pixels[1] = (200, 200, 30000)
pixels[2] = (200, 8000, 200)
pixels[3] = (8000, 200, 8000)
pixels.show()
print("tlc59711 test - show done.")

# these extra show writes shifts the informatoion on to the next chips...
pixels.show()
pixels.show()
pixels.show()
pixels.show()

print("The End")

results

original

P1760018_single__crop_small

multi

P1760021_multi__crop_small

so for me it is working fine.

Open Questions

Only thing open (i think):

  • do i have to be backwards compatible with the pixel indices order?
    currently it changes (it currently is a raw un-mapped representation of the buffer to write)

Level-Shifting

as i followed the guide for setting up the test- i just questioned myself if i have overlooked something regarding the Digital-Signal Levels and uC with 3.3V logic -
and checked again in the datasheet:
if you power the Breakout-Board VCC pin (that is connected to the VREG and VCC pin of the chip) with 5V you would have to have also 5V levels for the Signals (SDTI,SCKI) as the Datasheet states:

PIN Description MIN NOM MAX UNIT
VREG Supply voltage, VREG connected to VCC 3 3.3 5.5 V
VIH High-level input voltage (SDTI,SCKI) 0.7× VREG VREG V
VIL Low-level input voltage (SDTI,SCKI) GND 0.3× VREG V

and 0.7V*5V=3.5V - and that is the minimum for the High-State - so it is not guaranteed to work with 3.3V Signal Levels at 5V VCC, VREF.
so i remembered correctly and to work reliably in the recommend range you need a levelshifter in this configuration.

sadly the board connects the TLC59711 VCC to the V+ (+15 in schematics).
if this would be not the case you could use separate Voltages
breakoutboard VCC: 3.3V
breakoutboard V+ : 5V
to accomplish this you could ignore the nice V+ pins for the leds and connect them in another way.
i understand that this is a tradeof to not get to complicated for beginner users...

i just ignored this fact now for the test setup and followed the instructions.
and of course it works ;-)

@kattni
Copy link
Contributor

kattni commented Apr 14, 2021

@s-light @FoamyGuy Hey! Checking in :). There are some merge conflicts to deal with but they appear to be simple ones.

Where are we at with this?

@s-light
Copy link
Contributor Author

s-light commented Apr 15, 2021

i can check on the confilcits next week...

Where are we at with this?
i think @FoamyGuy did not get it to work at his site at all...

  • afteer this i did a test with the adafruit breakout board and it worked for me -
    maybe this has to do with the used board... ?!

@FoamyGuy
Copy link
Contributor

I tested this successfully with two TLC59711 breakouts and can control LEDs connect to both breakouts. Everything seems to be working as intended for me now.

I do think it would be great if we could offer some way to use the index order that matches the silkscreen on the Adafruit breakout, but I don't know if that is a strict requirement. @kattni do you have thoughts on this?

The one other thing I noticed is that the docs don't seem to include the API information any more, and they only have one of the example scripts listed.

Here are the docs built locally from this PR:
image

and here are the ones live now:
image

Thanks again for all your work on this @s-light! this is a great new feature to support multiple devices chained together!

@kattni
Copy link
Contributor

kattni commented Apr 26, 2021

@s-light OK - we are SO close! I was going to resolve the merge conflicts myself through GitHub but the conflicts in adafruit_tlc59711.py are more complicated than I expected. You're the one best suited to resolve them as you know what you added. Is this something you can get fixed up? We can address the documentation in another issue/PR. Once the conflicts are resolved, I want to get this merged. Thank you so much for sticking through this!

@FoamyGuy I don't think it's a strict requirement - I would say file an issue, and consider simply closing it, so the issue is there if anyone searches for it, and someone can make a request there if desired.

@jposada202020
Copy link
Contributor

@kattni I could take a look to the documentation once is merged, if that is ok,

@kattni
Copy link
Contributor

kattni commented Apr 26, 2021

@jposada202020 That would be brilliant! Keep an eye on this PR for when it's merged and then take a look.

@jposada202020
Copy link
Contributor

Will do already pin in my inbox :)

@s-light
Copy link
Contributor Author

s-light commented Apr 27, 2021

@kattni i think i have resolved all the conflicts -
and also installed the new pre-commit workflow locally... and after sum tweaks it passes ;-)

Copy link
Contributor

@kattni kattni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so exciting! Thank you @s-light for all your hard work and perseverance! Thank you @FoamyGuy for testing!

@kattni kattni merged commit f546bcb into adafruit:master Apr 27, 2021
@s-light s-light deleted the multi branch April 27, 2021 14:15
@s-light
Copy link
Contributor Author

s-light commented Apr 27, 2021

😃 🎉

@jposada202020
Copy link
Contributor

@s-light Thanks :)

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Apr 30, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x to 1.11.8 from 1.11.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_ADXL34x#29 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_APDS9960 to 2.2.7 from 2.2.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_APDS9960#29 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_AS726x to 2.0.5 from 2.0.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_AS726x#16 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_BNO055 to 5.3.1 from 5.3.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_BNO055#81 from jposada202020/improving_docs
  > Merge pull request adafruit/Adafruit_CircuitPython_BNO055#80 from GuenterQ/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_FXAS21002C to 2.1.8 from 2.1.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_FXAS21002C#22 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_FXOS8700 to 2.1.7 from 2.1.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_FXOS8700#23 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_GPS to 3.9.0 from 3.8.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_GPS#62 from lesamouraipourpre/minimum_sentence_size
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_ICM20X to 2.0.7 from 2.0.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_ICM20X#12 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_L3GD20 to 2.3.5 from 2.3.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_L3GD20#22 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_LIS2MDL to 2.1.9 from 2.1.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_LIS2MDL#13 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_LIS331 to 1.0.5 from 1.0.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_LIS331#3 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_LIS3DH to 5.1.10 from 5.1.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_LIS3DH#68 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_LIS3MDL to 1.1.10 from 1.1.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_LIS3MDL#16 from jposada202020/master
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_LSM303_Accel to 1.1.7 from 1.1.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_LSM303_Accel#11 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_LSM303DLH_Mag to 1.1.8 from 1.1.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_LSM303DLH_Mag#13 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_LSM9DS1 to 2.1.8 from 2.1.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_LSM9DS1#29 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_MLX90393 to 2.0.6 from 2.0.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_MLX90393#28 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_MMA8451 to 1.3.7 from 1.3.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_MMA8451#17 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_MPU6050 to 1.1.7 from 1.1.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_MPU6050#16 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_MSA301 to 1.2.7 from 1.2.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_MSA301#15 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_TCS34725 to 3.3.7 from 3.3.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_TCS34725#35 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_TLC59711 to 2.0.0 from 1.2.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_TLC59711#17 from jposada202020/master
  > Merge pull request adafruit/Adafruit_CircuitPython_TLC59711#5 from s-light/multi
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_VCNL4010 to 0.10.8 from 0.10.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_VCNL4010#18 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_VCNL4040 to 1.2.6 from 1.2.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_VCNL4040#13 from jposada202020/improving_docs
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_AzureIoT to 2.4.0 from 2.3.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_AzureIoT#31 from jimbobbennett/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bitmap_Font to 1.5.0 from 1.4.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_Bitmap_Font#46 from jposada202020/master
  > Merge pull request adafruit/Adafruit_CircuitPython_Bitmap_Font#43 from jposada202020/raise_error_no_boundingbox
  > Merge pull request adafruit/Adafruit_CircuitPython_Bitmap_Font#45 from FoamyGuy/simpletest_example

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Shapes to 2.1.0 from 2.0.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Shapes#37 from jposada202020/new_example_circle
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Shapes#36 from empirical-dan/patch-2

Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_Layout to 1.9.2 from 1.9.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_Layout#36 from jposada202020/solving_parameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants