-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLEDGarland.hpp
158 lines (140 loc) · 5.61 KB
/
LEDGarland.hpp
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
101
102
103
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
152
153
154
155
156
157
158
// LEDGarland.hpp
#ifndef _LEDGARLAND_HPP_
#define _LEDGARLAND_HPP_
#include <LEDMatrix.h>
#include <UniversalLEDLineEffects.h>
#include <UniversalLEDMatrixEffects.h>
#include <StaticLEDMatrixEffects.h>
#include <DynamicLEDMatrixEffects.h>
#define NUM_LINES 4
template<template <CRGB*, uint8_t, uint8_t> class MATRIX, CRGB* ledLine, uint8_t width, uint8_t height>
class LEDGarland : public LEDMatrix
{
private:
enum NOISE_NAME { OCEAN = 0, RAINBOW, CLOUD, FOREST, PARTY, LAVA };
LedEffectName const noiseEffects[6] =
{
"OCEAN_NOISE",
"RAINBOW_NOISE",
"CLOUD_NOISE",
"FOREST_NOISE",
"PARTY_NOISE",
"LAVA_NOISE"
};
static const uint8_t NUM_EFFECTS = 16;
LedEffectName availableEffects[NUM_EFFECTS] =
{
ColorsLedEffect<leds, width* height>::name,
SparklesLedEffect<leds, width* height>::name,
RainbowLedEffect<leds, width* height>::name,
BugsMatrixLedEffect<MATRIX, ledLine, width, height>::name,
noiseEffects[OCEAN],
BouncingBallsMatrixLedEffect<MATRIX, ledLine, width, height>::name,
noiseEffects[RAINBOW],
StarfallMatrixLedEffect<MATRIX, ledLine, width, height>::name,
noiseEffects[CLOUD],
FireMatrixLedEffect<MATRIX, ledLine, width, height>::name,
noiseEffects[FOREST],
SinusMatrixLedEffect<MATRIX, ledLine, width, height>::name,
noiseEffects[PARTY],
GravityMatrixLedEffect<MATRIX, ledLine, width, height>::name,
noiseEffects[LAVA],
BouncingLinesMatrixLedEffect<MATRIX, ledLine, width, height, NUM_LINES>::name,
};
public:
LEDGarland()
{
text = String("<<< ..... >>>");
};
~LEDGarland()
{
};
uint8_t howManyEffects() const override
{
return NUM_EFFECTS;
};
LedEffectName const* getAllEffectsNames() const override
{
return availableEffects;
};
bool setEffectByName(LedEffectName effectName) override
{
if (strcmp(BouncingLinesMatrixLedEffect<MATRIX, ledLine, width, height, NUM_LINES>::name, effectName) == 0)
{
delete activeEffect; activeEffect = new BouncingLinesMatrixLedEffect<MATRIX, ledLine, width, height, NUM_LINES>(random(5, 20));
}
else if (strcmp(BouncingBallsMatrixLedEffect<MATRIX, ledLine, width, height>::name, effectName) == 0)
{
delete activeEffect; activeEffect = new BouncingBallsMatrixLedEffect<MATRIX, ledLine, width, height>(10, 3);
}
else if (strcmp(BugsMatrixLedEffect<MATRIX, ledLine, width, height>::name, effectName) == 0)
{
delete activeEffect; activeEffect = new BugsMatrixLedEffect<MATRIX, ledLine, width, height>(random(10, 30), random(width, width << 1));
}
else if (strcmp(FireMatrixLedEffect<MATRIX, ledLine, width, height>::name, effectName) == 0)
{
delete activeEffect; activeEffect = new FireMatrixLedEffect<MATRIX, ledLine, width, height>(random(10, 30));
}
else if (strcmp(GravityMatrixLedEffect<MATRIX, ledLine, width, height>::name, effectName) == 0)
{
delete activeEffect; activeEffect = new GravityMatrixLedEffect<MATRIX, ledLine, width, height>(random(10, 30));
}
else if (strcmp(SinusMatrixLedEffect<MATRIX, ledLine, width, height>::name, effectName) == 0)
{
delete activeEffect; activeEffect = new SinusMatrixLedEffect<MATRIX, ledLine, width, height>(random(10, 50));
}
else if (strcmp(StarfallMatrixLedEffect<MATRIX, ledLine, width, height>::name, effectName) == 0)
{
delete activeEffect; activeEffect = new StarfallMatrixLedEffect<MATRIX, ledLine, width, height>(random(10, 30));
}
else if (strcmp(noiseEffects[LAVA], effectName) == 0)
{
delete activeEffect; activeEffect = new NoiseMatrixLedEffect<MATRIX, ledLine, width, height>(random(8, 30), LavaColors_p, random(5, 50));
if (activeEffect != NULL) activeEffect->setId(noiseEffects[LAVA]);
}
else if (strcmp(noiseEffects[OCEAN], effectName) == 0)
{
delete activeEffect; activeEffect = new NoiseMatrixLedEffect<MATRIX, ledLine, width, height>(random(8, 30), OceanColors_p, random(10, 40));
if (activeEffect != NULL) activeEffect->setId(noiseEffects[OCEAN]);
}
else if (strcmp(noiseEffects[RAINBOW], effectName) == 0)
{
delete activeEffect; activeEffect = new NoiseMatrixLedEffect<MATRIX, ledLine, width, height>(random(8, 50), RainbowColors_p, random(5, 50));
if (activeEffect != NULL) activeEffect->setId(noiseEffects[RAINBOW]);
}
else if (strcmp(noiseEffects[CLOUD], effectName) == 0)
{
delete activeEffect; activeEffect = new NoiseMatrixLedEffect<MATRIX, ledLine, width, height>(random(8, 30), CloudColors_p, random(15, 40));
if (activeEffect != NULL) activeEffect->setId(noiseEffects[CLOUD]);
}
else if (strcmp(noiseEffects[FOREST], effectName) == 0)
{
delete activeEffect; activeEffect = new NoiseMatrixLedEffect<MATRIX, ledLine, width, height>(random(8, 30), ForestColors_p, random(5, 50));
if (activeEffect != NULL) activeEffect->setId(noiseEffects[FOREST]);
}
else if (strcmp(noiseEffects[PARTY], effectName) == 0)
{
delete activeEffect; activeEffect = new NoiseMatrixLedEffect<MATRIX, ledLine, width, height>(random(8, 50), PartyColors_p, random(5, 50));
if (activeEffect != NULL) activeEffect->setId(noiseEffects[PARTY]);
}
else if (strcmp(ColorsLedEffect<leds, width * height>::name, effectName) == 0)
{
delete activeEffect; activeEffect = new ColorsLedEffect<leds, width* height>(random(10, 30));
}
else if (strcmp(SparklesLedEffect<leds, width * height>::name, effectName) == 0)
{
delete activeEffect; activeEffect = new SparklesLedEffect<leds, width* height>(random(10, 30));
}
else if (strcmp(RainbowLedEffect<leds, width * height>::name, effectName) == 0)
{
delete activeEffect; activeEffect = new RainbowLedEffect<leds, width* height>(random(10, 30));
}
else
{
return false;
}
if (activeEffect != nullptr) activeEffect->start();
return true;
};
};
#endif