Hi, I'm working on a car project to create a digital dash that runs on an app called "Realdash" which runs on android. The problem I'm having at the moment is with the power supply. I have a mausberry car switch from my previous project with raspberry pi car system and this worked really well. The mausberry car switch is a simple device which uses two GPIO pins to communicate to raspberry pi and tell it when to softly shut down when power is lost on ignition cable. There are 3 available scripts, for Raspbian/debian for OpenElec and for Arch.

My question is, whether it is possible to make it work on Nanopi M4v2 board. From mausberry car setup there only is one bash script which it uses and the source code for it is here:

If anybody else has any suggestion on how to tell Nanopi to safely shutdown and not turn off immediately after loss of power please advise.
For more info on mausberry circuits: (https://mausberry-circuits.myshopify.co ... ply-switch)

Rapsbian script:

cho '#!/bin/bash

#this is the GPIO pin connected to the lead on switch labeled OUT
GPIOpin1=23

#this is the GPIO pin connected to the lead on switch labeled IN
GPIOpin2=24

#Enter the shutdown delay in minutes
delay=0

echo "$GPIOpin1" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio$GPIOpin1/direction
echo "$GPIOpin2" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio$GPIOpin2/direction
echo "1" > /sys/class/gpio/gpio$GPIOpin2/value
let minute=$delay*60
SD=0
SS=0
SS2=0
while [ 1 = 1 ]; do
power=$(cat /sys/class/gpio/gpio$GPIOpin1/value)
uptime=$(</proc/uptime)
uptime=${uptime%%.*}
current=$uptime
if [ $power = 1 ] && [ $SD = 0 ]
then
SD=1
SS=${uptime%%.*}
fi

if [ $power = 1 ] && [ $SD = 1 ]
then
SS2=${uptime%%.*}
fi

if [ "$((uptime - SS))" -gt "$minute" ] && [ $SD = 1 ] && [ $power = 1 ]
then
poweroff
SD=3
fi

if [ "$((uptime - SS2))" -gt '20' ] && [ $SD = 1 ]
then
SD=0
fi

sleep 1
done' > /etc/switch.sh
sudo chmod 777 /etc/switch.sh
sudo sed -i '$ i /etc/switch.sh &' /etc/rc.local