Closed pecirep closed 6 years ago
Hi,
i believe in the header must be defined new array like this
uint_16 pixelStart = {0, 10, 15, 21, 22}; uint_16 pixelEnd = {9, 14, 20, 21, 30};
now is clear where every light starts and ends on rings.
on lightEngine() function you have the loop that apply rgb data to the rings:
for (int j = 0; j < pixelCount / lightsCount ; j++)
{
strip.SetPixelColor(j + i * pixelCount / lightsCount, RgbColor((int)current_rgb[i][0], (int)current_rgb[i][1], (int)current_rgb[i][2]));
}
pixelCount / lightsCount
made the division to have equal pixels / light
you need something like (note the i variable is the light number here):
for (int j = 0; j < pixelEnd[i] - pixelStart[i] ; j++) // i will have a loop with the number of pixels in that light
{
strip.SetPixelColor(pixelStart[i] + j, RgbColor((int)current_rgb[i][0], (int)current_rgb[i][1], (int)current_rgb[i][2]));
}
i hope this code will work directly, but i possible to require some modifications because i miss something.
Marius.
Ahh, i provide example for WS2812, you use SK6812, so there are some changes to variables names, but logic remain the same.
Thank you, I got it working now. I only modified your suggestion slightly. I left out pixelEnd and just used:
uint16_t pixelStart[6] = {0, 24, 40, 52, 60, 61};
and
for (int j = 0; j < pixelStart[i+1] - pixelStart[i] ; j++) // i will have a loop with the number of pixels in that light
{
strip.SetPixelColor(pixelStart[i] + j, RgbwColor((int)current_rgbw[i][0], (int)current_rgbw[i][1], (int)current_rgbw[i][2], (int)current_rgbw[i][3]));
}
because your code uses j < pixelCount
so having an array for the ending pixel would make the last pixel in each ring not light up (when j becomes 23 for example, that pixel is skipped and the loop is exited)
so I figured I would just use the starting pixel for each ring and add 61 as a pixel that does not exist but this is only accessed in pixelStart[5+1] - pixelStart[5] since lightsCount is still only 5, not 6.
I'll leave this here just in case someone else needs to do this. Thanks Marius!
I have a Lamp with 4 LED rings (24LEDs, 16, 12, 8) and one single LED in the center all connected to each other, so 61 LEDs in total. I would like to split them up into the 5 respective strips, so 1 "light" for each one. But seeing as I can only define how many LEDs I have and how many sections there are, I am not sure how I should achieve this. I have looked at your code and as far as I can see the individual pixels are never assigned to a specific lamp, there's just always a function that calculates it.
Do you have any suggestion how to achieve this? I have moderate experience with arduino code so I can do it myself if you can point me in the right direction or at least tell me which lines I should look at.
Thanks in advance!