本文整理汇总了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);
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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();
}