Commits

Trammell Hudson committed 891a084

pulse and wave on separate sections

Comments (0)

Files changed (1)

 *****************************************************************************/
 
 // Set the first variable to the NUMBER of pixels. 25 = 25 pixels in a row
-#define NUM_PIXELS 16
-Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, 12, NEO_GRB + NEO_KHZ800);
+#define NUM_PIXELS 32
+Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, 13, NEO_GRB + NEO_KHZ800);
 RGBPixel frame[NUM_PIXELS];
 
 void setup() {
 		return;
 	RGBPixel * const p = &frame[x];
 
-	r = (p->red + r) / 2;
-	g = (p->green + g) / 2;
-	b = (p->blue + b) / 2;
+	r = (p->red*3 + r) / 4;
+	g = (p->green*3 + g) / 4;
+	b = (p->blue*3 + b) / 4;
 
 	if (r < 0) r = 0; else if (r > 0xFF) r = 0xFF;
 	if (g < 0) g = 0; else if (g > 0xFF) g = 0xFF;
 	if (random(chance) != 0)
 		return;
 	int x = random(NUM_PIXELS);
-	avg_color(x, 255, 255, 255);
+	avg_color(x, 1000, 1000, 1000);
 }
 
 
-void draw_wave(sprite_t *s)
+void draw_wave(sprite_t *s, int low, int high)
 {
-    const int num = NUM_PIXELS;
+    const int num = high - low;
 
     uint8_t r = s->c.red;
     uint8_t g = s->c.blue;
 
     s->pos += s->vel;
     
-    if (s->pos > num + 1)
+    if (s->pos >= high)
     {
-        s->pos = num - 1;
+        s->pos = high-1;
         s->vel = -s->vel;
     } else
-    if (s->pos < -1)
+    if (s->pos < low)
     {
-        s->pos = 0;
+        s->pos = low;
         s->vel = -s->vel;
     } else
 	return;
 {
 	static int pos;
 
-	for (int i=0; i < NUM_PIXELS ; i++)
+	for (int i=0; i < 16 ; i++)
 		avg_color(i, 4, 0, 0);
 
 	// occasionally pulse everything red
 	if (pos == 0 || pos == 3)
-		for (int i = 0 ; i < NUM_PIXELS ; i++)
-			avg_color(i, pos == 0 ? 200 : 1000, 0, 0);
+		for (int i = 0 ; i < 16 ; i++)
+			avg_color(i, pos == 0 ? 400 : 1000, 0, 0);
+
 	// chase a single pixel around
 	avg_color(pos, 500, 200, 0);
+	avg_color((pos+1) % NUM_PIXELS, 500, 200, 0);
 	pos++;
-	if (pos >= NUM_PIXELS)
+	if (pos >= 16)
 		pos = 0;
 }
 
 
 void loop() {
-    if (0)
-    {
-	    for (int i=0; i < NUM_PIXELS ; i++)
-		avg_color(i, 0, 0, 0);
+    for (int i=16; i < 32 ; i++)
+	avg_color(i, 0, 0, 0);
 
-	    for (int i=0 ; i < sizeof(sprites)/sizeof(*sprites) ; i++)
-	      draw_wave(&sprites[i]);
-    } else {
-	pulse();
-    }
+    for (int i=0 ; i < sizeof(sprites)/sizeof(*sprites) ; i++)
+      draw_wave(&sprites[i], 16, 32);
 
-    sparkle(NUM_PIXELS/2);
+    pulse();
+
+    sparkle(NUM_PIXELS/4);
 
     for (int i=0; i < NUM_PIXELS; i++)
     {