crankshaft icon indicating copy to clipboard operation
crankshaft copied to clipboard

Feature Request: Rotary Encoder volume adjustment.

Open chrisfromwa opened this issue 6 years ago • 17 comments

Hello, I was told to submit feature requests here, if this is not the correct area my apologies.

I have just learned of CrankShaft, and really liking what I see. My goal with this, is to replace the stereo I currently have in my car.
I have a Raspberry PI3, and just purchased a WaveShare 7inch touch screen. This part all works perfectly!

Next is the audio portion, I purchased a HIFI Berry DAC pro, and able to get audio to my amps, but I have no way to control the volume level.

My Feature request:

  1. Enable a way to use a Rotary Encoder to adjust the volume and mute if the knob is pushed.
  2. When the volume level is changed, a popup display appears that show the current level of the volume
  3. When the PI is shutdown, and restarted. The previous volume level is remembered

I really hope this can be implemented, as this is something stopped me from going further in my custom install.

Thanks! Chris

chrisfromwa avatar Jun 11 '18 01:06 chrisfromwa

I agree with all of this. Just for point 3: What do you think about a setting for "start up volume"? Just think about when you hear music very loud and then you shutdown the pi. On next boot the volume would blow your ears;)

Maju3 avatar Jun 11 '18 03:06 Maju3

That would work OK for me.

Another option, I remember back in the day. Alpine had a feature where if you had your volume say at 35 and shut off the car. The next time you started it up, it would start at 0 and gradually go back up to 35. It was a neat thing we all liked back then.

But I'm also OK with it starting at a startup volume

chrisfromwa avatar Jun 11 '18 12:06 chrisfromwa

Oh you mean fading volume. That would be very cool :)

Maju3 avatar Jun 11 '18 16:06 Maju3

+1 for this feature

john-TC avatar Jun 12 '18 01:06 john-TC

In terms of implementation, this is very easy to do, just hook into Alsa's volume control

amixer -D pulse sset Master $1%+ where $1 is your chosen increment

As for the interface, you'd need to draw over the top layer, preferably somewhere away from the main viewport, i.e. in the "status bar", I'm not sure how to do that, but I'm sure someone else can figure it out, fork the code, then make a pull request.

@htruong what do you think of it?

x13-me avatar Jun 15 '18 13:06 x13-me

j-ak-e, Thanks for your response. Could you go into a little more detail how we could get this working? I'm new to the PI and CrankShaft.

Would love to see instructions for this added to the WIKI like volume buttons are.

chrisfromwa avatar Jun 23 '18 13:06 chrisfromwa

I'm now using Crankshaft NG @hawkeyexp Could this be added into consideration for an added feature?

Summary

  1. Enable a way to use a Rotary Encoder to adjust the volume and mute if the knob is pushed.
  2. When the volume level is changed, a meter bar appears that displays the current volume level.

This is the one major item that is stopping me from replacing the entire head unit currently in the car.

chrisfromwa avatar Jul 20 '18 18:07 chrisfromwa

should be easy as there are gpio pins for volume already, you only need to take up and down pulses from the rotary encoder for this to work i think. (dont know for sure i never used rotary encoders but i want too)

Richard6360 avatar Jul 26 '18 19:07 Richard6360

Adding myself to the list of those interested in this option.

inspector71 avatar Aug 19 '18 13:08 inspector71

I'm currently using a rotary encoder and a script I found on the internet that I've adjusted for the USB sound card. I just had surgery but when I get home I can post my setup for others.

edit: as promised, here is the site I used as reference: http://blog.amnuts.com/2017/01/11/rotary-volume-control-for-the-raspberry-pi/

in doing so, I used his code to make a python script for the USB sound card(likely it will be amixer "2" but you will have to make sure its that on your setup from the drop down menu in the settings). If you plan on using the built in audio then you may need to make adjustments with the amixer card number and the numid number. The page will help you figure all that out.

Once you have the file saved in the crankshaft folder in the boot partiton(mine is saved as volumecontrol.py) I added in "sudo python /boot/crankshaft/volumecontrol.py &" in the startup.sh file in the crankshaft folder.

It works well, but sometimes it seems like the built in audio changes on boot to a different card number, so the USB sound card isnt always card number 2 and it doesnt work. Generally a simple reboot fixes it.

Attached you will find my files.

volumecontrol.zip

byransays avatar Aug 29 '18 13:08 byransays

Hope you're surgery went well and you're enjoying Crankshaft as somewhat of a distraction through tricky times, just like me!

On Wed, 29 Aug 2018, 11:26 PM Bryan Jones [email protected] wrote:

I'm currently using a rotary encoder and a script I found on the internet that I've adjusted for the USB sound card. I just had surgery but when I get home I can post my setup for others.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/opencardev/crankshaft/issues/122#issuecomment-416952290, or mute the thread https://github.com/notifications/unsubscribe-auth/ABKpC-oimfigqiutrtwFA7hlf5Dcog5bks5uVpZzgaJpZM4Uh835 .

inspector71 avatar Aug 30 '18 10:08 inspector71

I would like to +1 this idea. putting together a system using crankshaft, and I'm morally opposed to push-button volume controls when space allows for a rotating knob.

Also, I hope that surgery went well, best wishes.

n3ptr avatar Oct 01 '18 04:10 n3ptr

Can I just say that I'm having quite a difficult day but reading your "morally opposed" phrasing just made it that much better 😀

I remember when I had the confidence and belief to use phrasing like that. Maybe it will return one day, can only hope I guess.

On Mon, 1 Oct 2018, 2:07 PM n3ptr [email protected] wrote:

I would like to +! this idea. putting together a system using crankshaft, and I'm morally opposed to push-button volume controls when space allows for a rotating knob.

Also, I hope that surgery went well, best wishes.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/opencardev/crankshaft/issues/122#issuecomment-425784220, or mute the thread https://github.com/notifications/unsubscribe-auth/ABKpC-JwgqL8I6LtPkta8LHqLAmQwT0eks5ugZT6gaJpZM4Uh835 .

inspector71 avatar Oct 01 '18 05:10 inspector71

Hi all, I've run into the same issues as the original poster. I'm not (currently) running CrankShaft, just OpenAuto directly in Raspbian, but it should work (in theory at least)

For the hardware side of things, I was inspired by this, which just generates the volume up/down key-press events. https://www.instructables.com/id/Digispark-Volume-Control/

And then I wrote the following which gives a nice overlay when the volume changes. https://github.com/meekys/vol_overlay

I'm looking at switching over to Crankshaft soon, so hopefully I'll be able to confirm whether this 'just works' soon enough. Awesome project!

meekys avatar Dec 18 '18 02:12 meekys

After christmas i will start to include a implemtation for csng :-)

hawkeyexp avatar Dec 19 '18 01:12 hawkeyexp

hawkeyexp, you are doing a great job!!

I'm interested too in either this feature or an on screen slider while in AA

Zulu0001 avatar Mar 09 '19 23:03 Zulu0001

@chrisfromwa Rotary volume should work in alpha 6, there is a volume slider on the bottom on the main screen. Is this what you were after?

matt2005 avatar Oct 20 '20 21:10 matt2005