Às mentioned above in post http://www.gl-inet.com/forums/topic/rotary-encoder-project/#post-7363 you have to assign something to a key called “rotary-gpio-custom.bus0” (and also bus 1 till 3).
Here is a topic that describes not exactly the same, but about pressing GPIO keys: http://www.avrfreaks.net/forum/gpio-key-device-doesnt-get-installed
I did see something in the topicstart:
I wonder if there should be a directory like it is in
/sys/bus/platform/drivers/leds-gpio
bind leds-gpio.2 uevent unbind
Maybe this will gice us some clue?
just got home,
I think you could be right,
Something in the area of gpio_a.16 and another with gpio_b.17 This needs a few days to find a braincell that’s a bit more digitally minded then the others
rotary-gpio-custom.bus0.gpio_a.16
rotary-gpio-custom.bus0.gpio_a.17
And also for id, steps, axis?
Or am I again thinking in the wrong direction here? (or too far ahead)
I think bus1, bus2 and bus3 can be left empty. The driver can handle 4 rotaties I have read somehere
But it’s not clear what values are expected for id, and axis.
Steps is most likely “20” that’s the number of steps of the rotary to make 1 full circle.
I wonder if we can find in the sourcecode what kind of value’s it expects?
after a lot of digging i cae across this page: http://lxr.free-electrons.com/source/Documentation/input/rotary-encoder.txt
It looks like this should now be all the info i need… and now i need to look how to enter the correct commands to set these values. That’s for tomorrow…
I need <id>,<steps>,<axis>,<gpioa>,<gpiob>,<inverted>
These are the values that I have in mind:
id = 0
steps = 20,
axis = ABS_X,
gpio_a = 16,
gpio_b = 17,
inverted = 0,
rene
45
Hey Frietpan first greetings to the netherlands from germany near the border !
You could take a look here: Build Your Own Wifi Radio : 14 Steps (with Pictures) - Instructables this guy is using a openwrt router to make a webradio,using a rotary encoder with a microcontroller. i think it could be done by adding a arduino nano or something else into the router this should be a solution for your problem
also take a look at this: Building a Wifi Radio – Part 8, Adding a Tuning Control | MightyOhm
Greetings Rene! Are you in the Aachen area perhaps? (near the Dutch mountains)
Thats a nice project! However, it uses an ‘expensive’ atmel to do the GPIO stuff. It looks less complicated then the route I took. Once this encoder stuff is figured out it should make things more easy. By connecting the encoder directly to the SoC there is no more need to use an extra chip do add a basic selector switch / control knob.
I want to use it as a volume knob / light dimmer and also as a OpenWrt config selector. … yeah too many ideas… 
The most practical use would be a config selector for a travel router. By making additional config folders ie /config1, /config, /config3, etc. When you turn the knob then another folder is used. This way you could store an endless number of configurations… Just by connecting a rotary to the GPIO’s But I’m not there yet… Getting close though. I’m now at the point where i have to figure out what kmod-rotary-gpio-custom wants to know exactly.
I have tried a few things but since i’m not comfortable with it yet i hope i don’t mess up anything.
rene
47
Yes i understand, but i´m not sure if the soc can handle the timings of the LOW/High´s from the encoder… sadly my rotary encoder is on its way from china to germany, will test in about three weeks xD
i´m located Near Borken (near in the Netherlands Winterswijk)
Cool,
I also had my doubts, but afterall there is kmod-input-gpio-encoder and kmod-rotary-gpio-custom these drivers seem specifically made for using encoders on GPIO pins. A little bit hard to understand how they work, but it’s all there and they seem to exist for quiet some time for linux. And the AR9331 SoC seems to be modern enough. It would be great if someone with more knowledge would jump in and tell us the secrets but it looks like we are the pioneering pirates. HAR HAR!
Now i also have to build a Radio.
Then I can tune in to one of the streams from Culturserver.de
Borken That’s not too far from here. It’s a little up north from Airport Weeze right?
I’m 15 minutes south of Eindhoven.
rene
49
i´m good thank you, i´ve just ordered a rotary from the uk!
http://www.ebay.de/itm/311219577453 looks really nice
Should be arriving in a few days i hope!
Yes the Radio Project does looks good sadly i´m not good at building cases! 
i´m located in the Ruhrgebiet,Eindhoven is 1 1/2 hour far away from here by car (144km)
It even has all the resistors mounted!
In my case the pull-up of de SW was not mounted.
Plastic breadboxes and tupperware boxes make low cost enclosures for prototypes.
Ruhrgebiet now I have to download a few Schimanski episodes to get in the mood and make plans for a visit. 
rene
51
Schimanski i´m waaaaaayyy too young for this!
(25 years old)
but if u come to the ruhrgebiet we should drink a beer! 
hope the rotary encoder arrives soon so i can compile my own openwrt and do a little bit soldering!^^
Will share my results for sure
I severely messed up a few minutes ago, I will re-flash and re-do all the things I did so far.
Schimi…, my age shows. Now I feel really old. HAHA - 44
@Rene:
Compiling OpenWrt, i’m not at ease with it all. …Fear of making bricks…
I have read the OpenWrt wiki and on the GLi blog there is also a tutorial, the configuration procedure doesn’t look too difficult, but still it feels like there is a potential to make mistakes that can make bricks. Now if it is possible to flash images from USB then I would give it a try. How do you know that your self compiled image is safe to flash? Do you like to gamble, or do you have tools to repair bricks?
@Rene I hope you discovered a few new clues. I have been trying to read up on this but it’s hard to find the right info, and even harder to understand it. (i’m still missing a few basic skills here)
I’m now going to play with Arduino and encoders to see if that can give more insight, though i doubt it will since Arduino is a bit different on this. Still i’m sure i’m going to learn something usefull.
rene
56
Hi Frietpan!
How are u?
Sorry for the delay in the response, i´ve still waiting for this little thing to arrive 
damn christmas holidays 
hehe the Deutsche Post elfs are overloaded?
In Arduino the Encoder stuff is pretty straightforward. It’s a bit frustrating that I don’t see how this stuff has to be configured in OpenWrt.
Wouldn’t it be nice if there would be a virtual duino-ish section in OpenWrt (WrDuino?? ) A section that allows you to control the GPIO’s by using the arduino IDE.
@ hamid
Jeroen pointed me to your questions in the GPIO thread, i’ll post my answer here to keep the encoder stuff in this thread.
The encoder i used is a quadrature encoder, most common available are made by keyes or xinda but there are many more. these encoders have 2 10k resistios Some also have a 10k pullup for the SW pin (pushbutton function when you press the encoder shaft)
First of all i’m glad to hear that you know a bit more about the kernel stuff i hope you can explain a bit (or all) that has to be checked and set. On the openWrt forum i could not find much on the topic, and even less in the wiki. I hope i can collect enough info to make a basic but useful wiki article on this.
Alzhao has compiled the kernel for us and so this should now be enabled in the kernel though its not yet clear to me how to make this work. it seems we should be able to configure the GPIO with a script that tells the software what pins to use. But i still can’t figure out how.
Meanwhile i have played a bit with arduino and encoders and there it’s not too hard to make it work, however Arduino is a different animal in this regard.
this is the most common rotary encoder so it should not be too hard to find. (in what part of the world do you live?)
@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.
I see we where looking in the right direction, though i still don’t fully understand it.
I’m trying the insmod command but not much luck with it yet. So now I start to wonder if the rotary_encoder.h is correctly compiled into the kernel for the AR150
insmod rotary-gpio-custom bus0=0,20,0,16,17,0
- ID 0
- 20 steps
- axis 0 (also tried x)
- GPIO 16 and 17
- not inverted
I will try with the clean CC firmware tomorrow and see how that turns out.
Looks like i really need to spend some time to learn to compile my own, but currentley I have a few other distractions that hold me back.
But if that insmod command is all it takes that’s really nice. 