ledmatrix: gamma correction for smoother brightness ramps #99
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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):