Dimming LUT
// Range = 0-4095, Steps = 32, Gamma = 2.2
const uint16_t GAMMA_LUT[32] = {
0, 2, 10, 24, 45, 74, 110, 155, 208, 270, 340, 419, 508, 605, 712, 829, 956, 1092, 1238, 1395, 1561, 1738, 1926, 2124, 2332, 2551, 2781, 3022, 3273, 3536, 3810, 4095
};
What is LED Gamma correction?
Perceptually Uniform Brightness
Linear PWM Brightness Distribution
LED Gamma correction is a common brightness compensation solution in LED dimming. It balances the non-linear relationship between the human eye’s logarithmic light perception and PWM duty cycles, aligning PWM output with how our eyes perceive brightness. This effectively reduces low-brightness stepping and makes LED brightness transitions smoother and more natural.
Lookup-table vs. formula method
- Lookup-table (LUT): Directly outputs precomputed values for target brightness ratios. Precision is limited by the number of pre-generated steps—fewer steps mean lower accuracy.
- Formula method: Calculates corrected values in real time using the Gamma formula (Corrected PWM = Max PWM × Target brightness ratio^Gamma). It supports dynamic Gamma adjustments and offers better flexibility/accuracy when hardware resources are sufficient.
Gamma Value Setting:
- Default Recommendation: 2.2–2.4, suitable for most general LED lighting scenarios such as indoor and commercial environments;
- Ambient Lighting: 2.4–2.6, provides finer brightness increments and a slower ramp-up, resulting in a smoother transition from dark to bright;
- Outdoor functional lighting: 1.8–2.2, prevents low-brightness levels from being washed out by ambient light, ensuring the lowest dimming steps remain perceptible and usable;
- Gamma calibration is more about empirical tuning than theoretical calculation. Adjustments should be made based on hardware conditions and actual visual perception.
LUT Duplicates:
- Time-based fading dimming:
Identical adjacent values are normal, invisible to the naked eye, and require no handling. - Fixed-step dimming:
Increase PWM resolution or reduce dimming steps to ensure visible brightness differences between each level.