From 321ef4a5368e167f09dabe7b4b06249a80e6bae2 Mon Sep 17 00:00:00 2001 From: ADELF Date: Mon, 10 Aug 2015 21:43:25 -0400 Subject: [PATCH] added colors --- LoquaciousAndLovely2015.ino | 140 +++++++++++++++++++++++++++++------- 1 file changed, 113 insertions(+), 27 deletions(-) diff --git a/LoquaciousAndLovely2015.ino b/LoquaciousAndLovely2015.ino index 871b290..c62534f 100644 --- a/LoquaciousAndLovely2015.ino +++ b/LoquaciousAndLovely2015.ino @@ -18,22 +18,25 @@ int mode = 0; int idx = 0; - int n_modes = 12; + int n_modes = 19; int modes[] = { // C -// int modes[] = new int[] { // Java - 600, 300, 300, 300, 300, 300, - 300, 300, 300, 300, 300, 300 + //int modes[] = new int[] { // Java + 400, 250, 250, 250, 250, 200, // number of frames each mode goes for. Add here if + 300, 300, 300, 300, 300, 600, + 50, 50, 50, 50, 50, 400,600 }; uint32_t currentColor; // C // color currentColor; // Java - int n_colors = 4; + int n_colors = 5; byte colors[] = { // C // int colors[] = new int[] { // Java 107,18,76, // Pink 32,112,104, // Turquoise + 0,17,51, // Royal Blue - 119,25,32 // Red + 110,25,32, // Red + 204,122,33 // Ochre }; uint32_t color(byte r, byte g, byte b) { // C @@ -105,6 +108,7 @@ for (int j=0; j=0) { x = bound(offsets[i]+step+j, len); + // stepColor(byte r, byte g, byte b, int step, float divisor) strips[i].setPixelColor(x,stepColor(127,127,127,j,tailsize)); x = bound(offsets[i]-step-j, len); @@ -115,6 +119,8 @@ strips[i].show(); } } + + void colorBleed(int idx, int r, int g, int b, float div) { int x; @@ -126,6 +132,7 @@ for (int j=1; j=0) @@ -172,30 +179,97 @@ } } - void blinkyBlinky(int idx) { - for (int i = 0; i < 5 ; i++) { - for (int led = 0; led < strips[i].numPixels (); led++) { - if (idx % 6 < 3) { - strips[i].setPixelColor(led, color(255, 255, 255)); - } else { - strips[i].setPixelColor(led, color(0, 0, 0)); + // void blinkyBlinky(int idx, uint32_t col) { // C + void blinkyBlinky(int idx, int r, int g, int b, float div) { //Java + for (int strip = 0; strip < 5 ; strip++) { + for (int led = 0; led < strips[strip].numPixels (); led++) { + if ((idx % 30 >= 0) && (idx% 30 < 10 )) { + if (strip == 0) { + strips[strip].setPixelColor(led, stepColor(r,g,b,idx,div)); + // strips[int(random(strip))].setPixelColor(led, col); + //delay(1); + } else { + strips[strip].setPixelColor(led, color(0, 0, 0)); + } + } else if ((idx % 30 >= 10) && (idx% 30 <20)) { + if ((strip == 1) || (strip ==3)) { + strips[strip].setPixelColor(led, stepColor(r,g,b,idx,div)); + } else { + strips[strip].setPixelColor(led, color(0, 0, 0)); + } + } + else if ((idx % 30 >= 20) && (idx % 30 < 30)) { + if ((strip == 2) || (strip ==4)) + strips[strip].setPixelColor(led, stepColor(r,g,b,idx,div)); + } else { + strips[strip].setPixelColor(led, color(0, 0, 0)); } } + strips[strip].show(); + } + } - strips[i].show(); + + void blinkyBlinky2(int idx, uint32_t col) { // C + //void blinkyBlinky2(int idx, int r, int g, int b, float div) { //Java + for (int strip = 0; strip < 5 ; strip++) { + for (int led = 0; led < strips[strip].numPixels (); led++) { + if (idx % 24 <= 12 ) { + strips[strip].setPixelColor(led, col); + // strips[int(random(strip))].setPixelColor(led, col); + //delay(1); + } else { + strips[strip].setPixelColor(led, color(250, 0, 0)); + } + } + strips[strip].show(); } - } + } + +// void sparklySparkly(int idx) { +// for (int i = 0; i < 5; i++) { +// for (int led = 0; led < strips[i].numPixels(); led++) { +// if (idx % 32 == 0){ +// if (random(5)> 3) { +// strips[i].setPixelColor(led, color(30, 30, 30)); +// } else { +// strips[i].setPixelColor(led, color(0, 0, 0)); +// } +// } else if ((idx % 32 > 0) && (idx % 32 <= 16)){ +// for (float j = 0; j < 5; j++) { +// //if (random(3) > 2) { +// strips[i].setPixelColor(led, color( red(strips[i].getPixelColor(led))*(1+(j/10)), +// green(strips[i].getPixelColor(led))*(1+j/10), +// blue(strips[i].getPixelColor(led))*(1+j/10))); +// +// } +// } else if ((idx % 32 > 16) && (idx % 32 <= 32)){ +// for (float j = 0; j < 5; j++) { +// //if (random(3) > 2) { +// strips[i].setPixelColor(led, color( red(strips[i].getPixelColor(led))/(1+(j/10)), +// green(strips[i].getPixelColor(led))/(1+j/10), +// blue(strips[i].getPixelColor(led))/(1+j/10))); +// +// } +// } +// } +// strips[i].show(); +// } +// } - void sparklySparkly(int idx) { - if (idx % 4 == 0) { - for (int i = 0; i < 5; i++) { - for (int led = 0; led < strips[i].numPixels(); led++) { - if (random(3) > 2) strips[i].setPixelColor(led, color(127, 127, 127)); - else strips[i].setPixelColor(led, color(0, 0, 0)); - } - strips[i].show(); + void sparklySparkly(int idx) { + for (int i = 0; i < 5; i++) { + for (int led = 0; led < strips[i].numPixels(); led++) { + if (idx % 32 == 0){ + if (random(5)> 3) { + strips[i].setPixelColor(led, color(60, 60, 60)); + } else { + strips[i].setPixelColor(led, color(0, 0, 0)); } + } } + strips[i].show(); + } } void clear() { @@ -221,30 +295,42 @@ switch(mode) { case 0: + // sparklySparkly(idx); gallop(idx); + //rainbowWarp(idx); break; case 1: case 2: case 3: case 4: + case 5: colorBleed(idx, colors[(mode-1)*3], colors[(mode-1)*3+1], colors[(mode-1)*3+2], modes[mode] / 4.0); break; - case 5: case 6: case 7: case 8: - colorWipe(idx, color(colors[(mode-5)*3], colors[(mode-5)*3+1], colors[(mode-5)*3+2])); - break; case 9: case 10: + colorWipe(idx, color(colors[(mode-6)*3], colors[(mode-6)*3+1], colors[(mode-6)*3+2])); + break; case 11: rainbowWarp(idx); break; case 12: + case 13: + case 14: + case 15: + case 16: + blinkyBlinky(idx, colors[(mode-12)*3], colors[(mode-12)*3+1], colors[(mode-12)*3+2], modes[mode]/4.0); + break; + case 17: +// blinkyBlinky2(idx, color(colors[(mode-13)*3], colors[(mode-13)*3+1], colors[(mode-13)*3+2])); + blinkyBlinky2(idx, color(255,255,10)); + break; + case 18: sparklySparkly(idx); break; } - delay(10); }