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 fractionSLOPE_MLUX_NUM / SLOPE_MLUX_DEN— 20.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_sumfor a single conversion.