OK, more questions - perhaps the gitter would be better for these, but whatever. I’m wanting to work on changing the color of an entire panel (23 cols x 10 rows, probably sk9822, so plenty fast) from X to Y. I don’t just want it to all fade at once, though - I want the top-left pixel to start fading (should complete fading in about 0.5-1s), then the pixels next to it, the ones next to them, etc. So the fade spreads like a “wave” across the matrix. Ideally this wave hits the top-right (row 1, col 23) and the bottom-left (row 10, col 1) pixel at the same time, about 0.25-0.5s after the wave initially starts. I’m really not sure the best way to implement this - as I thought about it, I ran into another potential problem: If I change from X to Y, then start changing from Y to Z before the first transition (X->Y) is completed, I would like for X->Y to continue running while Y->Z catches up. If it helps, I’m running on an ESP8266 - hopefully that’s got enough RAM to handle everything. (EDIT: Hoping for 30FPS or so, but more than that would be even better!)
If I understand correctly, it would be a diagonal sort of grad that wipes across the matrix?
Here’s something you can try and see how it looks. There might be a accurate way to do this, but hopefully this would be relatively straight forward to calculate.
Think of it as two grads, one horizontal, and one vertical. When you add these together you’ll get kind of a grad on an angle. (A bit less of straight line near the start and end but maybe it will look fine. Have to try it!) By shifting the two grads (horizontal one to the side, and vertical one down) the resultant angled grad will move from one corner toward the opposite.
This image first shows the two grads at “50% shifted over”, and then about “75% shifted over”.
@marmil That looks about right, actually! Do you have an pseudocode or an example link? I’ll see if I can adapt this. Additionally, I’ll have to work on keeping 1 transition going while I start another transition.
Thanks!
There’s a variety of ways the grad might be done and “moved”. Some ideas to explore could include: arduino’s map function, an array or table of predefined values, maybe one of FastLED’s wave functions (if triwave8 isn’t used you might get an interesting smoothing effect at the start/end), perhaps an animated gradient color palette, or maybe it’s just calculated on the fly.
As you work out a method, I would recommend using the serial monitor for observing numbers initially.
Probably start by doing each grad separately too.
Might be useful:
//add two numbers together, clamping to max 255
uint8_t valueSum = qadd8( valueA, valueB);
//multiply two numbers together, clamping to max 255
uint8_t valueMul = qmul8( valueA, valueB);
Also:
nscale8, nscale8_video, fadeLightBy, fadeToBlackBy
See: http://fastled.io/docs/3.1/
Thanks, Marc! I’m going to look into that - since I’m using the SK9822, I may have to do some refactoring to use the 5-bit “global brightness” option. Maybe change things from RGB to RGBA - but we’ll see how it turns out . Thanks!
I wouldn’t think global brightness would be useful in this case as that would effect all pixels, where as you’re wanting to effect specific pixels in a very specific way.
When you get some code going if you’d like to share or have questions please put it on http://gist.github.com and share the link. G+ here is not good for sharing large amounts of code.
Sorry, Marc - I wasn’t very clear. “Global Brightness” can apply to individual LEDs on the SK9822s (like APA102s) and I’ll want to use that to maintain color depth when my LEDs are dim. The main panel is being used just for lighting in general, but I want changes in lighting to “ripple” across it in the wave I’ve described. Regardless, this has given me a really good direction to work/search in, so I’ll keep you guys up to date as I make progress. Thanks again for the help!