Skip to content

Commit

Permalink
Wired test and got working
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateo-S committed Apr 11, 2019
1 parent 2c40060 commit 299b546
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions showcase/showcase.ino
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void effect(int currentEffect) {

checkIfPushed();
break;
case 3:
case 3:
checkIfPushed();
setSectionColorCRGB(1, CRGB::Green);
delay(500);
Expand All @@ -141,7 +141,7 @@ void effect(int currentEffect) {

checkIfPushed();
break;
case 4:
case 4:
checkIfPushed();
setSectionColorCRGB(1, CRGB::Blue);
delay(500);
Expand All @@ -164,7 +164,7 @@ void effect(int currentEffect) {

checkIfPushed();
break;
case 5:
case 5:
checkIfPushed();
setSectionColorCRGB(1, CRGB::Violet);
delay(500);
Expand All @@ -187,9 +187,12 @@ void effect(int currentEffect) {

checkIfPushed();
break;
case 6:
rainbow(3,FAST,FORWARD);
break;
case 6:
checkIfPushed();
rainbow(3, FAST, FORWARD);
checkIfPushed();

break;
default:
break;
}
Expand Down Expand Up @@ -233,36 +236,40 @@ void checkIfPushed() {
cim.write(180);
delay(1000);
cim.write(90);
}else{
cim.write(90);
}
}

void setLEDs(int index, CRGB value) {
leds[index] = value;
}

void rainbow(int cycles, int speed,int direction){ // TODO direction
for(int j=0; j<256*cycles; j++) {
for(int i=0; i< nLEDS; i++) {
if(direction==FORWARD){
setLEDs(i, Wheel(((i * 256 / nLEDS) + j) % 255));}
else{
setLEDs(i,Wheel(((i * 256 / nLEDS) + j) % 255));}
void rainbow(int cycles, int speed, int direction) { // TODO direction
for (int j = 0; j < 256 * cycles; j++) {
for (int i = 0; i < nLEDS; i++) {
if (direction == FORWARD) {
setLEDs(i, Wheel(((i * 256 / nLEDS) + j) % 255));
}
else {
setLEDs(i, Wheel(((i * 256 / nLEDS) + j) % 255));
}
FastLED.show();
delay(speed);
}
FastLED.show();
delay(speed);
}
}

CRGB Wheel(byte WheelPos) {
if(WheelPos < 85) {
return CRGB(1*(WheelPos * 3)/4, 1*(255 - WheelPos * 3)/4, 0);
}
else if(WheelPos < 170) {
if (WheelPos < 85) {
return CRGB(1 * (WheelPos * 3) / 4, 1 * (255 - WheelPos * 3) / 4, 0);
}
else if (WheelPos < 170) {
WheelPos -= 85;
return CRGB(1*(255 - WheelPos * 3)/4, 0, 1*(WheelPos * 3)/4);
}
return CRGB(1 * (255 - WheelPos * 3) / 4, 0, 1 * (WheelPos * 3) / 4);
}
else {
WheelPos -= 170;
return CRGB(0, 1*(WheelPos * 3)/4, 1*(255 - WheelPos * 3)/4);
return CRGB(0, 1 * (WheelPos * 3) / 4, 1 * (255 - WheelPos * 3) / 4);
}
}

0 comments on commit 299b546

Please sign in to comment.