/**
 * "Rain Fall" effect - Test
 * @param c
 * @param wait [in ms]
 * @param sleepafert [in s]
 */
void RainFall(Color_t c,uint8_t wait,int sleepafter) {
	int j, k;
	j = (numPixels() / 2) - 1;
	k = j + 1;
	for (; j >= 0; j--,k++) {
		// printf("Pixel - %i %i\n", j, k);
		setPixelColorT(j, c);
		setPixelColorT(k, c);
		show();
		usleep(wait * 1000);
	}
	sleep(sleepafter);
	//printf("Done:\n");
}
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
	uint16_t i, j;
	j = 0;
	for(i=0; i<numPixels(); i++) {
		setPixelColorT(i, Wheel(((i * 256 / numPixels()) + j) & 255));
		show();
		usleep(50000);
	}
	for(j = 0; j<256*5; j++) { // 5 cycles of all colors on wheel
		for(i=0; i<numPixels(); i++) {
			setPixelColorT(i, Wheel(((i * 256 / numPixels()) + j) & 255));
		}
		show();
		usleep(wait * 1000);
	}
}
// Fill the dots one after the other with a color
// Same as above - just the other way around the chain
void colorWipe_r(Color_t c, uint8_t wait) {
	int16_t i;
	for(i=numPixels()-1; i >= 0; i--) {
		setPixelColorT(i, c);
		show();
		usleep(wait * 1000);
	}
}
// Fill the dots one after the other with a color
void colorWipe(Color_t c, uint8_t wait) {
	uint16_t i;
	for(i=0; i<numPixels(); i++) {
		setPixelColorT(i, c);
		show();
		usleep(wait * 1000);
	}
}
// Rainbow
void rainbow(uint8_t wait) {
	uint16_t i, j;

	for(j=0; j<256; j++) {
		for(i=0; i<numPixels(); i++) {
			setPixelColorT(i, Wheel((i+j) & 255));
		}
		show();
		usleep(wait * 1000);
	}
}
// Slightly different, this makes the rainbow equally distributed throughout
// Same as rainbowCycle() but does a colour wipe with a rainbow effect before starting the Cycle
void rainbowCycle_wipe(uint8_t wait) {
	uint16_t i, j;
	j = 0;
	for(i=numPixels(); i>0; i--) {
		setPixelColorT(i, Wheel(((i * 256 / numPixels()) + j) & 255));
		show();
		usleep(50000);
	}
	// for(j; j<256*5; j++) { // 5 cycles of all colors on wheel
	// 	for(i=0; i<numPixels(); i++) {
	// 		setPixelColorT(i, Wheel(((i * 256 / numPixels()) + j) & 255));
	// 	}
	// 	show();
	// 	usleep(wait * 1000);
	// }
}
//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
	int j, q, i;
	for (j=0; j < 256; j+=4) {     // cycle through every 4th color on the wheel
		for (q=0; q < 3; q++) {
			for (i=0; i < numPixels(); i=i+3) {
				setPixelColorT(i+q, Wheel((i+j) % 255));    //turn every third pixel on
			}
			show();

			usleep(wait * 1000);
       
			for (i=0; i < numPixels(); i=i+3) {
				setPixelColor(i+q, 0, 0, 0);        //turn every third pixel off
			}
		}
	}
}
//Theatre-style crawling lights.
void theaterChase(Color_t c, uint8_t wait) {
	unsigned int j, q, i;
	for (j=0; j<15; j++) {  //do this many cycles of chasing
		for (q=0; q < 3; q++) {
			for (i=0; i < numPixels(); i=i+3) {
				setPixelColorT(i+q, c);			// Turn every third pixel on
			}
			show();
     
			usleep(wait * 1000);

			for (i=0; i < numPixels(); i=i+3) {
				setPixelColor(i+q, 0, 0, 0);	// Turn every third pixel off
			}
		}
	}
}
Example #9
0
void loop() {
  time_t rawtime; // raw time
  struct tm *ptime; // time struct holder
  // nyble vector for matrix columns
  // [hour/10, hour/1, minute/10, minute/1]
  uint8_t bTime[4] = {0b0000};
  // row/column inc.
  uint8_t x = 0;
  uint8_t y = 0;

  // get the time from system
  time(&rawtime);
  // load into the tm struct
  ptime = localtime(&rawtime);

  // convert the time to nybles for the matrix
  pixelTime(ptime, bTime);

  // quarter hour indicator
  if ( (ptime->tm_min % 15 == 0) && ptime->tm_sec == 0) {
    quarterHour(ptime->tm_hour, ptime->tm_min, QUARTER_WAIT);
  }

  if (pulse_second) {
    for (x = 0; x < PIXEL_ROW; x += width) {
      for (y = 0; y < PIXEL_COLUMN; y += height) {
        setPixelColorT(pixelMap[x][y],Color(0,0,0));
      }
    }
    show();
    usleep(100*100);
  }

  // set the matrix to the binary time
  setMatrix(bTime, sizeof(bTime)/sizeof(bTime[1]), Color(255,255,255), Color(255,0,0));

}