Use averaged brightness for limit calculation
This commit is contained in:
parent
ccfdd7aeab
commit
fe246bfa6d
|
@ -1 +1 @@
|
|||
264
|
||||
277
|
||||
|
|
|
@ -67,19 +67,18 @@ void LightSensor_Poll(void)
|
|||
unsigned int measurement = LightSensor_Measurement;
|
||||
LightSensor_NewMeasurement = false;
|
||||
float brightness = 1.0f - measurement / 65535.0f;
|
||||
|
||||
if(measurement != 65535 && brightness < LightSensor_MinimumBrightness)
|
||||
{
|
||||
LightSensor_MinimumBrightness = brightness;
|
||||
}
|
||||
if(brightness > LightSensor_MaximumBrightness)
|
||||
{
|
||||
LightSensor_MaximumBrightness = brightness;
|
||||
}
|
||||
|
||||
LightSensor_AbsoluteBrightness = LIGHTSENSOR_LAMBDA * LightSensor_AbsoluteBrightness
|
||||
+ (1.0f - LIGHTSENSOR_LAMBDA) * brightness;
|
||||
|
||||
if(LightSensor_AbsoluteBrightness < LightSensor_MinimumBrightness)
|
||||
{
|
||||
LightSensor_MinimumBrightness = LightSensor_AbsoluteBrightness;
|
||||
}
|
||||
if(LightSensor_AbsoluteBrightness > LightSensor_MaximumBrightness)
|
||||
{
|
||||
LightSensor_MaximumBrightness = LightSensor_AbsoluteBrightness;
|
||||
}
|
||||
|
||||
// Scale and saturate to get relative brightness value
|
||||
float range = LightSensor_MaximumBrightness
|
||||
- LightSensor_MinimumBrightness;
|
||||
|
|
Loading…
Reference in a new issue