Skip to content

Adds initial working code. #2

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 9 commits into from
Aug 24, 2018
Merged

Adds initial working code. #2

merged 9 commits into from
Aug 24, 2018

Conversation

caternuson
Copy link
Contributor

@caternuson caternuson commented Aug 14, 2018

See examples/tca9548a_simpletest.py for example usage.

Copy link
Collaborator

@sommersoft sommersoft left a comment

Choose a reason for hiding this comment

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

Other than these two "administrivia" things, looks excellent to me. We need to update the cookiecutter with these two changes; I plan on doing that tonight.

.pylintrc Outdated
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=
Copy link
Collaborator

Choose a reason for hiding this comment

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

While a patch is in work to do this, can you add board to the ignored-modules? This will cover future PyPi work.

.travis.yml Outdated

install:
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you change this to:

- pip install circuitpython-build-tools Sphinx sphinx-rtd-theme
- pip install --force-reinstall pylint==1.9.2

While pylint is currently happy, who knows what will get added in future versions. 😄

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Thank you for adding this! I think it'll be helpful. Just a few comments now.

self.i2c = i2c
self.address = address
self.used_channels = []

Copy link
Member

Choose a reason for hiding this comment

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

Add:

def __len__(self):
    return 8

That way it can be iterated over.


def __getitem__(self, key):
if not 0 <= key <= 7:
raise ValueError("Channel must be an integer in the range: 0-7")
Copy link
Member

Choose a reason for hiding this comment

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

IndexError instead since its a sequence.

if not 0 <= key <= 7:
raise ValueError("Channel must be an integer in the range: 0-7")
if key in self.used_channels:
raise ValueError("Channel already in use.")
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't track this because you could have multiple devices on a single channel. The locking should prevent bus usage conflicts.

if key in self.used_channels:
raise ValueError("Channel already in use.")
self.used_channels.append(key)
return TCA9548A_Channel(self, key)
Copy link
Member

Choose a reason for hiding this comment

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

I would cache the channel so the same object is returned for the same accesses.

requirements.txt Outdated
@@ -0,0 +1 @@
adafruit-circuitpython-busdevice
Copy link
Member

Choose a reason for hiding this comment

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

This isn't a dependency because its not imported by adafruit_tca9548c.py.

Copy link
Collaborator

@sommersoft sommersoft left a comment

Choose a reason for hiding this comment

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

My 2 requests are good now. Thanks @caternuson!

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Thanks! Sorry for the slow review!

@tannewt tannewt merged commit 57a4493 into adafruit:master Aug 24, 2018
@jerryneedell jerryneedell mentioned this pull request May 24, 2021
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