Add option to control power LED on Pi Zero

This commit is contained in:
Simon Long 2020-09-02 11:47:21 +01:00
parent a750ab8e5b
commit 13d220fa1e
2 changed files with 47 additions and 0 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
raspi-config (20200902) buster; urgency=medium
* Add option to control power LED on Pi Zero
-- Simon Long <simon@raspberrypi.com> Wed, 02 Sep 2020 11:46:19 +0100
raspi-config (20200817) buster; urgency=medium raspi-config (20200817) buster; urgency=medium
* Use processor ID to detect Pi 4 rather than board ID * Use processor ID to detect Pi 4 rather than board ID

View File

@ -1117,6 +1117,45 @@ do_pi4video() {
fi fi
} }
get_leds () {
if grep -q "\\[actpwr\\]" /sys/class/leds/led0/trigger ; then
echo 1
else
echo 0
fi
}
do_leds() {
DEFAULT=--defaultno
CURRENT=0
if [ $(get_leds) -eq 1 ]; then
DEFAULT=
CURRENT=1
fi
if [ "$INTERACTIVE" = True ]; then
whiptail --yesno "Would you like the power LED to flash during disk activity?" $DEFAULT 20 60 2
RET=$?
else
RET=$1
fi
if [ $RET -eq 0 ]; then
LEDSET="actpwr"
STATUS="flash for disk activity"
elif [ $RET -eq 1 ]; then
LEDSET="default-on"
STATUS="be on constantly"
else
return $RET
fi
sed $CONFIG -i -e "s/dtparam=act_led_trigger=.*/dtparam=act_led_trigger=$LEDSET/"
if ! grep -q "dtparam=act_led_trigger" $CONFIG ; then
sed $CONFIG -i -e "\$adtparam=act_led_trigger=$LEDSET"
fi
echo $LEDSET | tee /sys/class/leds/led0/trigger > /dev/null
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "The power LED will $STATUS" 20 60 1
fi
}
do_boot_behaviour() { do_boot_behaviour() {
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
@ -2486,6 +2525,7 @@ do_advanced_menu() {
"A9 Compositor" "Enable/Disable xcompmgr composition manager" \ "A9 Compositor" "Enable/Disable xcompmgr composition manager" \
"AA Pi 4 Video Output" "Video output options for Pi 4" \ "AA Pi 4 Video Output" "Video output options for Pi 4" \
"AB Overlay FS" "Enable/Disable read-only file system" \ "AB Overlay FS" "Enable/Disable read-only file system" \
"AC Power LED" "Set behaviour of power LED on Pi Zero" \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
RET=$? RET=$?
if [ $RET -eq 1 ]; then if [ $RET -eq 1 ]; then
@ -2503,6 +2543,7 @@ do_advanced_menu() {
A9\ *) do_xcompmgr ;; A9\ *) do_xcompmgr ;;
AA\ *) do_pi4video ;; AA\ *) do_pi4video ;;
AB\ *) do_overlayfs ;; AB\ *) do_overlayfs ;;
AC\ *) do_leds ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1 esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi fi