implemented random color fading for main light in e-lab

This commit is contained in:
root 2017-03-13 23:18:15 +00:00
parent 4e0c608ba5
commit 1f7761d53c
1 changed files with 32 additions and 7 deletions

View File

@ -21,7 +21,7 @@ STATE_2="n\x00\x02\x01\x00|!;\
n\x00\x02\x01\x00|FFCC11;\
000000000000000000"
STATE_3="!/usr/bin/python3 /home/automation/fensterbogenbeleuchtung_animations/animations.py|!;\
a\x00\x03\xff\xff\xff|FFCC11;\
a\x00\x03\xff\xff\xff|!;\
000000000000000000"
get_room_color_string() {
@ -81,16 +81,41 @@ case "$ROOM_NUMBER" in
fi
;;
2)
find "$(dirname "$TMPFILE_PID_BASE")" -name "$(basename "${TMPFILE_PID_BASE}_2_*")" -exec sh -c 'cat {} | xargs kill; rm -f {}' \;
# COLOR_A="$(echo "$STATE" | cut -d";" -f2 | cut -d"|" -f1)"
COLOR_B="$(echo "$STATE" | cut -d";" -f2 | cut -d"|" -f2)"
# echo -en "$COLOR_A" > /dev/udp/172.23.92.18/49152 &
COLOR_B_TMP=$COLOR_B
for i in 5 4 3; do
wget -q -O- http://172.23.92.5/ecmd?channel%20$i%20$(printf "%d" "0x${COLOR_B_TMP:0:2}") > /dev/null 2>&1 &
COLOR_B_TMP="$(echo "$COLOR_B_TMP" | cut -c3-)"
done
# if [ "${COLOR_B:0:1}" == "!" ]; then
#
# else
# echo -en "$COLOR_A" > /dev/udp/172.23.92.18/49152 &
# fi
if [ "${COLOR_B:0:1}" == "!" ]; then
(
R=$(( RANDOM % 256 )); G=$(( RANDOM % 256 )); B=$(( RANDOM % 256 ))
while true; do
R_=$(( RANDOM % 256 )); G_=$(( RANDOM % 256 )); B_=$(( RANDOM % 256 ))
while [ $R -ne $R_ -o $G -ne $G_ -o $B -ne $B_ ]; do
DR=$(sign $(($R_-$R))); DG=$(sign $(($G_-$G))); DB=$(sign $(($B_-$B)))
R=$(($R+$DR)); G=$((G+$DG)); B=$(($B+$DB))
for i in 5:$R 4:$G 3:$B; do
wget -q -O- http://172.23.92.5/ecmd?channel%20$(echo $i | cut -d: -f1)%20$(echo $i | cut -d: -f2) > /dev/null 2>&1 &
COLOR_B_TMP="$(echo "$COLOR_B_TMP" | cut -c3-)"
done
sleep .1
done
done
) &
echo $! > ${TMPFILE_PID_BASE}_2_B
else
COLOR_B_TMP=$COLOR_B
for i in 5 4 3; do
wget -q -O- http://172.23.92.5/ecmd?channel%20$i%20$(printf "%d" "0x${COLOR_B_TMP:0:2}") > /dev/null 2>&1 &
COLOR_B_TMP="$(echo "$COLOR_B_TMP" | cut -c3-)"
done
fi
;;
3)
# find "$(dirname "$TMPFILE_PID_BASE")" -name "$(basename "${TMPFILE_PID_BASE}_3_*")" -exec sh -c 'cat {} | xargs kill; rm -f {}' \;
# COLOR_A="$(echo "$STATE" | cut -d";" -f3 | cut -d"|" -f1)"
# COLOR_B="$(echo "$STATE" | cut -d";" -f3 | cut -d"|" -f2)"
# echo -en "$COLOR_A" > /dev/null