Skip to content

Commit 0364c17

Browse files
committed
Combine rainbow(glitter), AudioRingsEffect tweak, Octopus offset to %
1 parent 53fb855 commit 0364c17

File tree

5 files changed

+13
-50
lines changed

5 files changed

+13
-50
lines changed

src/MoonLight/Layers/PhysicalLayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct LightsHeader {
5656
uint8_t offsetRGB3 = UINT8_MAX;
5757
uint8_t offsetBrightness2 = UINT8_MAX; // 31
5858
uint16_t nrOfChannels; // 32, so we can deal with exceptional cases e.g. RGB2040 make sure it starts at even position!!! for alignment!!!
59-
uint8_t lightPreset = UINT8_MAX; // 34, so we can deal with exceptional cases e.g. RGB2040
59+
uint8_t lightPreset = 2; // 34, so we can deal with exceptional cases e.g. RGB2040. default 2 / GRB
6060
// =============
6161
// 35 bytes total
6262
uint8_t fill[5]; // padding to align struct to 40 bytes total. lightsControl will send 37 bytes (prime number)!!! so Monitor.svelte can recognize this

src/MoonLight/Modules/ModuleEffects.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ class ModuleEffects : public NodeManager {
9090
addControlValue(control, getNameAndTags<FreqSawsEffect>());
9191
addControlValue(control, getNameAndTags<MarioTestEffect>());
9292
addControlValue(control, getNameAndTags<PixelMapEffect>());
93-
addControlValue(control, getNameAndTags<RainbowEffect>());
9493
addControlValue(control, getNameAndTags<RandomEffect>());
9594
addControlValue(control, getNameAndTags<RingRandomFlowEffect>());
9695
addControlValue(control, getNameAndTags<RipplesEffect>());
@@ -132,7 +131,7 @@ class ModuleEffects : public NodeManager {
132131
addControlValue(control, getNameAndTags<WaverlyEffect>());
133132

134133
// FastLED effects
135-
addControlValue(control, getNameAndTags<RainbowWithGlitterEffect>());
134+
addControlValue(control, getNameAndTags<RainbowEffect>());
136135

137136
// Moving head effects, alphabetically
138137
addControlValue(control, getNameAndTags<AmbientMoveEffect>());
@@ -270,8 +269,6 @@ class ModuleEffects : public NodeManager {
270269
// FastLED
271270
else if (equalAZaz09(name, RainbowEffect::name()))
272271
node = allocMBObject<RainbowEffect>();
273-
else if (equalAZaz09(name, RainbowWithGlitterEffect::name()))
274-
node = allocMBObject<RainbowWithGlitterEffect>();
275272

276273
// Moving head effects, alphabetically
277274

src/MoonLight/Nodes/Effects/E_FastLED.h

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,50 +17,24 @@ class RainbowEffect : public Node {
1717
static uint8_t dim() { return _1D; }
1818
static const char* tags() { return "🔥⚡️"; }
1919

20-
uint8_t deltaHue = 7;
2120
uint8_t speed = 8; // default 8*32 = 256 / 256 = 1 = hue++
21+
uint8_t deltaHue = 7;
22+
uint8_t chanceOfGlitter = 80;
2223

2324
void setup() {
2425
addControl(speed, "speed", "slider", 0, 32);
2526
addControl(deltaHue, "deltaHue", "slider", 0, 32);
27+
addControl(chanceOfGlitter, "chanceOfGlitter", "slider", 0, 100);
2628
}
2729

2830
uint16_t hue = 0;
2931

3032
void loop() override {
3133
layer->fill_rainbow((hue += speed * 32) >> 8, deltaHue); // hue back to uint8_t
32-
}
33-
};
34-
35-
class RainbowWithGlitterEffect : public Node {
36-
public:
37-
static const char* name() { return "Rainbow with glitter"; }
38-
static uint8_t dim() { return _1D; }
39-
static const char* tags() { return "🔥⚡️"; } // ⚡️ means FastLED origin
40-
41-
bool glitter = false;
42-
uint8_t chance = 80;
43-
44-
void setup() override {
45-
// no palette control is created
46-
addControl(glitter, "glitter", "checkbox");
47-
addControl(chance, "chance", "slider");
48-
}
49-
50-
void loop() override {
51-
// built-in FastLED rainbow, plus some random sparkly glitter
52-
// FastLED's built-in rainbow generator
53-
layer->fill_rainbow(millis() / 50, 7);
54-
55-
if (glitter) addGlitter(chance);
56-
}
57-
58-
void addGlitter(fract8 chanceOfGlitter) {
59-
if (random8() < chanceOfGlitter) {
34+
if (chanceOfGlitter && random8() < chanceOfGlitter) {
6035
layer->setRGB(random16(layer->size.x), CRGB::White);
6136
}
6237
}
6338
};
6439

65-
6640
#endif

src/MoonLight/Nodes/Effects/E_MoonLight.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,11 +1574,7 @@ class RingRandomFlowEffect : public RingEffect {
15741574

15751575
uint8_t* hue = nullptr;
15761576

1577-
~RingRandomFlowEffect() {
1578-
freeMB(hue);
1579-
1580-
Node::~Node();
1581-
}
1577+
~RingRandomFlowEffect() { freeMB(hue); }
15821578

15831579
void onSizeChanged(const Coord3D& prevSize) override {
15841580
freeMB(hue);
@@ -1636,8 +1632,8 @@ class AudioRingsEffect : public RingEffect {
16361632
// setRingFromFtt((i * 2), i);
16371633
}
16381634

1639-
setRingFromFtt(2, 7); // set outer ring to bass
1640-
setRingFromFtt(0, 8); // set outer ring to bass
1635+
if (nrOfRings >= 2) setRingFromFtt(2, nrOfRings - 2); // set outer rings to bass
1636+
if (nrOfRings >= 1) setRingFromFtt(0, nrOfRings - 1); // set outer rings to bass
16411637
}
16421638
void setRingFromFtt(int index, int ring) {
16431639
byte val = sharedData.bands[index];

src/MoonLight/Nodes/Effects/E_WLED.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,6 @@ class GEQEffect : public Node {
333333

334334
~GEQEffect() {
335335
freeMB(previousBarHeight);
336-
337-
Node::~Node();
338336
}
339337

340338
void onSizeChanged(const Coord3D& prevSize) override {
@@ -763,13 +761,13 @@ class OctopusEffect : public Node {
763761
};
764762

765763
uint8_t speed = 16;
766-
Coord3D offset = {128, 128, 1};
764+
Coord3D offset = {50, 50, 50};
767765
uint8_t legs = 4;
768766
bool radialWave = false;
769767

770768
void setup() override {
771769
addControl(speed, "speed", "slider", 1, 32);
772-
addControl(offset, "offset", "coord3D", 0, 255, false);
770+
addControl(offset, "offset", "coord3D", 0, 100, false); // 0..100%
773771
addControl(legs, "legs", "slider", 1, 8);
774772

775773
addControl(radialWave, "radialWave", "checkbox");
@@ -788,13 +786,11 @@ class OctopusEffect : public Node {
788786

789787
~OctopusEffect() {
790788
freeMB(rMap);
791-
792-
Node::~Node();
793789
}
794790

795791
void setRMap() {
796-
const uint8_t C_X = layer->size.x / 2 + (offset.x - 128) * layer->size.x / 255;
797-
const uint8_t C_Y = layer->size.y / 2 + (offset.y - 128) * layer->size.y / 255;
792+
const uint8_t C_X = layer->size.x / 2 + (offset.x - 50) * layer->size.x / 100;
793+
const uint8_t C_Y = layer->size.y / 2 + (offset.y - 50) * layer->size.y / 100;
798794
Coord3D pos = {0, 0, 0};
799795
const uint8_t mapp = 180 / max(layer->size.x, layer->size.y);
800796
for (pos.x = 0; pos.x < layer->size.x; pos.x++) {

0 commit comments

Comments
 (0)