-
Notifications
You must be signed in to change notification settings - Fork 1
/
multi-beacon.cpp
100 lines (83 loc) · 2.78 KB
/
multi-beacon.cpp
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
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
96
97
98
99
100
#include "Arduino.h"
#include "PatternController.h"
#include "patterns/AlternatingColors.h"
#include "patterns/BeaconPulse2.h"
#include "patterns/BeaconPulse.h"
#include "patterns/BeaconScanner.h"
#include "patterns/ColorBars.h"
#include "patterns/Gradient.h"
#include "patterns/LarsonScanner.h"
#include "patterns/Lightning.h"
#include "patterns/Rainbow.h"
#include "patterns/RandomColors.h"
#include <FastLED.h>
#include <TimerOne.h>
#define POWER_LED_PIN A3
#define KNOB_PIN A0
#define SWITCH_PIN 3
#define LED_PIN 4
#define NUM_LEDS_PER_BEACON 24
#define NUM_BEACONS 6
#define NUM_LEDS (NUM_LEDS_PER_BEACON * NUM_BEACONS)
#define CHIPSET WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
PatternController pattern_master = PatternController(leds, NUM_LEDS);
AlternatingColors alt = AlternatingColors(24);
ColorBars cb = ColorBars(CRGB::Blue, CRGB::Black, 24);
LarsonScanner larson = LarsonScanner(CRGB::Red, CRGB::Black);
RandomColors randomcolors = RandomColors(4);
BeaconPulse2 bp2 = BeaconPulse2();
Rainbow rainbow = Rainbow(1);
Gradient grad = Gradient();
BeaconPulse bp = BeaconPulse();
BeaconScanner bs = BeaconScanner();
Lightning lightning = Lightning(CRGB::White, 24);
// These values are used in updateBrightness().
uint8_t brightnesses[] = {7, 20, 35, 60, 80, 120, 255};
uint8_t num_brightnesses = sizeof(brightnesses) / sizeof(brightnesses[0]);
// This function will be called periodically to update the brightness levels.
void updateBrightness() {
if(digitalRead(SWITCH_PIN) == HIGH){
FastLED.setBrightness(0);
} else {
uint16_t knob_val = analogRead(KNOB_PIN);
uint8_t index = (num_brightnesses * knob_val) >> 10;
FastLED.setBrightness(brightnesses[index]);
}
}
void setup(){
#ifdef DEBUG
Serial.begin(115200);
#endif
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalSMD5050);
pattern_master.add(&alt);
pattern_master.add(&cb);
larson.set_fps(80);
pattern_master.add(&larson);
randomcolors.set_fps(15);
pattern_master.add(&randomcolors);
pattern_master.add(&bp2);
//pattern_master.add(new Sos());
pattern_master.add(&grad);
bp.set_fps(20);
pattern_master.add(&bp);
pattern_master.add(&rainbow);
pattern_master.add(&bs);
pattern_master.add(&lightning);
pattern_master.set_fps(30);
pattern_master.pattern_duration = 15000;
// Set up switch which is used to turn leds all the way off
pinMode(SWITCH_PIN, INPUT_PULLUP);
// Set up timer to run the brightness button checks periodically
Timer1.initialize(100000); // Period in Microseconds = 0.1 seconds
Timer1.attachInterrupt(updateBrightness);
updateBrightness();
//Status pin so I know that we made it through Setup
pinMode(POWER_LED_PIN, OUTPUT);
digitalWrite(POWER_LED_PIN, HIGH);
}
void loop(){
pattern_master.show();
FastLED.show();
}