public
Created

bash script with TTS for announcing wire colors touched via Makey Makey device

  • Download Gist
makeymakey.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
#!/bin/bash
 
while :
do
 
 
_key()
{
local kp
ESC=$'\e'
_KEY=
read -d '' -sn1 _KEY
case $_KEY in
"$ESC")
while read -d '' -sn1 -t1 kp
do
_KEY=$_KEY$kp
case $kp in
[a-zA-NP-Z~]) break;;
esac
done
;;
esac
printf -v "${1:-_KEY}" "%s" "$_KEY"
}
 
_key x
 
case $x in
$'\e[11~' | $'\e[OP') key=F1 ;;
$'\e[12~' | $'\e[OQ') key=F2 ;;
$'\e[13~' | $'\e[OR') key=F3 ;;
$'\e[14~' | $'\e[OS') key=F4 ;;
$'\e[15~') key=F5 ;;
$'\e[16~') key=F6 ;;
$'\e[17~') key=F7 ;;
$'\e[18~') key=F8 ;;
$'\e[19~') key=F9 ;;
$'\e[20~') key=F10 ;;
$'\e[21~') key=F11 ;;
$'\e[22~') key=F12 ;;
$'\e[A' ) key=UP
say "you touched the red wire" ;;
$'\e[B' ) key=DOWN
say "you touched the blue wire" ;;
$'\e[C' ) key=RIGHT
say "you touched the yellow wire" ;;
$'\e[D' ) key=LEFT
say "you touched the green wire" ;;
?) key=$x ;;
*) key=??? ;;
esac
 
echo "You have pressed $key"
 
 
done

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.