FastLED with APA102 leds not working

Anyone using these and got it working with a Photon?

I’ve used lots of APA102 strips with Arduinos and all works well.

Tried the simple example(blink, from the online lib) on Photon but it appears to do nothing except randomly light a couple of LEDS when it starts up. I notice the code won’t compile if I use any led types with a clock pin - which is what these strips need. Non clock pin types compile ok.

The library notes that for all platforms ‘some examples won’t compile’ but it does not say which and I can find no
mention of this anywhere.

TIA

@steeley, take a look at this topic:

:smile:

1 Like

Thanks - looks like that might have potential, Although it doesn’t work for me, Despite using the exact instructions on giithub.

I think I’ll just stick with the Arduino boards for my LED stuff as that works fine for now.

What are the exact features you need of the FastLED lib for your APA102 LEDs?

Since their protocol is rather close to what SPI does, you can take advantage of the DMA capabilities of that interface and it’s dead easy to run these LEDs off A3/A5 on the Particles.

Thats a good point - could go via SPI.
Don’t need anything special - just had a load of existing FastLED based code that I thought I might use.

I had no trouble using the library called “dotstar.”

If it helps, this is how I control my APA102 strips

#define LED_COUNT  (600)
uint32_t AP102[LED_COUNT + (LED_COUNT/16 + 1) + (1)];  // LEDs + (at least 1 leadout clock bit per 2 LEDs) + (extra byte as lead in for next round)
uint8_t  brightness = 31;
volatile bool dmaReady = true;

void cbDMA() {
  dmaReady = true;
}

void setup() {
  SPI.begin();
  SPI.setClockSpeed(30, MHZ); 
  SPI.setBitOrder(MSBFIRST);
  ...
}

void loop() {
  //memset((void*)AP102, 0, sizeof(AP102)); // to clear all pixels fast

  // just a dummy sample to show how to set the pixels
  for (int i=0; i < LED_COUNT; i++) {
    AP102[i] = 0xE0 | b << 24 | g << 16 | r << 8 | brightness;
  }

  if (dmaReady) {
    dmaReady = false;
    SPI.transfer(AP102, NULL, sizeof(AP102), cbDMA); // use NULL for callback for sync operation 
  }
}

And that’s faster than the dotstar library :wink:

Thanks - I’ll give it a go.