Skip to content

CIE1931 Compensation

Arnd edited this page Jan 31, 2021 · 2 revisions

LED CIE 1931 lightness compensation

When fading or brightening a LED using PWM from 0 - 255 the actual PWM value and what our eyes perceive as the brightness do not correspond completely. Particularly in the lower PWM range we can see minute differences in brightness at each step, but after reaching 50% PWM duty cycle and higher we can barely see the difference.

The CIE 1931 Color Space describes a number of factors regarding color and vision, and within this there is a formula to compute brightness. Unfortunately this formula uses floating point and raises a variable to the power of 3 and this means that the Arduino has no chance of computing this at runtime.

This library uses a pre-calculated table to implement CIE1931 lightness corrections. This works very well in giving a nice linear change to the LED lightness but comes at a cost - 256 Bytes of program memory is reserved for this (8-bit table with 256 elements).

For those who don't need a linear progression or don't have those 255 Bytes of memory available, it is possible to edit the "smoothLED.h" header file and to comment out the line #define CIE_MODE_ACTIVE

This will remove the table and the associated calls in the program and save that space. Unless you are fading low-power LED values over time the difference probably not be noticeable to the naked eye.

Clone this wiki locally