-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscoreboard_chrono.ino
46 lines (39 loc) · 1.18 KB
/
scoreboard_chrono.ino
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
#define NUMBER_LEDS_CHRONO NUM_LEDS_DIGIT *4+2
// Define the array of leds
CRGB chrono_leds[NUMBER_LEDS_CHRONO];
int chrono_time = 1200; // time in seconds
unsigned long previousMillis = 0;
const long interval = 1000; // every second
void setupChrono() {
FastLED.addLeds<WS2811, CHRONO_DATA_PIN, RGB>(chrono_leds, NUMBER_LEDS_CHRONO);
showScoreboardTime();
chrono_leds[42] = CRGB::Red;
chrono_leds[43] = CRGB::Red;
Serial.println("Setup Chrono");
FastLED[0].showLeds();
}
void SetChronoTime() {
unsigned long currentMillis = millis();
if (chrono_started == true) {
if (currentMillis - previousMillis >= interval) {
// make sure time is set every seconds
previousMillis = currentMillis;
chrono_time = chrono_time - 1;
if (chrono_time == 0) {
chrono_started = false;
//trigger end
}
showScoreboardTime();
}
}
}
void showScoreboardTime() {
int minutes = chrono_time / 60;
int secondes = chrono_time % 60;
Serial.print( minutes);
Serial.print(":");
Serial.println(secondes);
setNumber(chrono_leds, secondes,0);
setNumber(chrono_leds, minutes, 44);//minutes,NUM_LEDS_DIGIT*2+2);
FastLED[0].showLeds(BRIGHTNESS);
}