Automatically writing screen brightness to disk
#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


Messages In This Thread
RE: Automatically writing screen brightness to disk - by Bedwyr - 04-29-2019, 03:36 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)