]> www.fi.muni.cz Git - bike-lights.git/commit - firmware/ambient.c
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)
commit5a5088f09ea11dd3c36f3bb6833a0c5d85715641
tree847bcdf46f34c1b341cf547c8ff808def99f464a
parent245a5fcfa3da6628a5634a9899913c0be143ffa9
ambient.c: rewrite

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.
firmware/ambient.c