Gamma control by light sensor
Being the lazy bastard that I am I decided that it would be too complicated (read too much of an effort) for me to push a button to change frontend gamma from day to night so why not have a sensor to do all the hard work for me? That way when the darkness falls the gamma would be switched on to around half the normal value and when the day breaks it would be switched back on to normal value automagically.
First the hardware. Pulled out my breadboard and off to work. As usually people do, I started with the most complicated scheme for the purpose i.e. with an op-amp running as a voltage comparator.
All fine, but I can have the same thing a lot simpler, so I tried with a darlington.
Fine too, but that left me with a problem: I needed a 12V source for the scheme to work (I know it's not that hard to find one in a computer case :), but I like the KISS principle). So I ended up with just the photo-transistor and a diode for added protection since DTR in low state is -12V (I'd rather be on the safe side :)). This has a disadvantage though: due to the extreme simplicity you can't adjust the level of light it's gonna respond to, but things are working just fine for me without adjusting anything (I even stayed wake last night to see the level of ambiental light at dawn when it will switch and it switched just fine). The photo-transistor is soldered at the end of two wires, isolated with shrink-wrap tubing and fitted inside a dc jack housing. The transparent head comes from a ball point pen cap which I had around; it needed some step by step cutting to get the exact diameter so I could fit it tight in the jack housing. It connects to pins 4 and 8 (DTR and CTS) of the com port on your computer.
Now the software. Since the routine is integrated in the frontend I'm writing I decided to make it available to you guys as a standalone program. Remember that the program just sits in the tray and does not accept any user input (except exit command of course) it just monitors the serial port for the CTS line status (sensor connects the DTR line - which is set to high when the program starts - to CTS line when there's light falling on it and disconnects the two when there's no light) so if you run it without the sensor connected it will just darken your screen. You've been warned :). Oh and by the way set the com port your sensor will be on in the ini file. Other than that hope somebody will find it useful.