I’d like to say i’m a fastspi user, but i really don’t get my head around the maths and the functions.
I’m using the Fast_SPI2, and i’m using the input from an adxl345 accelerometer to show a single led on a strip of ws2811
i can map the data from the adxl345 to be a number between 0 and 32 (the number of pixels on the ws2811 strip.
but i can’t see how to light a specific led.
memset(leds, 255, NUM_LEDS * sizeof(struct CRGB));
LED.showRGB((byte*)leds, NUM_LEDS);
delay(20);
is what i’m messing around with!
The library puts out rgb data for all the LEDs in one shot - which is why you have an array of rgb objects, one per pixel, so, to set the first pixel values you would say:
leds[0].r = 255;
leds[0].g = 0;
leds[0].b = 0;
That sets pixel 0 to red (setting blue and green to 0 and red to max brightness). Then call show giving it the entire led array.
For another example, to make the fifth pixel white at half brightness:
leds[4].r = 128;
leds[4].g = 128;
leds[4].b = 128;
Why 4? In C arrays are zero indexed - so the first element is the zeroth element, the second element is at index 1, etc…
To sum up - your work is going to consist of “set all the LEDs to the values I want for this frame” then “show the frame” and going back and forth.
Does that help as a start?
ahh man… no wonder i’m so confused… that helps loads!
The memset is a shortcut to make all the values 255 in one shot.
The final release of the library will include documentation and a lot of annotated examples which should help things as well.