Skip to content

Commit

Permalink
Fix battery watchdog to prevent turning off LEDs when the battery is …
Browse files Browse the repository at this point in the history
…full.
  • Loading branch information
fewtarius committed Sep 17, 2024
1 parent 612f753 commit 7087726
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion PKGBUILD/steamfork-device-support/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Maintainer: Fewtarius

pkgname=steamfork-device-support
pkgver=2024.09.06
pkgver=2024.09.17
pkgrel=1
pkgdesc='Hardware support provider for PC handhelds.'
arch=('any')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ then
fi

BATCNT=0
FLASHDELAY=20
FLASHDELAY=2
LED_PATH="/sys/class/leds/multicolor:chassis"

unset CURRENT_MODE
Expand All @@ -31,19 +31,37 @@ case $(get_setting system.loglevel) in
esac

function set_rgb() {
$DEBUG && log ${0} "multi_intensity: ${1} brightness: ${2}"
$DEBUG && log ${0} "set_rgb: multi_intensity: ${1} brightness: ${2}"
echo "${1}" >${LED_PATH}/multi_intensity
echo "${2}" >${LED_PATH}/brightness
}

function get_intensity() {
LED_INTENSITY=$(cat ${LED_PATH}/multi_intensity)
$DEBUG && log ${0} "get_intensity: multi_intensity: ${LED_INTENSITY}"
echo ${LED_INTENSITY}
}

function get_brightness() {
LED_BRIGHTNESS=$(cat ${LED_PATH}/brightness)
$DEBUG && log ${0} "get_brightness: brightness: ${LED_BRIGHTNESS}"
echo ${LED_BRIGHTNESS}
}

function led_flash() {
local INTENSITY=$(get_intensity)
local BRIGHTNESS=$(get_brightness)

set_rgb "0 0 0" "0"
sleep .5
for i in $(seq 1 1 3)
do
set_rgb "255 0 0" "255"
sleep .5
set_rgb "0 0 0" "0"
sleep .5
done
set_rgb "${INTENSITY}" "${BRIGHTNESS}"
}

while true
Expand All @@ -54,7 +72,7 @@ do
if (( "${BATCNT}" >= "${FLASHDELAY}" )) &&
[[ "${AC_STATUS}" =~ Disch ]]
then
if (( ${BATLEFT} < "20" ))
if (( ${BATLEFT} <= "20" ))
then
led_flash
FLASHDELAY=${BATLEFT}
Expand All @@ -65,7 +83,7 @@ do
if [[ "${AC_STATUS}" =~ ^Charg ]]
then
# Reset the LED as if the battery was full.
set_rgb "0 0 0" "0"
set_rgb "${LED_INTENSITY}" "${LED_BRIGHTNESS}"
fi
fi
BATCNT=$(( ${BATCNT} + 1 ))
Expand Down

0 comments on commit 7087726

Please sign in to comment.