Helios64 UPS. System shutdown when battery reach 7.0V. (#2599)

* Helios64 UPS. System shutdown when battery reach 7.0V.
This commit is contained in:
Evka2k 2021-02-05 12:27:15 +02:00 committed by GitHub
parent c83ba333a3
commit 933a00515b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 2 deletions

View File

@ -410,6 +410,7 @@ family_tweaks_bsp()
# UPS service
cp $SRC/packages/bsp/helios64/helios64-ups.service $destination/lib/systemd/system/
cp $SRC/packages/bsp/helios64/helios64-ups.timer $destination/lib/systemd/system/
install -m 755 $SRC/packages/bsp/helios64/helios64-ups.sh $destination/usr/bin/helios64-ups.sh
fi

View File

@ -3,4 +3,4 @@ Description=Helios64 UPS Action
[Service]
Type=oneshot
ExecStart=/usr/sbin/poweroff
ExecStart=/usr/bin/helios64-ups.sh

View File

@ -0,0 +1,12 @@
#!/bin/sh
#7.0V 916 Recommended threshold to force shutdown system
TH=916
val=$(cat '/sys/bus/iio/devices/iio:device0/in_voltage2_raw')
sca=$(cat '/sys/bus/iio/devices/iio:device0/in_voltage_scale')
adc=$(echo "$val * $sca / 1" | bc)
if [ "$adc" -le $TH ]; then
/usr/sbin/poweroff
fi

View File

@ -2,8 +2,9 @@
Description=Helios64 UPS Shutdown timer on power loss
[Timer]
OnActiveSec=10m
OnActiveSec=20
AccuracySec=1s
OnUnitActiveSec=10
[Install]
WantedBy=timers.target