-
Notifications
You must be signed in to change notification settings - Fork 8
Resolving issue #6 chaining TLC boards. #8
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
Conversation
Extended README with new example file. Extended library with support for multiple chained boards.
Will test. |
examples/tlc5947_chain.py
Outdated
|
||
# Define pins connected to the TLC5947 | ||
SCK = board.SCK | ||
MOSI = board.MOSI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Realize the other example is like this, but delete these two lines and just use the board
pins directly in the SPI constructor (see below).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you see as advantage of the suggested change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just more inline with other SPI examples. At least more current ones. The variables aren't used anywhere else in the code, so no need to create them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. Thanks. Though a good compiler would find this and inline by itself, it will most probably ease understanding. I will prepare that.
Do you think that the expression for LATCH just below is to big to do the same? Basically LATCH is also used only once, it only occurs again in code commented-out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. What you had was totally functional. So this is just cosmetic nitpicking.
I'd leave the LATCH line as is since it's an object creation. That could go in the constructor, but I think the resulting syntax isn't very beginner friendly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR updated; changes done as suggested.
examples/tlc5947_chain.py
Outdated
LATCH = digitalio.DigitalInOut(board.D5) | ||
|
||
# Initialize SPI bus. | ||
spi = busio.SPI(clock=SCK, MOSI=MOSI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to:
spi = busio.SPI(board.SCK, board.MOSI)
All these asserts should be changed to exception. But not in this PR. I gave this a quick functional test with two boards and it works as expected. Adafruit CircuitPython 3.1.1 on 2018-11-02; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board, busio, digitalio
>>> import adafruit_tlc5947
>>> LATCH = digitalio.DigitalInOut(board.D7)
>>> spi = busio.SPI(board.SCK, board.MOSI)
>>> tlc = adafruit_tlc5947.TLC5947(spi, LATCH, num_drivers=2)
>>> tlc[0] = 2000
>>> tlc[24] = 2000
>>> tlc[0] = 0
>>> tlc[24] = 0
>>> tlc[0] = 4095
>>> tlc[24] = 4095
>>> Green LED = Board 0 / Output 0 |
SPI variables are now inlined.
@brennen I'm good. My testing was pretty light though. Just two outuputs. |
Updating https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15 to 1.0.0 from 0.5.3: > Merge pull request adafruit/Adafruit_CircuitPython_ADS1x15#19 from caternuson/iss17_update Updating https://github.com/adafruit/Adafruit_CircuitPython_BluefruitSPI to 1.0.1 from 1.0.0: > Merge pull request adafruit/Adafruit_CircuitPython_BluefruitSPI#7 from adafruit/tannewt-patch-1 Updating https://github.com/adafruit/Adafruit_CircuitPython_BME280 to 2.2.1 from 2.2.0: > Merge pull request adafruit/Adafruit_CircuitPython_BME280#18 from robert-hh/master Updating https://github.com/adafruit/Adafruit_CircuitPython_CharLCD to 3.0.3 from 3.0.2: > Merge pull request adafruit/Adafruit_CircuitPython_CharLCD#23 from adafruit/pypi-readme Updating https://github.com/adafruit/Adafruit_CircuitPython_DS3231 to 2.1.2 from 2.1.1: > Merge pull request adafruit/Adafruit_CircuitPython_DS3231#13 from adafruit/lowercase_module_name Updating https://github.com/adafruit/Adafruit_CircuitPython_TLC5947 to 1.2.0 from 1.1.1: > Merge pull request adafruit/Adafruit_CircuitPython_TLC5947#8 from ArthurDent62/chain_TLCs Updating https://github.com/adafruit/Adafruit_CircuitPython_Motor to 1.3.3 from 1.3.2: > Merge pull request adafruit/Adafruit_CircuitPython_Motor#20 from adafruit/pypi-readme
Code tested with debug statements. Will still need testing with real boards.