Files
ROFLS_Arena/ROFLS_Arena_LED_Strip_Clock/LED_Driving_functions.ino

130 lines
5.5 KiB
C++

// contains all the functions to drive the LEDs
// 0
const int LitArray0 [] = {8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55};
// 1
const int LitArray1 [] = {8,9,10,11,12,13,14,15,48,49,50,51,52,53,54,55};
// 2
const int LitArray2 [] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47};
// 3
const int LitArray3 [] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55};
// 4
const int LitArray4 [] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31,48,49,50,51,52,53,54,55};
// 5
const int LitArray5 [] = {0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55};
// 6
const int LitArray6 [] = {0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55};
// 7
const int LitArray7 [] = {8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,48,49,50,51,52,53,54,55};
// 8
const int LitArray8 [] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55};
// 9
const int LitArray9 [] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55};
// colon
const int COLONArray [] = {224,225,226,227,228,229,230,231};
// tap out
const int LitArrayTap [] = {0,1,2,3,4,5,6,7,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151};
//const int LitArrayOut [] = {0,1,2,3,4,5,6,7,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159};
const int LitArrayOut [] = {56,57,58,59,60,61,62,63,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215};
// set digits of the timer/clock, use: setDIGIT(<digit ID>, <Number>, <red channel intensity 0-255>, <green channel intensity 0-255>, <blue channel intensity 0-255>)
void setDIGIT(int DIGIT_ID, int DIGIT, int RED, int GREEN, int BLUE) {
DIGIT_ID = map(DIGIT_ID, 1, 4, 0, 3); // swap index/ID number from 1-4 to 0-3
switch (DIGIT) {
case 0:
// set 0
for (int i : LitArray0) {
leds_TIMER[i + (NUM_LEDS_PER_DIGIT * DIGIT_ID )].setRGB(RED,GREEN,BLUE);
}
break;
case 1:
// set 1
for (int i : LitArray1) {
leds_TIMER[i + (NUM_LEDS_PER_DIGIT * DIGIT_ID )].setRGB(RED,GREEN,BLUE);
}
break;
case 2:
// set 2
for (int i : LitArray2) {
leds_TIMER[i + (NUM_LEDS_PER_DIGIT * DIGIT_ID )].setRGB(RED,GREEN,BLUE);
}
break;
case 3:
// set 3
for (int i : LitArray3) {
leds_TIMER[i + (NUM_LEDS_PER_DIGIT * DIGIT_ID )].setRGB(RED,GREEN,BLUE);
}
break;
case 4:
// set 4
for (int i : LitArray4) {
leds_TIMER[i + (NUM_LEDS_PER_DIGIT * DIGIT_ID )].setRGB(RED,GREEN,BLUE);
}
break;
case 5:
// set 5
for (int i : LitArray5) {
leds_TIMER[i + (NUM_LEDS_PER_DIGIT * DIGIT_ID )].setRGB(RED,GREEN,BLUE);
}
break;
case 6:
// set 6
for (int i : LitArray6) {
leds_TIMER[i + (NUM_LEDS_PER_DIGIT * DIGIT_ID )].setRGB(RED,GREEN,BLUE);
}
break;
case 7:
// set 7
for (int i : LitArray7) {
leds_TIMER[i + (NUM_LEDS_PER_DIGIT * DIGIT_ID )].setRGB(RED,GREEN,BLUE);
}
break;
case 8:
// set 8
for (int i : LitArray8) {
leds_TIMER[i + (NUM_LEDS_PER_DIGIT * DIGIT_ID )].setRGB(RED,GREEN,BLUE);
}
break;
case 9:
// set 9
for (int i : LitArray9) {
leds_TIMER[i + (NUM_LEDS_PER_DIGIT * DIGIT_ID )].setRGB(RED,GREEN,BLUE);
}
break;
}
}
// set colon
void setCOLON(int RED, int GREEN, int BLUE) {
for (int i : COLONArray) {
leds_TIMER[(i)].setRGB(RED,GREEN,BLUE);
}
}
void showTimeDisplay(int MINUTES, int SECONDS, int RED, int GREEN, int BLUE, int BRIGHTNESS) {
// set all digits
if (MINUTES == 99) {
for (int i : LitArrayTap) {
leds_TIMER[i].setRGB(RED,GREEN,BLUE);
}
} else if (SECONDS == 99) {
for (int i : LitArrayOut) {
leds_TIMER[i].setRGB(RED,GREEN,BLUE);
}
} else {
setDIGIT(1, ((MINUTES/10)%10), RED, GREEN, BLUE);
setDIGIT(2, (MINUTES%10), RED, GREEN, BLUE);
setDIGIT(3, ((SECONDS/10)%10), RED, GREEN, BLUE);
setDIGIT(4, (SECONDS%10), RED, GREEN, BLUE);
setCOLON(RED, GREEN, BLUE);
}
// actually display the digits
FastLED.show(BRIGHTNESS);
// clear the arrays
FastLED.clearData();
}