opencardev / crankshaft

Crankshaft: A turnkey GNU/Linux solution that transforms a Raspberry Pi to an Android Auto head unit.
http://getcrankshaft.com
GNU General Public License v3.0
2.17k stars 262 forks source link

Feature Request: Rotary Encoder volume adjustment. #122

Open chrisfromwa opened 6 years ago

chrisfromwa commented 6 years ago

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

Maju3 commented 6 years ago

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;)

chrisfromwa commented 6 years ago

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

Maju3 commented 6 years ago

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

john-TC commented 6 years ago

+1 for this feature

x13-me commented 6 years ago

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?

chrisfromwa commented 6 years ago

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 commented 6 years ago

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.

Richard6360 commented 6 years ago

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)

inspector71 commented 6 years ago

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

byransays commented 6 years ago

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

inspector71 commented 6 years ago

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 notifications@github.com 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 .

n3ptr commented 6 years ago

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.

inspector71 commented 6 years ago

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 notifications@github.com 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 .

meekys commented 5 years ago

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!

hawkeyexp commented 5 years ago

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

Zulu0001 commented 5 years ago

hawkeyexp, you are doing a great job!!

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

matt2005 commented 4 years ago

@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?