kopia lustrzana https://github.com/Aircoookie/WLED
use CIE brightness also for ESP8266
rodzic
e7babc071d
commit
1cc47b02cf
|
@ -501,9 +501,7 @@ void BusPwm::show() {
|
||||||
if (!_valid) return;
|
if (!_valid) return;
|
||||||
unsigned numPins = NUM_PWM_PINS(_type);
|
unsigned numPins = NUM_PWM_PINS(_type);
|
||||||
unsigned maxBri = (1<<_depth) - 1;
|
unsigned maxBri = (1<<_depth) - 1;
|
||||||
#ifdef ESP8266
|
// use CIE brightness formula
|
||||||
unsigned pwmBri = (unsigned)(roundf(powf((float)_bri / 255.0f, 1.7f) * (float)maxBri)); // using gamma 1.7 to extrapolate PWM duty cycle
|
|
||||||
#else // use CIE brightness formula
|
|
||||||
unsigned pwmBri = (unsigned)_bri * 100;
|
unsigned pwmBri = (unsigned)_bri * 100;
|
||||||
if(pwmBri < 2040) pwmBri = ((pwmBri << _depth) + 115043) / 230087; //adding '0.5' before division for correct rounding
|
if(pwmBri < 2040) pwmBri = ((pwmBri << _depth) + 115043) / 230087; //adding '0.5' before division for correct rounding
|
||||||
else {
|
else {
|
||||||
|
@ -512,8 +510,6 @@ void BusPwm::show() {
|
||||||
temp = temp * temp * temp * (1<<_depth) - 1;
|
temp = temp * temp * temp * (1<<_depth) - 1;
|
||||||
pwmBri = (unsigned)temp;
|
pwmBri = (unsigned)temp;
|
||||||
}
|
}
|
||||||
Serial.println(pwmBri);
|
|
||||||
#endif
|
|
||||||
for (unsigned i = 0; i < numPins; i++) {
|
for (unsigned i = 0; i < numPins; i++) {
|
||||||
unsigned scaled = (_data[i] * pwmBri) / 255;
|
unsigned scaled = (_data[i] * pwmBri) / 255;
|
||||||
if (_reversed) scaled = maxBri - scaled;
|
if (_reversed) scaled = maxBri - scaled;
|
||||||
|
|
Ładowanie…
Reference in New Issue