Hi,
many thanks.
Based on your indication, i've done my things and all work very well.
I want to share with you my project so if you do a thought you can implement directly in new version.
I'done this on raspberry pi 2:
Installed fbi with sudo apt-get install fbi
Have create a script called E_STOP.sh and background.sh and an image file estop.jpg.
E_STOP.sh:
#! /bin/sh
#
# SCHEMATIC
#
# (->|-) = Diodo 1N4007 o 1N4148
# (NC E-STOP) = Contatto NC pulsante di emergenza
#
# GPIO4-----(->|-)------ CHx FAN
# GPIO27----(->|-)------ CHx FAN
#
# 3V3-----------(NC E-STOP)-------GPIO17
#
NAME="Test"
SLUG="Test"
KEY="14e7bf36-7537-46ad-a92b-08c43c81e82a"
TARGET=30 #Temperatura di innesco della FAN
sudo echo "4" > /sys/class/gpio/export #GPIO4 FAN OR-1
sudo echo "17" > /sys/class/gpio/export #GPIO17 INPUT E-STOP
sudo echo "27" > /sys/class/gpio/export #GPIO27 FAN OR-2
sudo echo "out" > /sys/class/gpio/gpio4/direction
sudo echo "in" > /sys/class/gpio/gpio17/direction
sudo echo "out" > /sys/class/gpio/gpio27/direction
sudo echo "0" > /sys/class/gpio/gpio27/value
while :
do
STATUS=$(cat /sys/class/gpio/gpio17/value)
if [ $STATUS = "0" ]; then
# ESTOP PRESSED
sudo wget -O /tmp/estop.log "http://localhost:3344/printer/api/"$NAME"?a=emergencyStop&apikey="$KEY""</div><div> sleep 1
sudo rm -r /tmp/estop.log
sudo wget -O /tmp/estop.log "http://localhost:3344/printer/api/"$NAME"?a=deactivate&apikey="$KEY"&data=%7B%22printer%22%3A%22"$SLUG"%22%7D"</div><div> sleep 1
sudo rm -r /tmp/estop.log
sudo echo "1" > /sys/class/gpio/gpio27/value
sudo fbi -T 1 /home/pi/Desktop/estop.jpg
while :
do
STATUS=$(cat /sys/class/gpio/gpio17/value)
if [ $STATUS = "1" ]; then
break
else
sleep 2
sudo pkill -f fbi
sleep 2
sudo fbi -T 1 /home/pi/Desktop/estop.jpg
fi
done
#ESTOP RELEASED
sudo wget -O /tmp/estop.log "http://localhost:3344/printer/api/"$NAME"?a=activate&apikey="$KEY"&data=%7B%22printer%22%3A%22"$SLUG"%22%7D"</div><div> sudo echo "0" > /sys/class/gpio/gpio27/value
sudo pkill -f fbi
else
#READ TEMPERATURE
sudo wget -O /tmp/temp.log "http://localhost:3344/printer/api/"$NAME"?a=stateList&apikey="$KEY"&data=%7BincludeHistory%3Afalse%7D"</div><div> TEMP=$(cat /tmp/temp.log | jq '.Test.extruder[0].tempRead')
VAL=$(printf '%d\n' "$TEMP")
if test $VAL -ge $TARGET
then
sudo echo "1" > /sys/class/gpio/gpio4/value
else
sudo echo "0" > /sys/class/gpio/gpio4/value
fi
sudo rm -r /tmp/temp.log
sleep 1
fi
done
#------------------------------
background.sh:
#! /bin/sh
sudo nohup /home/pi/Desktop/E_STOP.sh &
sleep 5
and put all in /home/pi/Desktop directory
after have moved background.sh into /etc/init.d directory
have assigned -x permission to all script
end have registered background.sh to start at boot with:
sudo
update-rc.d background.sh defaults
and finally reboot system
Now the fan to cool the hothend is directly controlled by GPIO4 according the temperature.
If i press emergency button, script send a reset, and deactivate printer , activate hothend fan and blink every 2 seconds the image on display.
If i restore the emergency button the image stop blink and the printer is reactivated.