Here a simple code I'm using to increment and decrement an active LED position and make it a color corresponding to its position on the strip. Yes, I realize the increment and decrement portions of code are written in two different ways, this was an attempt to see if calling .show() half as often would result in faster output (it doesn't).
#include <FastLED.h>
// How many leds in your strip?
#define NUM_LEDS 144
// For led chips like WS2812, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
// Clock pin only needed for SPI based chipsets when not using hardware SPI
#define DATA_PIN 9
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS); // GRB ordering is typical
FastLED.setMaxPowerInVoltsAndMilliamps(5, 500);
pinMode (8, OUTPUT);
digitalWrite (8, HIGH);
pinMode (10, OUTPUT);
digitalWrite (10, LOW);
//FastLED.setMaxRefreshRate(0);
}
void loop() {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(i, 255, 255);
leds[i-1] = CRGB::Black;
FastLED.show();
//FastLED.clear();
}
for (int i = NUM_LEDS; i > 0; i--) {
leds[i] = CHSV(i, 255, 255);
FastLED.show();
FastLED.clear();
}
}
The pinMode stuff is my hacky way of using three consecutive pins for power and data (don't judge me). Anyway, as you can see, I'm not using any delay in the code, and I'm still getting a super slow display on my strip. I need to display the "down and back" of 144 LEDs on a strip at approximately 2Hz (one end to the other, and back, being one period).
The data I've ready suggest that a 2.5ms delay is inherent in the fastLED library and/or necessary for the WS2812 chipset. Let's say that's true (because I haven't found a 2.5ms delay in the library as of yet), that still works out to a down-and-back (incrementing then decrementing through each position in a 144 LED strip) happening in about .7 seconds, which obviously wouldn't give me 2Hz, but would be above 1Hz, whereas what I'm actually measuring is more like a second-and-a-half.
Can someone point out where this extra delay is coming in, and how I might get it out?
Thanks a ton.