using this useful c code:
http://code.google.com/p/adqmisc/source ... sor.c?r=68
and adding the line:
Code: Select all
i2c-dev
I can read the value of the light sensor, in a scale between 0 and 810 (didn't get a major value).
So I wrote a very simple wrapper useful to autoset the brightness of the display:
Code: Select all
#!/bin/bash
# autobright.sh
while true
do
L=`/opt/bin/rls`
echo "$L/25"|bc > /sys/devices/platform/openframe-bl/backlight/openframe-bl/brightness
sleep 1
done
gcc -o rls readlightsensor.c
it's very simple, in STDIO writes the value, you can test it loading the i2c-dev module:
modprobe i2c-dev (only the first time, later, thanks to /etc/modules will be loaded automatically at boot)
watch ./rls
you can test it pointing a light torch to the sensor!
don't forget to chmod +x the autobright.sh and run it with: ./autobright.sh
you will see brightness change depending on the light.
The command sleep 1 is to create a little pause between updates, if you remark the line you'll get a nice realtime brightness adsjustment!
If you want to run it automatically, simple put it on /etc/rc.local with a & at the end of the command to run in background!
Hope you enjoy it!