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()
|
||||
MINBRIGHTNESS = 2;
|
||||
MAXBRIGHTNESS = 20;
|
||||
MINBRIGHTNESS = 0;
|
||||
MAXBRIGHTNESS = 10;
|
||||
|
||||
LIGHTSENSOR_BOTTOM = 270;
|
||||
LIGHTSENSOR_TOP = 350;
|
||||
LIGHTSENSOR_BOTTOM = 0;
|
||||
LIGHTSENSOR_TOP = 900;
|
||||
|
||||
l = [LIGHTSENSOR_BOTTOM - 10:LIGHTSENSOR_TOP + 10];
|
||||
b = zeros(size(l));
|
||||
|
||||
LIGHTSENSOR_SCALE = 1024;
|
||||
LIGHTSENSOR_BASE = 1.35;
|
||||
LIGHTSENSOR_BASE = 1.40;
|
||||
|
||||
if (LIGHTSENSOR_BASE <= 1)
|
||||
error 'LIGHTSENSOR_BASE must be > 1';
|
||||
|
|
|
@ -71,25 +71,24 @@ void SWversion(void);
|
|||
#define LIGHTSENSOR_INPUTPIN 0
|
||||
// bottom of light sensor (ambient light values at or lower than this level will
|
||||
// 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
|
||||
// be mapped to MAXBRIGHTNESS)
|
||||
#define LIGHTSENSOR_TOP 300
|
||||
#define LIGHTSENSOR_TOP 900
|
||||
// weight for exponential decaying averaging (actual weigth is 2 ^ LIGHTSENSOR_WEIGHT)
|
||||
#define LIGHTSENSOR_WEIGHT 4
|
||||
// base of exponential mapping (must be > 1)
|
||||
#define LIGHTSENSOR_BASE 1.35
|
||||
#define LIGHTSENSOR_BASE 1.40
|
||||
|
||||
// DAY Brightness setting 0 = off 20 = full
|
||||
#define MAXBRIGHTNESS 20
|
||||
#define MAXBRIGHTNESS 10
|
||||
// start MAXBRIGHTNESS at DAYLIGHTHOUR (7 am)
|
||||
#define DAYLIGHTHOUR 7
|
||||
// NIGHT Brightness setting 0 = off 20 = full
|
||||
#define MINBRIGHTNESS 2
|
||||
// start MINBRIGHTNESS at NIGHTLIGHTHOUR (7 pm)
|
||||
#define NIGHTLIGHTHOUR 19
|
||||
|
||||
|
||||
#define N_PWM_STEPS 11
|
||||
|
||||
//#define LED1 Led1=1
|
||||
//#define LED2 Led2=1
|
||||
|
@ -355,7 +354,7 @@ ISR(TIMER2_OVF_vect) {
|
|||
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];
|
||||
|
||||
Serial.print("lightsensor: ");
|
||||
/*Serial.print("lightsensor: ");
|
||||
Serial.print(lightlevel_sample);
|
||||
Serial.print(" / ");
|
||||
Serial.print(lightlevel_avg);
|
||||
Serial.print(", brightness: ");
|
||||
Serial.println(current_brightnes);
|
||||
Serial.println(current_brightnes);*/
|
||||
#else
|
||||
if ((hour < DAYLIGHTHOUR) | (hour >= NIGHTLIGHTHOUR))
|
||||
current_brightnes=MINBRIGHTNESS;
|
||||
|
|
Loading…
Reference in New Issue