Open ilium007 opened 3 years ago
>>> mcp = mcp23017.MCP23017(i2c, 0x20)
>>> i2c
I2C(1, scl=B6, sda=B7, freq=420000)
>>> mcp
<MCP23017 object at 2000bcf0>
>>> mcp.pin(1, mode=1, pullup=True)
False
>>>
MCP23008 is a single 8-bit port variant of the MCP23017. While one would expect it to behave similar, if not the same, there's a bunch of code in the library expects to two ports.
I don't have any MCP23008 chips/modules to test with, but I could fork this and rip out all of the 2nd port code if you're able to test it and confirm it all works. Sorry I missed this issue earlier. It's been a while. Are you still interested in the MCP23008?
@mcauser I recently started a project with both a MCP23008 and a MCP23017. I was looking for a library for the MCP23008 but there's not much out there. I'd be very interested in helping you test this if you made a port for the MCP23008.
Hi @plmetz , See https://github.com/mcauser/micropython-mcp23008 It's a fork of the current library with all of the PortB code removed.
I haven't tested it on any hardware yet, or written up any documentation. It should work. If you're able to do some testing, that would be awesome! Refer to the readme of this library for examples how to use it, with only the first 8 bits/pins available.
import mcp23008
mcp = mcp23008.MCP23008(i2c, 0x20)
List interface
mcp[0].value()
...
mcp[7].value()
Method interface
mcp.pin(0)
...
mcp.pin(7)
Property interface
mcp.mode = 0xfe
mcp.gpio = 0x01
Thanks for pulling that library together. It works wonderfully, as far as I can tell. I am a hobbyist just getting started with electronics and python, so by no means an expert, but I did some testing, and on the MCP23008, I was able to:
If there is any other specific testing that you think would be warranted I'd be happy to try.
What is your plan with the MCP23008 library? Leave it as a standalone or would you integrate it into this library? Or a "MCP230x" library?
Hey, there's not a huge difference between them and the MCP23017 was well tested, so it should be good to go. I'll add documentation and examples soon. Could use some examples/tutorials for using things like rotary encoders.
There's a lot of overlap between the two libraries, so a common MCP230x may make sense down the track. The libraries are already quite large, so it would have to be done in a way that doesn't negatively impact each other.
I'll leave MCP23008 as is for now and add some readmes/docs to make it more complete. Then add a common ancestor to the backlog.
I'm also able to submit some PRs for the documentation. As I work on my project with it I should also be able to get an example together. It's a busy time of year so might not be right away but I'd love to help.
I wrote an example for the MCP23008
Unfortunately doesn't seem to work for MCP23008. Was able to create the mcp object but can't configure a pin for input or output.