Moode Forum
[SOLVED] 9.1.5 & Pi Touch 1: Wrong (max) brightness when waking from screen blanking - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: [SOLVED] 9.1.5 & Pi Touch 1: Wrong (max) brightness when waking from screen blanking (/showthread.php?tid=7201)

Pages: 1 2


9.1.5 & Pi Touch 1: Wrong (max) brightness when waking from screen blanking - jenzd - 12-15-2024

Hi all,

I use a Pi 3 B in combination with the official touch display (Pi Touch 1). After I recently switched from version 8.3.9 to the current version 9.1.5, I noticed a new issue/bug with respect  to brightness after screen blanking:

I usually set the screen brightness to a reduced value of "63" (which is correctly restored when the Pi boots up). When the display returns from screen blanking after some minutes of inactivity, however, it always turns on at maximum brightness.

Additional settings: Screen blank is set to "10 Mins", Wake on play is turned on.

Thanks & best regards
Jens


RE: 9.1.5 & Pi Touch 1: Wrong (max) brightness when waking from screen blanking - Tim Curtis - 12-15-2024

Odd.

AFAIK return from screen blanking is handled by the Xserver subsystem. The screen brightness for the Touch1 is handled by a couple of things.

# config.txt - the overlay creates /sys/class/backlight/rpi_backlight/
dtoverlay=rpi-backlight

# set brightness
/bin/su -c "echo BRIGHTNESS_VALUE > /sys/class/backlight/rpi_backlight/brightness"

Whats the value of /rpi_backlight/brightness after returning from screen blank?


RE: 9.1.5 & Pi Touch 1: Wrong (max) brightness when waking from screen blanking - jenzd - 12-15-2024

Hi Tim,

Thanks for looking into this.

/rpi_backlight/brightness stays at "63" for the whole time, i.e. before, during and after the screen blank.

Issuing "echo 63 > /sys/class/backlight/rpi_backlight/brightness" after returning from screen blank reduces the brightness of the display again, though.

Best regards
Jens


RE: 9.1.5 & Pi Touch 1: Wrong (max) brightness when waking from screen blanking - Tim Curtis - 12-15-2024

(12-15-2024, 12:33 PM)jenzd Wrote: Hi Tim,

Thanks for looking into this.

/rpi_backlight/brightness stays at "63" for the whole time, i.e. before, during and after the screen blank.

Issuing "echo 63 > /sys/class/backlight/rpi_backlight/brightness" after returning from screen blank reduces the brightness of the display again, though.

Best regards
Jens

The challenge is how to detect a return from screen blank.


RE: 9.1.5 & Pi Touch 1: Wrong (max) brightness when waking from screen blanking - jenzd - 12-15-2024

By the way, has anybody else noticed the similar behaviour on his setup? I am probably not the only one using the (old) official 7 inch display. And as screen blank is activated ("10 Mins") by default, it should in principle happen to anybody who chooses to reduce screen brigthness.


RE: 9.1.5 & Pi Touch 1: Wrong (max) brightness when waking from screen blanking - jenzd - 12-15-2024

I think I have a rough idea what the issue might be:
When I look into "/sys/class/backlight", there are acutally two subdirectories/configurations here:

The first one is "rpi_backlight/" where "brightness" is set to 63.
The second one is "10-0045/" where "brightness" is set to 255.

Interestingly the "echo xx > brightness" command works in both subdirectories and changes screen brightness to the respective value.

The setting in "10-0045/" is the one the screen returns to after screen blank.


RE: 9.1.5 & Pi Touch 1: Wrong (max) brightness when waking from screen blanking - Tim Curtis - 12-15-2024

(12-15-2024, 01:25 PM)jenzd Wrote: I think I have a rough idea what the issue might be:
When I look into "/sys/class/backlight", there are acutally two subdirectories/configurations here:

The first one is "rpi_backlight/" where "brightness" is set to 63.
The second one is "10-0045/" where "brightness" is set to 255.

Interestingly the "echo xx > brightness" command works in both subdirectories and changes screen brightness to the respective value.

The setting in "10-0045/" is the one the screen returns to after screen blank.

Thats interesting.

Here's the function that handles screen brightness. When I last tested, the Touch1 needed rpi_backlight/brightness and the Touch2 needed *-0045/brightness which I assumed were exclusive to each.

Code:
function updDSIScnBrightness($screenType, $brightnessValue) {
    if ($screenType == '1') {
        sysCmd('/bin/su -c "echo '. $brightnessValue . ' > /sys/class/backlight/rpi_backlight/brightness"');
    } else {
        sysCmd('/bin/su -c "echo '. $brightnessValue . ' > /sys/class/backlight/*-0045/brightness"');
    }
}

I'll test updating both for the Touch1 and if that works I'll include it in upcoming 920 and the in-place update.


RE: 9.1.5 & Pi Touch 1: Wrong (max) brightness when waking from screen blanking - jenzd - 12-15-2024

(12-15-2024, 02:51 PM)Tim Curtis Wrote: I'll test updating both for the Touch1 and if that works I'll include it in upcoming 920 and the in-place update.

Cool, thanks! Smile


RE: 9.1.5 & Pi Touch 1: Wrong (max) brightness when waking from screen blanking - Tim Curtis - 12-16-2024

Here's the commit if you want to add the line and test on your end.
https://github.com/moode-player/moode/commit/d77ff32d45ecf5d9f828262b42019104ba1aba17


RE: 9.1.5 & Pi Touch 1: Wrong (max) brightness when waking from screen blanking - jenzd - 12-17-2024

Hi Tim,

while the patch works on my end, the proper solution might even be simpler: I noticed (by accident) that "dtoverlay=rpi-backlight" in the config.txt no longer seems to be necessary for the Pi Touch 1 at all. When I change that to "#dtoverlay=rpi-backlight", the display still works and consistently sets brightness to the value stored in "10-0045/" (and keeps it after screen blank). In this configuration, there is no extra folder "rpi_backlight/" anymore.

So my suggestion would be to remove "dtoverlay=rpi-backlight" and write just to "10-0045/brightness". Or would that cause any other known issues?

By the way, I wouldn't have tried this if there wasn't a little bug in the backup restore procedure: At one point during my tests I used a backup (created in 9.1.5) to restore my settings. Afterwards I noticed that the "rpi_backlight/" folder was gone and the rpi-backlight line was commented out in config.txt (while using the "Pi Touch 1" setting should have left this in).

Side note: During the following tests, I also noticed two (minor) additional issues in the backup restore procedure which are, however, totally independent of the backlight issue:
  • Audio output was set to an external USB audio interface (device 0) before restoring. This is also the setting which I can see in the backup file "moodecfg.ini". The restore procedure set the audio output to HDMI (device 1) instead.
  • The setting "Preference => Library => random album" seems to be missing in the backup file and is therefore not restored.
Best regards,
Jens