-
Notifications
You must be signed in to change notification settings - Fork 40
ledmatrix: gamma correction for smoother brightness ramps #99
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
base: main
Are you sure you want to change the base?
Conversation
|
FWIW, I'm not at all sure that I hooked the gamma correction at the right points in the code --- definitely open to guidance if you'd like it moved! |
|
It's also worth calling out that gamma correction makes all mid-range brightnesses look dimmer (by design!). So it might be good to increase the default brightness multiplier (currently 51 on PVT looks like?) to something higher. I'm happy to find a value that matches the approximate intensity of the original firmware if you'd like. |
|
This change reminds me of what FastLED does. Great idea and work. Can I use this code in my fork of the repo? |
|
Would appreciate progress on this change! I also noticed this issue. |
This costs ~256 bytes of flash (once referenced). I've tried to keep the generated code readable.
The brightness values sent to the LED controller actually control a PWM duty cycle. LEDs emit light roughly in proportion to the PWM duty cycle, but human vision perceives brightness on an exponential curve -- generally it takes 2x the physical luminous flux for the eye to perceive something as one step brighter. As a result, brightness ramps (like the one generated by --all-brightnesses) were rapidly brightening to what appeared to be max, and then flattening. This change adds gamma correction, which maps the linear input brightness values to a non-linear function of PWM duty cycles, causing the ramp to look far more ramp-y. The gamma value I've chosen here is arguably a preference, I messed with output on a PVT panel until I found something that looked approximately right.
With gamma scaling, 51 is very dim, need to increase the default brightness to be able to see the bootup animation. Signed-off-by: Daniel Schaefer <dhs@frame.work>
0e2480b to
4dbdac6
Compare
|
I rebased on the main branch and I tried it out. I noticed that the default brighness was way too low with this change, so I increased it a bit.
On my system everything below 37 is off. Everything below 51 is basically off, the LEDs have some variance, some are off, some are extremley dim. |
The brightness values sent to the LED controller actually control a PWM
duty cycle. LEDs emit light roughly in proportion to the PWM duty cycle,
but human vision perceives brightness on an exponential curve --
generally it takes 2x the physical luminous flux for the eye to perceive
something as one step brighter.
As a result, brightness ramps (like the one generated by
--all-brightnesses) were rapidly brightening to what appeared to be max,
and then flattening.
This change adds gamma correction, which maps the linear input
brightness values to a non-linear function of PWM duty cycles, causing
the ramp to look far more ramp-y.
The gamma value I've chosen here is arguably a preference, I messed with
output on a PVT panel until I found something that looked approximately
right.
Photo of a panel with the firmware from

main(left) vs this change (right):