本文整理汇总了C++中Adafruit_NeoPixel::numPixels方法的典型用法代码示例。如果您正苦于以下问题:C++ Adafruit_NeoPixel::numPixels方法的具体用法?C++ Adafruit_NeoPixel::numPixels怎么用?C++ Adafruit_NeoPixel::numPixels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Adafruit_NeoPixel
的用法示例。
在下文中一共展示了Adafruit_NeoPixel::numPixels方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TheaterChase
void TheaterChase() {
int i,b=0;
if (ChaseCycle > 0)
{
if (TheaterChaseQ == 0) b=3;
if (TheaterChaseQ == 1) b=0;
if (TheaterChaseQ == 2) b=1;
if (TheaterChaseQ == 3) b=2;
for (i=0; i < strip.numPixels(); i=i+4)
strip.setPixelColor(i+b, 0); //turn prev every third pixel off
for (i=0; i < strip.numPixels(); i=i+4)
strip.setPixelColor(i+TheaterChaseQ, StripColor); //turn every third pixel on
strip.show();
TheaterChaseQ++;
if (TheaterChaseQ > 3)
{
TheaterChaseQ=0;
ChaseCycle--;
}
}
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
}
}
示例2: xmasRedGreenTwinkles
void xmasRedGreenTwinkles(u16 runSec)
{
const u8 flashOnDelayMs = 20;
const u8 flashPauseMs = 150;
const u8 numTwinklesPerSwap = 3;
bool redOrGreenFirst = false;
u32 startMs = millis();
u8 numTwinklesToNextSwap = 0;
while (millis() < startMs + runSec * 1000UL) {
if (!numTwinklesToNextSwap--) {
numTwinklesToNextSwap = numTwinklesPerSwap;
redOrGreenFirst = !redOrGreenFirst;
}
u8 twinkleLedIdx = random(0, pixels.numPixels() - 1);
pixels.setPixelColor(twinkleLedIdx, 0xffffff);
pixels.show();
delay(flashOnDelayMs);
for (u8 i = 0; i < pixels.numPixels(); ++i) {
u32 c = (i + redOrGreenFirst) & 1 ? 0xff0000 : 0x00ff00;
pixels.setPixelColor(i, c);
}
pixels.show();
delay(flashPauseMs);
}
}
示例3: smoothRunners
void smoothRunners(u16 runSec, u16 delayMs, struct Segment* segmentPtrIn, u8 numSegments)
{
u16 superPosBuf[numSegments];
u16 numSuperPositions = pixels.numPixels() << 8;
u16 superPosOffset = numSuperPositions / numSegments;
for (u8 i = 0; i < numSegments; ++i) {
superPosBuf[i] = i * superPosOffset;
}
u32 startMs = millis();
while (millis() < startMs + runSec * 1000UL) {
clear(0, 0);
Segment* segmentPtr = segmentPtrIn;
for (u8 i = 0; i < numSegments; ++i) {
u16 superPos = superPosBuf[i];
superPos = wrapAdd(superPos, segmentPtr->speed, numSuperPositions);
superPosBuf[i] = superPos;
u8 numSegmentPixels = segmentPtr->lengthPercent * pixels.numPixels() / 100;
if (numSegmentPixels < 2) {
numSegmentPixels = 2;
}
drawTaperedSegment(superPos, numSegmentPixels, segmentPtr->color);
++segmentPtr;
}
pixels.show();
delay(delayMs);
}
}
示例4: 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);
}
}
}
示例5: 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);
}
}
示例6: rainbowFade2White
void rainbowFade2White(uint8_t wait, int rainbowLoops, int whiteLoops) {
float fadeMax = 100.0;
int fadeVal = 0;
uint32_t wheelVal;
int redVal, greenVal, blueVal;
for(int k = 0 ; k < rainbowLoops ; k ++) {
for(int j=0; j<256; j++) { // 5 cycles of all colors on wheel
for(int i=0; i< strip.numPixels(); i++) {
wheelVal = Wheel(((i * 256 / strip.numPixels()) + j) & 255);
redVal = red(wheelVal) * float(fadeVal/fadeMax);
greenVal = green(wheelVal) * float(fadeVal/fadeMax);
blueVal = blue(wheelVal) * float(fadeVal/fadeMax);
strip.setPixelColor( i, strip.Color( redVal, greenVal, blueVal ) );
}
// First loop, fade in!
if(k == 0 && fadeVal < fadeMax-1) {
fadeVal++;
}
// Last loop, fade out!
else if(k == rainbowLoops - 1 && j > 255 - fadeMax ) {
fadeVal--;
}
strip.show();
delay(wait);
}
}
delay(500);
for(int k = 0 ; k < whiteLoops ; k ++) {
for(int j = 0; j < 256 ; j++) {
for(uint16_t i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(0,0,0, gamma[j] ) );
}
strip.show();
}
delay(2000);
for(int j = 255; j >= 0 ; j--) {
for(uint16_t i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(0,0,0, gamma[j] ) );
}
strip.show();
}
}
delay(500);
}
示例7: theaterChaseRainbow
//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel
for (int q=0; q < 3; q++) {
for (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on
}
strip.show();
delay(wait);
for (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}
示例8: theaterChase
//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
for (int j=0; j<10; j++) { //do 10 cycles of chasing
for (int q=0; q < 3; q++) {
for (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, c); //turn every third pixel on
}
strip.show();
delay(wait);
for (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}
示例9: colorWipe
//NEOPIXEL LIBRARRY
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
示例10: setStrip
// Fill the dots one after the other with a color
void setStrip(Adafruit_NeoPixel s, uint8_t r, uint8_t g, uint8_t b) {
for (uint16_t i = 0; i < s.numPixels(); i++) {
s.setPixelColor(i, r, g, b);
//delay(wait);
}
s.show();
}
示例11: stripSet
void stripSet(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
}
// move the show outside the loop
strip.show();
delay(wait);
}
示例12: pulseWhite
void pulseWhite(uint8_t wait) {
for(int j = 0; j < 256 ; j++) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(0,0,0, gamma[j] ) );
}
delay(wait);
strip.show();
}
for(int j = 255; j >= 0 ; j--){
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(0,0,0, gamma[j] ) );
}
delay(wait);
strip.show();
}
}
示例13: colorAll
// Set all pixels in the strip to a solid color, then wait (ms)
void colorAll(uint32_t c, uint8_t wait) {
uint16_t i;
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
}
strip.show();
delay(wait);
}
示例14: 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);
}
}
示例15: 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);
}