Page 1 of 1
Linux autobrightness
Posted: Sun Feb 03, 2013 2:54 pm
by Leonardo
Hi
using this useful c code:
http://code.google.com/p/adqmisc/source ... sor.c?r=68
and adding the line:
to the file /etc/modules
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
the binary "/opt/bin/rls" is obtained compiling the readlightsensor.c with the command:
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!
Re: Linux autobrightness
Posted: Sun Feb 03, 2013 4:12 pm
by Mevi
Wow, impressive.

Re: Linux autobrightness
Posted: Sun Feb 03, 2013 4:47 pm
by Leonardo
LOL

Why do you say that?!
Ah I forgot: obviously, it works in console too, doesn't depend by X session!
Re: Linux autobrightness
Posted: Mon Feb 04, 2013 12:47 am
by Mevi
In Windows for Joggler, the brightness can be adjusted manually, which is really boring.
I'm always impressed when Linux guys post, probably because I will forever be a Linux noob and it just looks so exotic. I worked in IT support for years.. DOS and Windows, SQL, hardware installs, that kind of thing. I think if I ever had my time over, I would have gotten into Linux sooner.
Re: Linux autobrightness
Posted: Mon Feb 04, 2013 8:36 am
by roobarb!
Hehe - that's exactly the same method I use in the auto brightness setting in SqueezePlay! I remember being so impressed getting it to work for the first time.
If you use 'seq' in a for loop you can also make the brightness appear to fade up and down instead of jumping.
Re: Linux autobrightness
Posted: Mon Feb 04, 2013 9:16 am
by Leonardo
Hi Roobarb, sorry I didn't tried your SqueezePlay yet

I search for a topic about brightness and I didn't find anything so I though to share my little script!
Good tip the "seq"

Re: Linux autobrightness
Posted: Mon Feb 04, 2013 9:19 am
by Leonardo
Mevi wrote:In Windows for Joggler, the brightness can be adjusted manually, which is really boring.
switch to linux

Don't use windows since... '95? years, not version

I was been a proud 2.0 kernel user!
Re: Linux autobrightness
Posted: Mon Feb 04, 2013 3:49 pm
by Mevi
Well I bought my first Joggler about six months before I joined this forum, shortly after finding out that you could run Linux on it. The plan was that I set it up as a "desk clock" at work and learn Linux on it when the boss wasn't around on Fridays. Problem was they caught me tinkering too many times, so I brought it home.
I tried all the Linux distros, but I really didn't devote enough time to learning the nuts and bolts. A bit like me and cars - I can drive, but I'm clueless about fixing them.
Right around the time Eric & Dan got Windows booting on it, I was signed off long term sick and spent my time making my own XP release.
Re: Linux autobrightness
Posted: Mon Feb 04, 2013 4:21 pm
by gegs
Mevi wrote:...I'm always impressed when Linux guys post, probably because I will forever be a Linux noob and it just looks so exotic...
Join the club Mevi! I've been a linux noob since about 1998*
*
I don't remember exactly but I do remember getting SuSE linux 5.1 shortly after it came out, which was some time toward the end of last century.
Re: Linux autobrightness
Posted: Tue Feb 05, 2013 11:38 am
by Mevi
I've got a Linux DVD that Canonical sent me somewhere (I was STILL on dial up at the time) and I've had OSX Tiger on my old laptop once. Anyone heard of BeOS? I used that for a while at home. I try most things at least once, but Windows with all it's faults is a familiar friend... You know the kind that you've known since school and who sometimes acts like a complete dick, but is there to help you out when you need them.
Re: Linux autobrightness
Posted: Tue Feb 05, 2013 3:13 pm
by pete
Very nice Leonardo!
Here the Jogglers in the house have become "do alls" and while they still speak to the mothership I would like them to also be able to run independantly which some are doing today.
Personally though here really started to "play" with computers around the 1970's.
That said I was taking physics classes and would play "Star Trek" via a teletype printer in a water closet net to the physics lab.
It was really slow but fun and passed the time as the class was something like 4-6 hours worth at that time.
Re: Linux autobrightness
Posted: Tue Feb 05, 2013 6:05 pm
by Leonardo
hehe I'm younger, my first experience with PCs is in the 80s with the Commodore computers!
Me too used dial up to BBS around Italy for the happyness of my parents when they received telephone bills

