Hi Ace!
Hmm,... I do not recall "#define BRIGHTNESS" in the original twinkle code, but I could be wrong.
I do know that NeoPixel does not have a global brightness function, but FastLED (the library I'd use) does: setBrightness().
So if you switched to FastLED then you could call that function any time. Also note that FastLED is a faster and more mature library for controlling LEDs.
Delay vs Millis; Millis would allow more accurate time, and is supposed to be non-blocking (if you write the code correctly). I have to admit that I have not really used it as a replacement for Delay though. So I'm not sure how suitable it will be for your purpose.
I found this article which gives a good explanation - I hope it's helpful.
Using a potentiometer for speed is most certainly possible.
What I'd do, and I'm not saying this is the only and most correct solution, is write your own "delay()" function.
In that function you'd read the potentiometer value and use it, or multiply the indicated delay with that and then do the actual delay.
Something like this:
#define PotPin 2
...
void myDelay(unsigned long milliseconds) { // milliseconds = max delay
int PotVal;
PotVal = analogRead(potPin); // analogRead reads a value 0 ... 1023
delay( (PotVal * milliseconds)/1023 );
}
I have not tested this code, but it could be a good start. You'd call the function like the delay(X) function: myDelay(X).
This may not respond instantly and smoort, again I have not tested this.
To reduces the "pause" in Twinkle, you'll have to keep in mind that each time the function is called it blanks all LEDs, and after that a count number of times does the effect, and then executes a Delay.
So to speed things up, you could do this;
void Twinkle(byte red, byte green, byte blue, int Count, int SpeedDelay, boolean OnlyOne) {
setAll(0,0,0);
for (int i=0; i<Count; i++) {
setPixel(random(NUM_LEDS),red,green,blue);
showStrip();
delay(SpeedDelay);
if(OnlyOne) {
setAll(0,0,0);
}
}
// delay(SpeedDelay); // Remove this delay
}
Hope this is helpful 