Skip to content

Add global brightness support for ADA102 and SK9822 - #653

Merged
focalintent merged 2 commits into
FastLED:masterfrom
extesy:hdr
Sep 20, 2018
Merged

focalintent merged 2 commits into
FastLED:masterfrom
extesy:hdr

Conversation

@extesy

@extesy extesy commented Sep 15, 2018

Copy link
Copy Markdown
Contributor

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.

Comment thread chipsets.h Resolved
@extesy

extesy commented Sep 17, 2018

Copy link
Copy Markdown
Contributor Author

@focalintent Does this PR look better now?

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

R-OLE commented Sep 20, 2018 •

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

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

extesy commented Sep 21, 2018

Copy link
Copy Markdown
Contributor Author

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

@PhotonicVelocity

Copy link
Copy Markdown

@extesy When using FASTLED_USE_GLOBAL_BRIGHTNESS=1, for certain brightness values the brightness of the LEDs drops to almost all the way off. This causes a flickering when smoothly changing brightness values. The values at which this happens are: 8, 16, 24, 33, 41, 49, 66, 74, 82, 99, 107, 132, 140, 165, and 198. Which is a very strange sequence...

Is this a known issue (part of your "less accurate" statement)? Changing the parameter to 2 fixes this but this seems like a bug and I'd like to use the fastest code possible.

@extesy

extesy commented Jan 10, 2019

Copy link
Copy Markdown
Contributor Author

@burgerga123 See #657

@LukasAV

LukasAV commented Dec 20, 2019

Copy link
Copy Markdown

Hi, I could not quite figure out how to use the brightness control for the APA 102 LEDs.

Are these brightness bits only used for internal calculation or should I control them using FastLED.setBrightness(), which was initially only meant for setup and not effect brightness?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

control global brightness on APA102 (and other chip supporting it)

5 participants