Skip to content

Updating for MCP4728A4 #13

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 3 commits into from
Aug 8, 2022
Merged

Updating for MCP4728A4 #13

merged 3 commits into from
Aug 8, 2022

Conversation

BlitzCityDIY
Copy link
Contributor

Updating library to be able to pass 0x64 I2C address for MCP4728A4 variant (see revision history on product copy: https://www.adafruit.com/product/4470).

Updating library to be able to pass 0x64 I2C address for MCP4728A4 variant
@github-actions
Copy link

github-actions bot commented Aug 5, 2022

👋 Thanks for this pull request! Unfortunately, it looks like the automated continuous integration (CI) test(s) failed. These can be tricky to fix so we've written a guide on how to fix them locally. It has pages about running pre-commit locally and another about building the docs locally with sphinx. Thanks for contributing to CircuitPython! If you have more questions, feel free to join the Adafruit Discord and post in #circuitpython-dev.

Updating for CI
@BlitzCityDIY BlitzCityDIY requested a review from tekktrik August 5, 2022 14:39
@tekktrik
Copy link
Member

tekktrik commented Aug 6, 2022

Did the CI add all those extra lines in the example file? If possible, it may be more legible to keep it as it was.

For the library, thanks for the type annotation! Perhaps it might be nice to add the different I2C addresses as public global variables at the top:

MCP4728_DEFAULT_ADDRESS = 0x60
MCP4728A4_DEFAULT_ADDRESS = 0x64

Then we can additionally encourage people to use them as/if needed:

i2c = board.I2C()
mcp4728 = MCP4728(i2c, address=MCP4728A4_DEFAULT_ADDRESS)

What do you think, would that be helpful?

@BlitzCityDIY
Copy link
Contributor Author

Thanks! It totally did add all those lines so I just removed those. This is my first time contributing to a library so I appreciate the feedback! I think global variables would definitely be helpful and I could point them out in the Learn guide. You're saying these variables would be in the example files?

@tekktrik
Copy link
Member

tekktrik commented Aug 6, 2022

If you change _MCP4728_DEFAULT_ADDRESS to MCP4728_DEFAULT_ADDRESS up at the top and add MCP4728A4_DEFAULT_ADDRESS = 0x64 underneath, you could use them in an example file like such:

import board
import adafruit_mcp4728

i2c = board.I2C()  # uses board.SCL and board.SDA

# Use the default address for the MCP4728A4 variant of the board
mcp4728 = adafruit_mcp4728.MCP4728(i2c, address=adafruit_mcp4728.MCP4728A4_DEFAULT_ADDRESS)

...

Just make those changes and push the fix for the extra spaces and it should be good to go!

Updating both variants of the board as public global variables and adding an example in the main example file. Also fixing spacing from original local pre-commit run
@BlitzCityDIY
Copy link
Contributor Author

got it, yeah i definitely like that. just PR'd that update

Copy link
Member

@tekktrik tekktrik left a comment

Choose a reason for hiding this comment

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

Looks great to me, nice!

@tekktrik tekktrik merged commit b9abe1f into main Aug 8, 2022
@BlitzCityDIY BlitzCityDIY deleted the MCP4728A4_update branch August 8, 2022 02:44
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Aug 8, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_MCP4728 to 1.3.0 from 1.2.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_MCP4728#13 from adafruit/MCP4728A4_update
  > Added Black formatting badge
  > Changed .env to .venv in README.rst

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_LYWSD03MMC to 1.0.9 from 1.0.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE_LYWSD03MMC#5 from NanoExplorer/struct_features
  > Changed .env to .venv in README.rst
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.

2 participants