improve brightness curve
This commit is contained in:
parent
eebe634383
commit
9812e2a2e7
|
@ -66,6 +66,7 @@ float enable_fadevalue_change_per_loop=0.01; //fixed value. For manual calculato
|
|||
float set_brightness=2; //0 to 1
|
||||
#define BRIGHTNESS_MIN 0.0
|
||||
#define BRIGHTNESS_MAX 2.0 //if temperature is in between both strips brightness of 2 means both are at full power. otherwise brightness will be clipped
|
||||
#define BRIGHTNESSCURVE 1.4
|
||||
float brightness=set_brightness;
|
||||
float brightness_change_per_loop=0; //will be calculated by Handler
|
||||
|
||||
|
@ -324,8 +325,8 @@ void loopHandler() {
|
|||
uint16_t pwmCW;
|
||||
uint16_t pwmWW;
|
||||
float temp=mapFloat(temperature, TEMPERATURE_MIN, TEMPERATURE_MAX, 0.0,1.0); //0=warmwhite, 1=coldwhite
|
||||
pwmCW=pow((brightness*enable_fadevalue)*temp/2.0, 2) *2.0 *PWM_MAX; //calculate brightness for led stripe, scale to 0-1, ^2, rescale to 0-2, scale for pwm
|
||||
pwmWW=pow((brightness*enable_fadevalue)*(1-temp)/2.0, 2) *2.0 *PWM_MAX;
|
||||
pwmCW=pow((brightness*enable_fadevalue)/2.0, BRIGHTNESSCURVE) *2.0 *temp *PWM_MAX; //calculate brightness for led stripe, scale to 0-1, ^2, rescale to 0-2, scale for pwm
|
||||
pwmWW=pow((brightness*enable_fadevalue)/2.0, BRIGHTNESSCURVE) *2.0 *(1-temp) *PWM_MAX;
|
||||
|
||||
if (pwmCW>PWM_MAX) { pwmCW=PWM_MAX; } //limit
|
||||
if (pwmWW>PWM_MAX) { pwmWW=PWM_MAX; } //limit
|
||||
|
|
Loading…
Reference in New Issue