So, I am able to do this manually, and I will give my example of how I have achieved the result, but as in most cases there is sometimes a better and easier way to achieve the same result.
I am using shiftbrites first of all, and the base code I have received from Garrett at Macetech is as follows.
void NewKittFill(int dir, int FillSpeed, int FadeSteps, int red, int green, int blue) {
for (int i = 0; i < NumLEDs; i++) {
KittFadeFactor = ((KittFakeArray(KittTotalSize - FillCount + i)) * (FadeSteps - FadeCount - 1) + (KittFakeArray(KittTotalSize - FillCount - 1 + i)) * (FadeCount)) / (2 * FadeSteps);
LEDChannels[i][0] = (long) red * KittFadeFactor / 1023;
LEDChannels[i][1] = (long) green * KittFadeFactor / 1023;
LEDChannels[i][2] = (long) blue * KittFadeFactor / 1023;
So as most of you know this creates a fade among all the LEDs as defined in LEDChannels. What I was desiring was to have individual control of each shiftbrite as for the color. so if I wanted the first to be red, the second green, and the third blue I could control each one. the problem with the above code is that when I call NewKittFill, I only specify one RGB setting and it writes it to all LED's.
This is where I have found a solution but a much harder one.
What I have done is the following:
void NewKittFill(int dir, int FillSpeed, int FadeSteps, int r1, int g1, int b1, int r2, int g2, int b2, int r3, int g3, int b3, int r4, int g4, int b4) {
int KittFadeFactor = 0;
int revIndex;
for (int FillCount = 0; FillCount < (KittTotalSize+NumLEDs); FillCount++) {
for (int FadeCount = 0; FadeCount < FadeSteps; FadeCount++) {
for (int i = 0; i < NumLEDs; i++) {
KittFadeFactor = ((KittFakeArray(KittTotalSize - FillCount + i)) * (FadeSteps - FadeCount - 1) + (KittFakeArray(KittTotalSize - FillCount - 1 + i)) * (FadeCount)) / (2 * FadeSteps);
if (dir == 0) {
LEDChannels[0][0] = (long) r1 * KittFadeFactor / 1023;
LEDChannels[0][1] = (long) g1 * KittFadeFactor / 1023;
LEDChannels[0][2] = (long) b1 * KittFadeFactor / 1023;
LEDChannels[1][0] = (long) r2 * KittFadeFactor / 1023;
LEDChannels[1][1] = (long) g2 * KittFadeFactor / 1023;
LEDChannels[1][2] = (long) b2 * KittFadeFactor / 1023;
LEDChannels[2][0] = (long) r3 * KittFadeFactor / 1023;
LEDChannels[2][1] = (long) g3 * KittFadeFactor / 1023;
LEDChannels[2][2] = (long) b3 * KittFadeFactor / 1023;
LEDChannels[3][0] = (long) r4 * KittFadeFactor / 1023;
LEDChannels[3][1] = (long) g4 * KittFadeFactor / 1023;
LEDChannels[3][2] = (long) b4 * KittFadeFactor / 1023;
Then in my loop I call it as such:
NewKittFill(0,rate,8, 1023,0,0, 1023,100,0, 1023,200,0, 1023,400,0);
This is ok if I am using 1-10 LED's but if I were to do this with anymore than ten LED's it would probably drive me insane. Im sure there has to be a better way to do this, but I am not sure how. Can I make a function for each RGB LED and then somehow call each one in the NewKittFill function?
Im not looking for anyone to write anything for me, I would just like if someone could point me in the right direction.
Thank you for your time:
Jeremy