Rotary encoder driver, now working.


There is a rotary encoder driver in the input driver groups. My plan was to add an encoder and make it working as a mouse wheel. The rotary encoder driver (rotary-encoder.c), is rather out of date, or had never been ported onto BBB and hence couldn’t work. Finally, I managed this to work and I want to share it, just in case someone will look for a solution as I did.

  1. New features:
  • create an event, which is recognized as a mouse by evdev X11 driver.
  • add “quarter” mode, so that every rotary “snap” is detected.
  • added support for “pincontrol” pins configuration from a cape.
  1. Bug fixes:
  • device three properties without values where not recognized (isn’t a bug in other drivers?), the problem is use the function “of_get_property” which returns NULL even though the property is defined, it returns NULL because the property has no value! I changed the code to use “of_find_property” instead.

I have a Grayhill encoder, the good quality optical one. The cheap mechanical ones, might not working ideally, and some de-bouncing/filtering might be required

I have attached the cape and driver update files. My cape is configured to use a rotary encoder on pins P8.11 and P8.15 (GPIO1_13, GPIO1_15). The switch is connected to P8.17 (GPIO0_27) and the cape configures using “gpio-keys” driver. I set this to a mouse middle button, but this event is not recognized by the evdev driver. Basically, it can be any keyboard button.

Any comment will be appreciated.
Piotr. (4.04 KB)