Last active
December 28, 2016 01:36
-
-
Save balkian/f375e47338f554523e6380954cba0d87 to your computer and use it in GitHub Desktop.
Simple script to control octoprint
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
begin | |
button = KEY_5 | |
prog = irexec | |
config = /home/balkian/octo.sh home | |
repeat = 0 | |
delay = 3 | |
end | |
begin | |
button = KEY_1 | |
prog = irexec | |
config = /home/balkian/octo.sh move -10 10 0 | |
repeat = 0 | |
delay = 3 | |
end | |
begin | |
button = KEY_2 | |
prog = irexec | |
config = /home/balkian/octo.sh move 0 10 0 | |
repeat = 0 | |
delay = 3 | |
end | |
begin | |
button = KEY_3 | |
prog = irexec | |
config = /home/balkian/octo.sh move 10 10 0 | |
repeat = 0 | |
delay = 3 | |
end | |
begin | |
button = KEY_4 | |
prog = irexec | |
config = /home/balkian/octo.sh move -10 0 0 | |
repeat = 0 | |
delay = 3 | |
end | |
begin | |
button = KEY_6 | |
prog = irexec | |
config = /home/balkian/octo.sh move 10 0 0 | |
repeat = 0 | |
delay = 3 | |
end | |
begin | |
button = KEY_7 | |
prog = irexec | |
config = /home/balkian/octo.sh move -10 -10 0 | |
repeat = 0 | |
delay = 3 | |
end | |
begin | |
button = KEY_8 | |
prog = irexec | |
config = /home/balkian/octo.sh move 0 -10 0 | |
repeat = 0 | |
delay = 3 | |
end | |
begin | |
button = KEY_9 | |
prog = irexec | |
config = /home/balkian/octo.sh move 10 -10 0 | |
repeat = 0 | |
delay = 3 | |
end |
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 | |
echo $(date) - "$@" >> /tmp/octo-log | |
CONF_FILE=$HOME/.octo.conf | |
if [ ! -f "$CONF_FILE" ]; | |
then | |
echo OCTO_API_KEY=$(OctoPrint/venv/bin/octoprint config get api.key | tr -d "'") > $CONF_FILE | |
echo OCTO_PORT=$(OctoPrint/venv/bin/octoprint config get server.port | tr -d "'") >> $CONF_FILE | |
echo OCTO_HOST=$(OctoPrint/venv/bin/octoprint config get server.host | tr -d "'") >> $CONF_FILE | |
echo 'Retrieved API key' | |
fi | |
source $CONF_FILE | |
function send_octo() { | |
curl -H "X-Api-Key: $OCTO_API_KEY" -H 'Content-Type: application/json' --data "$1" http://$OCTO_HOST:$OCTO_PORT/api/printer/printhead | |
} | |
case $1 in | |
move) | |
shift | |
x=$1 | |
y=$2 | |
z=$3 | |
echo $1 $2 $3 | |
send_octo '{"command": "jog","x": '$x',"y": '$y',"z": '$z'}' http://localhost:5000/api/printer/printhead | |
sleep 2 | |
;; | |
home) | |
send_octo '{ "command": "home", "axes": ["x", "y", "z"] }' | |
;; | |
nothing) | |
echo "nothing $(date)" >> /tmp/prueba | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment