Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some more gpiomon/gpiod changes #13051

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions package/batocera/utils/rpigpioswitch/rpi_gpioswitch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,16 @@ function onoffshim_start()


# This is Button command (GPIO17 default)
echo $1 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio$1/direction

power=$(cat /sys/class/gpio/gpio$1/value)
power=$(gpioget 0 $1)
echo $$ > /tmp/powerswitch.pid
[ $power -eq 0 ] && switchtype=1 #Sliding Switch
[ $power -eq 1 ] && switchtype=0 #Momentary push button

until [ $power -eq $switchtype ]; do
power=$(cat /sys/class/gpio/gpio$1/value)
sleep 1
done
gpiomon --num-events=1 -s 0 $1
sleep 0.1
power=$(gpioget 0 $1)
done

# Switch off
if [ "$?" = "0" ]; then
Expand All @@ -217,8 +216,9 @@ function onoffshim_start()

function onoffshim_stop()
{
# Cleanup GPIO init, default Button command (GPIO 17)
echo "$1" > /sys/class/gpio/unexport
# Cleanup script and gpiomon processes
pid=$(cat /tmp/powerswitch.pid)
kill $(pgrep -P $pid) $pid &> /dev/null
}

function onoffshim_config()
Expand Down Expand Up @@ -372,6 +372,7 @@ function retroflag_start()
echo "# Overlay setup for proper powercut, needed for Retroflag cases" >> "/boot/config.txt"
echo "dtoverlay=RetroFlag_pw_io.dtbo" >> "/boot/config.txt"
fi

[ $CONF -eq 1 ] && return
#------ CONFIG SECTION ------

Expand Down