#!/bin/bash # ENER314 interface script by TDGalea. # galeatd@gmail.com # tdgalea.co.uk # GPIO pins D0="/sys/class/gpio/gpio17/value" D1="/sys/class/gpio/gpio22/value" D2="/sys/class/gpio/gpio23/value" D3="/sys/class/gpio/gpio27/value" mod="/sys/class/gpio/gpio25/value" if [ "$2" = "" ];then echo "Usage:" echo " $0 [socket-id] [state]" echo "e.g. to turn socket 2 ON, issue the following command:" echo "$0 2 1" exit 9 fi # Socket identification. case ${1,,} in 0) (echo "1">$D0;echo "1">$D1;echo "0">$D2);; all) (echo "1">$D0;echo "1">$D1;echo "0">$D2);; 1) (echo "1">$D0;echo "1">$D1;echo "1">$D2);; a) (echo "1">$D0;echo "1">$D1;echo "1">$D2);; 2) (echo "0">$D0;echo "1">$D1;echo "1">$D2);; b) (echo "0">$D0;echo "1">$D1;echo "1">$D2);; 3) (echo "1">$D0;echo "0">$D1;echo "1">$D2);; c) (echo "1">$D0;echo "0">$D1;echo "1">$D2);; 4) (echo "0">$D0;echo "0">$D1;echo "1">$D2);; d) (echo "0">$D0;echo "0">$D1;echo "1">$D2);; esac # State identification. case ${2,,} in 0) echo "0">$D3;; f) echo "0">$D3;; false) echo "0">$D3;; off) echo "0">$D3;; 1) echo "1">$D3;; t) echo "1">$D3;; true) echo "1">$D3;; on) echo "1">$D3;; esac # Wait for encoder to catch up. sleep 0.1 # Pulse modulator. echo "1">$mod;sleep 0.1;echo "0">$mod # Restore all pins. echo "0">$D0 echo "0">$D1 echo "0">$D2 echo "0">$D3 # End exit 0