Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Behaviour of push button Mute on GPIO22
#1
Hello,

I have a Raspberry Pi 3 with and IQaudIO Pi-DigiAMP+, running Moode 4.1 (updated in-place from 4.0).

I have added a rotary encoder with push button bought from the IQaudIO store.

The rotary encoder works out of the box with Moode (using GPIO 23 and 24).

The push button (momentary switch) is connected to GPIO 22.
When I press it, it mutes, when I release it, it unmutes. I would prefer a mute toggle at each press.


Where is the code managing GPIO 22 mute? 
I have looked for it, but only found stuff for the rotary encoder, nothing using GPIO 22. I do not even know where the current behaviour is coming from... Could it be a driver feature?
Any idea about changing the current behaviour?

Thanks for your help!

Nico
http://www.youplala.net/tag/hi-fi/
Reply
#2
No taker yet?

Nico
http://www.youplala.net/tag/hi-fi/
Reply
#3
Hi. 
What you have there is a momentary switch. Maybe you can have a look at this tutorial and google "mpc commands" to see if there is a command to toggle mute. Or to set volume=0 on and off. Or just set it to toggle play/pause.
Remy
Reply
#4
Does IQaudIO provide a guide or custom driver for controlling the encoder?

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#5
(05-17-2018, 04:39 PM)camelreef Wrote: Hello,

I have a Raspberry Pi 3 with and IQaudIO Pi-DigiAMP+, running Moode 4.1 (updated in-place from 4.0).

I have added a rotary encoder with push button bought from the IQaudIO store.

The rotary encoder works out of the box with Moode (using GPIO 23 and 24).

The push button (momentary switch) is connected to GPIO 22.
When I press it, it mutes, when I release it, it unmutes. I would prefer a mute toggle at each press.


Where is the code managing GPIO 22 mute? 
I have looked for it, but only found stuff for the rotary encoder, nothing using GPIO 22. I do not even know where the current behaviour is coming from... Could it be a driver feature?
Any idea about changing the current behaviour?

Thanks for your help!
a
Nico
http://www.youplala.net/tag/hi-fi/

Hi Nico,

I use a rotary encoder with a momentary push button switch to toggle mute. I use an IQaudIO DAC+ and didnt have any luck using the scripts that they provide. Python script that I use is below as well as mute.service to start the script on boot 

You'll need to change the GPIO pin number and script location for your setup

Code:
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
import subprocess
import os
GPIO.setmode(GPIO.BOARD)

# Select unused GPIO header pin to be used to toggle mute
InputPin = 13

   # Set selected pin to input, and enable internal pull-up
GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP)

   # Wait for a button press on the selected pin (pulled to ground, falling edge)
GPIO.wait_for_edge(13, GPIO.FALLING)

   # When pressed, toggle mute
os.system('amixer set Digital toggle')
Code:
#Save as mute.service and place in /etc/systemd/system/
#To enable run 'sudo systemctl enable mute.service' then 'sudo systemctl start mute.service'

[Unit]
Description=Mute
After=mpd.service

[Service]
ExecStart=/home/pi/scripts/mute.py
TimeoutSec=0
Restart=always
RestartSec=1
StartLimitInterval=30
StartLimitBurst=20

[Install]
WantedBy=multi-user.target
Hope this helps

Chris
Reply
#6
Oh, replies! Sorry, I was expecting an email notification that never came! I hadn't lost interest!

Tim: IQaudIO does provide stuff, but because there is already some sort of functionality out of the box, I didn't want to add anything on top without seeking information first.

Chris: I'll use that script, thanks!

Thanks to all who replied!
Reply
#7
@cjward23 I've tried your script, and it complains that this pin is already used.

I come to the conclusion that there is already something in the base Moode install that uses it... But my search, so far, for of grep and such, is not unearthing the culprit!
Reply
#8
@Tim Curtis there is something in Moode using GPIO22/PIN15, because when I try to control it, I get complains that it's being used. Any idea what it is?
Reply
#9
During moOde startup the code below is executed in the script /var/www/command/util.sh

Code:
# unmute IQaudIO Pi-AMP+, Pi-DigiAMP+
if [[ $1 = "unmute-pi-ampplus" || $1 = "unmute-pi-digiampplus" ]]; then
    echo "22" >/sys/class/gpio/export
    echo "out" >/sys/class/gpio/gpio22/direction
    echo "1" >/sys/class/gpio/gpio22/value    
    exit
fi

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#10
I also wanted to get a rotary encoder switch working (ALPS EC12E2424407). The rotary encoder (volume) runs without problems, but I can't get the switch (mute) to work with the above scripts (cjward13) on GPIO 13.
Are the above scripts still up to date?

sudo systemctl status mute gives the following output. for me (linux beginner) it looks ok ....

● mute.service - Mute
Loaded: loaded (/etc/systemd/system/mute.service; disabled; vendor preset: enabled)
Active: active (running) since Wed 2020-04-15 21:01:21 CEST; 3s ago
Main PID: 2966 (python)
Tasks: 1 (limit: 2200)
Memory: 2.2M
CGroup: /system.slice/mute.service
└─2966 python /home/pi/scripts/mute.py

Apr 15 21:01:21 moode systemd[1]: Started Mute.
Reply


Forum Jump: