|
if (mode == BLINKER_CMD_MIOT_NIGHT) { // NIGHT 月光
colorR = 255;
colorG = 255;
colorB = 255;
colorW = 10;
pixelShow();
}
else if (mode == BLINKER_CMD_MIOT_COLOR) { //COLOR 彩光
// Your mode function
rainbow(20);
}
else if (mode == BLINKER_CMD_MIOT_WARMTH) { //WARMTH 温馨
colorR = 255;
colorG = 128;
colorB = 0;
colorW = 60;
pixelShow();
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if (WheelPos < 85) {
return pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if (WheelPos < 170) {
WheelPos -= 85;
return pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
void rainbow(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);
}
}
|
|