Hi @ScruffR, here we are again under a clear sky full of great DOTSTARs…
Starting from your above sketch, remotely controlling DOTSTARS with a Particle function, I modified it to set the colour and brightness of individual LEDs for my “status panel” (to be connected to a Raspberry Pi)
Below sketch “kinda works”, but not fully yet:
Colour and intensity of the leds is OK, but not the correct pixel Nr. is transmitted to the strip.
( See my comment in the loop() )
const int LEDCOUNT = 70;
uint32_t pxBuffer[1 + LEDCOUNT + LEDCOUNT/16 + 1];
uint32_t setAPA102Color(int px, uint8_t r, uint8_t g, uint8_t b, uint8_t brightness = 31);
for (int px = 0; px < LEDCOUNT; px++)
pxBuffer[px] = 0x000000E0;
setAPA102Color(-1,0,0,0,31); // Initializing the strip...
// TEST: Alternate the colours for 3 LEDs to RED and BLUE...
// ATTENTION: I expect #40,41 & 41 to respond, but instead, #0,1,2 respond... Troubleshoot!
uint32_t setAPA102Color(int px, uint8_t r, uint8_t g, uint8_t b, uint8_t brightness)
uint32_t color = 0;
color |= (brightness << 0) | 0xE0;
color |= (b << 8);
color |= (g << 16);
color |= (r << 24);
pxBuffer[px] = color;
SPI.transfer(pxBuffer, NULL, sizeof(pxBuffer), NULL);
Thanks for any tip which can point me in the right direction again…
BTW: Sorry for the blocking “delay()” commands again…