Vertex Channel Control Script
GPIO 21, 22, 23, 24, 25
# !/bin/bash
if [ -z $1 ]
then
echo "No channel given (01-16)"
exit 0
fi
# Define RPi2 bits - use gpio readall - wPi pins
BCD1=21
BCD2=22
BCD4=23
BCD8=24
BCD16=25
BCD32=25
case "$1" in
01) echo "Channel 1"
BCD_data1=0
BCD_data2=0
BCD_data4=0
BCD_data8=0
BCD_data32=1
;;
02) echo "Channel 2"
BCD_data1=1
BCD_data2=0
BCD_data4=0
BCD_data8=0
BCD_data32=1
;;
03) echo "Channel 3"
BCD_data1=0
BCD_data2=1
BCD_data4=0
BCD_data8=0
BCD_data32=1
;;
04) echo "Channel 4"
BCD_data1=1
BCD_data2=1
BCD_data4=0
BCD_data8=0
BCD_data32=1
;;
05) echo "Channel 5"
BCD_data1=0
BCD_data2=0
BCD_data4=1
BCD_data8=0
BCD_data32=1
;;
06) echo "channel 6"
BCD_data1=1
BCD_data2=0
BCD_data4=1
BCD_data8=0
BCD_data32=1
;;
07) echo "Channel 7"
BCD_data1=0
BCD_data2=1
BCD_data4=1
BCD_data8=0
BCD_data32=1
;;
08) echo "Channel 8"
BCD_data1=1
BCD_data2=1
BCD_data4=1
BCD_data8=0
BCD_data32=1
;;
09) echo "Channel 9"
BCD_data1=0
BCD_data2=0
BCD_data4=0
BCD_data8=1
BCD_data32=1
;;
10) echo "Channel 10"
BCD_data1=1
BCD_data2=0
BCD_data4=0
BCD_data8=1
BCD_data32=1
;;
11) echo "Channel 11"
BCD_data1=0
BCD_data2=1
BCD_data4=0
BCD_data8=1
BCD_data32=1
;;
12) echo "Channel 12"
BCD_data1=1
BCD_data2=1
BCD_data4=0
BCD_data8=1
BCD_data32=1
;;
13) echo "channel 13"
BCD_data1=0
BCD_data2=0
BCD_data4=1
BCD_data8=1
BCD_data32=1
;;
14) echo "Channel 14"
BCD_data1=1
BCD_data2=0
BCD_data4=1
BCD_data8=1
BCD_data32=1
;;
15) echo "Channel 15"
BCD_data1=0
BCD_data2=1
BCD_data4=1
BCD_data8=1
BCD_data32=1
;;
16) echo "channel 16"
BCD_data1=1
BCD_data2=1
BCD_data4=1
BCD_data8=1
BCD_data32=1
;;
17) echo "low power"
BCD_data32=1
;;
18) echo "high power"
BCD_data32=0
;;
*) echo "Invalid entry $1"
echo "Two digits 01-16 Valid"
exit 1
;;
esac
# Initialize lines
gpio mode $BCD1 out
gpio mode $BCD2 out
gpio mode $BCD4 out
gpio mode $BCD8 out
gpio mode $BCD16 out
sleep .2
#Set Default Low Power Workaround
gpio write $BCD16 0
sleep .5
#End
# Setup BCD lines
gpio write $BCD1 $BCD_data1
gpio write $BCD2 $BCD_data2
gpio write $BCD4 $BCD_data4
gpio write $BCD8 $BCD_data8
sleep .5
#High Power Workaround
gpio write $BCD32 $BCD_data32
#End
echo "Channel $1 written to BCD - $BCD_data16$BCD_data8$BCD_data4$BCD_data2$BCD_data1"
exit 0