-
Notifications
You must be signed in to change notification settings - Fork 1
/
filament.sh
41 lines (29 loc) · 872 Bytes
/
filament.sh
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
#!/bin/sh
MYDIR=`basename $(pwd)`
NAMENDATEI=Filament_config.sh
. /home/pi/filament_runout_Repetier/$MYDIR/$NAMENDATEI
gpio mode $pin up
gpio mode $pin in
while true
do
result="$( gpio read $pin )"
if [ "$result" = "$sensor" ]; then
echo "Filament rounout"
curl -k "http://$ip:$port/printer/api/$printer?apikey=$apikey&a=send&data=%7B%22cmd%22%3A%22%40pause%20Filament%20runout%22%7D%0A%0A%40pause%20Filament%20Rounout"
while true
do
result="$( gpio read $pin )"
if [ "$result" = "$sensor" ]; then
curl -k "http://$ip:$port/printer/api/$printer?apikey=$apikey&a=send&data=%7B%22cmd%22%3A%22M117%20Filament%20runout%22%7D"
fi
sleep 1
if [ "$result" != "$sensor" ]; then
echo "Filament inserted"
curl -k "http://$ip:$port/printer/api/$printer?apikey=$apikey&a=send&data=%7B%22cmd%22%3A%22M117%20Filament%20inserted%22%7D"
break
fi
sleep 1
done
fi
sleep 0.5
done