(02-03-2025, 07:23 PM)Tim Curtis Wrote: Yes, when music starts playing the auto-screenblank is cancelled because in the general usage scenario its useful to be able to see whats playing, how much time is left, whats next in the Queue etc. Auto-dimming if it were possible would also need to be cancelled to satisfy this scenario.
Theres a brightness option in Peripheral Config for DSI displays. It should work as long as the display uses the same system parameter for brightness as does the Pi Touch 1 or 2.
Well the brightness option does not work in my case with that Waveshare 7.9" display.
To solve my problem a handy script inserted in /etc/rc.local helped.
Code:
#!/bin/bash
#dim_display.sh - look play status and dim display after 60 Sec. to conserve local display
DELAY=60
TIMER=$DELAY
DIMMED=80
while sleep 1;
do
# check if any input piped in
if IFS= read -d '' -n1 -t 0.01; then
# echo 'Not empty!'
while IFS= read -r -t 0.01;
do
# echo "$REPLY"
if [[ $REPLY == *"RawTouchBegin"* ]]; then
# echo "Touch Event"
# in any case reset timeout and max brightness
TIMER=$DELAY
echo 255 > /sys/class/backlight/10-0045/brightness
fi
done
fi
DIMSTATE=$(cat /sys/class/backlight/10-0045/brightness )
STATUS=$(mpc status)
if [[ $STATUS = *"playing"* ]];
then
# echo "is playing"
if [[ $DIMSTATE -eq 255 ]];
then
# echo "not dimmed"
if [[ $TIMER -gt 0 ]];
then
# echo "decrement timer $TIMER"
TIMER=$((TIMER-1))
else
# echo "dim display"
echo $DIMMED > /sys/class/backlight/10-0045/brightness
fi
fi
else
# echo "not playing"
if (( DIMSTATE < 255 ));
then
# echo "reset dimmed"
TIMER=$DELAY
echo 255 > /sys/class/backlight/10-0045/brightness
fi
fi
done
One needs to install xinput tool
$ sudo apt-get install xinput
In /etc/rc.local insert this command to the end before exit 0
Code:
# this handles display brightness
DISPLAY=:0.0 xinput --test-xi2 --root | /home/moode/dim_display.sh 2>&1 &
So when moode is playing the display dims after 60 seconds. Any touch event will return to max brightness
If moode is not playing then display blanks after time set in peripherial configuration. Again any touch event makes display visible.
This is a little bit clumpsy solution, but works perfectly for me.
Regards
Felix