Gradually reset maximum/minimum brightness
This commit is contained in:
parent
53aa19d91f
commit
5d1ef2263a
|
@ -1 +1 @@
|
||||||
417
|
424
|
||||||
|
|
|
@ -99,6 +99,17 @@ void LightSensor_Poll(void)
|
||||||
{
|
{
|
||||||
LightSensor_RelativeBrightness = LIGHTSENSOR_MAX;
|
LightSensor_RelativeBrightness = LIGHTSENSOR_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Slowly reset limit values
|
||||||
|
static int decay_counter = 0;
|
||||||
|
decay_counter++;
|
||||||
|
if(decay_counter == LIGHTSENSOR_LIMIT_RESET_TIME * 1000
|
||||||
|
/ LIGHTSENSOR_INTERVAL / LIGHTSENSOR_MAX)
|
||||||
|
{
|
||||||
|
decay_counter = 0;
|
||||||
|
LightSensor_MaximumBrightness -= 1;
|
||||||
|
LightSensor_MinimumBrightness += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,10 @@
|
||||||
// 'Forgetting factor' of the rolling brightness average
|
// 'Forgetting factor' of the rolling brightness average
|
||||||
#define LIGHTSENSOR_LAMBDA_BITS 4
|
#define LIGHTSENSOR_LAMBDA_BITS 4
|
||||||
|
|
||||||
|
// Time until minimum and maximum value are completely reset (in seconds)
|
||||||
|
#define LIGHTSENSOR_LIMIT_RESET_TIME \
|
||||||
|
(24 * 60 * 60)
|
||||||
|
|
||||||
// Bounds for converting absolute to relative brightness: Consider everything
|
// Bounds for converting absolute to relative brightness: Consider everything
|
||||||
// near the minimum or maximum 0.0 or 1.0, respectively
|
// near the minimum or maximum 0.0 or 1.0, respectively
|
||||||
#define LIGHTSENSOR_LOW_BOUND ((unsigned int)(0.005 * LIGHTSENSOR_MAX))
|
#define LIGHTSENSOR_LOW_BOUND ((unsigned int)(0.005 * LIGHTSENSOR_MAX))
|
||||||
|
|
Loading…
Reference in a new issue