Thank you for your donation!


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


Behaviour of push button Mute on GPIO22
#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


Messages In This Thread
RE: Behaviour of push button Mute on GPIO22 - by cjward23 - 05-26-2018, 07:37 AM

Forum Jump: