//稍微不同的是,這使得彩虹均勻分布
void rainbowCycle(unsigned int wait)
{
unsigned int i, j;
for(j=0;j<256*5;j++)
{ // 5 cycles of all colors on wheel 車(chē)輪上所有顏色的5個(gè)循環(huán)
for(i=0;i<numLEDs;i++)
{
SetPixelColor(i, Wheel(((i * 256 / numLEDs) + j) & 255));
}
PixelUpdate();
HAL_Delay (wait);
}
}
//Theatre-style crawling lights.呼吸燈
void theaterChase(unsigned long c, unsigned int wait)
{
int j,q;
unsigned int i;
for (j=0; j<10; j++)
{ //do 10 cycles of chasing 做10個(gè)循環(huán)
for (q=0; q < 3; q++)
{
for (i=0; i<numLEDs; i=i+3)
{
SetPixelColor(i+q, c); //turn every third pixel on 把每一個(gè)第三個(gè)像素
}
PixelUpdate();
HAL_Delay(wait);
for (i=0; i<numLEDs; i=i+3)
{
SetPixelColor(i+q, 0); //turn every third pixel off 把每一個(gè)第三個(gè)像素關(guān)掉
}
PixelUpdate();
}
}
}
//Theatre-style crawling lights with rainbow effect
//帶有彩虹效果的戲劇式爬行燈
void theaterChaseRainbow(unsigned int wait)
{
int j,q;
unsigned int i;
for (j=0; j < 256; j++)
{ // cycle all 256 colors in the wheel 在輪子上循環(huán)所有256色
for (q=0; q < 3; q++)
{
for (i=0; i < numLEDs; i=i+3)
{
SetPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel off 把每一個(gè)第三個(gè)像素
}
PixelUpdate();
HAL_Delay(wait);
for (i=0; i < numLEDs; i=i+3)
{
SetPixelColor(i+q, 0); //turn every third pixel off 把每一個(gè)第三個(gè)像素關(guān)掉
}
}
}
}
// Fill the dots one after the other with a color
//用一種顏色填充這些圓點(diǎn)
void colorWipe(unsigned long c, unsigned int wait)
{
unsigned int i=0;
for( i=0; i<numLEDs; i++)
{
SetPixelColor(i, c);
PixelUpdate();
HAL_Delay(wait);
}
}
void main()
{
while(1)
{
rainbow(45);
rainbowCycle(40);
theaterChase(Color(0,0,255),80); // Blue
theaterChase(Color(0,255,0),80); // Blue
theaterChase(Color(255,0,0),80); // Blue
theaterChaseRainbow(40);
colorWipe(255,255);
}
}