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


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

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


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

示例1: additiveColorMix

u32 additiveColorMix(u32 color1, u32 color2)
{
    u8 r1, g1, b1, r2, g2, b2;
    colorPackedToScalar(&r1, &g1, &b1, color1);
    colorPackedToScalar(&r2, &g2, &b2, color2);
    r1 = colorChannelClampedAdd(r1, r2);
    g1 = colorChannelClampedAdd(g1, g2);
    b1 = colorChannelClampedAdd(b1, b2);
    u32 c = pixels.Color(r1, g1, b1);
    return c;
}
开发者ID:thostr,项目名称:neopixelstuff,代码行数:11,代码来源:rgb_sketch.cpp

示例2: 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:bsherwin,项目名称:SparkButton,代码行数:20,代码来源:SparkButton.cpp

示例3: 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

示例4: colorLookHere

void colorLookHere(uint32_t c, uint8_t wait){
  uint32_t off = pixels.Color(0,0,0);
  uint16_t max_pixels = pixels.numPixels();
  uint16_t half_max_pixels = max_pixels/2;

  uint8_t trailSize = 3;

  for(uint16_t i=0;i<=half_max_pixels;i++){
    pixels.setPixelColor(half_max_pixels-i,c);
    pixels.setPixelColor(half_max_pixels+i,c);

    if((i-trailSize)>=0) pixels.setPixelColor(half_max_pixels+i-trailSize,off) ;
    if(i>=trailSize) pixels.setPixelColor(half_max_pixels-i+trailSize,off);
    pixels.show();
    delay(wait);
  }
}
开发者ID:weareleka,项目名称:arduino-prototype-projects,代码行数:17,代码来源:remote-simplecode.cpp

示例5: 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

示例6: Wheel

uint32_t Wheel(byte WheelPos) {

  if(WheelPos < 85) {

   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);

  } else if(WheelPos < 170) {

   WheelPos -= 85;

   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);

  } else {

   WheelPos -= 170;

   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);

  }

}
开发者ID:sharmaharsh,项目名称:Musical-LEDS,代码行数:21,代码来源:ArduinoCode.c

示例7: colorWipeLeft

void colorWipeLeft(uint32_t c, uint8_t wait) {
  uint32_t off = pixels.Color(0,0,0);

  uint8_t trailSize = 5;

  for(uint16_t i=0; i<pixels.numPixels(); i++) {
    pixels.setPixelColor(i, c);
    if((i-trailSize)>=0) pixels.setPixelColor(i-trailSize,off);
    pixels.show();
    delay(wait);
  }
}
开发者ID:weareleka,项目名称:arduino-prototype-projects,代码行数:12,代码来源:remote-simplecode.cpp

示例8: 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

示例9: colorWipeRight

void colorWipeRight(uint32_t c, uint8_t wait) {
  uint32_t off = pixels.Color(0,0,0);
  uint16_t max_pixels = pixels.numPixels();

  uint8_t trailSize = 5;

  for(uint16_t i=0; i<=max_pixels; i++) {
    pixels.setPixelColor(max_pixels-i, c);
    if(i>=trailSize)pixels.setPixelColor(max_pixels-i+trailSize,off);
    pixels.show();
    delay(wait);
  }
}
开发者ID:weareleka,项目名称:arduino-prototype-projects,代码行数:13,代码来源:remote-simplecode.cpp

示例10: warning_blink

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

示例11: sync_led

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();
    }
  }
开发者ID:prashnts,项目名称:dotfiles,代码行数:46,代码来源:esp8266_fw.c

示例12: 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

示例13: calcTaperedSegmentPixel

// Example for 7 pixels.
//
//        X
//       X X
//      X   X
//     X     X
//
// pixel 3 is center and will be set to brightestVal.
// There are 4 pixels on each side, sharing the center pixel
// The values of the 4 pixels are assigned in such a way that an imagined 5th pixel on each side is 0.
// So, for 4 pixels:
//   single step = 255 / 4 = 63
//   steps for 7 pixels: 64, 127, 191, 255, 191, 127, 64
u32 calcTaperedSegmentPixel(u8 numSegmentPixels, u8 pos, u32 centerColor)
{
    if (pos == 0 || pos == numSegmentPixels + 1) {
        return 0x000000;
    }

    u8 centerPos = numSegmentPixels / 2;
    u8 rCenter, gCenter, bCenter;
    colorPackedToScalar(&rCenter, &gCenter, &bCenter, centerColor);
    u8 rStep = rCenter / (centerPos + 1);
    u8 gStep = gCenter / (centerPos + 1);
    u8 bStep = bCenter / (centerPos + 1);

    u8 segmentIndex;
    if (pos <= centerPos) {
        segmentIndex = pos + 1;
    }
    else {
        segmentIndex = numSegmentPixels - pos;
    }

    return pixels.Color(rStep * segmentIndex, gStep * segmentIndex, bStep * segmentIndex);
}
开发者ID:thostr,项目名称:neopixelstuff,代码行数:36,代码来源:rgb_sketch.cpp

示例14: update_pixel

void update_pixel(int pixel, int r, int g, int b) {
  pixels.setPixelColor(pixel, pixels.Color(r, g, b));
  pixels.show();
}
开发者ID:prashnts,项目名称:dotfiles,代码行数:4,代码来源:esp8266_fw.c

示例15: fullWhite

void fullWhite() {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0,0,0, 255 ) );
  }
  strip.show();
}
开发者ID:BernsteinA,项目名称:SparkCore-NeoPixel,代码行数:6,代码来源:rgbw-strandtest.cpp


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