Please, help to define mirroring function! I want to make function,

(варешяф рйезот) #1

Please, help to define mirroring function!
I want to make function, that would make mirroring effect. Leds would be put on circle. I want to set middle led, from each animation would be played to both sides(halfs) in reverse direction each. In circle coords example it means, that if mirror point set to 90 degree, animation would play to one side from 90 to -90, and other half - from 90 to 270 degree.
One more example what I want: I want to call for example juggle (15) and it will start mirroring at 15-th led from data beginning to all leds. If NUM_LEDS = 100, animation would play one side from 15 to NUM_LEDS/2+15, and to other direction from 15 to 0 and continue to NUM_LEDS/2+15+1 reversed. Hope you understand )
I’m afraid to make too much if…else and make nested for(). I’m not good programmer.
If somebody able to help me - please ))
Or say simple way how I need to think to be able to do that. Sorry, I cant find good English idioms to say more close that I mean )

(Ken White) #2

@fa25514ad7a4d6321c2d - Look at @Aaron_Liddiment ’s great work at:

He has functions that do mirroring in a matrix. This might give you some insight on how to accomplish your mirroring needs.

(Marc Miller) #3

Here an example that has mirroring.

You can also look into using memmove8 as another option for copying data around.

(варешяф рйезот) #4

Thanks! I found this
It is by Russian, but as I understand - it is quick algorithm (lecture 6):
void shiftk(int *a, int n, int k)
Also code available here

I will try to to conjure on code, may be this will give some results ))

(варешяф рйезот) #5

@marmil it is good example, but I want to make “point of mirroring” variable. Not just NUM_LEDS/2 point.
My sketches call just in loop-function. I will add mirroring processor before call FastLED.Show, and this gives me more freedom for animations looks with just a little code and controller’s time.
For example, if I will have 5 animations - then with mirroring I will make variant more and more. In some cases I’m able to make point of mirroring variable and thats gives additional functionality for sketch. Hope, you are understand that I want to say with my terrible English ) Sorry!