Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Automatically writing screen brightness to disk
#1
I'd like the screen brightness slider function from Retropie to stick through power downs and power ups. I don't have or really have to have automated ambient sensing using some photocell or similar. It would just be a nice quality-of-life addition to the unit. Is that possible?
Reply
#2
Hello, I use a old image and I had trouble to recover the good brightness too.
New image should be able to work the right way, BTW here is my workaround:
- Check if '/home/pi/Freeplay/setPCA9633/fpbrightness.val' exist.
- If it does, edit '/etc/rc.local' and add before 'python /home/pi/Freeplay/Freeplay-Support/shutdown_daemon.py' line :

Code:
/home/pi/Freeplay/setPCA9633/setPCA9633 --verbosity=0 --i2cbus=1 --address=0x62 --mode1=0x01 --mode2=0x15 --led0=PWM --pwm0=0x$(printf "%x\n" $(cat /home/pi/Freeplay/setPCA9633/fpbrightness.val)) > /dev/null

- Then restart.
Hope this will help Smile
Reply
#3
It did work, thanks. If I understand the command right, the RPI interface writes brightness settings to fpbrightness.val and you're just pulling that on boot to the pulsewidth modulator? (I don't work with displays very often, but mildly curious)
Reply
#4
I am passing the value from 'fpbrightness.val' to 'setPCA9633' pwm0 argument.
Freeplay motherboards use PCA9633 to control backlight, 'setPCA9633' is a program to control it.
Reply
#5
Thanks.
Reply
#6
I'm sorry. I was out of town for the past 10 days or so.

As a followup on this, could you post the output from these commands, Bedwyr?

cat /boot/freeplaycfg.txt
cat /home/pi/Freeplay/setPCA9633/setFreeplayBacklight.sh
cat /etc/rc.local

I want to see if I can figure out what has caused this to happen in the first place. Maybe you just had an older SD image file, but I'd like to see.
Card Fighters' Clash 2 English Translation ( http://cfc2english.blogspot.com/ )
Neo Geo Pocket Flash Cart and Linker Project ( http://www.flashmasta.com/ )
Avatar art thanks to Trev-Mun ( http://trevmun.deviantart.com/ )
Reply
#7
(04-23-2019, 04:12 AM)Flavor Wrote: I'm sorry. I was out of town for the past 10 days or so.

As a followup on this, could you post the output from these commands, Bedwyr?

cat /boot/freeplaycfg.txt
cat /home/pi/Freeplay/setPCA9633/setFreeplayBacklight.sh
cat /etc/rc.local

I want to see if I can figure out what has caused this to happen in the first place. Maybe you just had an older SD image file, but I'd like to see.

I'll try to remember that when I get home.
Reply
#8
Delayed, but here you go. This is with Porcinus's suggested changes.


Code:
#FREEPLAYSTARTUP=RUNPY            #start up running a python script
#FREEPLAYSTARTUP=RUNCMD           #start up running a specific command (bash script, exe, etc)
#FREEPLAYSTARTUP=CMDLINE          #start up to a shell command prompt
FREEPLAYSTARTUP=EMULATIONSTATION

STARTUPPY=/boot/fpstartup.py      #used if FREEPLAYSTARTUP=RUNPY
STARTUPCMD="jstest /dev/input/js0"  #used if FREEPLAYSTARTUP=RUNCMD (untested)/home/pi/Freeplay/setPCA9633/setFreeplayBacklight.sh > /dev/null

Code:
#!/bin/bash
var1="$1"

if [ -z "$var1" ]; then
 fileval=`cat /home/pi/Freeplay/setPCA9633/fpbrightness.val`
 if [ -z "$fileval" ]; then
   var1="ON"
 else
   var1=$( printf "%x" $fileval )
 fi
 #echo "$var1"
fi

if [ "$var1" == "ON" ] || [ "$var1" == "on" ] || [ "$var1" == "255" ]; then
   /home/pi/Freeplay/setPCA9633/setPCA9633 -y 1 -a 0x62 -d ON -w WAKE -i YES -l ON
   /home/pi/Freeplay/setPCA9633/setPCA9633 -y 1 -a 0x62 -w SLEEP
elif [ "$var1" == "OFF" ] || [ "$var1" == "off" ] || [ "$var1" == "0" ]; then
   /home/pi/Freeplay/setPCA9633/setPCA9633 -y 1 -a 0x62 -d ON -w WAKE -i YES -l OFF
   /home/pi/Freeplay/setPCA9633/setPCA9633 -y 1 -a 0x62 -w SLEEP
else
   /home/pi/Freeplay/setPCA9633/setPCA9633 -y 1 -a 0x62 -d ON -w WAKE -i YES -l PWM -p "$var1"
fi

Code:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
 printf "My IP address is %s\n" "$_IP"
fi

/home/pi/Freeplay/setPCA9633/setPCA9633 --verbosity=0 --i2cbus=1 --address=0x62 --mode1=0x01 --mode2=0x15 --led0=PWM --pwm0=0x$(printf "%x\n" $(cat /home/pi/Freeplay/setPCA9633/fpbrightness.val)) > /dev/null

python /home/pi/Freeplay/Freeplay-Support/shutdown_daemon.py &

exit 0
Reply
#9
(04-29-2019, 03:36 AM)Bedwyr Wrote: Delayed, but here you go. This is with Porcinus's suggested changes.
Thanks! I guess I can see that it's now running using Porcinus' fix, but I can't tell why it was missing the original line that sets the brightness. I guess I'll make sure it's fixed for people in the upcoming SD image.
Card Fighters' Clash 2 English Translation ( http://cfc2english.blogspot.com/ )
Neo Geo Pocket Flash Cart and Linker Project ( http://www.flashmasta.com/ )
Avatar art thanks to Trev-Mun ( http://trevmun.deviantart.com/ )
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)