Module light

Module light 

Source
Expand description

Ambient light sensing for the T1000-E.

The sensor sits on P0.29 (AIN5) behind two enables: the shared sensor 3.3 V rail (P1.06) and a sensor-enable line (P0.04), both active-high. It is a phototransistor loaded to ground, so the node voltage rises with illuminance from a small dark offset and rails once the load resistor saturates — the transfer function is a straight line between those two ends.

The SAADC and the sensor rail are owned by run_battery_monitor; this module is the request side of that ownership, plus the pure conversion, which is host-testable and therefore deliberately not gated on the target.

The light channel runs at 14-bit resolution with hardware oversampling, which is why the counts here are four times the 12-bit-scale numbers the vendor driver works in. Full scale is 3.6 V (Gain1_6 against the 0.6 V internal reference), so one count is 3600 / 16384 ≈ 0.2197 mV.

Constants§

DARK_OFFSET_RAW
Raw count at zero illuminance, subtracted before scaling.
MAX_REPORTABLE_MLUX
The largest value this board can report — the reading at SATURATION_RAW, about 253 lux.
SATURATION_RAW
Raw count above which the reading is clamped: 12288, which is 2.7 V and three-quarters of full scale.
SLOPE_MLUX_DEN
SLOPE_MLUX_NUM
Millilux per count above DARK_OFFSET_RAW, as the fraction SLOPE_MLUX_NUM / SLOPE_MLUX_DEN20.636 mlux per count.

Functions§

millilux_from_sum
Convert an accumulated run of SAADC counts on AIN5 to millilux.
raw_to_millilux
Convert one SAADC count on AIN5 to millilux — millilux_from_sum for a single conversion.