Code part deux:
//red drum analysis
if (redChaseButton==1) {
redPulseWidthDecay=0;
redRight=stripSize-1;
}
else {
if (redPulseButton==1) {
redPulseWidthDecay=2;
}
else {
redPulseWidthDecay=6;
}
redRight=53;
}
//Red Drum array setup
for (int i=redLeft; i<drum1position; i++) {
drum1[i]=drum1[i+1]-redPulseWidthDecay;
if (drum1[i]<0) drum1[i]=0;
}
for (int i=redRight-1;i>drum1position;i--) {
drum1[i]=drum1[i-1]-redPulseWidthDecay;
if (drum1[i]<0) drum1[i]=0;
}
//clear out other segments if chase button is turned off
if (redChaseButton!=1) {
for (int i=redRight;i<stripSize;i++) {
drum1[i]=drum1[i]-10;
if (drum1[i]<0) drum1[i]=0;
}
}
drum1[drum1position]=outputValue1;
if ((outputValue1!=0) && (redChaseButton==1)) {
drum1[drum1position]=127;
}
if ((redFullButton==1) && (redChaseButton!=1)) {
for (int j=redLeft;j<redRight;j++) {
drum1[j]=outputValue1;
}
}
//green drum analysis
if (greenChaseButton==1) {
greenPulseWidthDecay=0;
greenLeft=0;
greenRight=stripSize-1;
}
else {
if (greenPulseButton==1) {
greenPulseWidthDecay=1;
}
else {
greenPulseWidthDecay=4;
}
greenLeft=54;
greenRight=106;
}
//green Drum array setup
for (int i=greenLeft; i<drum2position; i++) {
drum2[i]=drum2[i+1]-greenPulseWidthDecay;
if (drum2[i]<0) drum2[i]=0;
}
for (int i=greenRight-1;i>drum2position;i--) {
drum2[i]=drum2[i-1]-greenPulseWidthDecay;
if (drum2[i]<0) drum2[i]=0;
}
//clear out other segments if chase button is turned off
if (greenChaseButton!=1) {
for (int i=0;i<greenLeft;i++) {
drum2[i]=drum2[i]-10;
if (drum2[i]<0) drum2[i]=0;
}
for (int i=greenRight+1;i<stripSize;i++) {
drum2[i]=drum2[i]-10;
if (drum2[i]<0) drum2[i]=0;
}
}
drum2[drum2position]=outputValue2;
if ((outputValue2!=0) && (greenChaseButton==1)) {
drum2[drum2position]=127;
}
if ((greenFullButton==1) && (greenChaseButton!=1)) {
for (int j=greenLeft;j<greenRight;j++) {
drum2[j]=outputValue2;
}
}
//blue drum analysis
if (blueChaseButton==1) {
bluePulseWidthDecay=0;
blueRight=stripSize-1;
blueLeft=0;
}
else {
if (bluePulseButton==1) {
bluePulseWidthDecay=1;
}
else {
bluePulseWidthDecay=4;
}
blueLeft=107;
blueRight=160;
}
//blue Drum array setup
for (int i=blueLeft; i<drum3position; i++) {
drum3[i]=drum3[i+1]-bluePulseWidthDecay;
if (drum3[i]<0) drum3[i]=0;
}
for (int i=blueRight-1;i>drum3position;i--) {
drum3[i]=drum3[i-1]-bluePulseWidthDecay;
if (drum3[i]<0) drum3[i]=0;
}
//clear out other segments if chase button is turned off
if (blueChaseButton!=1) {
for (int i=0;i<blueLeft;i++) {
drum3[i]=drum3[i]-10;
if (drum3[i]<0) drum3[i]=0;
}
}
drum3[drum3position]=outputValue3;
if ((outputValue3!=0) && (blueChaseButton==1)) {
drum3[drum3position]=127;
}
if ((blueFullButton==1) && (blueChaseButton!=1)) {
for (int j=blueLeft;j<blueRight;j++) {
drum3[j]=outputValue3;
}
}
// Now that the arrays are good, push them to the strip
for (int i=0; i<stripSize; i++){
strip.setPixelColor(i,drum1[i],drum2[i],drum3[i]);
}
strip.show();
}