implemented lounge color control

This commit is contained in:
root 2017-02-24 21:07:48 +00:00
parent 8043247fe3
commit 02ac4c9bdc
2 changed files with 27 additions and 22 deletions

View File

@ -3,8 +3,7 @@
COMMAND_FILE=/tmp/command
lounge_light() {
COLOR=$1
echo "not implemented" #FIXME
./light.sh $1
}
lounge_light_toggle() {
@ -23,7 +22,7 @@ while true; do
lounge_light_toggle
;;
lounge_light*)
lounge_light "$(echo "$COMMAND " | cut -d" " -f2 | grep -oe "[a-z]\?[0-9a-fA-F]*" | head -n1)"
lounge_light "$(echo "$line " | cut -d" " -f2 | grep -oe "[a-z]\?[0-9a-fA-F]*" | head -n1)"
;;
*)
echo "ERROR; available commands:" >&2

View File

@ -5,6 +5,7 @@ touch $TMPFILE
LIGHT_STATE=$(cat $TMPFILE)
[ -z "$LIGHT_STATE" ] && LIGHT_STATE=0
if [ -z "$1" ]; then
STATE_0="a\x00\x03\x00\x00\x00;000000000000000000"
STATE_1="a\x00\x03\xff\xff\xff;255255255255255255"
STATE_2="n\x00\x02\x01\x00;170000070150000050"
@ -25,6 +26,11 @@ case $LIGHT_STATE in
LIGHT_STATE=0
;;
esac
else
COLOR_A="$(echo $1 | sed "s/\(..\)\(..\)\(..\)/\\\x\2\\\x\1\\\x\3/g")"
COLOR_B="$(echo $1 | while read -N2 code; do printf "%03d" $((16#$code)); done)"
STATE="a\x00\x03$COLOR_A;$COLOR_B$COLOR_B"
fi
for i in {1..5}; do
echo -en "$(echo "$STATE" | cut -d";" -f1)" > /dev/udp/172.23.92.15/49152 &