コード例 #1
0
 void rainbowCycle_A(uint8_t wait) {
   uint16_t i, j;
 
   for(j=0; j<256*3; j++) { 
     for(i=0; i< 13; i++) {
      
       strip_h.setPixelColor(i, Wheel(((i * 50 / 13) + j) & 255));
       delayMicroseconds(550);
     }
     for(k=0; k< 7; k++) {
       strip_s.setPixelColor(k, Wheel(((k * 50 / 7) + j) & 255));
       delayMicroseconds(550);
     }
     strip_s.show();
     strip_h.show();
    //   delay(wait);
   }
 }
コード例 #2
0
ファイル: sheet.cpp プロジェクト: deldreth/SacredDoorway
void Sheet::wipeDown (int sh, uint16_t r, uint16_t g, uint16_t b) {
	if (sh == 2 || sh == 4 || sh == 6) {
		for (int i = sheets[sh]; i > sheets[sh - 1]; i--) {
			strip.setPixelColor(i, r, g, b);
			strip.setPixelColor(419 - i, r, g, b);
			
			strip.show();
			delay(30);
		}
	}
	else {
		for (int i = sheets[sh - 1]; i < sheets[sh]; i++) {
			strip.setPixelColor(i, r, g, b);
			strip.setPixelColor(419 - i, r, g, b);
			
			strip.show();
			delay(30);
		}
	}
}
コード例 #3
0
ファイル: arduino.cpp プロジェクト: takustaqu/bakkathon
void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
    delay(wait);
  }
}
コード例 #4
0
ファイル: arduino.cpp プロジェクト: takustaqu/bakkathon
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}
コード例 #5
0
ファイル: rgb_sketch.cpp プロジェクト: thostr/neopixelstuff
void clear(u32 color, u16 clearMs)
{
    u16 delayMs = clearMs / pixels.numPixels();
    for (u16 i = 0; i < pixels.numPixels(); ++i) {
        pixels.setPixelColor(i, color);
        if (delayMs) {
            pixels.show();
            delay(delayMs);
        }
    }
}
コード例 #6
0
void SparkButton::rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) { // 1 cycle of all colors on wheel
    for(i=0; i< 12; i++) {
      uint8_t WheelPos = ((i * 256 / ring.numPixels()) + j) & 255;
      if(WheelPos < 85) {
         ring.setPixelColor(i,ring.Color(WheelPos * 3, 255 - WheelPos * 3, 0));
      } else if(WheelPos < 170) {
         WheelPos -= 85;
         ring.setPixelColor(i,ring.Color(255 - WheelPos * 3, 0, WheelPos * 3));
      } else {
         WheelPos -= 170;
         ring.setPixelColor(i,ring.Color(0, WheelPos * 3, 255 - WheelPos * 3));
      }
    }
    ring.show();
    delay(wait);
  }
}
コード例 #7
0
void snake(uint32_t bg, uint32_t snake, int length){

	for (int i = 0; i < PIXEL_COUNT; i++) {
		stripSet(bg, 0);
		for (int j = 0; j < length; j++) {
			strip.setPixelColor(i + j, snake);
		}
		strip.show();
		delay(30);
	}
}
コード例 #8
0
ファイル: sheet.cpp プロジェクト: deldreth/SacredDoorway
void Sheet::wipeUp (int sh, uint32_t rgb) {
	if (sh == 2 || sh == 4 || sh == 6) {
		for (int i = sheets[sh - 1]; i < sheets[sh]; i++) {
			strip.setPixelColor(i, rgb);
			strip.setPixelColor(419 - i, rgb);
			
			strip.show();
			delay(50);
		}
	}
	else {
		for (int i = sheets[sh]; i > sheets[sh - 1]; i--) {
			strip.setPixelColor(i, rgb);
			strip.setPixelColor(419 - i, rgb);
			
			strip.show();
			delay(50);
		}
	}
}
コード例 #9
0
ファイル: primary.c プロジェクト: bosgood/flora-band-remix
void lightUp() {
  if (++colorIndex == NUM_COLORS) {
    colorIndex = 0;
  }

  int red = colorList[colorIndex][0];
  int green = colorList[colorIndex][1];
  int blue = colorList[colorIndex][2];

  // Bounds detection
  if (currentPixel == 0) {
    direction = 1;
  } else if (currentPixel == NUM_PIXELS) {
    direction = -1;
  }

  // Advancing the pixel
  currentPixel = currentPixel + (1 * direction);

  // now we will 'fade' it in 5 steps
  for (int x = 0; x < 5; x++) {
    int r = red * (x+1); r /= 5;
    int g = green * (x+1); g /= 5;
    int b = blue * (x+1); b /= 5;

    strip.setPixelColor(currentPixel, strip.Color(r, g, b));
    strip.show();
    delay(BLINK_DELAY);
  }

  // & fade out in 5 steps
  for (int x = 5; x >= 0; x--) {
    int r = red * x; r /= 5;
    int g = green * x; g /= 5;
    int b = blue * x; b /= 5;

    strip.setPixelColor(currentPixel, strip.Color(r, g, b));
    strip.show();
    delay(BLINK_DELAY);
  }
}
コード例 #10
0
void whiteOverRainbow(uint8_t wait, uint8_t whiteSpeed, uint8_t whiteLength ) {

  if(whiteLength >= strip.numPixels()) whiteLength = strip.numPixels() - 1;

  int head = whiteLength - 1;
  int tail = 0;
  int loops = 3;
  int loopNum = 0;
  static unsigned long lastTime = 0;

  while(true) {
    for(int j=0; j<256; j++) {
      for(uint16_t i=0; i<strip.numPixels(); i++) {
        if( (i >= tail && i <= head)
          || (tail > head && i >= tail)
          || (tail > head && i <= head) ) {
          strip.setPixelColor(i, strip.Color(0,0,0, 255 ) );
        } else {
          strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
        }
      }

      if(millis() - lastTime > whiteSpeed) {
        head++;
        tail++;
        if(head == strip.numPixels()) {
          loopNum++;
        }
        lastTime = millis();
      }

      if(loopNum == loops) return;

      head %= strip.numPixels();
      tail %= strip.numPixels();
      strip.show();
      delay(wait);
    }
  }

}
コード例 #11
0
void setLed(double temp)
{
  char rgb[3];
  rgb[1] = 0;
  if (temp <= MIN_TEMP || temp >= MAX_TEMP)
    warning_temp(temp);
  else
    {
      warning = 0;
      rgb[2] = 255 - (temp / MAX_TEMP * 255);
      rgb[0] = 255 * (temp / MAX_TEMP * 255);
      double nbr_led = (temp / MAX_TEMP) * NUM_LED;
      for(int j=0; j < NUM_LED; j++) {
	strip.setPixelColor(j, strip.Color(0, 0, 0));
      }
      for(int i=0; i < nbr_led; i++) {
	strip.setPixelColor(i, strip.Color(rgb[0], rgb[1], rgb[2]));
      }
      strip.show();
    }
}
コード例 #12
0
// TODO: Integrate rainbowSequence to a game class, e.g: games.cpp/.h
void rainbowSequence(uint8_t wait){
  uint16_t i, j;


    for(j=0; j<256; j++) {
      for(i=0; i<pixels.numPixels(); i++) {
        pixels.setPixelColor(i, Wheel((i+j) & 255));
      }
      pixels.show();
      delay(wait);
    }
}
コード例 #13
0
void colorBeat(uint32_t c, uint8_t wait){
  for(int j=0;j<2;j++){
    for(uint16_t i=0; i<pixels.numPixels();i++){
      pixels.setPixelColor(i,c);
    }
    pixels.show();
    fade();
    delay(wait);
    pixels.setBrightness(200);
  }

}
コード例 #14
0
void sprite(int num, uint32_t c0, uint32_t c1, uint32_t c2, int wait) {
		
	uint32_t colors[] = {c0, c1, c2};
	
	for (int i=0; i < num; i++){
		int colorIndex = random(3);
		strip.setPixelColor(random(strip.numPixels()), colors[colorIndex]);
	}
	
	strip.show();
	delay(wait);
}
コード例 #15
0
void InternetButton::smoothLedOn(float i, uint8_t r, uint8_t g, uint8_t b){
    //uint8_t intI = lrintf(i);
    //Serial.print("intI: ");
    //Serial.println(intI);

    //float differ = i-(float)intI + 0.5;
    //Serial.print("differ: ");
    //Serial.println(differ);

    float tempI;
    float differ = modff(i, &tempI);
    uint8_t intI = (uint8_t)tempI;


    // checks to see if it's reeeeally close to being an integer
    //if(abs(differ) < 0.01){
      // intI-1 shifts the location from human readable to the right index for the LEDs
    //  ring.setPixelColor(intI-1, ring.Color(r,g,b));
    //  Serial.println("tripped int check");
    //}
    //else {
      // diff > 0 means that it's closer to the lower one
      float differ1 = 1.0-differ;
      //differ1 = logf(differ1);
      //differ = logf(differ);
      if(differ > 0.5){
        differ1 /= 2;
        //ring.setPixelColor(intI-2, ring.Color((int)(differ1*r),(int)(differ1*g),(int)(differ1*b)));
        ring.setPixelColor(intI-1, ring.Color((int)(differ1*r),(int)(differ1*g),(int)(differ1*b)));
        ring.setPixelColor(intI, ring.Color((int)(differ*r),(int)(differ*g),(int)(differ*b)));
      }
      else {
        differ /= 2;
        //ring.setPixelColor(intI-2, ring.Color((int)(differ*r),(int)(differ*g),(int)(differ*b)));
        ring.setPixelColor(intI-1, ring.Color((int)(differ1*r),(int)(differ1*g),(int)(differ1*b)));
        ring.setPixelColor(intI, ring.Color((int)(differ*r),(int)(differ*g),(int)(differ*b)));
      }
    //}
    ring.show();
}
コード例 #16
0
ファイル: pixels.cpp プロジェクト: RockTheBike/lighting_test
void advanceAll(float wheelAdvance){
	for(int i = 0; i < NUM_STRIPS; i++){
		//setStrip(*strips[i], r, g, b);
		Adafruit_NeoPixel* strip = strips[i];
		for(uint16_t j = 0; j < strip->numPixels(); j++){
//			uint32_t t = strip->getPixelColor(j);
//			uint8_t r = (t >> 16) & 0xFF;
//			uint8_t g = (t >> 8) & 0xFF;
//			uint8_t b = t & 0xFF;
			strip->setPixelColor(j, Wheel(wheelAdvance));
		}
	}
}
コード例 #17
0
void TheaterChase() {
	 int i=0;
   if (ChaseCycle > 0)
   {
	 if  (TheaterChaseQ < 3 )
	 {
		 // erase previous

		 if (TheaterChaseQ!=0)
		 {
			 for (i=0; i < strip.numPixels(); i=i+3)
		                  strip.setPixelColor(i+TheaterChaseQ-1, 0);        //turn prev every third pixel off
		 }

         for (i=0; i < strip.numPixels(); i=i+3)
                        strip.setPixelColor(i+TheaterChaseQ, StripColor);    //turn every third pixel on
         strip.show();
         TheaterChaseQ++;
	 }
	 else
	 {
	   ChaseCycle--;
	   TheaterChaseQ=0;
	   // erase last one
		 for (i=0; i < strip.numPixels(); i=i+3)
	                  strip.setPixelColor(i+2, 0);        //turn every third pixel off last time
	     strip.show();
	 }

   }
   else
   {
	   // finish this demo
		StripDemoType++;         // next demo type
		TheaterChaseTimer.stop();   // stop this demo dimer
		StripDemoTimer.initializeMs(2000, StartDemo).start(true);  // start another demo after 2 seconds
   }
}
コード例 #18
0
void warning_blink()
{
  if (warning < 0 && blink >= CYCLE / 2)
    {
      for(int j=0; j < NUM_LED; j++) {
	strip.setPixelColor(j, strip.Color(0, 0, 255));
      }
    }
  else if (warning > 0 && blink >= CYCLE / 2)
    {
      for(int j=0; j < NUM_LED; j++) {
	strip.setPixelColor(j, strip.Color(255, 0, 0));
      }
    }
  else if (warning != 0 && blink < CYCLE / 2)
    {
      for(int j=0; j < NUM_LED; j++) {
	strip.setPixelColor(j, strip.Color(0, 0, 0));
      }
    }
  blink = (blink == CYCLE) ? 0 : blink + 1;
  strip.show();
}
コード例 #19
0
void ColorWipe() {

	if (StripNo < strip.numPixels())
	{
		strip.setPixelColor(StripNo, StripColor);
		strip.show();
		StripNo++;
	}
	else
	{
		StripDemoType++;         // next demo type
		ColorWipeTimer.stop();   // stop this demo timer
		StripDemoTimer.initializeMs(2000, StartDemo).start(true);  // start next demo after 2 seconds
	}

}
コード例 #20
0
void loop() {
  uint8_t record[8];

  HIDIO.readWait(record, sizeof(record));

  switch ((enum command)(record[0])) {
  case read_digital:
    record[3] = digitalRead(record[1]);
    break;

  case write_digital:
    digitalWrite(record[1], record[2]);
    break;

  case read_analog:
    record[3] = analogRead(record[1]);
    break;

  case write_analog:
    analogWrite(record[1], record[2]);
    break;

  case read_serial:
    record[3] = Serial.read();
    break;

  case write_serial:
    Serial.write(record[2]);
    break;

  case set_rgb:
    strip.setPixelColor(0, record[1], record[2], record[3]);
    strip.show();
    break;

  default:
    break;
  }

  record[4] = 0;
  record[5] = 0;
  record[6] = loops;
  record[7] = loops >> 8;
  HIDIO.write(record, sizeof(record));
  loops++;
}
コード例 #21
0
ファイル: esp8266_fw.c プロジェクト: prashnts/dotfiles
void sync_led(WiFiClient client) {
  int new_brightness = -1;

  while (client.available()) {
    String line = client.readStringUntil('\r');

    int ix_magic_ld = line.indexOf("ld");
    int ix_colon = line.indexOf(":");

    if (ix_magic_ld != -1) {
      // Sync the LEDs
      int ix_led = line.substring(ix_magic_ld + 2, ix_colon).toInt();

      // The RGB value are encoded in Base 10 (not base 16) with "zero" padding.
      // LD<LED_INDEX>: FFFFFF
      // | |          | |
      // 0 2          C 2

      String hexval = line.substring(ix_colon + 2);

      long value = strtol(hexval.c_str(), NULL, 16);

      int led_r = value >> 16;
      int led_g = value >> 8 & 0xFF;
      int led_b = value & 0xFF;

      pixels.setPixelColor(ix_led, pixels.Color(led_r, led_g, led_b));
      pixels.show();
      #if DEBUG
      Serial.print("LED#");
      Serial.print(ix_led);
      Serial.print(" <rgb>:");
      Serial.print(led_r);
      Serial.print(',');
      Serial.print(led_g);
      Serial.print(',');
      Serial.print(led_b);
      Serial.print('\n');
      #endif
    }
    int ix_magic_br = line.indexOf("brightness");
    if (ix_magic_br != -1) {
      // Update the Brightness Values
      new_brightness = line.substring(ix_colon + 2).toInt();
    }
  }
コード例 #22
0
ファイル: ColorWipeEffect.cpp プロジェクト: rootux/sabaled
void ColorWipeEffect::tick(void) {
	// callcounter++;
	// if (callcounter % (*globalSpeedFactor) != 0)
	//  	return;
	 
	Section *sect = &sections[sectionsStart];
	Adafruit_NeoPixel *strip = sect->strip;

	// Fill the dots one after the other with a color
	int tempIndex = currentIndex;
	
	uint32_t tempColorValue = (uint32_t)*SabaleUtils::globalSourceColor;

    strip->setBrightness(tempIndex);
    strip->setPixelColor(tempIndex, tempColorValue);
    strip->show();

	currentIndex++;

	// Touched the end of the strip - go back to the start
	if (tempIndex == strip->numPixels()) {
		currentIndex = 0;
	}
}
コード例 #23
0
ファイル: lights.cpp プロジェクト: 0x27/redalert
void off(){
  for(int i=0;i<NUMPIXELS;i++){
    pixels.setPixelColor(i,0,0,0);
  }
  pixels.show();
}
コード例 #24
0
void SparkButton::allLedsOn(uint8_t r, uint8_t g, uint8_t b){
    for(int i = 0; i<PIXEL_COUNT; i++){
            ring.setPixelColor(i, ring.Color(r, g, b));
    }
    ring.show();
}
コード例 #25
0
void SparkButton::allLedsOff(){
    for(int i = 0; i<PIXEL_COUNT; i++){
            ring.setPixelColor(i, ring.Color(0, 0, 0));
    }
    ring.show();
}
コード例 #26
0
void ball(void)
{
    static double speed = 5;
    static double friction = 0.01;
    static double position = 0;
    
    double pi = 3.14159;
    MPU6050::Values values;
    double forceAngle = 00;
    double forceNorme = 0;
    uint8_t ii, count, led;
    Serial.print("position ");
    Serial.println(position);
    mpu.readValues(&values, NULL);
    Serial.print("x accel ");
    Serial.print(values.xAccel);
    Serial.print(" y accel ");
    Serial.println(values.yAccel);
    values.yAccel = -values.yAccel;
    if (values.xAccel == 0) {
        if (values.yAccel < 0) {
            forceAngle = -90;
        } else {
            forceAngle = 90;
        }
    } else {
        forceAngle = atan((double)values.yAccel / (double)values.xAccel) * 180 / pi;
        if (values.xAccel < 0) {
            forceAngle -= 180;
        }
    }
    forceNorme = sqrt(values.yAccel * values.yAccel + values.xAccel * values.xAccel);
    forceNorme = forceNorme / 50000.0;
    Serial.print("angle ");
    Serial.print(forceAngle);
    Serial.print(" diff angle ");
    Serial.print(position - forceAngle);
    Serial.print(" force ");
    Serial.println(sin((position - forceAngle) * pi / 180.0) * forceNorme);
    speed -= sin((position - forceAngle) * pi / 180.0) * forceNorme;
    if (speed > 0 && speed > friction) {
        speed -= friction;
    } else if (speed < 0 && -speed > friction) {
        speed += friction;
    } else {
        speed = 0;
    }
    position += speed;
    while (position > 360) {
        position -= 360;
    }
    while (position < 0) {
        position += 360;
    }
    count = strip1.numPixels();
    led = position * count / 360.0;
    for (ii = 0; ii < count; ii++) {
        if (led == ii) {
            strip1.setPixelColor(ii, 0x0f0f0f);
        } else {
            strip1.setPixelColor(ii, 0);
        }
    }
    Serial.print("position ");
    Serial.print(position);
    Serial.print(" speed ");
    Serial.print(speed);
    Serial.print(" led ");
    Serial.println(led);
    strip1.show();
}
コード例 #27
0
ファイル: main.cpp プロジェクト: alepar/nerf
void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b) {
    pixels.setPixelColor(n, GAMMAS[r], GAMMAS[g], GAMMAS[b]);
}
コード例 #28
0
void colorSet(uint32_t c) {
    for (uint16_t i = 0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, c);
    }
    strip.show();
}
コード例 #29
0
ファイル: ExtendoHand.cpp プロジェクト: XixiLuo/extendo
void ExtendoHand::setColor(unsigned long color) {
    leds.setPixelColor(0, (uint32_t) color);
    leds.show();
}
コード例 #30
0
ファイル: esp8266_fw.c プロジェクト: prashnts/dotfiles
void update_pixel(int pixel, int r, int g, int b) {
  pixels.setPixelColor(pixel, pixels.Color(r, g, b));
  pixels.show();
}