Skip to content

Commit

Permalink
Completed second animation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesper Larsson authored and Jesper Larsson committed Mar 27, 2016
1 parent 324ef7c commit de2a04b
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion OvveLeds.ino
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,20 @@ void loop() {
}

void tickColorCircleAnimation() {

for(int i = 0; i < strip1.numPixels(); i++) {
int n = state + i;
strip1.setPixelColor(i, R(n), G(n), B(n));
}
for(int i = 0; i < strip2.numPixels(); i++) {
int n = state + i;
strip2.setPixelColor(i, R(n), G(n), B(n));
}

state++;
state = state % 6*255;

strip1.show();
strip2.show();
}

void tickStaticWineredAnimation() {
Expand Down Expand Up @@ -88,3 +101,52 @@ void toggleMode() {
break;
}
}

byte R(int n) {
n = n % 6*255;
if(n <= 1*255 || 5*255 < 255) {
return 255;
}
else if(1*255 < n && n <= 2*255) {
return 255 - (n % 255);
}
else if(2*255 < n && n <= 4*255) {
return 0;
}
else if(4*255 < n && n <= 5*255) {
return n % 255;
}
}

byte G(int n) {
n = n % 6*255;
if(n <= 1*255) {
return n % 255;
}
else if(1*255 < n && n <= 3*255) {
return 255;
}
else if(3*255 < n && n <= 4*255) {
return 255 - (n % 255);
}
else if(4*255 < n) {
return 0;
}
}

byte B(int n) {
n = n % 6*255;
if(n <= 2*255) {
return 0;
}
else if(2*255 < n && n <= 3*255) {
return n % 255;
}
else if(3*255 < n && n <= 5*255) {
return 255;
}
else if(5*255 < n) {
return 255 - (n % 255);
}
}

0 comments on commit de2a04b

Please sign in to comment.