Light Sensor: Difference between revisions

From OLPC
Jump to navigation Jump to search
No edit summary
Line 36: Line 36:
== References ==
== References ==


* (yet to be released) [http://dev.laptop.org/git/projects/runin/tree/runin-light-sensor runin-light-sensor] script for testing data stream from sensor,
* [http://dev.laptop.org/git/projects/runin/tree/runin-light-sensor runin-light-sensor] script for testing data stream from sensor,
* [http://dev.laptop.org/git/olpc-kernel/commit/?h=arm-3.0&id=389a4492d0e7ccbff0f66870a85b3723304721d6 kernel implementation] first included in os40,
* [http://dev.laptop.org/git/olpc-kernel/commit/?h=arm-3.0&id=389a4492d0e7ccbff0f66870a85b3723304721d6 kernel implementation] first included in os40,
* [http://dev.laptop.org/git/users/rsmith/ec-1.75/tree/ols.c embedded controller implementation],
* [http://dev.laptop.org/git/users/rsmith/ec-1.75/tree/ols.c embedded controller implementation],

Revision as of 21:47, 30 August 2011

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