Skip to content
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

Using GPIO Extender #28

Open
Snowgoose74 opened this issue Aug 3, 2023 · 2 comments
Open

Using GPIO Extender #28

Snowgoose74 opened this issue Aug 3, 2023 · 2 comments

Comments

@Snowgoose74
Copy link

Hi Mike,
Firstly, thanks for an excellent MicroPython library for the rotary encoder. So many resources use Circuit Python or Arduino only, so it's great to come across this!

My issue is that I'm using an MCP 23017 to extend the number of GPIO pins. This is because I'm using a Pico to drive an LED matrix and almost all the GPIOs are used for this purpose. I have an adafruit 23017 GPIO extender board working on I2C (using QWIIC connection).

I address the pins like this (where x is the pin number I'm addressing):

mcp = mcp23017.MCP23017(i2c, 0x20)
mcp.pin(x, mode=1, pullup=True)

My tiny brain can't work out a way to use these extended GPIO pins with your Rotary Encoder module. Is this possible?
Interrupts on the extender are through 2 pins (INTA works with the first 8 pins and INTB for the second 8). I assume I need to connect these interrupt pins to a spare GPIO on the Pico itself in order to get interrupts to work?

Many thanks
Dave

@miketeachman
Copy link
Owner

Hi Dave,
Unfortunately, I can't see a way to use a GPIO extender with this library. Internally, this Rotary library uses the MicroPython Pin class which requires direct access to the microprocessor pins. As far as I know there is no way to map a Pin class object to the GPIO extender library. It's a similar problem that is discussed in this issue #24. I suggest trying to find an encoder library that uses polling techniques, rather than the interrupt techniques that are used in this library. A library that uses polling can be adapted to poll pin values from the GPIO extender. The downside to polling approach is a much slower response when the encoder is turned. Clicks will be missed if the encoder is turned too quickly.
Hope this helps!
Mike

@Snowgoose74
Copy link
Author

Hi Mike,
I thought as much. Speed isn't too much of an issue for me so I'll see if I can find a polling library.

Thanks again for your work here...it allowed me to have fun using rotary encoders for the first time!!

Best wishes
Dave

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

No branches or pull requests

2 participants