Skip to content

Instantly share code, notes, and snippets.

@Tmw
Last active February 1, 2016 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tmw/1ce212f7d88f33947518 to your computer and use it in GitHub Desktop.
Save Tmw/1ce212f7d88f33947518 to your computer and use it in GitHub Desktop.
The expanded refresh function
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