Re: Linux autobrightness
Posted: Fri Feb 08, 2013 10:31 pm
by Leonardo
Roobarb, I used the seq following your suggestion, I'm not satisfied at all... this is my code:
Code: Select all
#!/bin/bash
ACTUAL=`cat /sys/devices/platform/openframe-bl/backlight/openframe-bl/actual_brightness`
while true
do
L=`/opt/bin/rls`
LNEW=`echo $L/25|bc`
if [ $ACTUAL -lt $LNEW ]; then STEP="1"; else STEP="-1"; fi
# echo $L $LNEW $STEP
for I in $(seq $ACTUAL $STEP $LNEW ); do
echo $I > /sys/devices/platform/openframe-bl/backlight/openframe-bl/brightness
sleep .01
done
ACTUAL=$LNEW
done
as you can see is quite simple, the only trick I used is to compare new brightness level to actual and set the $STEP variable to let the seq command work properly... two questions:
I put a little delay to have a softer smooth, did you?
Is the "/25" correction correct? It seems to be ok but I'm not sure!
Re: Linux autobrightness
Posted: Mon Feb 11, 2013 11:07 am
by gegs
Mevi wrote:Anyone heard of BeOS? I used that for a while at home...
I used to triple boot Windows 98 / SuSE linux / BeOS and as time progressed I used the latter two most of the time. Windows was reserved for when there was no equivalent for a Win program on the other two platforms and also for the FAF (Family Acceptance Factor).
BeOS was lovely but I gave up on it when it was discontinued. Hardware drivers were a problem and it was only going to get worse with a lack of community and commercial support. I think it was designed mainly for the embedded systems market but linux was already too well established in that field for it to succeed at that time. Shame though, because it was very slick, clean and professional.
I hadn't checked it out for ages but it appears that the BeOS philosophy still lives with Haiku -
http://www.haiku-os.org/ - and Google has donated $5,000 to the project, which is a nice gesture. There is even a Haiku/ARM project in its early stages -
http://www.haiku-os.org/blog/ithamar/20 ... eps_moving - so we might see it at some future date on the Joggler (EDIT--- I meant to say the Raspberry Pi. Anybody looking for a green light to port x86 BeOS to the Joggler has my permission

).
Re: Linux autobrightness
Posted: Mon Feb 11, 2013 4:57 pm
by Leonardo
Hi Gegs, mee to played with BeOS times ago, I had a old pc with it installed!
Why do you say there's an Haiku/ARM so we might see it on Joggler? Jogglers hasn't ARM processor, but a i386, so, theorically and creating a properly boot procedure, the current Haiku could work on our O2J! Did I misunderstand your post?
Re: Linux autobrightness
Posted: Mon Feb 11, 2013 5:48 pm
by gegs
Leonardo wrote:Hi Gegs, mee to played with BeOS times ago, I had a old pc with it installed!
Why do you say there's an Haiku/ARM so we might see it on Joggler? Jogglers hasn't ARM processor, but a i386, so, theorically and creating a properly boot procedure, the current Haiku could work on our O2J! Did I misunderstand your post?
Whoops sorry! I've been flitting around between this and a Raspberry Pi forum and meant to say we might soon see it on the Pi. I think the Pi developer community might be more interested in doing so than the Joggler one, but who knows? It is also more likely to appear on the Pi because it is a current piece of hardware and hasn't been discontinued (hence a larger and growing user base).
I knew the Joggler was an x86 device (it can run Windows XP) but got a bit sloppy trying to type too many things during a short break. I'll amend my previous post.
Re: Linux autobrightness
Posted: Mon Feb 11, 2013 6:18 pm
by Leonardo
Infact, RPI mounts a ARM!!! So theory says we could run Haiku on Jog without problems!
At the moment I took a look to the live cd, it's not that bad!
Anyway my goal is to have a very very minimal distro with X session (a browser is enough for me).
I'm going OT now, I can suggest you all to take a look to "Dooble browser", it's a multiplatform very light web browser. I'm using it on a Ubuntu server base (from Exotica), a very minimal WM (DWM) and this. Without "embedding" the OS I have it up and running in about 30 seconds!
Re: Linux autobrightness
Posted: Mon Feb 11, 2013 9:45 pm
by gegs
We're getting a bit off-topic here. Maybe we should start a Haiku/BeOS thread if people are interested.
Re: Linux autobrightness
Posted: Tue Feb 12, 2013 4:56 pm
by pete
I like using the autobrightness features. I have though been using the "buttons" for manually shutting off the display and getting my wife to touch a touchscreen here.
Forcing the "touch" stuff a bit as my wife has always been afraid of breaking the house by touching the touchscreens have jogglers here and there in the master bedroom.
Removing the talking pieces when she touched the screens have helped a bit.
Re: Linux autobrightness
Posted: Tue Feb 12, 2013 10:07 pm
by Leonardo
talking about brightness, if I set level 32 (anyway a high level), my Joggler became very hot! Is the same for yours?