]> www.fi.muni.cz Git - bike-lights.git/commitdiff
ambient.c: rewrite
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Thu, 18 Jul 2013 21:29:32 +0000 (23:29 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Thu, 18 Jul 2013 21:29:32 +0000 (23:29 +0200)
We now measure two running averages - ambient_slow and ambient_fast.
The _fast is computed based on the ADC readings and few bits of averaging.
The _slow is computed based on _fast and few bits of averaging.

We don't want to change the zone too often, but on the other hand,
we want fast reaction to the strong ambient light level changes.
So we compute the new ambient zone based on _fast, and when the new
one is current one +1 or -1, we retry using the _slow value.
Only when even the _slow suggests that the ambient zone has changed,
we permit the change to the neighbouring level. Changes to the more distant
zone are permitted immediately.

Also the logging rewritten to accomodate minimum, a few bits of
max-min, and a few bits of level drop.


No differences found