New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add global brightness support for ADA102 and SK9822 #653

Merged
merged 2 commits into from Sep 20, 2018

Conversation

Projects
None yet
3 participants
@extesy
Contributor

extesy commented Sep 15, 2018

ADA102 and SK9822 controllers allow fine brightness control using lower 5 bits in the first byte of each pixel. Currently this byte is hardcoded to be 0xFF which means it always uses full brightness. FastLED does brightness scaling by dividing 8-bit values and it produces super inaccurate results with low brightness settings (values below 5 is almost unusable).

This pull requests makes full use of per-pixel brightness control to avoid scaling down actual color values and this preserves much better color accuracy at low brightness settings, creating pretty much "HDR mode".

I've tested this code using LOLIN D32 and ADA102 strip. I don't have SK9822 in my posession yet but its code was identical to ADA102 before my changes so I expect it to work as well.

To enable "HDR mode" uncomment new config parameter in fastled_config.h and set your strip brightness to some very low number. FASTLED_USE_GLOBAL_BRIGHTNESS=1 is faster but less accurate and FASTLED_USE_GLOBAL_BRIGHTNESS=2 is slower but more accurate.

Fixes #91 and #469.

Show resolved Hide resolved chipsets.h
@extesy

This comment has been minimized.

Show comment
Hide comment
@extesy

extesy Sep 17, 2018

Contributor

@focalintent Does this PR look better now?

Contributor

extesy commented Sep 17, 2018

@focalintent Does this PR look better now?

@focalintent focalintent merged commit 38105c6 into FastLED:master Sep 20, 2018

@R-OLE

This comment has been minimized.

Show comment
Hide comment
@R-OLE

R-OLE Sep 20, 2018

Users should be made aware that these two chips respond differently to changes made to these 5 bit brightness fields that might not be obvious at first, and for the APA102 has potential undesirable effects.

The APA102 brightness controls a (relatively) low frequency PWM, a frequency that can cause noticeable flicker for viewers that have relative motion to the LEDs. (ref 1) That is likely a reason that the default brightness value was set to full scale - to avoid this PWM effect.

The SK9822 has a totally different implementation of this brightness field, which appears to be based on a current regulation scheme, and does not suffer from flicker. (ref 2)

Also there has been some discussion about this brightness adjustment being scaled slightly differently between these chips, with a denominator of 31 or 32. (ref 3) In the same thread there was some concern that there may, or may not, be be some shifting of the color in the SK9822 when adjusting the brightness via GBC.


ref 1: Tim's Blog - APA102 aka “Superled”
ref 2: Tim's Blog - SK9822 – a clone of the APA102?
ref 3: SmartMatrix APA102 Library

R-OLE commented Sep 20, 2018

Users should be made aware that these two chips respond differently to changes made to these 5 bit brightness fields that might not be obvious at first, and for the APA102 has potential undesirable effects.

The APA102 brightness controls a (relatively) low frequency PWM, a frequency that can cause noticeable flicker for viewers that have relative motion to the LEDs. (ref 1) That is likely a reason that the default brightness value was set to full scale - to avoid this PWM effect.

The SK9822 has a totally different implementation of this brightness field, which appears to be based on a current regulation scheme, and does not suffer from flicker. (ref 2)

Also there has been some discussion about this brightness adjustment being scaled slightly differently between these chips, with a denominator of 31 or 32. (ref 3) In the same thread there was some concern that there may, or may not, be be some shifting of the color in the SK9822 when adjusting the brightness via GBC.


ref 1: Tim's Blog - APA102 aka “Superled”
ref 2: Tim's Blog - SK9822 – a clone of the APA102?
ref 3: SmartMatrix APA102 Library

@focalintent

This comment has been minimized.

Show comment
Hide comment
@focalintent

focalintent Sep 20, 2018

Member

This was discussed in the comments above on this PR -- this is also why this is off by default and why, for the most part I haven't exposed the brightness at all. If/when this gets exposed in documentation for users it'll have all these caveats and more.

This is mostly temporary anyway, as this will likely get revised in the wake of the RGB16 support where the mapping options may become more interesting.

Member

focalintent commented Sep 20, 2018

This was discussed in the comments above on this PR -- this is also why this is off by default and why, for the most part I haven't exposed the brightness at all. If/when this gets exposed in documentation for users it'll have all these caveats and more.

This is mostly temporary anyway, as this will likely get revised in the wake of the RGB16 support where the mapping options may become more interesting.

@extesy

This comment has been minimized.

Show comment
Hide comment
@extesy

extesy Sep 21, 2018

Contributor

@focalintent Speaking of RGB16 and RGBW - do you have any timelines for it in mind?

Contributor

extesy commented Sep 21, 2018

@focalintent Speaking of RGB16 and RGBW - do you have any timelines for it in mind?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment