Moode Forum
[SOLVED] GPIO Config - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: [SOLVED] GPIO Config (/showthread.php?tid=1669)



GPIO Config - owagott - 08-26-2019

Hi There,

I want to assign several functions to one button.
http://192.168.178.46/gpio-config.php

It doesn't work with

mpc stop && mpc clear && mpc load Favorites && mpc play
or
mpc stop && mpc clear && mpc load 'Default Playlist' && mpc play


salute


RE: GPIO Config - Tim Curtis - 08-26-2019

Multiple commands need to be in an executable script.

Example:

cd ~
sudo nano ./test_script.sh

test_script.sh
Code:
#!/bin/bash
mpc stop && mpc clear && mpc load Favorites && mpc play

sudo chmod +x ./test_script.sh

Then specify the full path to the script as the CMD in GPIO Config.

/home/pi/test_script.sh


RE: GPIO Config - owagott - 08-31-2019

Thanks for this Tip.

nano ./button.sh
chmod +x ./button.sh


http://192.168.178.46/gpio-config.php

/home/pi/button.sh 1
/home/pi/button.sh 2
/home/pi/button.sh 3
/home/pi/button.sh 9

Code:
#!/bin/bash

if [ $# -lt 1 ]
then
       echo "Usage : $0 buttonnumber"
       exit
fi

case "$1" in

1)
   mpc stop
   mpc clear
   mpc load 'Default Playlist'
   mpc play

   ;;
2)
   mpc stop
   mpc clear
   mpc load musik
   mpc play

   ;;
3)  
   mpc stop
   mpc clear
   mpc load Favorites
   mpc play

   ;;
9)
  mpc random
  mpc next
  mpc random
  ;;
*) echo "Signal number $1 is not processed"
  ;;
esac



RE: GPIO Config - Tim Curtis - 08-31-2019

Nice :-)