2020-01-24 02:44:17 +00:00
|
|
|
#!/bin/sh
|
2019-12-11 21:11:53 +00:00
|
|
|
|
2023-08-04 14:16:20 +00:00
|
|
|
OFFSET=448
|
2023-08-02 20:36:25 +00:00
|
|
|
|
|
|
|
GPIO40=$((40 + $OFFSET))
|
|
|
|
GPIO41=$((41 + $OFFSET))
|
|
|
|
|
2020-01-24 02:44:17 +00:00
|
|
|
setup() {
|
|
|
|
echo "${1}" > /sys/class/gpio/export 2>/dev/null
|
|
|
|
echo in > "/sys/class/gpio/gpio${1}/direction" 2>/dev/null
|
2019-12-11 21:11:53 +00:00
|
|
|
}
|
|
|
|
|
2020-01-24 02:44:17 +00:00
|
|
|
check_gpio() {
|
|
|
|
if [ ! -d "/sys/class/gpio/gpio${1}" ]; then
|
|
|
|
setup "${1}"
|
2019-12-11 21:11:53 +00:00
|
|
|
fi
|
2020-01-24 02:44:17 +00:00
|
|
|
state=$(cat "/sys/class/gpio/gpio${1}/value")
|
|
|
|
echo "${state}"
|
2019-12-11 21:11:53 +00:00
|
|
|
}
|
|
|
|
|
2023-08-02 20:36:25 +00:00
|
|
|
gpio40=$(check_gpio $GPIO40)
|
|
|
|
gpio41=$(check_gpio $GPIO41)
|
2019-12-11 21:11:53 +00:00
|
|
|
|
2020-01-24 02:44:17 +00:00
|
|
|
if [ "${gpio40}" -eq "0" ] && [ "${gpio41}" -eq "0" ]; then
|
2019-12-11 21:11:53 +00:00
|
|
|
echo "discharging"
|
2020-01-24 02:44:17 +00:00
|
|
|
elif [ "${gpio40}" -eq "0" ]; then
|
2019-12-11 21:11:53 +00:00
|
|
|
echo "full"
|
2020-01-24 02:44:17 +00:00
|
|
|
elif [ "${gpio41}" -eq "0" ]; then
|
2019-12-11 21:11:53 +00:00
|
|
|
echo "charging"
|
|
|
|
fi
|