Last active
February 1, 2016 21:57
-
-
Save Tmw/1ce212f7d88f33947518 to your computer and use it in GitHub Desktop.
The expanded refresh function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void refresh(){ | |
// Loop over each LED | |
for (int cycle = 0; cycle < 16; cycle++) { | |
for (int currentLed = 0; currentLed < NUMBER_OF_CONNECTED_LEDS; currentLed++) { | |
int maskPosition = currentLed * 4; | |
if (cycle == 1 && brightnessMask_layer1[maskPosition]) { | |
turnOnLed(currentLed, 0); | |
} | |
else if ((cycle == 2 || cycle == 3) && brightnessMask_layer1[maskPosition+1]) { | |
turnOnLed(currentLed, 0); | |
} | |
else if (cycle >= 4 && cycle <= 7 && brightnessMask_layer1[maskPosition+2]) { | |
turnOnLed(currentLed, 0); | |
} | |
else if (cycle >= 8 && cycle <= 15 && brightnessMask_layer1[maskPosition+3]) { | |
turnOnLed(currentLed, 0); | |
} | |
} | |
for (int currentLed = 0; currentLed < NUMBER_OF_CONNECTED_LEDS; currentLed++) { | |
int maskPosition = currentLed * 4; | |
if (cycle == 1 && brightnessMask_layer2[maskPosition]) { | |
turnOnLed(currentLed, 1); | |
} | |
else if ((cycle == 2 || cycle == 3) && brightnessMask_layer2[maskPosition+1]) { | |
turnOnLed(currentLed, 1); | |
} | |
else if (cycle >= 4 && cycle <= 7 && brightnessMask_layer2[maskPosition+2]) { | |
turnOnLed(currentLed, 1); | |
} | |
else if (cycle >= 8 && cycle <= 15 && brightnessMask_layer2[maskPosition+3]) { | |
turnOnLed(currentLed, 1); | |
} | |
} | |
for (int currentLed = 0; currentLed < NUMBER_OF_CONNECTED_LEDS; currentLed++) { | |
int maskPosition = currentLed * 4; | |
if (cycle == 1 && brightnessMask_layer3[maskPosition]) { | |
turnOnLed(currentLed, 2); | |
} | |
else if ((cycle == 2 || cycle == 3) && brightnessMask_layer3[maskPosition+1]) { | |
turnOnLed(currentLed, 2); | |
} | |
else if (cycle >= 4 && cycle <= 7 && brightnessMask_layer3[maskPosition+2]) { | |
turnOnLed(currentLed, 2); | |
} | |
else if (cycle >= 8 && cycle <= 15 && brightnessMask_layer3[maskPosition+3]) { | |
turnOnLed(currentLed, 2); | |
} | |
} | |
for (int currentLed = 0; currentLed < NUMBER_OF_CONNECTED_LEDS; currentLed++) { | |
int maskPosition = currentLed * 4; | |
if (cycle == 1 && brightnessMask_layer4[maskPosition]) { | |
turnOnLed(currentLed, 3); | |
} | |
else if ((cycle == 2 || cycle == 3) && brightnessMask_layer4[maskPosition+1]) { | |
turnOnLed(currentLed, 3); | |
} | |
else if (cycle >= 4 && cycle <= 7 && brightnessMask_layer4[maskPosition+2]) { | |
turnOnLed(currentLed, 3); | |
} | |
else if (cycle >= 8 && cycle <= 15 && brightnessMask_layer4[maskPosition+3]) { | |
turnOnLed(currentLed, 3); | |
} | |
} | |
clearLeds(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment