New Larson Scanner
This commit is contained in:
parent
6bb63c68bd
commit
3bf250e14a
|
@ -10,6 +10,7 @@
|
|||
uint16_t effectI=0,effectJ=0,wait = 50;
|
||||
unsigned long lastCall = 0;
|
||||
byte wPos = 0;
|
||||
uint8_t state = 0;
|
||||
|
||||
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
|
@ -98,42 +99,57 @@ void loopHandler() {
|
|||
}
|
||||
else if (effect == "larson") {
|
||||
int SpeedDelay = 20;
|
||||
int ReturnDelay = 50;
|
||||
int EyeSize = 5;
|
||||
uint32_t rgb[3] = {0};
|
||||
for(int i = 0; i < pixels.numPixels()-EyeSize-2; i++) {
|
||||
pixels.clear();
|
||||
pixels.show();
|
||||
|
||||
getRGBValues(rgb,wheel(wPos));
|
||||
pixels.setPixelColor(i, rgb[0]/10, rgb[1]/10, rgb[2]/10);
|
||||
switch(state){
|
||||
case 0:
|
||||
if(lastCall + wait < millis()){
|
||||
state++;
|
||||
}
|
||||
|
||||
for(int j = 1; j <= EyeSize; j++) {
|
||||
pixels.setPixelColor(i+j, wheel(wPos++));
|
||||
}
|
||||
uint32_t rgb[3] = {0};
|
||||
getRGBValues(rgb,wheel(wPos));
|
||||
pixels.setPixelColor(i+EyeSize+1, rgb[0]/10, rgb[1]/10, rgb[2]/10);
|
||||
pixels.show();
|
||||
delay(SpeedDelay);
|
||||
break;
|
||||
case 1:
|
||||
for(int i = 0; i < pixels.numPixels()-EyeSize-2; i++) {
|
||||
pixels.clear();
|
||||
getRGBValues(rgb,wheel(wPos));
|
||||
pixels.setPixelColor(i, rgb[0]/10, rgb[1]/10, rgb[2]/10);
|
||||
for(int j = 1; j <= EyeSize; j++) {
|
||||
pixels.setPixelColor(i+j, wheel(wPos++));
|
||||
}
|
||||
getRGBValues(rgb,wheel(wPos));
|
||||
pixels.setPixelColor(i+EyeSize+1, rgb[0]/10, rgb[1]/10, rgb[2]/10);
|
||||
pixels.show();
|
||||
|
||||
delay(SpeedDelay);
|
||||
}
|
||||
lastCall = millis();
|
||||
state++;
|
||||
break;
|
||||
case 2:
|
||||
if(lastCall + wait < millis()){
|
||||
state++;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
for(int i = pixels.numPixels()-EyeSize-2; i > 0; i--) {
|
||||
pixels.clear();
|
||||
getRGBValues(rgb,wheel(wPos));
|
||||
pixels.setPixelColor(i, rgb[0]/10, rgb[1]/10, rgb[2]/10);
|
||||
for(int j = 1; j <= EyeSize; j++) {
|
||||
pixels.setPixelColor(i+j, wheel(wPos++));
|
||||
}
|
||||
pixels.setPixelColor(i+EyeSize+1, rgb[0]/10, rgb[1]/10, rgb[2]/10);
|
||||
pixels.show();
|
||||
|
||||
delay(SpeedDelay);
|
||||
}
|
||||
lastCall = millis();
|
||||
state++;
|
||||
break;
|
||||
default:
|
||||
state = 0;
|
||||
}
|
||||
delay(wait);
|
||||
|
||||
for(int i = pixels.numPixels()-EyeSize-2; i > 0; i--) {
|
||||
pixels.clear();
|
||||
pixels.show();
|
||||
getRGBValues(rgb,wheel(wPos));
|
||||
pixels.setPixelColor(i, rgb[0]/10, rgb[1]/10, rgb[2]/10);
|
||||
//pixels.setPixelColor(i, 255/10, 0, 0);
|
||||
for(int j = 1; j <= EyeSize; j++) {
|
||||
//pixels.setPixelColor(i+j, 255, 0, 0);
|
||||
pixels.setPixelColor(i+j, wheel(wPos++));
|
||||
}
|
||||
pixels.setPixelColor(i+EyeSize+1, rgb[0]/10, rgb[1]/10, rgb[2]/10);
|
||||
pixels.show();
|
||||
delay(SpeedDelay);
|
||||
}
|
||||
delay(wait);
|
||||
}
|
||||
else if (effect == "randomfade") {
|
||||
if(lastCall + wait > millis()){
|
||||
|
|
Loading…
Reference in New Issue