OpenCPN-low-energy/screen-management

Jump to: navigation, search

Screen management

The energy consumed by the screen have a strong impact on the consumption, you might have noticed that if you have a laptop and a small capacity battery.

Screen brightness

Start up

A start up we run this script. It forces all graphic cards and acpi support to modify the brightness to 50 %. This method can be used on any configuration (if you have at least a folder in /sys/class/backlight/), the script changes the brightness regardless of the controler type (acpi or graphic card).

Troubleshooting

Executing the script only when the distribution boot won't reduce the screen brightness. In deed when you login the graphical interface, the screen brightness rise to 95 %. To face this, we had to run our script after the login but, this implies to touch files the user doesn't have permission to modify.

We found the following solution :

  • Detect the way adapted to the computer
  • Apply permissions to write files in /sys/class/backlight/*/brightness for users
  • Run our script whenever a LXDE session starts

The algorithm to change the permissions of the brightness configuration files :

for FILE in $(/bin/ls -d1 /sys/class/backlight/*/brightness); do
    if [ $? -eq 0 ]; then
		chown root:users $FILE
		chmod g+w $FILE
	fi
done

We use the /etc/xdg/lxsession/LXDE/autostart file to run our brightness modification script at each LXDE session start.

Measures of the low brightness

The following measures have been taken on the 0.1.6 version of our distribution :

Comparison screen brightness.png

This chart shows well the energy required by the screen. We can do save 1 Watt by reducing by half the screen brightness. We could reduce much more this parameter, but keep in mind that the sea can be sunny and you might not be able so see the screen anymore if we reduce the screen brightness much more !

You can find the chart here and the raw data here.

Changing the brightness in a user session

Changing the screen brightness isn't challenging. To detect how you can change it, do the following :

If you are lucky, the "Functions Keys" of your laptop will be mapped and you will be able to change easily the brightness. If the keys works for you, skip the rest of the paragraph.

You will need to use the terminal emulator to execute this, lxterminal is installed by default. # and $ at the start at commands means that you have to run this command respectively as root (privileged user) or as a regular user. If you have the version 0.1.8 or higher of our distribution, you won't need root permissions to modify the brightness configuration files in /sys/class/backlight/*/brightness.

Let's start with this output :

$ xbacklight
100.000000

If you get a value as a result for this command, you can change your screen brightness by executing $ xbacklight -set 40, here 40 is the percentage of brightness. If this solution works for you skip the next points.

If you have this output No outputs have backlight property that mean you will have to use a different way.

Try this command in the terminal :

# ls /proc/acpi/video/ 2> /dev/null |wc -l

If the output of this command is other than 0, that means acpi supports the screen. To change the screen brightness, you first have to determine what is the greater value you can set. This could be done by # cat /sys/class/backlight/acpi_video0/max_brightness (you may need to change the path slightly : video0 may not suit your laptop). Then you can set your new luminosity with this command # echo 5 > /sys/class/backlight/acpi_video0/brightness. One more time, if this works for you skip the next point.

If the last command doesn't work for you, that means you don't have acpi support for video, thus you will have to modify something closest to the hardware. First you will have to know the real name of your video driver, this is done by :

$ /bin/ls -d /sys/class/backlight/*_backlight/ /sys/class/backlight/intel_backlight/

Note that we used the full path to reach ls to avoid alias system.

You can see that i have an Intel graphic card. I will this path for the next examples, watch out "copy paste" if you have another output for the command output above.

The maximum brightness is very different from a device to another so i encourage you to know the max value by executing :

$ cat /sys/class/backlight/intel_backlight/max_brightness
4882

Like the output value is quite high, be careful to not set a too low value because you will face a pitch black screen.

Then, you can set the screen brightness by doing this :

# echo 1000 > /sys/class/backlight/intel_backlight/brightness

If none of this solutions works, i am sorry i don't have any solution for you. However, if you have another solution to do this, please let us know.

Screen saver

We went further with the screen and used some screen saver "magic" to reduce even more the consumption. In order to reduce even more the consumption when the screen saver is on, we enable dpms. If you don't enable dpms, xscreensaver (and xset) only displays a black "image", dpms takes care to turn off the screen. Here is the interesting part of the ~/.xscreensaver file :

timeout:	0:05:00    # 5 minutes
cycle:		0:00:00
lock:		False      # don't ask for the password
[.../...]
dpmsEnabled:	True
dpmsQuickOff:	True

You can find the entire file here.

Dpms has however a weakness, when the screen saver resume from his black screen, it changes our screen brightness. To have both (the reduced luminosity and the screen turned off) we first look if a script was executed when xscreensaver resumes. Unsuccessful, we turned to cron tasks to run our brightness script every 2 minutes.

Here is the cron task :

*/2 * * * * /usr/bin/brightness nosleep

Measures results

The following measures have been taken on a "devel" version so it's perfectly normal to have a low power consumed for the "base" :

Comparison xscreensaver options.png

You can see that the dpms option have a huge impact on the power consumption. As a matter of fact, without the option, xscreensaver only display a black screen without reducing the brightness. With the dpms options, xscreensaver turn off the screen.

You can find the raw data and the chart here.

Hacking / Tuning

  • /etc/init.d/suse_studio_custom The service to run at computer's startup.
  • /etc/xdg/lxsession/LXDE/autostart If you want to disable the script.
  • /usr/bin/brightness The script.
  • ~/.xscreensaver (and /etc/skel/.xscreensaver for future users) The screen saver properties.
  • /var/spool/cron/crontabs/root The cron file once installed.