I am guessing the lerp8by8 function might be good for me here — can someone give me an example of how it might work? Or if anyone has any better ideas for linear interpolation between frames?
memset8(tempBuff, 0, sizeof(tempBuff));
memcpy8(tempBuff, buff, sizeof(tempBuff));
for (int t = 0; t < 32; t++) {
for (int i = 0; i < NUM_LEDS; i++) {
for (int x = 0; x < 3; x++) {
temp[i][x] = map(t, 0, 31, leds[i][x], tempBuff[i][x]);
}
}
//clear leds
memset8(leds, 0, sizeof(leds));
//overwrite leds with temp
memcpy8(leds, temp, sizeof(leds));
FastLED.show();
delay(1);
}
Sorry, I can’t exactly make out what you’re doing in this loop, but there are two ways I can think of to transition between frames: some form of lerp8by8 if you are doing palettes [and the palettes are “linear”] or the blend() function if you are blending CRGBs. Take a look at colorutils.h for blend() documentation!
OK, got it. I understand the code now: 32 frames of your “map()” function, without interpolation implemented yet.
I haven’t done any direct tests on lerp8by8 to understand edge cases (if any?) Your description is exactly what it should be doing and it could just be a code issue?
But really this sounds like a good candidate for using the CRGB structure and doing blends… In other words, change your leds array from byte[NUM_LEDS][3] to CRGB[NUM_LEDS].
(Also I’m not sure why you’re zeroing the LEDs before filling them again? But maybe you have a reason)
Yeah, the two lines should be equivalent.
But there are some strange cases where they could be different - for instance, depending on the declared type of your leds or tempBuff arrays, maybe the uncommented line is overflowing or has a sign error, but then gets cast back into a normal range & appears to be working. Whereas I believe lerp8by8 doesn’t get those, and pegs at 0 and 255.
CRGB structure has a lerp8 method too – just for kicks try
leds[i].lerp8(tempBuff[i], 128)
but sorry, I don’t get it - not sure why that would be resulting in 255. I’m using it in my code and it hasn’t had that problem. Give blend() a try, too…
Hi all, I’m interested in this as well, but can’t see a “blend()” fn anywhere. Searching the github repo for “blend()” alse returns empty. Have I missed something?
So this works great — except that for some reason it’s not doing all my LEDs — it’s missing off the last one. Even though the LED count is 24 (it does the same odd behaviour if I knock the number down to 20)
@James_Carruthers looks like you might want to try nblend(leds, tempBuff, 24, 127) to replace the entire code block you previously posted. (change 127 to "i’ to replace the more recent for loop one)