[Voyage-linux] About GPIO support
Stéphane Acounis
(spam-protected)
Thu Feb 10 21:47:13 HKT 2011
Le Thu, 10 Feb 2011 08:21:21 -0500
Jon Meek <meekjt at gmail.com> a écrit:
> Stéphane - When you implement the power off button please post the
> details!
>
Ohhhh very simple, it works quite well. I have an Alix 3D2 board and
the switch is located near the USB connector (S1 written on the PCB).
Just solder two wires and connect them to a normally opened push button.
I have wrote a simple bash script (power-button):
------------------------------------------------------------------------------
#!/bin/bash
while true; do
button=`od -x /dev/cs5535_gpio24 | cut -c 11-12 | head -1`
if [ $button == "30" ]; then
sleep 3
button=`od -x /dev/cs5535_gpio24 | cut -c 11-12 | head -1`
if [ $button == "30" ]; then
beep -f 1000 -r 2 -n -r 5 -l 10 --new
/sbin/poweroff
else
exit
fi
fi
sleep 1
done
------------------------------------------------------------------------------
and installed a line in the root's crontab:
@reboot /data/Scripts/power-button
Then pressing more than 3 seconds on the switch will do a clean halt of
the board.
If someone has a better and more efficient way to monitor the switch, please share.
--
Stéphane ACOUNIS
SUBATECH Nantes - Service d'Électronique
Tél: 02-51-85-84-28 06-64-62-99-20
«Faut pas se laisser abattre» devise Kennedy
More information about the Voyage-linux
mailing list