Linux autobrightness

General discussion relating to the O2 Joggler, from the default O2 setup, to alternative operating systems and applications.
Post Reply
User avatar
Leonardo
Posts: 146
Joined: Tue Dec 25, 2012 10:51 pm

Linux autobrightness

Post by Leonardo »

Hi
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
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!
User avatar
Mevi
Posts: 774
Joined: Tue Oct 25, 2011 4:39 pm

Re: Linux autobrightness

Post by Mevi »

Wow, impressive. :shock:
I've Got The Moves Like Joggler

Windows XP Professional SP3 plus Tablet PC for O2 Joggler
http://www.jogglerwiki.com/forum/viewto ... ?f=2&t=305

How to build your own Windows XP for the Joggler
http://www.jogglerwiki.com/wiki/WindowsXP
User avatar
Leonardo
Posts: 146
Joined: Tue Dec 25, 2012 10:51 pm

Re: Linux autobrightness

Post by Leonardo »

LOL :D
Why do you say that?!
Ah I forgot: obviously, it works in console too, doesn't depend by X session!
User avatar
Mevi
Posts: 774
Joined: Tue Oct 25, 2011 4:39 pm

Re: Linux autobrightness

Post 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.
I've Got The Moves Like Joggler

Windows XP Professional SP3 plus Tablet PC for O2 Joggler
http://www.jogglerwiki.com/forum/viewto ... ?f=2&t=305

How to build your own Windows XP for the Joggler
http://www.jogglerwiki.com/wiki/WindowsXP
User avatar
roobarb!
Posts: 1772
Joined: Sat Mar 05, 2011 1:30 pm
Location: Salford, UK
Contact:

Re: Linux autobrightness

Post 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.
BirdsLikeWires - Get fresh builds of Debian Bullseye, Bookworm, and Trixie for OpenFrame with the latest 5.10, 6.1, and 6.12 kernels! 8-)
User avatar
Leonardo
Posts: 146
Joined: Tue Dec 25, 2012 10:51 pm

Re: Linux autobrightness

Post 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" :)
User avatar
Leonardo
Posts: 146
Joined: Tue Dec 25, 2012 10:51 pm

Re: Linux autobrightness

Post by Leonardo »

Mevi wrote:In Windows for Joggler, the brightness can be adjusted manually, which is really boring.
switch to linux :D
Don't use windows since... '95? years, not version :D
I was been a proud 2.0 kernel user!
User avatar
Mevi
Posts: 774
Joined: Tue Oct 25, 2011 4:39 pm

Re: Linux autobrightness

Post 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. :D

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.
I've Got The Moves Like Joggler

Windows XP Professional SP3 plus Tablet PC for O2 Joggler
http://www.jogglerwiki.com/forum/viewto ... ?f=2&t=305

How to build your own Windows XP for the Joggler
http://www.jogglerwiki.com/wiki/WindowsXP
gegs
Posts: 1146
Joined: Fri Mar 04, 2011 3:22 pm
Location: Edinburgh

Re: Linux autobrightness

Post 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.
User avatar
Mevi
Posts: 774
Joined: Tue Oct 25, 2011 4:39 pm

Re: Linux autobrightness

Post 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.
I've Got The Moves Like Joggler

Windows XP Professional SP3 plus Tablet PC for O2 Joggler
http://www.jogglerwiki.com/forum/viewto ... ?f=2&t=305

How to build your own Windows XP for the Joggler
http://www.jogglerwiki.com/wiki/WindowsXP
User avatar
pete
Posts: 2961
Joined: Mon Aug 01, 2011 6:33 am
Location: Time Traveler

Re: Linux autobrightness

Post 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.
- Pete
O2 Jogglers running EFI Ubuntu / Squeezeplayer
OpenPeak Voip Telephony / Zigbee tabletops hardware modded with Seabios / RTC / Ethernet ROM edits / SSD drives running XPe for automation screens

Auto mater
User avatar
Leonardo
Posts: 146
Joined: Tue Dec 25, 2012 10:51 pm

Re: Linux autobrightness

Post 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 :D
User avatar
Leonardo
Posts: 146
Joined: Tue Dec 25, 2012 10:51 pm

Re: Linux autobrightness

Post 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!
gegs
Posts: 1146
Joined: Fri Mar 04, 2011 3:22 pm
Location: Edinburgh

Re: Linux autobrightness

Post 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 ;) ).
Last edited by gegs on Mon Feb 11, 2013 5:51 pm, edited 1 time in total.
User avatar
Leonardo
Posts: 146
Joined: Tue Dec 25, 2012 10:51 pm

Re: Linux autobrightness

Post 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?
gegs
Posts: 1146
Joined: Fri Mar 04, 2011 3:22 pm
Location: Edinburgh

Re: Linux autobrightness

Post 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.
User avatar
Leonardo
Posts: 146
Joined: Tue Dec 25, 2012 10:51 pm

Re: Linux autobrightness

Post 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!
gegs
Posts: 1146
Joined: Fri Mar 04, 2011 3:22 pm
Location: Edinburgh

Re: Linux autobrightness

Post by gegs »

We're getting a bit off-topic here. Maybe we should start a Haiku/BeOS thread if people are interested.
User avatar
pete
Posts: 2961
Joined: Mon Aug 01, 2011 6:33 am
Location: Time Traveler

Re: Linux autobrightness

Post 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.
- Pete
O2 Jogglers running EFI Ubuntu / Squeezeplayer
OpenPeak Voip Telephony / Zigbee tabletops hardware modded with Seabios / RTC / Ethernet ROM edits / SSD drives running XPe for automation screens

Auto mater
User avatar
Leonardo
Posts: 146
Joined: Tue Dec 25, 2012 10:51 pm

Re: Linux autobrightness

Post by Leonardo »

talking about brightness, if I set level 32 (anyway a high level), my Joggler became very hot! Is the same for yours?
Post Reply