millilux_from_sum

Function millilux_from_sum 

Source
pub fn millilux_from_sum(sum: u32, conversions: u32) -> u32
Expand description

Convert an accumulated run of SAADC counts on AIN5 to millilux.

Takes the sum and the number of conversions in it rather than a pre-computed mean, because the mean of a run of counts is fractional and a mean rounded to whole counts throws that away. Both divisions — by the conversion count and by the slope’s denominator — are therefore done last, against the scaled sum.

Clamped at both ends: below the dark offset the sensor is reporting its own leakage, above saturation it is reporting the load resistor.