I struggled with the rotary encoder plug-in with a cheap KY 040 encoder off amazon ... very spurious and unpredictable volume and switch behaviour, probably caused by using interrupt-driven code with no hardware de-bouncing. To get over it I wrote a very basic (less than half a page of code) and simple python script that works very reliably (albeit not very elegant) as follows. You may need to play with the sleep times and you will need to change the GPIO pin numbers depending on your set-up. I used the REST API (see here https://volumio.github.io/docs/API/REST_API.html) to control things because it was so easy and didn't need any extra libraries:
script.png (26.37 KiB) Viewed 3087 times
Once you've tested this, you will need to add it to the boot startup script. I just use update-rc.d and it works fine.
Thank you for your post. I have some issue with rotary encoder too. You have interesting approach . I have pair tips: - you can paste code. It's better as image. Volumio forum has button for this. It called "Code" - This code takes very much compute power. When is rotary encoder idle, so your code checks the state of pins 200 per second. You can use diffrent approach. Operation system can call your function, when processor detects a change on GPIO. https://www.stuffaboutcode.com/2015/05/ ... coder.html - Play/Pause functionality. It will be better use toggle functionality.
It's also good to mention which versions you are running on, i.e. which versino of Volumio and which version of the plugin. I can confirm the behaviour being choppy, this has greatly improved in recent versions.
Hi Saiyato, first thank you for your work on plugins. Today I retested rotary encoder in my sestup. It works! But I had some trouble. - notes in plugin are little confusing - in notes contains word "pin". I think, you mean raspberry pins on 40 pins connector and not GPIO. Please, can you change it. - some GPIOs aren't proper for this work. I mean GPIOs for I2S or for I2C. It's my case, I use DAC hat. You can recomand some GPIOs. I think GPIO 20, 16 and 12 are ok. - plugin works after restart (I think first setup. Maybe, can you add this information to main text on top. - I have oposite direction for volume. I use ky040 rotary encoder. I set clk to 16 and dt to 20, coding is ky040. When I make a turn clockwise then volume make a step down. It's correct?
The pins are actual GPIO numbers, not the header numbers. You are correct in the sense that some GPIO pins are unusable if you're using a HAT DAC. However, not everyone uses a HAT DAC, some people prefer USB, therefore all pins are selectable. I'll try to clarify.
Which version of the plugin are you using? I just published a new version on github, the one in the store is out-dated. There have been various patches to that version after intensive testing. When connected correctly rotating clockwise will increase the volume, but again, the code on github is way more stable.
Yes some people use USB DAC, but for a novice is hard to understand which hadrware pin must connect and whitch GPIO must set as number in plugin. I had to print raspberry's pinout (https://www.element14.com/community/ser ... 3_gpio.png). I'm beginner in this field. I try to say, when you change a little texts in your plugin, then you help many users.
I don't know what version number. I use this plugin from volumio GUI (store version). I didn't download plugin from github. I read michelangelo post about don't use a zip file instalation. How hard is upload new version of plugin into volumio store?