Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gamma correction for LED fading #65

Open
Bomaker opened this issue Feb 4, 2019 · 0 comments
Open

Gamma correction for LED fading #65

Bomaker opened this issue Feb 4, 2019 · 0 comments

Comments

@Bomaker
Copy link

Bomaker commented Feb 4, 2019

Hi,
Could you add a gamma correction for LED brightness?
It can be learned from "LED.cpp - Library for LEDs. Created by Benjamin Wüst" which I cannot find anymore on github (have a local copy though).

int LED::calculate_linear_fade_position_to_exponential(int position, double pwm_max_steps, double gamma_correction)
{
 // This function needs scientific backup!
 // http://www.wolframalpha.com/input/?i=plot+y%3Dround%28255*%28x%2F255%29^%282.2%29%29+from+x%3D0+to+255
 int out = round(pwm_max_steps * ( pow( (position/ 255.0) , gamma_correction) ));
 return out;
} 

Gamma of 2.2 seems to be good. BTW, why isn't the bool activeLow = false not working with fade?
Cool library nevertheless! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant