Members | Sign In
Chippernut Forums > Shift Light v2.4
avatar

New animation

posted Jun 20, 2017 17:48:47 by V.urchaga
Hello!

I am trying to make a new animation so that the led lights on the opposite of animation 2.

In animation 2 the led's light up from the inside to out. I want to create a new animation that lights the LEDs from outside to inside.

Could you help me?

Regards
page   1
1 reply
avatar
V.urchaga said Feb 19, 2018 18:22:01
Hi!!


I have modified part of the code for the fourth animation. But it does not work correctly.

Can anybody help me??

void build_segments() {

if (pixelanim == 3) {
seg_mover = NUMPIXELS - 1;
}

while (current_seg_number < 4) {
display.showNumberDec(current_seg_number);

int coloradjust1 = rotary_process();
if (coloradjust1 == -128) {
seg_mover--;
}
if (coloradjust1 == 64) {
seg_mover++;
}

if (digitalRead(button_pin) == LOW) {
delay(250);
current_seg_number++;
}

switch (current_seg_number) {
case 1:
if (pixelanim == 1) {
seg_mover = constrain(seg_mover, 0, (NUMPIXELS - 1));
seg1_end = seg_mover;
strip.setPixelColor(seg1_end, color1);
for (int x = seg1_end + 1; x < NUMPIXELS; x++) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
} else if (pixelanim == 3) {
seg_mover = constrain(seg_mover, 0, (NUMPIXELS - 1));
seg1_start = seg_mover;
strip.setPixelColor(seg1_start, color1);
for (int x = seg1_start - 1; x > -1; x--) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
} else if (pixelanim == 2) {
seg1_start = ((NUMPIXELS - 1) / 2);
if (((NUMPIXELS - 1) % 2) > 0) {
seg1_start = seg1_start + 1;
}
seg_mover = constrain(seg_mover, seg1_start, (NUMPIXELS - 1));
seg1_end = seg_mover;

for (int x = seg1_start; x < seg1_end + 1; x++) {
strip.setPixelColor(x, color1);
}
for (int x = seg1_end + 1; x < (NUMPIXELS); x++) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}

if (((NUMPIXELS - 1) % 2) > 0) {
for (int x = seg1_start - 1; x > seg1_start - (seg1_end - seg1_start) - 2; x--) {
strip.setPixelColor(x, color1);
}
for (int x = seg1_start - (seg1_end - seg1_start) - 2; x > -1; x--) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
if (DEBUG) {
Serial.println("MoDULo");
}
} else {
for (int x = seg1_start; x > seg1_start - (seg1_end - seg1_start) - 1; x--) {
strip.setPixelColor(x, color1);
}
for (int x = seg1_start - (seg1_end - seg1_start) - 1; x > -1; x--) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
}
}else if (pixelanim == 4) {
seg1_start = ((NUMPIXELS - 1) / 2);
if (((NUMPIXELS - 1) % 2) > 0) {
seg1_end = seg1_end - 1;
}
seg_mover = constrain(seg_mover, seg1_end, (NUMPIXELS + 1));
seg1_start = seg_mover;

for (int x = seg1_end; x < seg1_start - 1; x--) {
strip.setPixelColor(x, color1);
}
for (int x = seg1_start - 1; x > (NUMPIXELS); x--) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}

if (((NUMPIXELS - 1) % 2) > 0) {
for (int x = seg1_end - 1; x < seg1_end - (seg1_start - seg1_end) - 2; x++) {
strip.setPixelColor(x, color1);
}
for (int x = seg1_end - (seg1_start - seg1_end) - 2; x < -1; x++) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
if (DEBUG) {
Serial.println("MoDULo");
}
} else {
for (int x = seg1_end; x < seg1_end - (seg1_start - seg1_end) - 1; x++) {
strip.setPixelColor(x, color1);
}
for (int x = seg1_end - (seg1_start - seg1_end) - 1; x < -1; x++) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
}
}

if (DEBUG) {
Serial.print("S1end: ");
Serial.println(seg1_end);
Serial.print("S1start: ");
Serial.println(seg1_start);
}

strip.show();


break;



case 2:
if (pixelanim == 1) {
seg_mover = constrain(seg_mover, seg1_end + 1, (NUMPIXELS - 1));
seg2_end = seg_mover;
strip.setPixelColor(seg2_end, color2);
for (int x = seg2_end + 1; x < strip.numPixels(); x++) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
} else if (pixelanim == 3) {
seg_mover = constrain(seg_mover, 0, (seg1_start - 1));
seg2_start = seg_mover;
strip.setPixelColor(seg2_start, color2);
for (int x = seg2_start - 1; x > -1; x--) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
} else if (pixelanim == 2) {
//seg1_start = ((NUMPIXELS-1)/2);
seg2_start = seg1_end + 1;
// if (((NUMPIXELS-1)%2)> 0){seg1_start=seg1_start+1;}
seg_mover = constrain(seg_mover, seg2_start, (NUMPIXELS - 1));
seg2_end = seg_mover;

for (int x = seg2_start; x < seg2_end + 1; x++) {
strip.setPixelColor(x, color2);
}
for (int x = seg2_end + 1; x < (NUMPIXELS); x++) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}

if (((NUMPIXELS - 1) % 2) > 0) {
for (int x = seg1_start - (seg1_end - seg1_start) - 2; x > seg1_start - (seg2_end - seg1_start) - 2; x--) {
strip.setPixelColor(x, color2);
}
for (int x = seg1_start - (seg2_end - seg1_start) - 2; x > -1; x--) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
if (DEBUG) {
Serial.println("MoDULo");
}
} else {
for (int x = seg1_start - (seg1_end - seg1_start) - 1; x > seg1_start - (seg2_end - seg1_start) - 1; x--) {
strip.setPixelColor(x, color2);
}
for (int x = seg1_start - (seg2_end - seg1_start) - 1; x > -1; x--) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
}

}else if (pixelanim == 4) {
//seg1_start = ((NUMPIXELS-1)/2);
seg2_end = seg1_start + 1;
// if (((NUMPIXELS-1)%2)> 0){seg1_start=seg1_start+1;}
seg_mover = constrain(seg_mover, seg2_end, (NUMPIXELS - 1));
seg2_start = seg_mover;

for (int x = seg2_end; x < seg2_start + 1; x--) {
strip.setPixelColor(x, color2);
}
for (int x = seg2_start + 1; x > (NUMPIXELS); x--) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}

