ledmatrix: gamma correction for smoother brightness ramps
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):
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.