Created
July 26, 2015 12:09
-
-
Save HAPI-Tech-Solution/d3f85d53347e266c02ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#gpio 20,21 pullup mode set. | |
`gpio -g mode 20 up` | |
`gpio -g mode 21 down` | |
`gpio -g mode 26 down` | |
`gpio -g mode 16 down` | |
`gpio -g mode 19 out` | |
`gpio -g write 19 1` | |
countA=0 | |
countB=0 | |
#LCD initialize | |
`i2cset -y 1 0x3c 0 1 2 0xf 1 i` | |
PBX=`gpio -g read 20` | |
PBKey=`gpio -g read 21` | |
#check people count file | |
if [ -e /home/pi/count.txt ];then | |
count_people=`cat /home/pi/count.txt|tail -1` | |
else | |
`echo 0 >> /home/pi/count.txt` | |
count_people=`cat /home/pi/count.txt|tail -1` | |
fi | |
while : | |
#Line 1 set | |
`i2cset -y 1 0x3c 0 0x80 i` | |
# "ボクハイツデモOKダヨ!" | |
`i2cset -y 1 0x3c 0x40 0xce 0xde 0xb8 0xca 0xb2 0xc2 0xc3 0xde 0xd3 0x4f 0x4b 0xc0 0xde 0xd6 0x21 i` | |
#Line 2 set | |
`i2cset -y 1 0x3c 0 0xa0 i` | |
#ゼヒオシテイッテネ(ハァト | |
`i2cset -y 1 0x3c 0x40 0xbe 0xde 0xcb 0xb5 0xbc 0xc3 0xb2 0xaf 0xc3 0xc8 0x28 0xca 0xa7 0xc4 i` | |
do | |
#read current PB eneble | |
while [ 0 -eq "${PBX}" -o 1 -eq "${PBkey}" ] | |
do | |
PBX=`gpio -g read 20` | |
PBKey=`gpio -g read 21` | |
done | |
#wait PB | |
while : | |
do | |
PBX=`gpio -g read 20` | |
PBKey=`gpio -g read 21` | |
PBToglle=`gpio -g read 26` | |
PBShoot=`gpio -g read 16` | |
if [ 1 -eq "${PBToglle}" ];then | |
`gpio -g write 19 0` | |
else | |
`gpio -g write 19 1` | |
fi | |
#PB enable | |
if [ 0 -eq "${PBX}" ];then | |
#LCD double line set | |
`i2cset -y 1 0x3c 0 0x2c 0x01 i` | |
for i in 1 2 3 | |
do | |
#ドーン! | |
`i2cset -y 1 0x3c 0x40 0xc4 0xde 0xb0 0xdd 0x21 i` | |
done | |
break | |
i=0 | |
fi | |
if [ 1 -eq "${PBKey}" -a 0 -eq "${PBToglle}" -a 0 -eq "${PBShoot}" ];then | |
if [ 0 -eq "${countA}" ];then | |
#Line1 Read to the | |
`i2cset -y 1 0x3c 0 0x28 0x01 i` | |
`i2cset -y 1 0x3c 0x40 0x52 0x65 0x61 0x64 0x79 0x20 0x74 0x6f 0x20 0x74 0x68 0x65 0x20 i` | |
#Line2 ARMED standby | |
`i2cset -y 1 0x3c 0 0xa0 i` | |
`i2cset -y 1 0x3c 0x40 0x41 0x52 0x4d 0x45 0x44 0x20 0x73 0x74 0x61 0x6e 0x64 0x62 0x79 i` | |
countA=$((countA + 1)) | |
fi | |
fi | |
if [ 1 -eq "${PBKey}" -a 1 -eq "${PBToglle}" -a 0 -eq "${PBShoot}" ];then | |
if [ 0 -eq "${countB}" ];then | |
#Line1 Check SYSTEM Now | |
`i2cset -y 1 0x3c 0 0x28 0x02 i` | |
`i2cset -y 1 0x3c 0x40 0x43 0x68 0x65 0x63 0x6b 0x20 0x53 0x59 0x53 0x54 0x45 0x4d 0x20 0x4e 0x6f 0x77 i` | |
#Line2 ARMED standby | |
`i2cset -y 1 0x3c 0 0xa0 i` | |
`i2cset -y 1 0x3c 0x40 0x53 0x79 0x73 0x74 0x65 0x6d 0x20 0x41 0x6c 0x6c 0x20 0x47 0x72 0x65 0x65 0x6e i` | |
sleep 2 | |
`i2cset -y 1 0x3c 0 0x2c 0x01 i` | |
`i2cset -y 1 0x3c 0x40 0x54 0x41 0x52 0x47 0x45 0x54 0x20 0x63 0x6c 0x65 0x61 0x72 0x20 0x4c 0x6f 0x63 i` | |
countB=$((countB + 1)) | |
fi | |
fi | |
if [ 1 -eq "${PBKey}" -a 1 -eq "${PBToglle}" -a 1 -eq "${PBShoot}" ];then | |
`i2cset -y 1 0x3c 0 0x2c 0x01 i` | |
`i2cset -y 1 0x3c 0x40 0x53 0x68 0x6f 0x6f 0x74 0x21 0x53 0x68 0x6f 0x6f 0x74 0x21 i` | |
count_people=$((count_people + 1)) | |
`echo "${count_people}" >> /home/pi/count.txt` | |
`mpg123 /home/pi/bomb.mp3 &` | |
countA=0 | |
countB=0 | |
break | |
fi | |
done | |
#Following Twitter OAuth | |
getdate=`date +"%Y%m%d"|cut -b3-` | |
UNIX_T=`date -u +%s` | |
#Initialize | |
i=0 | |
#API applicaton keys | |
Consumerkey=大人の事情で検閲され(ry | |
consumerSecret=大人の事情で検閲され(ry | |
tokenSecret=大人の事情で検閲され(ry | |
Accesstoken=大人の事情で検閲され(ry | |
#make the oauth_nonce_code. | |
while [ 10 -gt ${i} ]; | |
do | |
i=$((i + 1)) | |
codemake=`echo $RANDOM $RANDOM $RANDOM $RANDOM|sed -e 's/ //g'` | |
oauth_nonce_code=${codemake}${oauth_nonce_code} | |
done | |
oauth_nonce_code=`echo ${oauth_nonce_code}|cut "-b-32"` | |
#Create OAuth signature | |
oauth_signature_id_base=`echo -n "POST&https%3A%2F%2Fapi.twitter.com%2F1.1%2Fstatuses%2Fupdate.json&oauth_consumer_key%3D${Consumerkey}%26oauth_nonce%3D${oauth_nonce_code}%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D${UNIX_T}%26oauth_token%3D${Accesstoken}%26oauth_version%3D1.0%26status%3D%25E3%2582%2588%25E3%2581%2586%25E3%2581%2593%25E3%2581%259D%25E2%2599%25AA%25E7%25A7%2581%25E9%2581%2594%25E3%2581%25AE%25E3%2583%2596%25E3%2583%25BC%25E3%2582%25B9%25E3%2581%25B8%25E3%2580%2582%250D%250A%25E7%25B7%258A%25E6%2580%25A5%25E5%2581%259C%25E6%25AD%25A2%25E3%2583%259C%25E3%2582%25BF%25E3%2583%25B3%25E7%2599%25BA%25E5%258B%2595%25E3%2581%2597%25E3%2581%25BE%25E3%2581%2599%25E3%2581%259F%25EF%25BC%2581%250D%250A%25E3%2581%25A9%25E3%2581%25A3%25E3%2581%258B%25E3%2583%25BC%25E3%2583%25BC%25E3%2583%25BC%25E3%2583%25BC%25E3%2583%25BC%25E3%2583%25BC%25E3%2582%2593%25EF%25BC%2581%250D%250A${count_people}%25E4%25BA%25BA%25E7%259B%25AE%25E3%2581%25A7%25E3%2581%2599%250D%250A%2523nttokyo"|openssl dgst -sha1 -binary -hmac "${consumerSecret}&${tokenSecret}"|base64|perl -MURI::Escape -lne 'print uri_escape($_)'` | |
##post to tweet | |
curl --request 'POST' 'https://api.twitter.com/1.1/statuses/update.json' --data "status=%E3%82%88%E3%81%86%E3%81%93%E3%81%9D%E2%99%AA%E7%A7%81%E9%81%94%E3%81%AE%E3%83%96%E3%83%BC%E3%82%B9%E3%81%B8%E3%80%82%0D%0A%E7%B7%8A%E6%80%A5%E5%81%9C%E6%AD%A2%E3%83%9C%E3%82%BF%E3%83%B3%E7%99%BA%E5%8B%95%E3%81%97%E3%81%BE%E3%81%99%E3%81%9F%EF%BC%81%0D%0A%E3%81%A9%E3%81%A3%E3%81%8B%E3%83%BC%E3%83%BC%E3%83%BC%E3%83%BC%E3%83%BC%E3%83%BC%E3%82%93%EF%BC%81%0D%0A${count_people}%E4%BA%BA%E7%9B%AE%E3%81%A7%E3%81%99%0D%0A%23nttokyo" --header "Authorization: OAuth oauth_consumer_key="""${Consumerkey}""", oauth_nonce="""${oauth_nonce_code}""", oauth_signature="""${oauth_signature_id_base}""", oauth_signature_method="HMAC-SHA1", oauth_timestamp="""${UNIX_T}""", oauth_token="""${Accesstoken}""", oauth_version="1.0"" --verbose | |
sleep 1 | |
##LCD set clear and line1 | |
`i2cset -y 1 0x3c 0 0x28 0x01 i` | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment