@frietpan

 

Thanks for the update. I ordered some rotary encoders, but I got a bit excited and ordered them naked (no breakout board or Resistors). This is not a problem, I can make my own PCB for them.

 

So, from rerading the source file for the gpio kernel module, when you modprobe/insmod the module you need to specify the parameters for the bus you are using.

https://dev.openwrt.org/browser/trunk/package/kernel/rotary-gpio-custom/src/rotary-gpio-custom.c?rev=37007

The codes checks for the params in the following order;

the structure of the rotary_encoder_platform_data is found here;

http://lxr.free-electrons.com/source/include/linux/rotary_encoder.h?v=3.18

So;

  • Are the number of params supplied < 5? If so, don't continue
  • (Ooh, my rotary encoders just arrived as I'm typing!)
  • param 0 - device id (int) (remember we zero index in code)
  • param 1 - step count (int)
  • param 2 - axis (int)
  • param 3 - gpio_a (int)
  • param 4 - gpio_b (int)
  • param 5 - If 1 invert a AND b, else, NOT invert a AND b.
As far as I can see, it should be along the lines of;
insmod rotary-gpio-custom bus0=0,20,?,(gpio a number), (gpio b number),0
I need to dig deeper in the code to find what the values for axis should be, but the module hardcodes "relative axis" to false so perhaps experiment with values of 0,1,2 etc.

I don’t yet have my router to test this myself, bus once this has loaded, you should have a bus device for it that you can cat the value of in a loop while you turn the knob.

Also, as far as I can see, the kernel module does not manage the press switch, you must handle that seperately with a GPIO.