Members | Sign In
Chippernut Forums > Shift Light v2.3


posted Aug 19, 2015 00:18:20 by BjørnHoffmann
I just tried to code the "Pixel Animation Mode 4" - Out-center.

I changed the "pixelanim = constrain(pixelanim, 1, 3);" (line 997 Unedited v2 Code)


pixelanim = constrain(pixelanim, 1, 4);

Then I insert the following code between lines 1025 and 1026 (Unedited v2 Code).

else if (pixelanim == 4) {
for (int a = 0; a < NUMPIXELS/2; a++) {
strip.setPixelColor(a, color1);
strip.setPixelColor(NUMPIXELS - a, color1);;

Then i moved on to the "build_segments" function, which just blew my mind. :D
It's as clear as mud to me.

Are there any plans to implement this "Animation Style" in further revisions?

Thanks a million!

page   1
1 reply
Jonduino said Aug 19, 2015 12:23:06
Good idea! An Out-to-Center animation would be interesting. I'd have to sit down and figure that one out :) - You're correct, whenever you add a 'pixelanim' you have to adjust the code for several menu items... just wait til you get to the build_arrays function (that will also need to be updated).

To keep the shift light as fast as possible, it builds a custom array of values that correspond to the NeoPixel address, RPM, and color for each LED. This gets even more tricky, when the total number of neopixels isn't known (someone could have 3, someone else could have 17) -- that's why you see the modulo operator in there so often, it's trying to determine the center point of the center-out animation. After many failed attempts, I coded what I considered a brute-force method: the build_segments function creates a seg_start and/or seg_end point for each section of the neopixel array, then the build_array function sorts it out from there. It's a bit of a mess.. but it works. :)

I'll add this one to my list of future upgrades, unless you beat me to it first. :) Let me know what you come up with. Thanks for stopping by!

Login below to reply: