Light Sensor: Difference between revisions
No edit summary |
|||
Line 12: | Line 12: | ||
In OpenFirmware at the [[Ok]] prompt, type |
In OpenFirmware at the [[Ok]] prompt, type |
||
als@ .d (cr d# 200 ms many |
ok als@ .d (cr d# 200 ms many |
||
and press enter. The sensor readings will be displayed continuously, until you press a key. |
and press enter. The sensor readings will be displayed continuously, until you press a key. |
||
(If you always get the same reading, please report the defect, and also type |
|||
ok test /leds |
|||
and observe the flashing pattern. Normal pattern on a B1 is wireless indicator bright, storage indicator bright, wireless indicator dim.) |
|||
== Programming == |
== Programming == |
Revision as of 21:38, 29 August 2011
NOTE: The contents of this page are not set in stone, and are subject to change! This page is a draft in active flux ... |
A light sensor is built into the XO-1.75.
XO-1.75 B1 has a restricted form of the feature, in that the wireless activity indicator is affected by the sensor, and any future use of the storage indicator will affect the sensor.
XO-1.75 A3 has a restricted form of the feature, in that the sensor is affected by the battery and power LED.
The sensor is managed by the embedded controller, and is averaged and updated at a rate that depends on the brightness of the light. Reading the averaged value can be done up to 213 times per second, but there is no great advantage to reading that quickly.
Testing
In OpenFirmware at the Ok prompt, type
ok als@ .d (cr d# 200 ms many
and press enter. The sensor readings will be displayed continuously, until you press a key.
(If you always get the same reading, please report the defect, and also type
ok test /leds
and observe the flashing pattern. Normal pattern on a B1 is wireless indicator bright, storage indicator bright, wireless indicator dim.)
Programming
- your program must read /sys/devices/platform/olpc-ols.0/power_state and parse the result as an integer,
- your program should avoid reading power_state at a rate more than the sample rate the sensor is configured for, because this consumes extra power by making the CPU and the EC more busy,
Internals
The sensor is a reverse biased LED. The EC charges the LED as if it is a capacitor, and then times how long it takes to discharge. The discharge time is mostly related to the ambient light, and slightly related to operating temperature of the embedded controller.
XO-1.75 B1 Restriction
The sensor is adjacent to the wireless indicator. The EC disables the wireless indicator while taking a sample. The storage indicator, if it is used, may affect the sample.
XO-1.75 A3 Restriction
The sensor is adjacent to the battery indicator, and as a result generates distorted samples when the laptop is connected to a DC power cable.
References
- (yet to be released) runin-light-sensor script for testing data stream from sensor,
- kernel implementation first included in os40,
- embedded controller implementation,
- OpenFirmware implementation.