diff --git a/build-number.txt b/build-number.txt index 53c86ff..9524ef4 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -417 +424 diff --git a/src/light_sensor.c b/src/light_sensor.c index 4ec450f..8a87dbd 100644 --- a/src/light_sensor.c +++ b/src/light_sensor.c @@ -99,6 +99,17 @@ void LightSensor_Poll(void) { 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; + } } } diff --git a/src/light_sensor.h b/src/light_sensor.h index bc99ee2..1315b28 100644 --- a/src/light_sensor.h +++ b/src/light_sensor.h @@ -15,6 +15,10 @@ // 'Forgetting factor' of the rolling brightness average #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 // near the minimum or maximum 0.0 or 1.0, respectively #define LIGHTSENSOR_LOW_BOUND ((unsigned int)(0.005 * LIGHTSENSOR_MAX))