You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
APA102/SK9822 global brightness sometimes incorrect #656
I am very happy that FastLED is now making use of the global brightness aspect of the APA102/SK9822 LEDs. Even with the brightness turned down very low (and using much less power), these LEDs are capable of providing a wide dynamic range of colors with this feature.
However, while trying out the global brightness setting for an SK9822 LED strip, I noticed some odd brightness behavior that I was able to track down the cause of. Specifically, in the following chipsets.h code:
the right side of the s0 calculation is occasionally greater than 255, in which case uint8_t s0 wraps around (262 → 6), resulting in a grossly incorrect brightness. This happens for several values of s.
Even if the overflow is caught and s is set to 255, the algorithm does not preserve scale*brightness, leading to significant deviations in the resulting LED brightness at lower scale factors. I suggest using the following, in which scale*brightness deviates by at most 0.4% (and typically much less):
One thing I've noticed during the testing is that when setCorrection(TypicalLEDStrip) is used (like in provided FastLED examples) the hue shift is very apparent on low brightness settings. White color becomes some weird purple-ish tint.
I have been using setCorrection(UncorrectedColor) and did not notice a hue change through even the lowest brightness levels. Now that I try setCorrection(TypicalLEDStrip), I can see the hue changes at very low brightness changes. I can see one issue that causes hue changes: the 8-bit storage of the RGB scale factors in the controller.hcomputeAdjustment() routine. The scale factors s0, s1, s2 that are used in the APA102/SK9822 global illumination calculation in the parent post above are given by scale*(Correction[k]+1)*(Temp[k]+1)/65536 where scale is the overall scale passed into show(), and Correction and Temp are the RGB color correction and color temperature factors. Here are some results using the TypicalLEDStrip correction:
Scale
Correction
Adjusted (s0,s1,s2)
255
(255,176,240)
(255,176,240)
128
(255,176,240)
(128,88,120)
64
(255,176,240)
(64,44,60)
32
(255,176,240)
(32,22,30)
16
(255,176,240)
(16,11,15)
8
(255,176,240)
(8,5,7)
4
(255,176,240)
(4,2,3)
3
(255,176,240)
(3,2,2)
2
(255,176,240)
(2,1,1)
1
(255,176,240)
(1,0,0)
Because the final scale factors are restricted to integer values, they cannot be kept in the same ratios as the numbers get small. Calling show(4) results in a more purple hue [→(4,2,3)] than show(255) [→(255,176,240)], while show(3) is reddish [→(3,2,2)], show(2) is even more red [→(2,1,1)], and show(1) is just red [→(1,0,0)].
This scaling procedure works fine for 8-bit RGB outputs, but APA102/SK9822's essentially have a dynamic range of 31*256 (~13 bits) that this procedure was not meant to handle (in its current form).
@extesy, @christophepersoz: When you say low brightness levels, are you talking about scales below around 8, where the finite resolution effects of the adjusted scales start to be significant?
Thanks for all this explanations.
What I did notice apply to all the brightness scale value corrected. The APA102C tends to be more reddish when setCorrection is applied.
I haven’t had the time to investigate more about this as I’m currently abroad for work.
Keeping you in touch when back home.
On 27 Sep 2018, at 23:20, cmsavage ***@***.***> wrote:
I have been using setCorrection(UncorrectedColor) and did not notice a hue change through even the lowest brightness levels. Now that I try setCorrection(TypicalLEDStrip), I can see the hue changes at very low brightness changes. I can see one issue that causes hue changes: the 8-bit storage of the RGB scale factors in the controller.h computeAdjustment() routine. The scale factors s0, s1, s2 that are used in the APA102/SK9822 global illumination calculation in the parent post above are given by scale*(Correction[k]+1)*(Temp[k]+1)/65536 where scale is the overall scale passed into show(), and Correction and Temp are the RGB color correction and color temperature factors. Here are some results using the TypicalLEDStrip correction:
Scale Correction Adjusted (s0,s1,s2)
255 (255,176,240) (255,176,240)
128 (255,176,240) (128,88,120)
64 (255,176,240) (64,44,60)
32 (255,176,240) (32,22,30)
16 (255,176,240) (16,11,15)
8 (255,176,240) (8,5,7)
4 (255,176,240) (4,2,3)
3 (255,176,240) (3,2,2)
2 (255,176,240) (2,1,1)
1 (255,176,240) (1,0,0)
Because the final scale factors are restricted to integer values, they cannot be kept in the same ratios as the numbers get small. Calling show(4) results in a more purple hue [→(4,2,3)] than show(255) [→(255,176,240)], while show(3) is reddish [→(3,2,2)], show(2) is even more red [→(2,1,1)], and show(1) is just red [→(1,0,0)].
This scaling procedure works fine for 8-bit RGB outputs, but APA102/SK9822's essentially have a dynamic range of 31*256 (~13 bits) that this procedure was not meant to handle (in its current form).
@extesy, @christophepersoz: When you say low brightness levels, are you talking about scales below around 8, where the finite resolution effects of the adjusted scales starts to be significant?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
Activity
cmsavage commentedon Sep 26, 2018
Attaching spreadsheet for looking at brightness and scale calculations.
GlobalBrightness_rollover.xlsx
kasperkamperman commentedon Sep 26, 2018
Just a quick chime in. I've compared global brightness on APA102 and SK9822 and they both really have a different behaviour. In my experience the SK9822 starts to shift Hue as well when changing the GBC parameter. I didn't test with the FastLED implementation, but with SmartMatrix. Some discussion: https://community.particle.io/t/smartmatrix-apa102-library-open-hardware-photon-apa102-shield/21562/67
extesy commentedon Sep 26, 2018
I didn't have SK9822 to test this on but I do have it now and will check the math soon. Thanks for the spreadsheet, @cmsavage!
extesy commentedon Sep 27, 2018
One thing I've noticed during the testing is that when
setCorrection(TypicalLEDStrip)is used (like in provided FastLED examples) the hue shift is very apparent on low brightness settings. White color becomes some weird purple-ish tint.christophepersoz commentedon Sep 27, 2018
cmsavage commentedon Sep 27, 2018
I have been using
setCorrection(UncorrectedColor)and did not notice a hue change through even the lowest brightness levels. Now that I trysetCorrection(TypicalLEDStrip), I can see the hue changes at very low brightness changes. I can see one issue that causes hue changes: the 8-bit storage of the RGB scale factors in thecontroller.hcomputeAdjustment() routine. The scale factorss0, s1, s2that are used in the APA102/SK9822 global illumination calculation in the parent post above are given byscale*(Correction[k]+1)*(Temp[k]+1)/65536wherescaleis the overall scale passed intoshow(), andCorrectionandTempare the RGB color correction and color temperature factors. Here are some results using theTypicalLEDStripcorrection:(s0,s1,s2)Because the final scale factors are restricted to integer values, they cannot be kept in the same ratios as the numbers get small. Calling
show(4)results in a more purple hue [→(4,2,3)] thanshow(255)[→(255,176,240)], whileshow(3)is reddish [→(3,2,2)],show(2)is even more red [→(2,1,1)], andshow(1)is just red [→(1,0,0)].This scaling procedure works fine for 8-bit RGB outputs, but APA102/SK9822's essentially have a dynamic range of 31*256 (~13 bits) that this procedure was not meant to handle (in its current form).
@extesy, @christophepersoz: When you say low brightness levels, are you talking about scales below around 8, where the finite resolution effects of the adjusted scales start to be significant?
christophepersoz commentedon Sep 27, 2018