Skip to content

pixel value of 1 not visible when dithering is set to 0.  #86

Closed

Description

@kasperkamperman

Since I'm experimenting with different dither algorithms (like https://github.com/raplin/HexaWS2811) I've turned dithering off with FastLED.setDither(0). I've found that when you do this a value of 1 doesn't get visible on my strip (tested it both on APA102 and WS2812b).

See my test code on Gist:
https://gist.github.com/kasperkamperman/72a6cb11e1bf2db2ff6a

Activity

  1. focalintent commented on Oct 26, 2014

    @focalintent
    Contributor

    This is a side effect of how scale8 works - mark and I are very aware of that, but given that it would nearly double the CPU time taken by scale8 to fix, (cycles that we don't have available on certain AVR implementations - and we want behavior to be consistent across platforms) - we're leaving it alone for now.

    scale8 is (scale*value>> 8) - 1 * 255 is 255, right shift that 8 and you get 0.

  2. kasperkamperman commented on Oct 26, 2014

    @kasperkamperman
    Author

    Sorry, I think I don't get your explanation line completely and I would like to understand it to find a work around.

    scale8 is (scale*value>> 8) - 1 * 255 is 255, right shift that 8 and you get 0.

    Please correct me if my thinking is wrong:
    I think that the default scale the full range so 255.
    So that would mean 255*1 >> 8 = 0
    But 0 - 1 is not possible with unsigned numbers?

    Is there scaling involved when writing RGB colors to the led output?
    Do I understand it right that when dithering is turned off both a value of CRGB(0,0,0) and CRGB(1,1,1) give an output of 0?

    What is the value then of CRGB(2,2,2) is it the most minimum light value possible?
    So would that mean that the led range that can be controlled is actually from 1 (as 0) to 255 (as 254)?

    Because then I could map the dithering table from 0-255 to 1-254.

  3. focalintent commented on Oct 26, 2014

    @focalintent
    Contributor

    Yes - for the global brightness - we scale the RGB values before writing them out - and this is done independently of the dithering - and yes, CRGB(2,2,2) is going to be the most minimum light value for now.

    When brightness is set to 255 your values are going to be:

    0,0,1,...253,254

    I do have some thoughts on how to fix this long term - but I hate burning the cycles on avr. (That said, over the next 6 months, we're going to split functionality between avr and arm because we're starting to want to do things that just won't be possible on avr).

  4. kasperkamperman commented on Oct 26, 2014

    @kasperkamperman
    Author

    Ok. Thanks for the explanation. I suppose that if I don't make a call to
    setBrightness, it's just 255.

  5. focalintent commented on Oct 27, 2014

    @focalintent
    Contributor

    Yeah - the default brightness is 255. (in an ideal world, the logic would be changed to):

    if(scale<255) { value *= (scale+1); value >>= 8; } return value;

    that conditional adds more than a few cycles of overhead, sadly and I haven't had the time to dig through the asm/implementation to get it as close as possible to the performance of scale8 itself.

  6. kasperkamperman commented on Oct 27, 2014

    @kasperkamperman
    Author

    Where does this scaling happen? Do you use the scale function in lib8tion? Maybe I can modify it in my own copy to see if I'm satisfied with the result on the Teensy?

    I've checked led_sysdefs.h and there inline scale is mentioned however this seems commented (so not in use). Digging a bit in the code it seems that the actual scaling is called in loadAndScale?

    I think it might be good to mention the "0,0,1,...253,254" behavior on the FastLED design or temporal dithering documentation pages in the wiki.

  7. focalintent commented on Oct 27, 2014

    @focalintent
    Contributor

    It's not really either design or dithering - i'll find a place to mention it on there, though, as it isn't the first time this has come up.

    If you want to make the changes yourself - change the implementation of the scale8 function in the file lib8tion.h

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions