Reset Neopixel strip brightness

I need a strip of LEDs to light up in sequence, then reset entirely to zero and light up in sequence again.

I rewrote the setPixelColor function in the .cpp file to allow brightness as a third input and thus setting brightness individually for each pixel, like so:

void Adafruit_NeoPixel::setPixelColor( uint16_t n, uint32_t c, uint16_t brightness) {
 uint8_t
      r = (uint8_t)(c >> 16),
      g = (uint8_t)(c >>  8),
      b = (uint8_t)c;

  setPixelColor(n, (brightness*r/255) , (brightness*g/255), (brightness*b/255));
}

and consequently simply doing a strip.Brightness(0) command in either the loop overwrites all other brightness commands.

This is what the function looks like:

void setEvent(uint16_t dom, uint16_t string, float color, float brightness) 
{
    for(uint16_t i = 1; i < strip.numPixels(); i++) 
    {
      delay((color-4000)/2000);
        strip.setPixelColor( string * 30 + dom, Wheel((color - 4000)/50), 85*brightness);
    strip.show();
  }
}

And I run events through it like so:

void loop() 
{
  setEvent(11,   3,   4361.61879622,    2.2939910099);
  setEvent(2    , 1 , 4561.27373708 ,  1.6569421301);
  setEvent(27    , 4 , 8647.87475863 ,  2.7236235736);
  setEvent(14     ,4 ,10709.11274392  , 0.3108354715);
  setEvent(21    , 3 ,11697.47331108  , 0.3242952556);
  setEvent(20   ,  4 ,12127.16102035  , 2.7263199085);
  setEvent(5   ,  1 ,12437.58417103  , 2.6779749249);
  setEvent(26   ,  4 ,13025.89209964  , 0.7115367711);
  setEvent(1   ,  1 ,13138.88139434  , 1.2490356125);
  setEvent(26   ,  0 ,13782.74217978  , 2.3223196251);
  setEvent(13   ,  3 ,14278.41352928  , 0.9805144294);
}

The nearest solution I’ve come up with is to simply run the function twice for each coordinate with the brightness argument set to 0, but this results in the pixels going off one by one, rather slowly. Is there any way to zero out the whole strip without setting it to zero for every iteration of the loop?

Is there any way to zero out the whole strip without setting it to zero for every iteration of the loop?

Why not create another version of setEvent() that does NOT delay() and does not call show() in the for loop?

Doing that seems to either have no effect (lights remain lit) or it turns them off in the same sequence they turned on, which is a bit too slow for what i need

Doing that seems to either have no effect (lights remain lit) or it turns them off in the same sequence they turned on, which is a bit too slow for what i need

Sure be nice to see all of the code...

Sure

#include <Adafruit_NeoPixel.h>
#include <avr/power.h>

#define PIN 6

Adafruit_NeoPixel strip = Adafruit_NeoPixel(148, PIN, NEO_GRB + NEO_KHZ800);

void setup() 
{
    strip.begin();
    strip.show(); // Initialize all pixels to 'off'
}



void loop() 
{
  setEvent(11,   3,   4361.61879622,    2.2939910099);
  setEvent(2    , 1 , 4561.27373708 ,  1.6569421301);
  setEvent(27    , 4 , 8647.87475863 ,  2.7236235736);
  setEvent(14     ,4 ,10709.11274392  , 0.3108354715);
  setEvent(21    , 3 ,11697.47331108  , 0.3242952556);
  setEvent(20   ,  4 ,12127.16102035  , 2.7263199085);
  setEvent(5   ,  1 ,12437.58417103  , 2.6779749249);
  setEvent(26   ,  4 ,13025.89209964  , 0.7115367711);
  setEvent(1   ,  1 ,13138.88139434  , 1.2490356125);
  setEvent(26   ,  0 ,13782.74217978  , 2.3223196251);
  setEvent(13   ,  3 ,14278.41352928  , 0.9805144294);
}

void setEvent(uint16_t dom, uint16_t string, float color, float brightness) 
{
    for(uint16_t i = 1; i < strip.numPixels(); i++) 
    {
      delay((color-4000)/2000);
        strip.setPixelColor( string * 30 + dom, Wheel((color - 4000)/50), 20*log(85*brightness));
    strip.show();
  }
}

void dimEvent(uint16_t dom, uint16_t string, float color, float brightness) 
{
    for(uint16_t i = 1; i < strip.numPixels(); i++) 
    {
        strip.setPixelColor(0,0);
        strip.show();
  }
}

uint32_t Wheel(byte WheelPos) 
{
    WheelPos =  255 - WheelPos;
  if(WheelPos < 85)
  {
        return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
    else if(WheelPos < 170)
  {
      WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  else
  {
      WheelPos -= 170;
    return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  }
}
void dimEvent(uint16_t dom, uint16_t string, float color, float brightness) 
{
    for(uint16_t i = 1; i < strip.numPixels(); i++) 
    {
        strip.setPixelColor(0,0);
        strip.show();
  }
}

It would really
help if you used
Tools + Auto Format
so that your
code didn’t
jerk around.

strip.show() takes time. Calling that for each pixel will be slow. Set all the colors, THEN call show().

Actually calling the function might prove useful.

By the way, why does the function take 4 arguments, and use none of them?

Oops, I forgot to delete that. It was just something I tried that didn't work. I'll try messing with strip.show()...