PiSupply / JustBoom

Resources for JustBoom range
https://JustBoom.co
15 stars 5 forks source link

Not able to get rotary encoder work with Pi Zero W #1

Closed kelltob closed 7 years ago

kelltob commented 7 years ago

I Installed the script on my Raspi Zero W + JustBoom Amp Zero + JustBoom Player 1.041 via SSH (logged in as JustBoom) and disabled the UART. Wired the Rotary Encoder to pins 16/18/10/25/39.

Nothing happend when I turned the rotary encoder so I tried to run the scrip after installing python-alsaaudio with

python /opt/justboom/jb-rotary.py

and got this message:

Traceback (most recent call last): File "jb-rotary.py", line 154, in <module> easy_mixer = EasyMixer(start_volume,volume_increments, int(rotary_pins[0]), int(rotary_pins[1]), button_pin) # New mixer instantiation File "jb-rotary.py", line 64, in __init__ self.mixer = alsaaudio.Mixer('Digital') alsaaudio.ALSAAudioError: Unable to find mixer control 'Digital',0

Any ideas what I do wrong? sndrpiboomberry isn't default. Is this a problem? justboom@justboom:~$ cat /proc/asound/cards 0 [ALSA ]: bcm2835 - bcm2835 ALSA bcm2835 ALSA 1 [sndrpiboomberry]: snd_rpi_boomber - snd_rpi_boomberry_dac snd_rpi_boomberry_dac

francesco-vannini commented 7 years ago

Hi @kelltob , the script is really only designed for Raspbian. Although it will work for others in some cases it will need some adjustments. Your output shows that the ALSA devices on the JustBoom Player are slightly different than what you'd find on Rasbian. For the JustBoom Player we are developing a dedicated plugin for the rotary encoder so stay tuned.

In the meantime you could try changing a line in class EasyMixer from self.mixer = alsaaudio.Mixer('Digital') to self.mixer = alsaaudio.Mixer(control='Digital', cardindex=1)

this should fix the problem for the time being.

francesco-vannini commented 7 years ago

The last commit deb3621 should have fixed the script to run on both the JustBoom Player and other Raspbian OSs. I have also fixed the installation package dependencies. Let me know how this goes.

kelltob commented 7 years ago

Script starts without any problem and sets volume to 0 but turning the rotary encoder doesn't change anything. Same with the Button.

francesco-vannini commented 7 years ago

Which pins did you use to connect things? The ones you mentioned above (16/18/10/25/39)? Can you show me the board with the connections you made? Maybe use something like https://unsee.cc/

kelltob commented 7 years ago

Yes I used 16/18/10/25/39 https://unsee.cc/sapeditu/ https://unsee.cc/tezuposi/ https://unsee.cc/natisoru/

francesco-vannini commented 7 years ago

I could only see the last one as the others timed out already. Can you send me a link for that rotary encoder? Is that the type the requires one pin connected to VCC?

kelltob commented 7 years ago

Its a KY-040 similar to this http://amzn.eu/d6qyKsO

I connected the VCC pin to ground because in the script the gpio pins are pulled up. The VCC pin is only for the button and i think it doesn't matter. I also tried with the VCC connected to this pin but changed nothing.

img_20170525_194036602

img_20170525_193518767_hdr

img_20170525_193508184_hdr

francesco-vannini commented 7 years ago

That kind of rotary is not compatible with our code, it works under a slightly different principle. Have a look here to see what changes with that encoder https://www.modmypi.com/blog/how-to-use-a-rotary-encoder-with-the-raspberry-pi You need to use one like this https://www.pi-supply.com/product/rotary-encoder-push-switch/

Also those pins don't seem to be the right ones, have a look here https://pinout.xyz/pinout/amp_zero and maybe just start with the rotary without the button.

kelltob commented 7 years ago

Ohh you're right. Muting works now. I will try again when I've got a new rotary. Thanks for help

francesco-vannini commented 7 years ago

NP let us know how that goes