Народ помогите новичку разобраться. Есть ESP-WROOM-32, лента w2812, и 5 кнопок. Надо чтобы при нажатии на кнопки разные линии диодной ленты выполняли разные эффекты: первая линия статичные переключения цветов (1 кнопка), (2 кнопка) включение режимов второй линии, 3 кнопка включение режимов третий линии, 4 кнопка включение режимов четвертой линии, 5 кнопка включает 2+3+4 линию одновременно в одинаковые режимы. Есть какая-то ошибка в коде, потому как не выполняет действия по кнопка нормально 1 работает более или менее нормально, а остальные глючат.
// StrandTest from AdaFruit implemented as a state machine
// pattern change by push button
// By Mike Cook Jan 2016
// Fade function added Sept 2017
#define PIXEL_PIN_LIGHT 23 // pin connected to the small NeoPixels strip
#define PIXEL_PIN_BODY 22
#define PIXEL_PIN_VENT 17
#define PIXEL_PIN_TAIL 16
#define NUMPIXELSLIGHT 4 // number of LEDs on strip
#define NUMPIXELSBODY 40
#define NUMPIXELSVENT 40
#define NUMPIXELSTAIL 40
#define BUTTON_PIN_LIGHT 33
#define BUTTON_PIN_BODY 32
#define BUTTON_PIN_VENT 25
#define BUTTON_PIN_TAIL 26
#define BUTTON_PIN_DISKOTEKA 27
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel striplight = Adafruit_NeoPixel(NUMPIXELSLIGHT, PIXEL_PIN_LIGHT, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel stripbody = Adafruit_NeoPixel(NUMPIXELSBODY, PIXEL_PIN_BODY, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel stripvent = Adafruit_NeoPixel(NUMPIXELSVENT, PIXEL_PIN_VENT, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel striptail = Adafruit_NeoPixel(NUMPIXELSTAIL, PIXEL_PIN_TAIL, NEO_GRB + NEO_KHZ800);
unsigned long patternInterval = 20 ; // time between steps in the pattern
unsigned long lastUpdate = 0 ; // for millis() when last update occoured
unsigned long intervals [] = { 20, 20, 50, 100, 30, 20, 20, 50 } ; // speed for each pattern - add here when adding more cases
unsigned long intervals1 [] = { 20, 20, 50, 100, 30, 20, 20, 50 } ;
unsigned long intervals2 [] = { 20, 20, 50, 100, 30, 20, 20, 50 } ;
unsigned long intervals3 [] = { 20, 20, 50, 100, 30, 20, 20, 50 } ;
unsigned long intervals4 [] = { 20, 20, 50, 100, 30, 20, 20, 50 } ;
int fadeStep = 0; // stste variable for fade function
int numberOfCasesLight = 3; // how many case statements or patterns you have
int numberOfCasesBody = 8;
int numberOfCasesVent = 8;
int numberOfCasesTail = 8;
int numberOfCasesDiskoteka = 7;
//const byte BUTTON_PIN_LIGHT = 32; // pin to connect button switch to between pin and ground
//const byte BUTTON_PIN_BODY = 33;
//const byte BUTTON_PIN_VENT = 21;
//const byte BUTTON_PIN_TAIL = 19;
//const byte BUTTON_PIN_DISKOTEKA = 18;
void setup() {
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
//#if defined(ESP32) && (F_CPU == 16000000)
//clock_prescale_set(clock_div_1);
//#endif
striplight.begin(); // This initializes the NeoPixel library.
wipelight(); // wipes the LED buffers
stripbody.begin(); // This initializes the NeoPixel library.
wipebody(); // wipes the LED buffers
stripvent.begin(); // This initializes the NeoPixel library.
wipevent(); // wipes the LED buffers
striptail.begin(); // This initializes the NeoPixel library.
wipetail(); // wipes the LED buffers
wipediskoteka();
pinMode(BUTTON_PIN_LIGHT, INPUT_PULLUP); // change pattern button
pinMode(BUTTON_PIN_BODY, INPUT_PULLUP);
pinMode(BUTTON_PIN_VENT, INPUT_PULLUP);
pinMode(BUTTON_PIN_TAIL, INPUT_PULLUP);
pinMode(BUTTON_PIN_DISKOTEKA, INPUT_PULLUP);
pinMode(NUMPIXELSLIGHT, OUTPUT);
pinMode(NUMPIXELSBODY, OUTPUT);
pinMode(NUMPIXELSVENT, OUTPUT);
pinMode(NUMPIXELSTAIL, OUTPUT);
}
void loop() {
static int patternlight = 1, lastReadingLight;
int readingLight = digitalRead(BUTTON_PIN_LIGHT);
if(lastReadingLight == HIGH && readingLight == LOW){
patternlight++ ; // change pattern number
fadeStep = 0; // reset the fade state variable
if(patternlight > numberOfCasesLight) patternlight = 0; // wrap round if too big
patternInterval = intervals[patternlight]; // set speed for this pattern
wipelight(); // clear out the buffer
delay(50); // debounce delay
}
static int patternbody = 0, lastReadingBody;
int readingBody = digitalRead(BUTTON_PIN_BODY);
if(lastReadingBody == HIGH && readingBody == LOW){
patternbody++ ; // change pattern number
fadeStep = 0; // reset the fade state variable
if(patternbody > numberOfCasesBody) patternbody = 0; // wrap round if too big
patternInterval = intervals1[patternbody]; // set speed for this pattern
wipebody(); // clear out the buffer
delay(50); // debounce delay
}
static int patternvent = 0, lastReadingVent;
int readingVent = digitalRead(BUTTON_PIN_VENT);
if(lastReadingVent == HIGH && readingVent == LOW){
patternvent++ ; // change pattern number
fadeStep = 0; // reset the fade state variable
if(patternvent > numberOfCasesVent) patternvent = 0; // wrap round if too big
patternInterval = intervals2[patternvent]; // set speed for this pattern
wipevent(); // clear out the buffer
delay(50); // debounce delay
}
static int patterntail = 0, lastReadingTail;
int readingTail = digitalRead(BUTTON_PIN_TAIL);
if(lastReadingLight == HIGH && readingLight == LOW){
patterntail++ ; // change pattern number
fadeStep = 0; // reset the fade state variable
if(patterntail > numberOfCasesTail) patterntail = 0; // wrap round if too big
patternInterval = intervals3[patterntail]; // set speed for this pattern
wipetail(); // clear out the buffer
delay(50); // debounce delay
}
static int patterndiskoteka = 0, lastReadingDiskoteka; // start with the fade function
int readingDiskoteka = digitalRead(BUTTON_PIN_DISKOTEKA);
if(lastReadingDiskoteka == HIGH && readingDiskoteka == LOW){
patterndiskoteka++ ; // change pattern number
fadeStep = 0; // reset the fade state variable
if(patterndiskoteka > numberOfCasesDiskoteka) patterndiskoteka = 0; // wrap round if too big
patternInterval = intervals4[patterndiskoteka]; // set speed for this pattern
wipediskoteka(); // clear out the buffer
delay(50); // debounce delay
}
lastReadingLight = readingLight; // save for next time
lastReadingBody = readingBody; // save for next time
lastReadingVent = readingVent; // save for next time
lastReadingTail = readingTail; // save for next time
lastReadingDiskoteka = readingDiskoteka; // save for next time
if(millis() - lastUpdate > patternInterval) updatePatternlight(patternlight);
if(millis() - lastUpdate > patternInterval) updatePatternbody(patternbody);
if(millis() - lastUpdate > patternInterval) updatePatternvent(patternvent);
if(millis() - lastUpdate > patternInterval) updatePatterntail(patterntail);
if(millis() - lastUpdate > patternInterval) updatePatterndiskoteka(patterndiskoteka);
}
void updatePatternlight(int light){ // call the pattern currently being created
switch(light) {
case 0:
striplight.setPixelColor(0, striplight.Color(0, 0, 0)); //Off
striplight.setPixelColor(1, striplight.Color(0, 0, 0));
striplight.setPixelColor(2, striplight.Color(0, 0, 0));
striplight.setPixelColor(3, striplight.Color(0, 0, 0));
striplight.show();
lastUpdate = millis();
break;
case 1:
striplight.setPixelColor(0, striplight.Color(255, 255, 240)); //Off
striplight.setPixelColor(1, striplight.Color(255, 255, 240));
striplight.setPixelColor(2, striplight.Color(255, 255, 240));
striplight.setPixelColor(3, striplight.Color(255, 255, 240));
striplight.show();
lastUpdate = millis();
break;
case 2:
striplight.setPixelColor(0, striplight.Color(255, 0, 0)); // red
striplight.setPixelColor(1, striplight.Color(255, 0, 0));
striplight.setPixelColor(2, striplight.Color(255, 0, 0));
striplight.setPixelColor(3, striplight.Color(255, 0, 0));
striplight.show();
lastUpdate = millis();
break;
case 3:
striplight.setPixelColor(0, striplight.Color(0, 0, 255)); // red
striplight.setPixelColor(1, striplight.Color(0, 0, 255));
striplight.setPixelColor(2, striplight.Color(0, 0, 255));
striplight.setPixelColor(3, striplight.Color(0, 0, 255));
striplight.show();
lastUpdate = millis();
break;
}
}
void updatePatternbody(int body){ // call the pattern currently being created
switch(body) {
case 0:
colorWipeBody(stripbody.Color( 0, 0, 0)); // Black/off
break;
case 1:
colorWipeBody(stripbody.Color(255, 0, 0)); // Red
break;
case 2:
colorWipeBody(stripbody.Color( 0, 255, 0)); // Green
break;
case 3:
colorWipeBody(stripbody.Color( 0, 0, 255)); // Blue
break;
case 4:
colorWipeBody(stripbody.Color(226, 245, 20)); // yellow
break;
case 5:
colorWipeBody(stripbody.Color(29, 138, 42)); // darker green
break;
case 6:
colorWipeBody(stripbody.Color(28, 240, 255)); // aqua?
break;
case 7:
colorWipeBody(stripbody.Color(245, 20, 215)); // pink
break;
case 8:
colorWipeBody(stripbody.Color(242, 174, 15)); // orange
break;
}
}
void updatePatternvent(int vent){ // call the pattern currently being created
switch(vent) {
case 0:
colorWipeVent(stripvent.Color( 0, 0, 0)); // Black/off
break;
case 1:
colorWipeVent(stripvent.Color(255, 0, 0)); // Red
break;
case 2:
colorWipeVent(stripvent.Color( 0, 255, 0)); // Green
break;
case 3:
colorWipeVent(stripvent.Color( 0, 0, 255)); // Blue
break;
case 4:
colorWipeVent(stripvent.Color(226, 245, 20)); // yellow
break;
case 5:
colorWipeVent(stripvent.Color(29, 138, 42)); // darker green
break;
case 6:
colorWipeVent(stripvent.Color(28, 240, 255)); // aqua?
break;
case 7:
colorWipeVent(stripvent.Color(245, 20, 215)); // pink
break;
case 8:
colorWipeVent(stripvent.Color(242, 174, 15)); // orange
break;
}
}
void updatePatterntail(int tail){ // call the pattern currently being created
switch(tail) {
case 0:
colorWipeTail(striptail.Color( 0, 0, 0)); // Black/off
break;
case 1:
colorWipeTail(striptail.Color(255, 0, 0)); // Red
break;
case 2:
colorWipeTail(striptail.Color( 0, 255, 0)); // Green
break;
case 3:
colorWipeTail(striptail.Color( 0, 0, 255)); // Blue
break;
case 4:
colorWipeTail(striptail.Color(226, 245, 20)); // yellow
break;
case 5:
colorWipeTail(striptail.Color(29, 138, 42)); // darker green
break;
case 6:
colorWipeTail(striptail.Color(28, 240, 255)); // aqua?
break;
case 7:
colorWipeTail(striptail.Color(245, 20, 215)); // pink
break;
case 8:
colorWipeTail(striptail.Color(242, 174, 15)); // orange
break;
}
}
void updatePatterndiskoteka(int diskoteka){ // call the pattern currently being created
switch(diskoteka) {
case 0:
colorWipeAll(stripbody.Color(0, 0, 0)); //Off
//colorWipeVent(stripvent.Color(0, 0, 0));
//colorWipeTail(striptail.Color(0, 0, 0));
break;
case 1:
rainbowCycleBody();
rainbowCycleVent();
rainbowCycleTail();
break;
case 2:
theaterChaseRainbowBody();
theaterChaseRainbowVent();
theaterChaseRainbowTail();
break;
case 3:
colorWipeAll(stripbody.Color(255, 0, 0)); // red
//colorWipeVent(stripvent.Color(255, 0, 0));
//colorWipeTail(striptail.Color(255, 0, 0));
break;
case 4:
colorWipeAll(stripbody.Color(0, 255, 0)); // green
//colorWipeVent(stripvent.Color(0, 255, 0));
//colorWipeTail(striptail.Color(0, 255, 0));
//fade(0,255, 0,64, 0,0, 400); // fade from black to oraange and back
break;
case 5:
colorWipeAll(stripbody.Color(0, 0, 255)); // blue
//colorWipeVent(stripvent.Color(0, 0, 255));
//colorWipeTail(striptail.Color(0, 0, 255));
break;
case 6:
rainbowBody();
rainbowVent();
rainbowTail();
break;
case 7:
fadeBody(0,255, 0,64, 0,0, 400); // fade from black to oraange and back
fadeVent(0,255, 0,64, 0,0, 400);
fadeTail(0,255, 0,64, 0,0, 400);
break;
}
}
void fadeBody(int redStartValue, int redEndValue, int greenStartValue, int greenEndValue, int blueStartValue, int blueEndValue, int totalSteps) {
static float redIncrement, greenIncrement, blueIncrement;
static float red, green, blue;
static boolean fadeUp = false;
if (fadeStep == 0){ // first step is to initialise the initial colour and increments
red = redStartValue;
green = greenStartValue;
blue = blueStartValue;
fadeUp = false;
redIncrement = (float)(redEndValue - redStartValue) / (float)totalSteps;
greenIncrement = (float)(greenEndValue - greenStartValue) / (float)totalSteps;
blueIncrement = (float)(blueEndValue - blueStartValue) / (float)totalSteps;
fadeStep = 1; // next time the function is called start the fade
}
else { // all other steps make a new colour and display it
// make new colour
red += redIncrement;
green += greenIncrement;
blue += blueIncrement;
// set up the pixel buffer
for (int i = 0; i < stripbody.numPixels(); i++) {
stripbody.setPixelColor(i, stripbody.Color((int)red,(int)green,(int)blue));
}
// now display it
stripbody.show();
fadeStep += 1; // go on to next step
if(fadeStep >= totalSteps) { // finished fade
if(fadeUp){ // finished fade up and back
fadeStep = 0;
return; // so next call recalabrates the increments
}
// now fade back
fadeUp = true;
redIncrement = -redIncrement;
greenIncrement = -greenIncrement;
blueIncrement = -blueIncrement;
fadeStep = 1; // don't calculate the increments again but start at first change
}
}
}
void fadeVent(int redStartValue, int redEndValue, int greenStartValue, int greenEndValue, int blueStartValue, int blueEndValue, int totalSteps) {
static float redIncrement, greenIncrement, blueIncrement;
static float red, green, blue;
static boolean fadeUp = false;
if (fadeStep == 0){ // first step is to initialise the initial colour and increments
red = redStartValue;
green = greenStartValue;
blue = blueStartValue;
fadeUp = false;
redIncrement = (float)(redEndValue - redStartValue) / (float)totalSteps;
greenIncrement = (float)(greenEndValue - greenStartValue) / (float)totalSteps;
blueIncrement = (float)(blueEndValue - blueStartValue) / (float)totalSteps;
fadeStep = 1; // next time the function is called start the fade
}
else { // all other steps make a new colour and display it
// make new colour
red += redIncrement;
green += greenIncrement;
blue += blueIncrement;
// set up the pixel buffer
for (int i = 0; i < stripvent.numPixels(); i++) {
stripvent.setPixelColor(i, stripvent.Color((int)red,(int)green,(int)blue));
}
// now display it
stripvent.show();
fadeStep += 1; // go on to next step
if(fadeStep >= totalSteps) { // finished fade
if(fadeUp){ // finished fade up and back
fadeStep = 0;
return; // so next call recalabrates the increments
}
// now fade back
fadeUp = true;
redIncrement = -redIncrement;
greenIncrement = -greenIncrement;
blueIncrement = -blueIncrement;
fadeStep = 1; // don't calculate the increments again but start at first change
}
}
}
void fadeTail(int redStartValue, int redEndValue, int greenStartValue, int greenEndValue, int blueStartValue, int blueEndValue, int totalSteps) {
static float redIncrement, greenIncrement, blueIncrement;
static float red, green, blue;
static boolean fadeUp = false;
if (fadeStep == 0){ // first step is to initialise the initial colour and increments
red = redStartValue;
green = greenStartValue;
blue = blueStartValue;
fadeUp = false;
redIncrement = (float)(redEndValue - redStartValue) / (float)totalSteps;
greenIncrement = (float)(greenEndValue - greenStartValue) / (float)totalSteps;
blueIncrement = (float)(blueEndValue - blueStartValue) / (float)totalSteps;
fadeStep = 1; // next time the function is called start the fade
}
else { // all other steps make a new colour and display it
// make new colour
red += redIncrement;
green += greenIncrement;
blue += blueIncrement;
// set up the pixel buffer
for (int i = 0; i < striptail.numPixels(); i++) {
striptail.setPixelColor(i, striptail.Color((int)red,(int)green,(int)blue));
}
// now display it
striptail.show();
fadeStep += 1; // go on to next step
if(fadeStep >= totalSteps) { // finished fade
if(fadeUp){ // finished fade up and back
fadeStep = 0;
return; // so next call recalabrates the increments
}
// now fade back
fadeUp = true;
redIncrement = -redIncrement;
greenIncrement = -greenIncrement;
blueIncrement = -blueIncrement;
fadeStep = 1; // don't calculate the increments again but start at first change
}
}
}
void rainbowBody() { // modified from Adafruit example to make it a state machine
static uint16_t j=0;
for(int i=0; i<stripbody.numPixels(); i++) {
stripbody.setPixelColor(i, WheelBody((i+j) & 255));
}
stripbody.show();
j++;
if(j >= 256) j=0;
lastUpdate = millis(); // time for next change to the display
}
void rainbowVent() { // modified from Adafruit example to make it a state machine
static uint16_t j=0;
for(int i=0; i<stripvent.numPixels(); i++) {
stripvent.setPixelColor(i, WheelVent((i+j) & 255));
}
stripvent.show();
j++;
if(j >= 256) j=0;
lastUpdate = millis(); // time for next change to the display
}
void rainbowTail() { // modified from Adafruit example to make it a state machine
static uint16_t j=0;
for(int i=0; i<striptail.numPixels(); i++) {
striptail.setPixelColor(i, WheelTail((i+j) & 255));
}
striptail.show();
j++;
if(j >= 256) j=0;
lastUpdate = millis(); // time for next change to the display
}
void rainbowCycleBody() { // modified from Adafruit example to make it a state machine
static uint16_t j=0;
for(int i=0; i< stripbody.numPixels(); i++) {
stripbody.setPixelColor(i, WheelBody(((i * 256 / stripbody.numPixels()) + j) & 255));
}
stripbody.show();
j++;
if(j >= 256*5) j=0;
lastUpdate = millis(); // time for next change to the display
}
void rainbowCycleVent() { // modified from Adafruit example to make it a state machine
static uint16_t j=0;
for(int i=0; i< stripvent.numPixels(); i++) {
stripvent.setPixelColor(i, WheelVent(((i * 256 / stripvent.numPixels()) + j) & 255));
}
stripvent.show();
j++;
if(j >= 256*5) j=0;
lastUpdate = millis(); // time for next change to the display
}
void rainbowCycleTail() { // modified from Adafruit example to make it a state machine
static uint16_t j=0;
for(int i=0; i< striptail.numPixels(); i++) {
striptail.setPixelColor(i, WheelTail(((i * 256 / striptail.numPixels()) + j) & 255));
}
striptail.show();
j++;
if(j >= 256*5) j=0;
lastUpdate = millis(); // time for next change to the display
}
void theaterChaseRainbowBody() { // modified from Adafruit example to make it a state machine
static int j=0, q = 0;
static boolean on = true;
if(on){
for (int i=0; i < stripbody.numPixels(); i=i+3) {
stripbody.setPixelColor(i+q, WheelBody( (i+j) % 255)); //turn every third pixel on
}
}
else {
for (int i=0; i < striptail.numPixels(); i=i+3) {
stripbody.setPixelColor(i+q, 0); //turn every third pixel off
}
}
on = !on; // toggel pixelse on or off for next time
stripbody.show(); // display
q++; // update the q variable
if(q >=3 ){ // if it overflows reset it and update the J variable
q=0;
j++;
if(j >= 256) j = 0;
}
lastUpdate = millis(); // time for next change to the display
}
void theaterChaseRainbowVent() { // modified from Adafruit example to make it a state machine
static int j=0, q = 0;
static boolean on = true;
if(on){
for (int i=0; i < stripvent.numPixels(); i=i+3) {
stripvent.setPixelColor(i+q, WheelVent( (i+j) % 255)); //turn every third pixel on
}
}
else {
for (int i=0; i < stripvent.numPixels(); i=i+3) {
stripvent.setPixelColor(i+q, 0); //turn every third pixel off
}
}
on = !on; // toggel pixelse on or off for next time
stripvent.show(); // display
q++; // update the q variable
if(q >=3 ){ // if it overflows reset it and update the J variable
q=0;
j++;
if(j >= 256) j = 0;
}
lastUpdate = millis(); // time for next change to the display
}
void theaterChaseRainbowTail() { // modified from Adafruit example to make it a state machine
static int j=0, q = 0;
static boolean on = true;
if(on){
for (int i=0; i < striptail.numPixels(); i=i+3) {
striptail.setPixelColor(i+q, WheelTail( (i+j) % 255)); //turn every third pixel on
}
}
else {
for (int i=0; i < striptail.numPixels(); i=i+3) {
striptail.setPixelColor(i+q, 0); //turn every third pixel off
}
}
on = !on; // toggel pixelse on or off for next time
striptail.show(); // display
q++; // update the q variable
if(q >=3 ){ // if it overflows reset it and update the J variable
q=0;
j++;
if(j >= 256) j = 0;
}
lastUpdate = millis(); // time for next change to the display
}
void colorWipeAll(uint32_t c) { // modified from Adafruit example to make it a state machine
static int i =0;
stripbody.setPixelColor(i, c);
stripvent.setPixelColor(i, c);
striptail.setPixelColor(i, c);
stripbody.show();
stripvent.show();
striptail.show();
i++;
if(i >= (stripbody.numPixels()+stripvent.numPixels()+striptail.numPixels())){
i = 0;
wipebody(); // blank out strip
wipevent();
wipetail();
}
lastUpdate = millis(); // time for next change to the display
}
void colorWipeBody(uint32_t c) { // modified from Adafruit example to make it a state machine
static int i =0;
stripbody.setPixelColor(i, c);
stripbody.show();
i++;
if(i >= stripbody.numPixels()){
i = 0;
wipebody(); // blank out strip
}
lastUpdate = millis(); // time for next change to the display
}
void colorWipeVent(uint32_t c) { // modified from Adafruit example to make it a state machine
static int i =0;
stripvent.setPixelColor(i, c);
stripvent.show();
i++;
if(i >= stripvent.numPixels()){
i = 0;
wipevent(); // blank out strip
}
lastUpdate = millis(); // time for next change to the display
}
void colorWipeTail(uint32_t c) { // modified from Adafruit example to make it a state machine
static int i =0;
striptail.setPixelColor(i, c);
striptail.show();
i++;
if(i >= striptail.numPixels()){
i = 0;
wipetail(); // blank out strip
}
lastUpdate = millis(); // time for next change to the display
}
void wipelight(){ // clear all LEDs
for(int i=0;i<striplight.numPixels();i++){
striplight.setPixelColor(i, striplight.Color(0,0,0));
}
}
void wipebody(){ // clear all LEDs
for(int i=0;i<stripbody.numPixels();i++){
stripbody.setPixelColor(i, stripbody.Color(0,0,0));
}
}
void wipevent(){ // clear all LEDs
for(int i=0;i<stripvent.numPixels();i++){
stripvent.setPixelColor(i, stripvent.Color(0,0,0));
}
}
void wipetail(){ // clear all LEDs
for(int i=0;i<striptail.numPixels();i++){
striptail.setPixelColor(i, striptail.Color(0,0,0));
}
}
void wipediskoteka(){ // clear all LEDs
for(int i=0;i<(striptail.numPixels()+stripvent.numPixels()+stripbody.numPixels());i++){
striptail.setPixelColor(i, (striptail.Color(0,0,0)+stripvent.Color(0,0,0)+stripbody.Color(0,0,0)));
}
}
uint32_t WheelBody(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return stripbody.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return stripbody.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return stripbody.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
uint32_t WheelVent(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return stripvent.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return stripvent.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return stripvent.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
uint32_t WheelTail(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return striptail.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return striptail.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return striptail.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}