Is it possible to have a flag to disable gamma correction for Neopixels

Issue #194 resolved
Simon Walters created an issue

Hi John / Bernat

I’ve got a Neopixel Snowman attached to a Microbit V2 but I’d like to be able to turn the brightness down

But, I run into issues with the gamma correction at low brightness levels and colours don’t display properly

Could you add a flag or something to let us disable gamma correction if required please? 🙂

Merry Christmas

Simon

Comments (6)

  1. John Maloney repo owner

    NeoPixels are intensely, eye-hurting bright. In addition, at higher brightness levels they more current than many microcontrollers (and especially the micro:bit v1) can supply. For both those reasons, MicroBlocks only uses the lowest part of the NeoPixel brightness range for each channel (values [0..40]). However, to be consistent with the common RGB888 colors that many people know (and which are used by the MicroBlocks TFT display library), NeoPixel colors are specified as RGB888 and their limited range of [0..40] is spread across the range [0..255] using a non-linear gamma curve.

    What this means for your Neopixel Snowman is that the lowest color channel value that turns on a NeoPixel (around 40, I believe) is actually the dimmest that a NeoPixel can be. That’s a hardware property that can’t be changed.

    If you are specifying colors with the “color RGB”block, it is slightly confusing that small changes in a color channel value – for example changing red from 50 to 51 may make no difference. I could imagine adding a block specifically for NeoPixels that allowed you specify RGB values in the range 0 to 40 directly, without gamma correctly. That would give you more precise control since even a small incremental change (e.g. changing red from 2 to 3) would result in an actual NeoPixel color change.

    Would such a block be helpful?

  2. Simon Walters reporter

    Yes - I’d be quite happy to have some method of more precise control even if it was limited for current reasons. :)

  3. John Maloney repo owner

    Here’s a library with a block allowing you to set NeoPixel colors more directly with RGB ranges of 0-40.

    NeoPixelColor.ubl

    If you find this block useful let us know and perhaps we’ll include it in the NeoPixel library.

  4. Log in to comment