-
Notifications
You must be signed in to change notification settings - Fork 1
/
nato-lights.ino
62 lines (52 loc) · 1.7 KB
/
nato-lights.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "src/common.h"
#include "src/lights.h"
#include "src/pattern.h"
#include "src/patterns/pattern_colors.h"
#include "src/patterns/pattern_fire.h"
#include "src/patterns/pattern_trains.h"
#include "src/patterns/pattern_white.h"
unsigned long debounce;
CRGB leds[LED_BUFFER_SIZE];
LightsControl Lights;
HardwareControl Hardware;
void show(unsigned char strip, unsigned short offset, unsigned short count) {
for (signed short i = LED_COUNT - 1; i >= offset + count; i--) {
leds[i + LED_BUFFER_PADDING] = leds[i];
}
for (signed short i = count - 1; i >= 0; i--) {
for (unsigned char j = 0; j < LED_DUPLICATION; j++) {
leds[i * LED_DUPLICATION + j + offset] = leds[i + offset];
}
}
FastLED[strip].showLeds();
for (unsigned short i = 0; i < count; i++) {
leds[i + offset] = leds[i * LED_DUPLICATION + offset];
}
for (unsigned short i = offset + count; i < LED_COUNT; i++) {
leds[i] = leds[i + LED_BUFFER_PADDING];
}
}
void setup() {
#ifdef DEBUG
Serial.begin(9600);
#endif
FastLED.addLeds<LED_TYPE, LED_PIN_1>(leds, LED_OFFSET_1, LED_COUNT_1 * LED_DUPLICATION);
FastLED.addLeds<LED_TYPE, LED_PIN_2>(leds, LED_OFFSET_2, LED_COUNT_2 * LED_DUPLICATION);
FastLED.addLeds<LED_TYPE, LED_PIN_3>(leds, LED_OFFSET_3, LED_COUNT_3 * LED_DUPLICATION);
Lights = LightsControl();
Lights.addPattern<PatternWhite>();
Lights.addPattern<PatternColors>();
Lights.addPattern<PatternFire>();
Lights.addPattern<PatternTrains>();
Hardware = HardwareControl();
}
void loop() {
Lights.step();
show(0, LED_OFFSET_1, LED_COUNT_1);
show(1, LED_OFFSET_2, LED_COUNT_2);
show(2, LED_OFFSET_3, LED_COUNT_3);
delay(1);
if (Hardware.getNextButtonPressed()) {
Lights.nextPattern();
}
}