Skip to content

Commit acdc095

Browse files
committed
Small fixes
1 parent 5bc47f5 commit acdc095

File tree

5 files changed

+22
-42
lines changed

5 files changed

+22
-42
lines changed

docs/moonlight/drivers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Want to add a Driver to MoonLight, see [develop](../../develop/overview/). See a
7373
Receives Art-Net data from the network.
7474

7575
* DDP: If unchecked, processes data in Art-Net format, if checked, process data in DDP format
76-
* Port: The port listening to for Art-Net, When using DDP change 4048 is the default port for DDP.
76+
* Port: The port listening for Art-Net. When using DDP, change to 4048 (the default port for DDP).
7777
* Universe Min-Max: Filters Universes (Art-Net only).
7878
* View:
7979
* Select physical layer to directly store the received channels into the physical layer

src/MoonBase/NodeManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class NodeManager : public Module {
8282
template <typename T>
8383
Node* checkAndAlloc(const char* name) const {
8484
if (equalAZaz09(name, T::name())) {
85-
EXT_LOGD(ML_TAG, "Allocate %d", name);
85+
EXT_LOGD(ML_TAG, "Allocate %s", name);
8686
return allocMBObject<T>();
8787
} else
8888
return nullptr;

src/MoonLight/Modules/ModuleDrivers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class ModuleDrivers : public NodeManager {
128128
if (!node) node = checkAndAlloc<SE16Layout>(name);
129129

130130
#if FT_LIVESCRIPT
131-
else if (!node) {
131+
if (!node) {
132132
LiveScriptNode* liveScriptNode = allocMBObject<LiveScriptNode>();
133133
liveScriptNode->animation = name; // set the (file)name of the script
134134
node = liveScriptNode;

src/MoonLight/Modules/ModuleEffects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class ModuleEffects : public NodeManager {
250250
if (!node) node = checkAndAlloc<RippleYZModifier>(name);
251251

252252
#if FT_LIVESCRIPT
253-
else if (!node) {
253+
if (!node) {
254254
LiveScriptNode* liveScriptNode = allocMBObject<LiveScriptNode>();
255255
liveScriptNode->animation = name; // set the (file)name of the script
256256
node = liveScriptNode;

src/MoonLight/Nodes/Effects/E_WLED.h

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ class AntEffect : public Node {
811811

812812
uint8_t antSpeed = 192;
813813
uint8_t nrOfAnts = MAX_ANTS / 2;
814-
uint8_t antSizeControl = 32 / 255;
814+
uint8_t antSizeControl = 8;
815815
uint8_t blur = 0;
816816
bool gatherFood = true;
817817
bool passByControl = true;
@@ -824,34 +824,15 @@ class AntEffect : public Node {
824824
addControl(blur, "blur", "slider");
825825
addControl(gatherFood, "gatherFood", "checkbox");
826826
addControl(passByControl, "passBy", "checkbox");
827-
}
828-
829-
Ant* ants = nullptr;
830-
// uint16_t nrOfAnts = 0;
831827

832-
void onSizeChanged(const Coord3D& prevSize) override {
833-
Ant* newAlloc = reallocMB<Ant>(ants, MAX_ANTS);
834-
if (newAlloc) {
835-
ants = newAlloc;
836-
// nrOfAnts = MAX_ANTS;
837-
} else {
838-
EXT_LOGE(ML_TAG, "(re)allocate ants failed"); // keep old (if existed)
839-
}
828+
initAnts();
840829
}
841830

842-
~AntEffect() override { freeMB(ants); };
843-
844-
void onUpdate(const Char<20>& oldValue, const JsonObject& control) {
845-
// add your custom onUpdate code here
846-
if (control["name"] == "bpm") {
847-
if (control["value"] == 0) {
848-
}
849-
}
850-
}
831+
Ant ants[MAX_ANTS];
851832

852833
// Helper function to calculate ant color
853834
CRGB getAntColor(int antIndex, int numAnts, bool usePalette) {
854-
// if (usePalette)
835+
// if (usePalette)
855836
return ColorFromPalette(layerP.palette, antIndex * 255 / numAnts);
856837
// Alternate between two colors for default palette
857838
// return (antIndex % 3 == 1) ? SEGCOLOR(0) : SEGCOLOR(2);
@@ -868,23 +849,22 @@ class AntEffect : public Node {
868849
}
869850
}
870851

871-
// Initialize ants on first call
852+
// Initialize ants on first call
872853
void initAnts() {
873-
int confusedAntIndex = random(0, numAnts); // the first random ant to go backwards
874-
875-
for (int i = 0; i < MAX_ANTS; i++) {
876-
ants[i].lastBumpUpdate = millis();
854+
int confusedAntIndex = random(0, numAnts); // the first random ant to go backwards
877855

878-
// Random velocity
879-
float velocity = VELOCITY_MIN + (VELOCITY_MAX - VELOCITY_MIN) * random16(1000, 5000) / 5000.0f;
880-
// One random ant moves in opposite direction
881-
ants[i].velocity = (i == confusedAntIndex) ? -velocity : velocity;
882-
// Random starting position (0.0 to 1.0)
883-
ants[i].position = random16(0, 10000) / 10000.0f;
884-
// Ants don't have food yet
885-
ants[i].hasFood = false;
886-
}
856+
for (int i = 0; i < MAX_ANTS; i++) {
857+
ants[i].lastBumpUpdate = millis();
887858

859+
// Random velocity
860+
float velocity = VELOCITY_MIN + (VELOCITY_MAX - VELOCITY_MIN) * random16(1000, 5000) / 5000.0f;
861+
// One random ant moves in opposite direction
862+
ants[i].velocity = (i == confusedAntIndex) ? -velocity : velocity;
863+
// Random starting position (0.0 to 1.0)
864+
ants[i].position = random16(0, 10000) / 10000.0f;
865+
// Ants don't have food yet
866+
ants[i].hasFood = false;
867+
}
888868
}
889869

890870
unsigned numAnts;
@@ -958,7 +938,7 @@ class AntEffect : public Node {
958938
unsigned pixelPosition = roundf(newPosition * (layer->nrOfLights - 1));
959939

960940
// Determine ant color
961-
CRGB antColor = getAntColor(i, numAnts, true); //always use palette for now
941+
CRGB antColor = getAntColor(i, numAnts, true); // always use palette for now
962942

963943
// Render ant pixels
964944
for (int pixelOffset = 0; pixelOffset < antSize; pixelOffset++) {

0 commit comments

Comments
 (0)