Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmuELEC 4.0 on OGA: Brightness is not saved across reboots #470

Closed
miwasp opened this issue Feb 15, 2021 · 13 comments
Closed

EmuELEC 4.0 on OGA: Brightness is not saved across reboots #470

miwasp opened this issue Feb 15, 2021 · 13 comments
Labels
bug Something isn't working fix_in_comments A fix has been posted in the comments fixed_in_dev

Comments

@miwasp
Copy link

miwasp commented Feb 15, 2021

Describe the bug
No matter what value is set for brightness, it is reset to something different after reboot

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Main menu' (F6)
  2. Click on 'System settings'
  3. Set brightness to e.g. 81%
  4. Reboot
  5. Brightness is set back to 31% (in my case)

Expected behavior
Brightness should be saved across reboots

EmuELEC version:

  • Version 4.0

Device

  • Odroid Go Advance Black Edition
@shantigilbert
Copy link
Collaborator

If you set brightness via the hotkey, does it also happen ?

@miwasp
Copy link
Author

miwasp commented Feb 15, 2021

In short: Yes

If i change brightness via hotkey, this change can be seen in the system settings. So it makes no difference if you change brightness via hotkey or menu.
The current value is correctly saved in emuelec.conf, but for some reason another value is set after reboot or even after standby.

@shantigilbert shantigilbert added the bug Something isn't working label Feb 15, 2021
@shantigilbert
Copy link
Collaborator

Ok thanks, I will look into it.

@miwasp
Copy link
Author

miwasp commented Feb 16, 2021

The problem is the different range of "brightness.level" in emuelec.conf (0..100) and "/sys/class/backlight/backlight/brightness" (0..255).

This works so far for me on my OGA, no idea if it works for other devices:

> $ diff /storage/.config/emuelec/scripts/odroidgoa_utils.sh.org /storage/.config/emuelec/scripts/odroidgoa_utils.sh
63,65c63,66
< STEPS="20"
< CURRENTBRIGHT=$(cat /sys/class/backlight/backlight/brightness)
< MAXBRIGHT="255" #$(cat /sys/class/backlight/backlight/max_brightness)
<---
\> STEPS="5"
\> CURBRIGHT=$(cat /sys/class/backlight/backlight/brightness)
\> CURRENTBRIGHT=$(($CURBRIGHT*100/255))
\> MAXBRIGHT="100"
77,78c78,80
< 	echo "${STEPBRIGHT}" > /sys/class/backlight/backlight/brightness
< 	set_ee_setting "brightness.level" $(cat /sys/class/backlight/backlight/brightness)
<---
\> 	NEWVAL=$(($STEPBRIGHT*255/100))
\> 	echo "${NEWVAL}" > /sys/class/backlight/backlight/brightness
\> 	set_ee_setting "brightness.level" $STEPBRIGHT

@shantigilbert
Copy link
Collaborator

Thank you, I will test it out

@shantigilbert
Copy link
Collaborator

shantigilbert commented Feb 17, 2021

I don't understand this part

 	NEWVAL=$(($STEPBRIGHT*255/100))
 	echo "${NEWVAL}" > /sys/class/backlight/backlight/brightness
 	set_ee_setting "brightness.level" $STEPBRIGHT

you set one value to the /sys/class, but another to the .conf file? and this works?

@shantigilbert
Copy link
Collaborator

Ok I guess it does, since the value gets converted directly. Thanks for the fix I will push it

@shantigilbert shantigilbert added fix_in_comments A fix has been posted in the comments fixed_in_dev labels Feb 17, 2021
@miwasp
Copy link
Author

miwasp commented Feb 17, 2021

This works on my OGA.
Today i got my OGS. On OGS i can change the value with the hotkeys and i can see the change in the menu. I can even go to standby and switch it on again and still have the correct value of brightness. But if i restart the OGS, brightness is always 50 and i don‘t know where this is set.

@shantigilbert
Copy link
Collaborator

its set here

set_ee_setting "brightness.level" $STEPBRIGHT

and its saved on /emuelec/configs/emuelec.conf

@shantigilbert shantigilbert removed fix_in_comments A fix has been posted in the comments fixed_in_dev labels Feb 17, 2021
@miwasp
Copy link
Author

miwasp commented Feb 17, 2021

max_brightness on OGA is 255 and i mistakenly assumed it is 255 on all devices.
But max_brightness on OGS is 160!
This works for both OGA and OGS:

if [ "${1}" == "bright" ]; then
STEPS="5"
CURBRIGHT=$(cat /sys/class/backlight/backlight/brightness)
MAXSYSBRIGHT=$(cat /sys/class/backlight/backlight/max_brightness)
CURRENTBRIGHT=$(($CURBRIGHT*100/$MAXSYSBRIGHT))
MAXBRIGHT="100"
MINBRIGHT="2"
        if [ "${2}" == "+" ]; then
                STEPBRIGHT=$(($CURRENTBRIGHT+$STEPS))
        elif [ "${2}" == "-" ]; then
                STEPBRIGHT=$(($CURRENTBRIGHT-$STEPS))
        else
                STEPBRIGHT=${2}
        fi
        [ "$STEPBRIGHT" -ge "$MAXBRIGHT" ] && STEPBRIGHT="$MAXBRIGHT"
        [ "$STEPBRIGHT" -le "$MINBRIGHT" ] && STEPBRIGHT="$MINBRIGHT"
        #echo "Setting bright to $STEPBRIGHT"
        NEWVAL=$(($STEPBRIGHT*$MAXSYSBRIGHT/100))
        echo "${NEWVAL}" > /sys/class/backlight/backlight/brightness
        set_ee_setting "brightness.level" $STEPBRIGHT
fi

@shantigilbert
Copy link
Collaborator

Thank you!

@shantigilbert
Copy link
Collaborator

If you wish you can open a PR, or I can push the fix, let me know.

@miwasp
Copy link
Author

miwasp commented Feb 17, 2021

Please push the fix...

@shantigilbert shantigilbert added fix_in_comments A fix has been posted in the comments fixed_in_dev labels Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix_in_comments A fix has been posted in the comments fixed_in_dev
Projects
None yet
Development

No branches or pull requests

2 participants