当前位置: 首页>>代码示例>>C++>>正文


C++ Adafruit_NeoPixel::setPixelColor方法代码示例

本文整理汇总了C++中Adafruit_NeoPixel::setPixelColor方法的典型用法代码示例。如果您正苦于以下问题:C++ Adafruit_NeoPixel::setPixelColor方法的具体用法?C++ Adafruit_NeoPixel::setPixelColor怎么用?C++ Adafruit_NeoPixel::setPixelColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Adafruit_NeoPixel的用法示例。


在下文中一共展示了Adafruit_NeoPixel::setPixelColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rainbowCycle_A

 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);
   }
 }
开发者ID:wwebb,项目名称:WordClock,代码行数:18,代码来源:wordclock+(buckeyeworldcitizen).c

示例2: wipeDown

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);
		}
	}
}
开发者ID:deldreth,项目名称:SacredDoorway,代码行数:20,代码来源:sheet.cpp

示例3: rainbow

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);
  }
}
开发者ID:takustaqu,项目名称:bakkathon,代码行数:11,代码来源:arduino.cpp

示例4: rainbowCycle

// 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);
  }
}
开发者ID:takustaqu,项目名称:bakkathon,代码行数:12,代码来源:arduino.cpp

示例5: clear

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);
        }
    }
}
开发者ID:thostr,项目名称:neopixelstuff,代码行数:11,代码来源:rgb_sketch.cpp

示例6: rainbow

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);
  }
}
开发者ID:seanmitchellmcdonald,项目名称:SparkButton,代码行数:20,代码来源:SparkButton.cpp

示例7: snake

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);
	}
}
开发者ID:jrojas2016,项目名称:sound_portal,代码行数:11,代码来源:soundPortal.cpp

示例8: wipeUp

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);
		}
	}
}
开发者ID:deldreth,项目名称:SacredDoorway,代码行数:20,代码来源:sheet.cpp

示例9: lightUp

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);
  }
}
开发者ID:bosgood,项目名称:flora-band-remix,代码行数:41,代码来源:primary.c

示例10: whiteOverRainbow

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);
    }
  }

}
开发者ID:BernsteinA,项目名称:SparkCore-NeoPixel,代码行数:41,代码来源:rgbw-strandtest.cpp

示例11: setLed

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();
    }
}
开发者ID:baillel,项目名称:rotonde-arduino-neopixel,代码行数:21,代码来源:main.cpp

示例12: rainbowSequence

// 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);
    }
}
开发者ID:weareleka,项目名称:arduino-prototype-projects,代码行数:13,代码来源:remote-simplecode.cpp

示例13: colorBeat

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);
  }

}
开发者ID:weareleka,项目名称:arduino-prototype-projects,代码行数:12,代码来源:remote-simplecode.cpp

示例14: sprite

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);
}
开发者ID:jrojas2016,项目名称:sound_portal,代码行数:12,代码来源:soundPortal.cpp

示例15: smoothLedOn

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();
}
开发者ID:hpssjellis,项目名称:InternetButton,代码行数:40,代码来源:InternetButton2.cpp


注:本文中的Adafruit_NeoPixel::setPixelColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。