if (((NUMPIXELS - 1) % 2) > 0) {
for (int x = seg1_end - (seg1_start - seg1_end) - 2; x < seg1_start - (seg2_start - seg1_end) - 2; x++) {
strip.setPixelColor(x, color2);
}
for (int x = seg1_end - (seg2_start - seg1_end) - 2; x < -1; x++) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
if (DEBUG) {
Serial.println("MoDULo");
}
} else {
for (int x = seg1_end - (seg1_start - seg1_end) - 1; x > seg1_end - (seg2_start - seg1_end) - 1; x++) {
strip.setPixelColor(x, color2);
}
for (int x = seg1_end - (seg2_start - seg1_end) - 1; x < -1; x++) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
}

}

if (DEBUG) {
Serial.print("S2end: ");
Serial.println(seg2_end);
Serial.print("S2start: ");
Serial.println(seg2_start);
}

strip.show();
break;

case 3:

if (pixelanim == 1) {
seg_mover = constrain(seg_mover, seg2_end + 1, (strip.numPixels() - 1));
seg3_end = seg_mover;
// seg3_start = seg2_end +1;
strip.setPixelColor(seg3_end, color3);
for (int x = seg3_end + 1; x < strip.numPixels(); x++) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
} else if (pixelanim == 3) {
seg_mover = constrain(seg_mover, 0, (seg2_start - 1));
seg3_start = seg_mover;
strip.setPixelColor(seg3_start, color3);
for (int x = seg3_start - 1; x > -1; x--) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
} else if (pixelanim == 2) {
seg3_start = seg2_end + 1;
seg_mover = constrain(seg_mover, seg3_start, (NUMPIXELS - 1));
seg3_end = seg_mover;

for (int x = seg3_start; x < seg3_end + 1; x++) {
strip.setPixelColor(x, color3);
}
for (int x = seg3_end + 1; x < (NUMPIXELS); x++) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}

if (((NUMPIXELS - 1) % 2) > 0) {
for (int x = seg1_start - (seg2_end - seg1_start) - 2; x > seg1_start - (seg3_end - seg1_start) - 2; x--) {
strip.setPixelColor(x, color3);
}
for (int x = seg1_start - (seg3_end - seg1_start) - 2; x > -1; x--) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
if (DEBUG) {
Serial.println("MoDULo");
}
} else {
for (int x = seg1_start - (seg2_end - seg1_start) - 1; x > seg1_start - (seg3_end - seg1_start) - 1; x--) {
strip.setPixelColor(x, color3);
}
for (int x = seg1_start - (seg3_end - seg1_start) - 1; x > -1; x--) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
}
}else if (pixelanim == 4) {
seg3_end = seg2_start + 1;
seg_mover = constrain(seg_mover, seg3_end, (NUMPIXELS - 1));
seg3_start = seg_mover;

for (int x = seg3_end; x > seg3_start + 1; x--) {
strip.setPixelColor(x, color3);
}
for (int x = seg3_start + 1; x > (NUMPIXELS); x--) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}

if (((NUMPIXELS - 1) % 2) > 0) {
for (int x = seg1_end - (seg2_start - seg1_end) - 2; x < seg1_end - (seg3_start - seg1_end) - 2; x++) {
strip.setPixelColor(x, color3);
}
for (int x = seg1_end - (seg3_start - seg1_end) - 2; x < -1; x++) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
if (DEBUG) {
Serial.println("MoDULo");
}
} else {
for (int x = seg1_end - (seg2_start - seg1_end) - 1; x < seg1_end - (seg3_start - seg1_end) - 1; x++) {
strip.setPixelColor(x, color3);
}
for (int x = seg1_end - (seg3_start - seg1_end) - 1; x < -1; x++) {
strip.setPixelColor(x, strip.Color(0, 0, 0));
}
}
}

if (DEBUG) {
Serial.print("S3end: ");
Serial.println(seg3_end);
Serial.print("S3start: ");
Serial.println(seg3_start);
}
strip.show();
break;




}
}
}
Login below to reply: