Skip to content

Commit

Permalink
Helios64 UPS. System shutdown when battery reach 7.0V. (#2599)
Browse files Browse the repository at this point in the history
* Helios64 UPS. System shutdown when battery reach 7.0V.
  • Loading branch information
Evka2k authored Feb 5, 2021
1 parent c83ba33 commit 933a005
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/sources/families/include/rockchip64_common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion packages/bsp/helios64/helios64-ups.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Description=Helios64 UPS Action

[Service]
Type=oneshot
ExecStart=/usr/sbin/poweroff
ExecStart=/usr/bin/helios64-ups.sh
12 changes: 12 additions & 0 deletions packages/bsp/helios64/helios64-ups.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion packages/bsp/helios64/helios64-ups.timer
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 933a005

Please sign in to comment.