KMKfw / kmk_firmware

Clackety Keyboards Powered by Python
https://kmkfw.zulipchat.com
Other
1.38k stars 474 forks source link

Support bare DigitalInOut pins in Encoder module #774

Closed macdude95 closed 11 months ago

macdude95 commented 1 year ago

Background

I ran into an issue with trying to use a rotary encoder through a GPIO expander module. These modules often give you access to their pins in the form of digitalio.DigitalInOut objects. I made a small adjustment to the Encoder module in KMK to support a pin being some form of DigitalInOut object rather than a microcontroller.Pin object.

Description of Change

Check if pin is a microcontroller.Pin. If it is, keep the old logic of turning it into a digitalio.DigitalInOut object. If it isn't, just assume it's already a DigitalInOut object and use it as is.