These are chat archives for Makuna/NeoPixelBus

18th
Dec 2015
Michael Miller
@Makuna
Dec 18 2015 07:18
Pointers? Dithering by pulses two different levels or by blending colors?
sticilface
@sticilface
Dec 18 2015 11:21
ok, so i meant i2s... just spent an hour searching for the bloody thing again.
here is the link
his comments are "// This inspired me to create an ESP8266 library for the Arduino IDE
// I've added temporal dithering & gamma-correction
// for a 'more natural' light intensity profile."
here is the magic bit...
```
  // for every pixel in the input-array
  // - get the pixel value (either R,G, or B)
  // - for every dithered buffer 
  //   get the gamma-corrected output value
  // - and transform into i2s nibble

  for(b=0; b<NUM_RGB_BYTES; b++)
  {
    pixelbyte = *buffer++;

    for(i=0; i<WS2812_DITHER_NUM; i++)
    {
      gammabyte = gamma_dither[i][pixelbyte];
      *(i2s_ptr[i]++) = bitpatterns[ (gammabyte & 0x0f) ];
      *(i2s_ptr[i]++) = bitpatterns[ (gammabyte>>4) & 0x0f ];
    }
  }
I won't lie... not so sure what is going on under the hood there!
Michael Miller
@Makuna
Dec 18 2015 17:56
Ok, they are dithering overall brightness (gamma) at the expense of color accuracy.
Basically, your have three actual LEDs in each pixel (R, G, B). If you want to animate from <20,20,20> to <21,21,21> you have a step that does each color, so it would be <20,20,21>, <20,21,21>, and then finally <21,21,21>. So the overall brightness was smoother but color will go slightly blue, then aqua, before correcting to true color.
It seems like a new blend function that does this could be done easily enough.
The small color variations should be noticeable as long as the delta offset is keep small.
sticilface
@sticilface
Dec 18 2015 18:55
ah ok. i managed eventually to find the value of the WS2812_DITHER_NUM, which can be set to 8. How does that work?