I deleted my previous post in favor of this one.  I managed to contain

I deleted my previous post in favor of this one. I managed to contain the smoke inside of my head today (as opposed to billowing out of my ears.) I managed to get this far … short and sweet.

#include “FastSPI_LED2.h”
#define NUM_LEDS 32

// I just picked these for their location on the DIP package
#define DAT_PIN1 A0
#define CLK_PIN1 A1

CRGB leds[NUM_LEDS];

void setup() {
delay(500);
FastLED.addLeds<WS2801, DAT_PIN1, CLK_PIN1, BGR>(leds, NUM_LEDS);
}

class patternsClass{
public:
void singlePixel() {
for (int pixel = 0; pixel < NUM_LEDS; pixel++) {
leds[pixel] = CRGB::Blue;
FastLED.show();
delay(50);
leds[pixel] = CRGB::Black;
}
}
};

void loop() {
patternsClass patternObj;
patternObj.singlePixel();
}

Now on to my questions:
a) I know how I can define a second string with .addLeds() using another set of DATA and CLOCK pins. But, how would I reference that? Normally when I declare multiple strings, I end up with leds1, leds2, etc., etc. How would the singlePixel() function know what string to run on?

b) Right now that function is what I would call a ‘blocking function’ in that it won’t exit till the for loop is done. That’s bad. I need to be able to do other stuff while it’s running. Sort of like the Blink without Delay setup … So it has to be rewritten somehow. Is it just as simple as what I was doing originally, with a millis() check?

I’ll answer the first question for a bit (and totally skip the second question for now, as my kid seems to be sick, etc.). Anyway: don’t have your patterns write directly to THE “leds” array. Instead, have the pattern functions take an argument that’s a pointer to the start of whichever pattern array you want them writing to. In plain C, you might say:

CRGB leds1[NUM_LEDS_1];
CRGB leds2[NUM_LEDS_2];

// other setup

void singlePixel( CRGB* pixels, int pixelCount) {
for (int i = 0; i < pixelCount; i++) {
pixels[i] = CRGB::Blue;
FastLED.show();
delay(50);
pixels[i] = CRGB::Black;
}

You could then call it with:
singlePixel( leds1, NUM_LEDS_1);
or
singlePixel( leds2, NUM_LEDS_2);
and it would write into whichever pixel buffer you pass in as an argument.

Since you’re making a C++ class out of this, you could have the pointer to the pixel buffer and the pixel count be member variables:

class patternsClass{
private:
CRGB* mPixelBuf;
int mPixelCount;
public:
// define a constructor that lets you specify
// the pixel buffer and length
patternsClass( CRGB* buf, int len) {
mPixelBuf = buf;
mPixelCount = len;
}
void singlePixel() {
for (int i = 0; i < mPixelCount; i++) {
mPixelBuf[i] = CRGB::Blue;
FastLED.show();
delay(50);
mPixelBuf[i] = CRGB::Black;
}
}};

You’d then use that this way:

void loop() {
// first, run a pixel down led strip 1
patternsClass patternObj1( leds1, NUM_LEDS_1);
patternObj1.singlePixel();

// then run a pixel down led strip 2
patternsClass patternObj2( leds2, NUM_LEDS_2);
patternObj2.singlePixel();
}

[WARNING: I haven’t even compiled this code, just typed it here.]

I’ll leave the “how to interleave the control flow of two patterns” to someone else this evening, as I have to go attend to other matters for a bit.

Thanks Mark. I hope the kiddo’s feeling better. I’ll try fiddling with this some more later today …

Great, got both versions compiled and working, mine with the changes you suggested, and yours, almost verbatim (just needed to add the appropriate setup lines.) I don’t entirely understand your example but I’ll dig around and see if i can figure it out.

Next step for me is figuring out how to rewrite it so there’s no delay or blocking going on. This I can do in a non-class setup … this is going to require some experimenting and tinkering.