Rough parameter tuning + reduced flickering
* rough parameter tuning for TEPT4400 light sensor * reduced flickering at low brightness values by reducing number of brightness levels
This commit is contained in:
parent
fc2494631a
commit
9e158c13fd
|
@ -1,15 +1,16 @@
|
||||||
function lightlevelmapping()
|
function lightlevelmapping()
|
||||||
MINBRIGHTNESS = 2;
|
MINBRIGHTNESS = 0;
|
||||||
MAXBRIGHTNESS = 20;
|
MAXBRIGHTNESS = 10;
|
||||||
|
|
||||||
LIGHTSENSOR_BOTTOM = 270;
|
LIGHTSENSOR_BOTTOM = 0;
|
||||||
LIGHTSENSOR_TOP = 350;
|
LIGHTSENSOR_TOP = 900;
|
||||||
|
|
||||||
l = [LIGHTSENSOR_BOTTOM - 10:LIGHTSENSOR_TOP + 10];
|
l = [LIGHTSENSOR_BOTTOM - 10:LIGHTSENSOR_TOP + 10];
|
||||||
b = zeros(size(l));
|
b = zeros(size(l));
|
||||||
|
|
||||||
LIGHTSENSOR_SCALE = 1024;
|
LIGHTSENSOR_SCALE = 1024;
|
||||||
LIGHTSENSOR_BASE = 1.35;
|
LIGHTSENSOR_BASE = 1.35;
|
||||||
|
LIGHTSENSOR_BASE = 1.40;
|
||||||
|
|
||||||
if (LIGHTSENSOR_BASE <= 1)
|
if (LIGHTSENSOR_BASE <= 1)
|
||||||
error 'LIGHTSENSOR_BASE must be > 1';
|
error 'LIGHTSENSOR_BASE must be > 1';
|
||||||
|
|
|
@ -71,25 +71,24 @@ void SWversion(void);
|
||||||
#define LIGHTSENSOR_INPUTPIN 0
|
#define LIGHTSENSOR_INPUTPIN 0
|
||||||
// bottom of light sensor (ambient light values at or lower than this level will
|
// bottom of light sensor (ambient light values at or lower than this level will
|
||||||
// be mapped to MINBRIGHTNESS)
|
// be mapped to MINBRIGHTNESS)
|
||||||
#define LIGHTSENSOR_BOTTOM 270
|
#define LIGHTSENSOR_BOTTOM 0
|
||||||
// top of light sensor (ambient light values at or higher than this level will
|
// top of light sensor (ambient light values at or higher than this level will
|
||||||
// be mapped to MAXBRIGHTNESS)
|
// be mapped to MAXBRIGHTNESS)
|
||||||
#define LIGHTSENSOR_TOP 300
|
#define LIGHTSENSOR_TOP 900
|
||||||
// weight for exponential decaying averaging (actual weigth is 2 ^ LIGHTSENSOR_WEIGHT)
|
// weight for exponential decaying averaging (actual weigth is 2 ^ LIGHTSENSOR_WEIGHT)
|
||||||
#define LIGHTSENSOR_WEIGHT 4
|
#define LIGHTSENSOR_WEIGHT 4
|
||||||
// base of exponential mapping (must be > 1)
|
// base of exponential mapping (must be > 1)
|
||||||
#define LIGHTSENSOR_BASE 1.35
|
#define LIGHTSENSOR_BASE 1.40
|
||||||
|
|
||||||
// DAY Brightness setting 0 = off 20 = full
|
// DAY Brightness setting 0 = off 20 = full
|
||||||
#define MAXBRIGHTNESS 20
|
#define MAXBRIGHTNESS 10
|
||||||
// start MAXBRIGHTNESS at DAYLIGHTHOUR (7 am)
|
// start MAXBRIGHTNESS at DAYLIGHTHOUR (7 am)
|
||||||
#define DAYLIGHTHOUR 7
|
#define DAYLIGHTHOUR 7
|
||||||
// NIGHT Brightness setting 0 = off 20 = full
|
// NIGHT Brightness setting 0 = off 20 = full
|
||||||
#define MINBRIGHTNESS 2
|
#define MINBRIGHTNESS 2
|
||||||
// start MINBRIGHTNESS at NIGHTLIGHTHOUR (7 pm)
|
// start MINBRIGHTNESS at NIGHTLIGHTHOUR (7 pm)
|
||||||
#define NIGHTLIGHTHOUR 19
|
#define NIGHTLIGHTHOUR 19
|
||||||
|
#define N_PWM_STEPS 11
|
||||||
|
|
||||||
|
|
||||||
//#define LED1 Led1=1
|
//#define LED1 Led1=1
|
||||||
//#define LED2 Led2=1
|
//#define LED2 Led2=1
|
||||||
|
@ -355,7 +354,7 @@ ISR(TIMER2_OVF_vect) {
|
||||||
digitalWrite(LED4PIN,0);
|
digitalWrite(LED4PIN,0);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (timercount==0) timercount=20;
|
if (timercount==0) timercount=N_PWM_STEPS-1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -496,12 +495,12 @@ void loop(void)
|
||||||
|
|
||||||
current_brightnes = ambient_light_to_brightness[lightlevel_avg];
|
current_brightnes = ambient_light_to_brightness[lightlevel_avg];
|
||||||
|
|
||||||
Serial.print("lightsensor: ");
|
/*Serial.print("lightsensor: ");
|
||||||
Serial.print(lightlevel_sample);
|
Serial.print(lightlevel_sample);
|
||||||
Serial.print(" / ");
|
Serial.print(" / ");
|
||||||
Serial.print(lightlevel_avg);
|
Serial.print(lightlevel_avg);
|
||||||
Serial.print(", brightness: ");
|
Serial.print(", brightness: ");
|
||||||
Serial.println(current_brightnes);
|
Serial.println(current_brightnes);*/
|
||||||
#else
|
#else
|
||||||
if ((hour < DAYLIGHTHOUR) | (hour >= NIGHTLIGHTHOUR))
|
if ((hour < DAYLIGHTHOUR) | (hour >= NIGHTLIGHTHOUR))
|
||||||
current_brightnes=MINBRIGHTNESS;
|
current_brightnes=MINBRIGHTNESS;
|
||||||
|
|
Loading…
Reference in New Issue