Open Pastinakel opened 6 years ago
I've not read the script entirely and Python is definitely not my strong suit. But it looks like you are saving up the changes and "commit" then on the button push.
I'm now exploring whether or not ALSA can be called directly, this would make it more snappy. The only thing needed is to sync it to the Volumio UI. I'm guessing that's where the delay is at.
HW -> node JS -> UI
If you enable logging you will see that there is a snappy response from node JS when turning the knob, but calling Volumio (over the command line or socket) causes delays in the system.
The most sensible approach would be to have some visualisation (LCD) and buffer the changes before sending them to Volumio. My suggestion would be to update ALSA and have Volumio poll ALSA volume levels or subscribe to changes.
Note: this only fixes volume, there are other functions for the encoder ;)
Hi Saiyato,
Thanks for your reply.
The problem with the ALSA approach is that changes in ALSA mixer are not picked up by Volumio. Eg: If the volume is 80 and I change it to 50 in ALSA, it is still 80 in Volumio. Next time I decrease the volume by 10, it will be 70 if I do it in Volumio, and it will be 40 if I do it in Alsa. Quite a difference.
Direct control over ALSA mixer: https://github.com/iqaudio/tools/blob/master/IQ_rot.c
[...] HW -> node JS -> UI
If you enable logging you will see that there is a snappy response from node JS when turning the knob, but calling Volumio (over the command line or socket) causes delays in the system. [...] Maybe I had a slow Raspberry Pi 2 but in my experience there can be a delay in node JS. Big enough to miss most of the rotary movement.
Yeah, thats why I want to propagate the new volume to Volumio asynchronous, this will give you snappy response in terms of volume control, the GUI just lags behind a bit.
When I was working on the solution I did get good results from the log on my Pi3, not sure if I tried it on the Pi2 as well... I had to count detents carefully, but I didn't seem to miss any.
The direct control uses the same logic as I do for detent and direction detection, so that's a relieve for me :) Since I didn't experience misfire I was looking for node JS libraries to control alsa directly and subscribe to ALSA events. But that's mostly because I get javascript, Python however... not so much ;)
Hi, as said before by others, it is very hard to get it to work. So I used a different approach (also used by others): a python script that catches the rotary events and changes the volume in Volumio. Problem here is that Volumio is not reponding fast enough to process all movement. This script keeps adjusting the volume until it matches the one set by the rotary.
Maybe it helps others.