Helios64 UPS. System shutdown when battery reach 7.0V. (#2599)
* Helios64 UPS. System shutdown when battery reach 7.0V.
This commit is contained in:
parent
c83ba333a3
commit
933a00515b
@ -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
|
||||
|
||||
|
||||
@ -3,4 +3,4 @@ Description=Helios64 UPS Action
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/sbin/poweroff
|
||||
ExecStart=/usr/bin/helios64-ups.sh
|
||||
|
||||
12
packages/bsp/helios64/helios64-ups.sh
Executable file
12
packages/bsp/helios64/helios64-ups.sh
Executable 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
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user