Skip to content

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

Merged
merged 5 commits into from
Nov 30, 2018

Conversation

ArthurDent62
Copy link
Contributor

Code tested with debug statements. Will still need testing with real boards.

@caternuson caternuson requested a review from a team November 25, 2018 21:31
@brennen brennen self-requested a review November 27, 2018 01:47
@brennen
Copy link
Contributor

brennen commented Nov 27, 2018

Will test.


# Define pins connected to the TLC5947
SCK = board.SCK
MOSI = board.MOSI
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

@ArthurDent62 ArthurDent62 Nov 28, 2018

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

LATCH = digitalio.DigitalInOut(board.D5)

# Initialize SPI bus.
spi = busio.SPI(clock=SCK, MOSI=MOSI)
Copy link
Contributor

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)

@caternuson
Copy link
Contributor

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
Red LED = Board 1 / Output 0

tlc5947_test

SPI variables are now inlined.
@caternuson
Copy link
Contributor

@brennen I'm good. My testing was pretty light though. Just two outuputs.

@brennen brennen merged commit a410634 into adafruit:master Nov 30, 2018
@ArthurDent62 ArthurDent62 deleted the chain_TLCs branch December 1, 2018 19:52
tannewt pushed a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Dec 4, 2018
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
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.

3 participants