Skip to content

Split library into package and adapt examples+doc #32

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

Closed
wants to merge 12 commits into from

Conversation

dglaude
Copy link
Contributor

@dglaude dglaude commented Aug 16, 2020

This is a response to #27 .

I have split the best I could the various driver, updated all the example and tested the one I could (mostly Scroll pHAT HD and LedShim).

The sub-driver for those two being done by me, I adapted the copyright now that it is in a separate file, for the other it is a copy of the original comment and copyright.

The move to init.py and cleaning done there is visible in the git history, but copy of the file to make sub-driver mean loosing the git history on those. Maybe there is a way to inherit this history???

I tested the other MCU example on the Scoll pHAT HD, but not on Blinka.

Exemples and README should be up to date.

There is one thing I would like to discuss, it's the fact that one piece of hardware is priviledged, and the other inherit from that one and modify the x, y and formula to write pixels. So Matrix is imported differently than all the other. I would prefer to have a super class that has no implementation and make each sub-driver specify things.

@dglaude
Copy link
Contributor Author

dglaude commented Aug 16, 2020

Please advice if I should use a syntax like the following to simplify the example so that only the import vary:

# uncomment next line if you are using Feather CharlieWing LED 15 x 7
from adafruit_is31fl3731.CharlieWing import CharlieWing as MatrixDisplay

# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix
# from adafruit_is31fl3731 import Matrix as MatrixDisplay
# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet
# from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet as MatrixDisplay
# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7
# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD as MatrixDisplay

i2c = busio.I2C(board.SCL, board.SDA)

display = MatrixDisplay(i2c)

(Assuming this does works... it is a bit untested)

@tannewt
Copy link
Member

tannewt commented Aug 17, 2020

Thank you for this change! Definitely an improvement.

The move to init.py and cleaning done there is visible in the git history, but copy of the file to make sub-driver mean loosing the git history on those. Maybe there is a way to inherit this history???

I don't think there is a good way to have history of multiple files track back to one. It'll be clear enough when tracked back to the commit that moved everything.

There is one thing I would like to discuss, it's the fact that one piece of hardware is priviledged, and the other inherit from that one and modify the x, y and formula to write pixels. So Matrix is imported differently than all the other. I would prefer to have a super class that has no implementation and make each sub-driver specify things.

I totally agree. This shouldn't be too hard. You can rename Matrix to IS31FL3731 and then create a new Matrix class with the specifics of the matrix.

Please advice if I should use a syntax like the following to simplify the example so that only the import vary:

# uncomment next line if you are using Feather CharlieWing LED 15 x 7
from adafruit_is31fl3731.CharlieWing import CharlieWing as MatrixDisplay

# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix
# from adafruit_is31fl3731 import Matrix as MatrixDisplay
# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet
# from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet as MatrixDisplay
# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7
# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD as MatrixDisplay

i2c = busio.I2C(board.SCL, board.SDA)

display = MatrixDisplay(i2c)

(Assuming this does works... it is a bit untested)

I would do as Display so that it isn't confused with the actual Matrix class. Also, the filenames should be lower case so it'd be:
from adafruit_is31fl3731.charlie_wing import CharlieWing as Display.

@dglaude
Copy link
Contributor Author

dglaude commented Aug 19, 2020

I think I have implemented what was discussed by @tannewt:

  • lower case file
  • rename Matrix in IS31FL3731
  • make a new Matrix library
  • import with from adafruit_is31fl3731.charlie_wing import CharlieWing as Display

All the example should be adapted (and that last point actually limit the change to only the import statement.

Finally, I have not put protection against somebody from importing the abstract parent class. I do not really master OO in Python.

This is becoming rather complex a PR and I can only test with Scroll pHAT HD and LedShim... so I would welcome someone to test that independantly.

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.

Two small fixes to the readme. Organizations looks much better! Thank you.

@dglaude
Copy link
Contributor Author

dglaude commented Aug 21, 2020

Ok, I have cleaned the documentation part.

With Sphynx locally installed I could see the effect of my change and update the example and the presentation of those.

@dglaude dglaude requested a review from tannewt August 21, 2020 15:29
@FoamyGuy
Copy link
Contributor

I can test this out over the upcoming weekend with: https://www.adafruit.com/product/3137. I don't think have any of the other pieces of supported hardware.

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.

Re-organization looks good. @kattni can help get this released and guides updated.

@dglaude dglaude force-pushed the split-into-package branch from b9ddf64 to 1a726c3 Compare August 21, 2020 22:25
@dglaude
Copy link
Contributor Author

dglaude commented Aug 21, 2020

So I have rebase(?) so that #31 is included in this PR.

This might make PyPi more happy (as seen in Adafruit_CircuitPython_LSM6DS).
@FoamyGuy
Copy link
Contributor

I tested all of the example scripts except for the pillow and led_shim ones with a CharlieWing LED 15 x 7 and Feather Sense. Aside from the minor import typo mentioned above in the text example everything is working well.

Thanks for splitting these up!

@tannewt
Copy link
Member

tannewt commented Aug 25, 2020

Do we have a plan to update any dependent drivers and guides?

@makermelissa
Copy link
Collaborator

Closing as I have included all these changes as part of #38. Thanks for all this work.

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.

4 participants