Merge pull request #1767 from brooksytech/dev

RG351P battery led status
This commit is contained in:
Brooksytech 2023-07-19 20:04:25 -07:00 committed by GitHub
commit 731e8ce27d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 0 deletions

View file

@ -11,6 +11,9 @@ DEVICE_PLAYBACK_PATH_HP="HP"
DEVICE_FUNC_KEYA_MODIFIER="BTN_SELECT"
DEVICE_FUNC_KEYB_MODIFIER="BTN_START"
DEVICE_BRIGHTNESS="128"
DEVICE_BATTERY_LED_STATUS=true
DEVICE_PWR_LED_GPIO="77"
DEVICE_TEMP_SENSOR="/sys/devices/virtual/thermal/thermal_zone0/temp"
UI_SERVICE="weston.service"
# FREQ governors

View file

@ -26,6 +26,7 @@ export SLOW_CORES \
DEVICE_KEY_VOLUMEUP \
DEVICE_LED_CONTROL \
DEVICE_PWR_LED_CONTROL \
DEVICE_PWR_LED_GPIO \
DEVICE_PLAYBACK_PATH_HP \
DEVICE_PLAYBACK_PATH_SPK \
DEVICE_POWER_LED \

View file

@ -0,0 +1,64 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2020-present Fewtarius
# Simple script to watch the battery capacity and
# turn the power LED orange when it reaches 30%, red at 20%, and blinking red & orange at 10%
. /etc/profile
# Set export GPIO for Power LED
if [ ! -d "/sys/class/gpio/gpio${DEVICE_PWR_LED_GPIO}" ]; then
echo ${DEVICE_PWR_LED_GPIO} > /sys/class/gpio/export
fi
function set_led() {
case $1 in
red)
echo out >/sys/class/gpio/gpio${DEVICE_PWR_LED_GPIO}/direction
echo 1 >/sys/class/gpio/gpio${DEVICE_PWR_LED_GPIO}/value
;;
green)
echo out >/sys/class/gpio/gpio${DEVICE_PWR_LED_GPIO}/direction
echo 0 >/sys/class/gpio/gpio${DEVICE_PWR_LED_GPIO}/value
;;
orange)
echo in >/sys/class/gpio/gpio${DEVICE_PWR_LED_GPIO}/direction
;;
esac
}
while true
do
CAP=$(cat /sys/class/power_supply/battery/capacity)
STAT=$(cat /sys/class/power_supply/battery/status)
if [[ ${STAT} == "Discharging" ]]
then
#if (( ${CAP} <= 50 ))
#then
# for ctr in $(seq 1 1 5)
# do
# set_led orange
# sleep .5
# set_led red
# sleep .5
# done
# continue
#elif (( ${CAP} <= 20 ))
if (( ${CAP} <= 20 ))
then
set_led red
elif (( ${CAP} <= 30 ))
then
set_led orange
else
set_led green
fi
elif (( ${CAP} >= 95 ))
then
set_led green
fi
sleep 15
done