initial commit
This commit is contained in:
133
ROFLS_Arena_Controller/LED_Driving_functions.ino
Normal file
133
ROFLS_Arena_Controller/LED_Driving_functions.ino
Normal file
@@ -0,0 +1,133 @@
|
||||
// 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};
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
// set all digits
|
||||
void setTimeDisplay(int MINUTES, int SECONDS, int RED, int GREEN, int BLUE) {
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
void showTimeDisplay(int MINUTES, int SECONDS, int RED, int GREEN, int BLUE) {
|
||||
EVERY_N_MILLISECONDS(5) {
|
||||
// toggle between reading ADC data and refreshing LED strings (dunno, some artefacts appear if you do both really quickly after each other).
|
||||
// leave this in here, if needed, expand the delay between executions
|
||||
if (toggle) {
|
||||
toggle = false;
|
||||
if (prevMINUTES != MINUTES || prevSECONDS != SECONDS || prevCLOCKRED != RED || prevCLOCKGREEN != GREEN || prevCLOCKBLUE != BLUE) {
|
||||
setTimeDisplay(MINUTES, SECONDS, RED, GREEN, BLUE);
|
||||
FastLED.show(CLOCK_LED_BRIGHTNESS);
|
||||
FastLED.clearData();
|
||||
prevMINUTES = MINUTES;
|
||||
prevSECONDS = SECONDS;
|
||||
prevCLOCKRED = RED;
|
||||
prevCLOCKGREEN = GREEN;
|
||||
prevCLOCKBLUE = BLUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
toggle = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user