10-24-2020, 12:05 AM
(This post was last modified: 10-24-2020, 01:53 PM by Turril0x.
Edit Reason: Typos and bad explanations
)
Hi!
I want to output a signal through a GPIO pin while sound is being outputed, to trigger the PhoneMute cable of my radio, as I'm keeping it, and I also listen to the AM radio sometimes...
Basically, I want it to work as a handsfree system, so when audio is outputted from the Raspi (wether it is a call, GPS indication...), the radio gets muted and I can hear the call or whatever.
The CMDON and CMDOFF just turn a GPIO on or off.
Anyone has an idea of how I can solve this?
I want to output a signal through a GPIO pin while sound is being outputed, to trigger the PhoneMute cable of my radio, as I'm keeping it, and I also listen to the AM radio sometimes...
Basically, I want it to work as a handsfree system, so when audio is outputted from the Raspi (wether it is a call, GPS indication...), the radio gets muted and I can hear the call or whatever.
#!/bin/bash
DIR='/proc/asound/card2/pcm0p/sub0/status'
CMDON='python /home/pi/audioOutput/ledOn.py'
CMDOFF='python /home/pi/audioOutput/ledOff.py'
content=''
while true
do
new_content=`cat $DIR`
if [[ "$content" != "$new_content" ]]; then
content=$new_content
$CMDON
else
$CMDOFF
fi
sleep 0.25
done
I had this solution for raw Raspbian, but with OA, as pulseaudio is always running, the status file is never freed.The CMDON and CMDOFF just turn a GPIO on or off.
Anyone has an idea of how I can solve this?