Merge pull request #3 from Lapikud/projector-http-controls

Add NEC projector http controls
pull/6/head
Arti Zirk 5 years ago committed by GitHub
commit 19f1315535
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      README.md
  2. 167
      projektor/control.sh
  3. 7
      projektor/hotkey_commands.txt

@ -24,6 +24,8 @@ ln -s $CLONE/nginx/default /etc/nginx/default
ln -s $CLONE/projektor /opt/projektor ln -s $CLONE/projektor /opt/projektor
apt install python3-serial python3-bottle apt install python3-serial python3-bottle
``` ```
Optionally, set keyboard hotkeys from projektor/hotkey_commands.txt
# #
#### web #### web
``` ```
@ -51,4 +53,4 @@ systemctl start websockify.service
# #
Now, essential code seems to be symlinked and `git pull` keeps everything up-to-date.. Now, essential code seems to be symlinked and `git pull` keeps everything up-to-date..
And as always, this readme is under destruction :) And as always, this readme is under destruction :)

@ -0,0 +1,167 @@
#!/bin/bash
PROJECTOR_HOSTNAME='projektor'
display_help()
{
echo "Usage: $0 [option...] <command> <setting> [<parameter>]" >&2
echo
echo " -h, --help Show this message"
echo " -f, --force"
echo
echo "Commands:"
echo " get <setting>"
echo " set <setting> <on|off>"
echo " switch <setting>"
echo
echo "Settings:"
echo " power"
echo " mute"
echo " freeze"
echo
echo "Examples:"
echo " get mute"
echo " set freeze on"
echo " switch power"
exit 1
}
send_request()
{
D=""
for a in $@
do
D="$D%$a"
done
URL="http://$PROJECTOR_HOSTNAME/cgi-bin/pjctrl.cgi.elf?D=$D"
echo $(curl -s $URL | sed 's/\[//; s/\]//' | xargs -d ',')
}
get_power()
{
STATUS=(`send_request 06 00 85 00 00 01 01 87`)
echo ${STATUS[7]}
}
set_power()
{
if [[ $1 -eq 1 ]];
then
STATUS=`send_request 05 02 00 00 00 00`
else
STATUS=`send_request 05 02 01 00 00 00`
fi
}
switch_power()
{
STATUS=`get_power`
if [[ $STATUS -eq 1 ]];
then
STATUS=`set_power 0`
else
STATUS=`set_power 1`
fi
}
get_mute()
{
STATUS=(`send_request 06 00 85 00 00 01 03 89`)
echo ${STATUS[5]}
}
set_mute()
{
if [[ $1 -eq 1 ]];
then
STATUS=`send_request 05 02 10 00 00 00 13`
else
STATUS=`send_request 05 02 11 00 00 00 13`
fi
}
switch_mute()
{
STATUS=`get_mute`
if [[ $STATUS -eq 1 ]];
then
STATUS=`set_mute 0`
else
STATUS=`set_mute 1`
fi
}
get_freeze()
{
STATUS=(`send_request 06 00 BF 00 00 01 02 C2`)
echo ${STATUS[14]}
}
set_freeze()
{
if [[ $1 -eq 1 ]];
then
STATUS=`send_request 06 01 98 00 00 01 01 00`
else
STATUS=`send_request 06 01 98 00 00 01 02 00`
fi
}
switch_freeze()
{
STATUS=`get_freeze`
if [[ $STATUS -eq 1 ]];
then
STATUS=`set_freeze 0`
else
STATUS=`set_freeze 1`
fi
}
# options
while :
do
case "$1" in
-h | --help)
display_help
exit 0
;;
-f | --force)
echo "Nothing to force, man"
shift
;;
--)
shift
break
;;
-*)
display_help
exit 1
;;
*)
break
;;
esac
done
# commands
case "$1" in
get | set | switch)
FNAME="$1_$2"
if [[ `type -t $FNAME` == '' ]]
then
echo "Invalid parameter for $1"
display_help
exit 1
fi
OPT=`sed 's/on/1/; s/off/0/' <<< $3`
$FNAME $OPT
;;
*)
echo 'Invalid command'
display_help
exit 1
;;
esac

@ -1,3 +1,4 @@
# Receiver volume
curl -X POST -F 'mode=volumedown' http://viido/projektor/status curl -X POST -F 'mode=volumedown' http://viido/projektor/status
curl -X POST -F 'mode=volumeup' http://viido/projektor/status curl -X POST -F 'mode=volumeup' http://viido/projektor/status
@ -6,3 +7,9 @@ curl -X POST -F 'mode=viido' http://viido/projektor/status
curl -X POST -F 'mode=steam' http://viido/projektor/status curl -X POST -F 'mode=steam' http://viido/projektor/status
curl -X POST -F 'mode=hdmi' http://viido/projektor/status curl -X POST -F 'mode=hdmi' http://viido/projektor/status
curl -X POST -F 'mode=aux' http://viido/projektor/status curl -X POST -F 'mode=aux' http://viido/projektor/status
# Projector states
/opt/projektor/control.sh switch power
/opt/projektor/control.sh switch mute
/opt/projektor/control.sh switch freeze
Loading…
Cancel
Save