(02-22-2022, 10:00 PM)seipersei Wrote:None needed. This takes over the power/ status lights.(02-22-2022, 09:48 PM)Macdelf Wrote:Brilliant, thanks Macdelf I'm going to try this. How do I specify which GPIO/PIN it will need to use for the LED?(02-22-2022, 09:18 PM)Tim Curtis Wrote: If only using MPD then one way to determine play state is via the command below.
Code:# Playing
pi@moode:~ $ mpc status | grep playing
[playing] #50/50 0:10/0:39 (25%)
# Not playing
pi@moode:~ $ mpc status | grep playing
pi@moode:~ $
Here is a python script I use. I started with a display then found headless better. Just start this script in rc.local with
sudo python3 /home/pi/playled.py -d &
Code:import os
import subprocess
import time
#os.system("sudo sh -c 'echo none > /sys/class/leds/led0/trigger'")
#os.system("sudo sh -c 'echo none > /sys/class/leds/led1/trigger'")
while True:
output = subprocess.getoutput(["mpc -w status"])
if "[playing]" in output:
os.system("sudo sh -c 'echo 0 > /sys/class/leds/led0/brightness'")
os.system("sudo sh -c 'echo 1 > /sys/class/leds/led1/brightness'")
# print("Playing")
os.system("mpc -q -w idle")
else:
if "[paused]" in output:
os.system("sudo sh -c 'echo 0 > /sys/class/leds/led1/brightness'")
os.system("sudo sh -c 'echo 1 > /sys/class/leds/led0/brightness'")
# print("paused")
os.system("mpc -q -w idle")
else:
os.system("sudo sh -c 'echo 0 > /sys/class/leds/led1/brightness'")
os.system("sudo sh -c 'echo 0 > /sys/class/leds/led0/brightness'")
# print("stopped")
os.system("mpc -q -w idle")
Red is playing
Green is paused
No light is stopped, that also means Moode has booted.
As you probably guessed just insert the code into a file called playled.py in your home directory then edit rc.local in the /etc/ one to add the python 3 command.