Replies: 2 comments
-
You certainly can write i2c gpio expander interfaces in pure python, here's one for example: https://github.com/mcauser/micropython-mcp23017 It's got a few different interfaces described, the virtual pin one I believe is intended to work similar to a machine.Pin object. You simply create your pin object using the library functions rather than machine.Pin then pass that created object to whatever would normally be given a "real" pin object. |
Beta Was this translation helpful? Give feedback.
-
Thank you @andrewleech - In fact I'm using an MCP23017 as IO expander...however I was unaware that I could pass the mcp.pin as if it was a machine.pin (in hindsight its obvious). Having said that, it seems like it would be really useful if we could do something like this:
And then later you could just do Maybe that is already possible by subclassing |
Beta Was this translation helpful? Give feedback.
-
Firstly let me describe my problem. I've run out of pins so I'm using a I2C IO Expander to be able to access more pins. However this has the problem that these "new pins" are not accessible via
machine.Pin
module.This got me to researching how is this being handled on boards like PICO_W where there are special pins like
LED / EXT_GPIO0
which is in reality being controlled via the wireless controller (SPI?). I'm not a good enough C programmer to fully understand how its working....I mean I get the basics but not sure how to add my own....In essence, I'd like to define EXT_GPIO3 (the next available), and have that controlled via a call to I2C IO expander.
Would be a really great feature if I could do this all from micropython without needing to write any custom C code. I realize there would be a performance hit not doing it in C, but in my usecase it wouldn't matter too much.
Beta Was this translation helpful? Give feedback.
All reactions