Optimize and fix light sensor filter
Optimization: Don't compute the sum of all samples in filter window every run. Instead, keep track of the sum, subtract phased out sample, add new sample and divide new sum by number of valid samples. Massive CPU cycle savings. Thanks to Jonathan (zenpoy on gmail dot com) for pointing me in the right direction! Fix: The code for stopping the filter if the sensor has been stable the entire filter window time was only enabled if debug logging was enabled. Oops. CPU cycle savings in steady ambient light.
Loading
Please register or sign in to comment