Pleng
Well-Known Member
- Joined
- Dec 28, 2006
- Messages
- 3,030
Generally when the lid is closed on my Pandora I want to be saving as much energy as possible downclocking to 125Mhz and setting OPP to 2 would make sense. However some times I might want to close the lid and still be able to play music - something which current audio players would struggle to achieve at 125.
With this problem in mind I have created an updated op_lid.sh file which does the following if the screen goes down:
IF the CPU is set to a frequency of OVER 250, is is scaled down to 125Mhz/OPP2
IF the CPU is set to 250Mhz or less, nothing happens
When the lid is raised the original setting is restored (if it has been changed in the fist place).
This gives a nice little system where in every day use, the CPU will be downclocked when the lid is closed. If I want to over rule this, all I have to do is set the CPU to 250 (or less) before closing the lid and things will carry away as normal.
You can get the script [url="http://www.strappysolutions.com/demos/pandora/op_lid.sh"]here[/url], and the code is here:
You need to save the file to /usr/pandora/scripts, overwriting the file that's currently in place. Once you've done that you may need to do a sudo chmod 777 ./op_lid.sh to make sure it's runnable (hard to say I edited and saved mine as SU). You'll soon know if you've done it wrong as suddenly your screen will stop going off when you close the lid.
With this problem in mind I have created an updated op_lid.sh file which does the following if the screen goes down:
IF the CPU is set to a frequency of OVER 250, is is scaled down to 125Mhz/OPP2
IF the CPU is set to 250Mhz or less, nothing happens
When the lid is raised the original setting is restored (if it has been changed in the fist place).
This gives a nice little system where in every day use, the CPU will be downclocked when the lid is closed. If I want to over rule this, all I have to do is set the CPU to 250 (or less) before closing the lid and things will carry away as normal.
You can get the script [url="http://www.strappysolutions.com/demos/pandora/op_lid.sh"]here[/url], and the code is here:
Code:
#!/bin/bash
#actions done when the lid is closed
#only argument is 0 for open 1 for closed
#may also be called after inactivity, like X DPMS
if [ ! -e /tmp/powerstate ]; then #do nothing when in powersave mode
if [ "$1" = "1" ]; then #lid was closed
brightness=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness)
if [ $brightness -gt 0 ]; then
echo $brightness > /tmp/oldbright
fi
echo 0 > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness
echo 1 > /sys/devices/platform/omapfb/graphics/fb0/blank
#PLENG - If CPU Speed is
#greater than 250 then 'sleep'
PLCSPEED=`cat /proc/pandora/cpu_mhz_max`
PLOPP=`cat /proc/pandora/cpu_opp_max`
if [ "$PLCSPEED" -gt 250 ]; then
echo $PLCSPEED > /tmp/.OLDSPEED
echo $PLOPP > /tmp/.OLDOPP
echo 125 > /proc/pandora/cpu_mhz_max
echo 2 > /proc/pandora/cpu_opp_max
fi
elif [ "$1" = "0" ]; then # lid was opened
echo 0 > /sys/devices/platform/omapfb/graphics/fb0/blank
sleep 0.1s # looks cleaner, could flicker without
maxbright=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/max_brightness)
oldbright=0
if [ -f /tmp/oldbright ]; then
oldbright=$(cat /tmp/oldbright)
fi
if [ $oldbright -eq 0 ]; then
oldbright=$(cat /etc/pandora/conf/brightness.state)
fi
if [ $oldbright -ge 3 ] && [ $oldbright -le $maxbright ]; then
/usr/pandora/scripts/op_bright.sh $oldbright
else
/usr/pandora/scripts/op_bright.sh $maxbright
fi
#PLENG if we've been to sleep then
#restore old CPU values
if [ -e "/tmp/.OLDSPEED" ]; then
cat /tmp/.OLDOPP > /proc/pandora/cpu_opp_max
cat /tmp/.OLDSPEED > /proc/pandora/cpu_mhz_max
rm /tmp/.OLDOPP
rm /tmp/.OLDSPEED
fi
fi
fi
You need to save the file to /usr/pandora/scripts, overwriting the file that's currently in place. Once you've done that you may need to do a sudo chmod 777 ./op_lid.sh to make sure it's runnable (hard to say I edited and saved mine as SU). You'll soon know if you've done it wrong as suddenly your screen will stop going off when you close the lid.