本文整理汇总了C++中Adafruit_NeoPixel::show方法的典型用法代码示例。如果您正苦于以下问题:C++ Adafruit_NeoPixel::show方法的具体用法?C++ Adafruit_NeoPixel::show怎么用?C++ Adafruit_NeoPixel::show使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Adafruit_NeoPixel
的用法示例。
在下文中一共展示了Adafruit_NeoPixel::show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: glow
void glow(int del, int bri){
int cb = 0;
int d = del/(100 * bri/100);
if(d < 1){
d=1;
}
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i, R,G,B);
}
while(cb<bri){
cb++;
pixels.setBrightness(cb);
pixels.show();
delay(d);
}
while(cb>1){
cb--;
pixels.setBrightness(cb);
pixels.show();
delay(d);
}
}
示例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: disco
void disco(int del, int brightness){
pixels.setBrightness(brightness);
for(int i=0;i<NUMPIXELS;i++){
int ran = random(0,2);
if(ran == 0){
int r = random(0,256);
int g = random(0,256);
int b = random(0,256);
pixels.setPixelColor(i,r,g,b);
}
}
pixels.show();
delay(del * random(1,4));
for(int i=0;i<NUMPIXELS;i++){
int ran = random(0,4);
if(ran !=0){
int r = random(0,256);
int g = random(0,256);
int b = random(0,256);
pixels.setPixelColor(i,0,0,0);
}
}
pixels.show();
delay(del * random(1,3));
}
示例4: loop
void loop () {
DateTime now = RTC.now();
//this is running a test cycle that lights up both parts for a few minutes every hour.
//to change it to birthdays just add now.day and now.month conditions like below
if (now.minute() >= 11 && (now.minute() <= 13)){
rainbowCycle_A(20);
}
else if (now.minute() >= 22 && (now.minute() <= 25)){
rainbowCycle_B(20);
}
else{
for(q=0; q< 13; q++) {
strip_h.setPixelColor(q,0,0,0);
strip_d.setPixelColor(q,0,0,0);
strip_s.setPixelColor(q,0,0,0);
strip_h.show();
strip_d.show();
strip_s.show();
}
}
}
示例5: police
void police(int del, int bri){
pixels.setBrightness(bri);
int delFac = 6;
for(int k=0; k<6; k++){
if(k==3){
delay(del*delFac);
}
if(k<3){
for(int i=0;i<NUMPIXELS/2;i++){
pixels.setPixelColor(i, 255,0,0);
}
}
else{
for(int i=NUMPIXELS/2;i<NUMPIXELS;i++){
pixels.setPixelColor(i, 0,0,255);
}
}
pixels.show();
delay(del);
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i, 0,0,0);
}
pixels.show();
delay(del/2);
}
delay(del * delFac);
}
示例6: set_all_leds
void set_all_leds(unsigned long int color){
for(byte i=0;i<MAGIC_LEDS;i++){
top_panels.setPixelColor(i, color );
}
bottom_panels.setPixelColor(0, color );
bottom_panels.setPixelColor(1, color );
top_panels.show();
bottom_panels.show();
}
示例7: 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);
}
示例8: flashingLights
void flashingLights(int del, int brightness){
pixels.setBrightness(brightness);
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i, R,G,B);
}
pixels.show();
delay(del);
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i, 0,0,0);
}
pixels.show();
delay(del);
}
示例9: Init_LearnBitsShield
// Shield initialize function:
void Init_LearnBitsShield(){
// initialize serial ports:
Serial.begin(57600); // Pc Communication
Serial1.begin(57600); // Pi communication
Serial2.begin(57600); // Bluetooth Communication
// initialize motor driver
pinMode(MOT_STBY, OUTPUT);
pinMode(MOT_PWMA, OUTPUT);
pinMode(MOT_AIN1, OUTPUT);
pinMode(MOT_AIN2, OUTPUT);
pinMode(MOT_PWMB, OUTPUT);
pinMode(MOT_BIN1, OUTPUT);
pinMode(MOT_BIN2, OUTPUT);
digitalWrite(MOT_STBY, LOW); //Set standby
// initialize Neo pixels
pixels.begin(); // initializes NeoPixel library.
for(int ii=0;ii<NUMPIXELS;ii++){
pixels.setPixelColor(ii, pixels.Color(0,0,0)); // Set pixel color.
}
pixels.show(); // Updated pixel color Hardware.
}// end Init_LearnBitsShield
示例10: 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
}
}
示例11:
void Sheet::fade3xTo (int sh1, uint16_t sr1, uint16_t sg1, uint16_t sb1, uint16_t er1, uint16_t eg1, uint16_t eb1,
int sh2, uint16_t sr2, uint16_t sg2, uint16_t sb2, uint16_t er2, uint16_t eg2, uint16_t eb2,
int sh3, uint16_t sr3, uint16_t sg3, uint16_t sb3, uint16_t er3, uint16_t eg3, uint16_t eb3) {
int steps = 256;
for (int i = 0; i < steps; i++) {
SetColor(
sh1,
sr1 + i * (er1 - sr1) / steps,
sg1 + i * (eg1 - sg1) / steps,
sb1 + i * (eb1 - sb1) / steps,
false
);
SetColor(
sh2,
sr2 + i * (er2 - sr2) / steps,
sg2 + i * (eg2 - sg2) / steps,
sb2 + i * (eb2 - sb2) / steps,
false
);
SetColor(
sh3,
sr3 + i * (er3 - sr3) / steps,
sg3 + i * (eg3 - sg3) / steps,
sb3 + i * (eb3 - sb3) / steps,
false
);
strip.show();
}
}
示例12: Chakras
void Sheet::Chakras() {
uint32_t chakras[] = {
strip.Color(255, 255, 255), // white
strip.Color(230, 0, 255), // purple
strip.Color(34, 0, 255), // blue
strip.Color(0, 255, 34), // green
strip.Color(255, 247, 0), // yellow
strip.Color(255, 111, 0), // orange
strip.Color(255, 0, 0) // red
};
uint16_t cur = 6;
int i;
for(i = 29; i >= 0; i--) {
if (i == 26 || i == 22 || i == 18 || i == 14 || i == 10 || i == 6) {
cur--;
}
strip.setPixelColor(i, chakras[cur]);
strip.setPixelColor(420 - i, chakras[cur]);
strip.show();
delay(20);
strip.setPixelColor(i, 0);
strip.setPixelColor(420 - i, 0);
}
}
示例13: BlackSpiral
void Sheet::BlackSpiral (uint8_t wait) {
uint16_t i;
for (i = 0; i < 30; i++) {
strip.setPixelColor(i, 0);
strip.setPixelColor(390 + i, 0);
strip.setPixelColor(210 - i, 0);
strip.setPixelColor(211 + i, 0);
strip.setPixelColor(59 - i, 0);
strip.setPixelColor(361 + i, 0);
strip.setPixelColor(89 - i, 0);
strip.setPixelColor(331 + i, 0);
strip.setPixelColor(119 - i, 0);
strip.setPixelColor(301 + i, 0);
strip.setPixelColor(149 - i, 0);
strip.setPixelColor(271 + i, 0);
strip.setPixelColor(180 - i, 0);
strip.setPixelColor(241 + i, 0);
strip.show();
delay(wait);
}
}
示例14: move
bool Trail::move(){
int cur_mil = millis();
if (start_mil==0) {start_mil = cur_mil;}
int delta_pix = float(cur_mil-start_mil)*leds_per_mil;
if(prv_delta_pix != delta_pix) {
prv_delta_pix = delta_pix;
int head_pix = origin + delta_pix;
if(!direction) head_pix = origin - delta_pix;
if(head_pix<0) head_pix += strip_len;
if(head_pix>strip_len-1) head_pix -= strip_len;
for(int j=0; j<=length; j++) {
int p = head_pix-j;
if(!direction){
p = head_pix+j;
}
if(p<0) p += strip_len;
if(p>strip_len-1) p -= strip_len;
if( ( o2t_dir && direction) && (p>=origin && p<=target) ||
( o2t_dir && !direction) && (p<=origin || p>=target) ||
(!o2t_dir && !direction) && (p<=origin && p>=target) ||
(!o2t_dir && direction) && (p>=origin || p<=target) )
{
strip.setPixelColor(p, strip.Color(r-j*r_fade, g-j*g_fade, b-j*b_fade));
}
}
strip.show();
}
if (delta_pix - length >= o2t_delta) return true;
return false;
}
示例15: 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);
}
}