Questions about NeoPixel

Issue #420 resolved
yx feng created an issue

Hi John, when I use NeoPixel, I find that the strip brightness is very dim, when I use Adjust Brightness, it doesn't seem to work, when I use other platforms, the strip brightness will be very bright, what is the reason for this?
Thank you for your help, have a nice life!

Comments (8)

  1. John Maloney repo owner

    That is a very deliberate design choice.

    NeoPixel strips at full brightness are so bright they are difficult to look at directly. Worse, they consume a lot of power. In one of our early workshops, we had trouble with the microcontroller "browning out" and resetting whent a 30 NeoPixel strip was set to full brightness white. Unfortunately, when that happened the servo connected to that microcontroller went crazy and destroyed the student's delicate project.

    MicroBlocks now uses only the first part of total NeoPixel brightness range and we have not had a repeat of the brownout problem.

    Do you actually need for the NeoPixels to be brighter or are you just curious?

  2. yx feng reporter

    Hi John, I want to use MicroBlocks as the programming platform for the hardware part of our city sandbox, and I'm dealing with a simulated city light sandbox, and I found that when I use NeoPixel, I can't achieve the desired effect due to the low brightness (the strip of lights we hid underneath, and we did a soft-lighting treatment), do you have any good suggestions from your side?

  3. John Maloney repo owner

    Well, you could build a customized version of the firmware that uses the full brightness range. I think it would just be a one-line change.

    You can use either the Arduino IDE or the PlatformIO to build and install the firmware.

    If you want to do that, let me know and I can point you to the line you'd need to change.

  4. John Maloney repo owner

    Change the gamma() function in outputPrims.cpp in the vm folder to:

    static inline int gamma(int val) {
        // This function computes the n^3 gamma curve, where n is a brightness in the range 0.0..1.0,
        // with the result scaled to the integer range 0..neoMax, but it uses only integer arithmetic.
        // The input is assumed to be an integer in the range 0..255, and what's computed is the
        // neoMax * ((val / 255) ^ 3). Since (val / 255) has the range 0.0 and 1.0, ((val / 255) ^ 3)
        // will also be in the range 0.0..1.0, and that is scaled to 0..neoMax.
        // neoMax determines the max brightness (and power draw!) of each NeoPixel color channel,
        // which is about (neoMax / 255) * 20 mA per color channel.
    
        return val; // use original value
    //  const int neoMax = 40;
    //  const int divisor = (255 * 255) / neoMax;
    //  return ((val * val) / divisor) & 0xFF;
    }
    

    The firmware build/install instructions are in the README.md file at the top level of this repository.

  5. yx feng reporter

    Thank you very much, the changes have helped my project, I'll keep watching for any other issues next!

  6. Log in to comment