Skip to content

Commit be8a8f6

Browse files
committed
refactor setting all channels to 0
1 parent acc4964 commit be8a8f6

File tree

5 files changed

+5
-16
lines changed

5 files changed

+5
-16
lines changed

docs/moonlight/nodes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ MoonLight specific
7575
* if the loop() function contains setXXX functions is used it is an **effect** node. It will contain for-loops iterating over each virtual ! light defined by layout and modifier nodes. The iteration will be on the x-axis for 1D effects, but also on the y- and z-axis for 2D and 3D effects. setRGB is the default function setting the RGB values of the light. If a light has more 'channels' (e.g. Moving heads) they also can be set.
7676
* Moving heads
7777
* **addLight** will show where the moving head will be on the stage. In general only an array of a few lights e.g. 4 moving heads in a row. A moving head effect will then iterate over 4 lights where each light might do something different (e.g. implement a wave of moving head movement)
78-
* You need to define **channelsPerLight** in the layout node setup() - (it is default 3 to support normal LEDs). Currently MoonLight only supports identical moving heads with the same channels. The first light starts at DMX 0 (+1), the second at DMX channelsPerLight (+1) the third on DMX 2*channelsPerLight (+1) and so on. (+1): DMX typically starts at address 1 while MoonLight internal starts with 0... WIP. We are working on a solution to support different lights e.g a mix of 15 channel lights and 32 channel lights etc. You could set channelsPerLight to a higher number as the real light, e.g. 32 so each lights DMX address starts at a multiple of 32.
78+
* You need to define **channelsPerLight** in the layout node setup() - (it is default 3 to support normal LEDs). Currently MoonLight only supports identical moving heads with the same channels. The first light starts at DMX 0 (+1), the second at DMX channelsPerLight (+1) the third on DMX 2*channelsPerLight (+1) and so on. (+1): DMX typically starts at address 1 while MoonLight internal starts with 0... WIP. We are working on a solution to support different lights e.g a mix of 15 channel lights and 32 channel lights etc. You could set channelsPerLight to a higher number as the real lights channels, e.g. 32 so each lights DMX address starts at a multiple of 32.
7979
* **Layout**: The layout node also defines which functionality / channels the light support by defining **offsets**. Currently the following offsets are supported: offsetRGB, offsetWhite, offsetBrightness, offsetPan, offsetTilt, offsetZoom, offsetRotate, offsetGobo, offsetRGB1, offsetRGB2, offsetRGB3, offsetBrightness2 and need to be set in the setup() function.
80-
* The distinction between physical and virtual layer for moving heads is not useful if you have only 2-4 moving heads. However this is standard MoonLight feature. It might become useful if you have like 8 (identical) moving heads, 4 left and 4 right of the stage, then you can add a mirror modifier and the virtual layer will only control 4 lights, which then will be mapped to 8 physical lights. In theory you can also have a cube of like 512 moving heads and then exotic modifiers like pinwheel could be used to really go crazy. Let us know when you have one of these setups 🚨
80+
* The distinction between physical and virtual layer for moving heads is not useful if you have only 2-4 moving heads. However this is a standard MoonLight feature. It might become useful if you have like 8 (identical) moving heads, 4 left and 4 right of the stage, then you can add a mirror modifier and the virtual layer will only control 4 lights, which then will be mapped to 8 physical lights. In theory you can also have a cube of like 512 moving heads and then exotic modifiers like pinwheel could be used to really go crazy. Let us know when you have one of these setups 🚨
8181
* Moving heads will be controlled using [ArtNed](https://moonmodules.org/MoonLight/moonbase/module/artnet/). addPin is not needed for moving heads, although you might want to attach LEDs for a visual view of what is send to ArtNet.
8282
* Effect nodes **set light**: Currently setRGB, setWhite, setBrightness, setPan, setTilt, setZoom, setRotate, setGobo, setRGB1, setRGB2, setRGB3, setBrightness2 is supported. In the background MoonLight calculates which channel need to be filled with values using the offsets (using the setLight function).
8383
* If offsetBrightness is defined, the RGB values will not be corrected for brightness in [ArtNed](https://moonmodules.org/MoonLight/moonbase/module/artnet/).

src/MoonLight/Nodes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class Node {
4747
virtual void setup() {
4848
if (hasLayout) {
4949
layerV->layerP->lights.header.resetOffsets(); //reset offsets to default
50-
layerV->resetLights(); //all channels to 0
5150
layerV->requestMapPhysical = true;
5251
layerV->requestMapVirtual = true;
5352
}

src/MoonLight/PhysicalLayer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ PhysicalLayer::PhysicalLayer() {
2323
ESP_LOGD(TAG, "constructor");
2424

2525
lights.header.resetOffsets(); //reset the offsets to default
26+
memset(lights.channels, 0, MAX_CHANNELS); // set all the channels to 0
2627

2728
// initLightsToBlend();
2829

@@ -53,6 +54,8 @@ PhysicalLayer::PhysicalLayer() {
5354
lights.header.size = {0,0,0};
5455
lights.header.isPositions = 1; //in progress...
5556
delay(100); //wait to stop effects
57+
//set all channels to 0 (e.g for multichannel to not activate unused channels, e.g. fancy modes on MHs)
58+
memset(lights.channels, 0, MAX_CHANNELS); // set all the channels to 0
5659
//dealloc pins
5760
sortedPins.clear(); //clear the added pins for the next pass
5861
} else if (pass == 2) {

src/MoonLight/VirtualLayer.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,6 @@ void VirtualLayer::fadeToBlackMin() {
259259
}
260260
}
261261

262-
void VirtualLayer::resetLights() {
263-
uint8_t channels[64];
264-
memset(channels, 0, sizeof(channels));
265-
for (uint16_t index = 0; index < nrOfLights; index++) {
266-
setLight(index, channels, 0, MIN(layerP->lights.header.channelsPerLight, 64));
267-
}
268-
if (layerP->lights.header.channelsPerLight > 64)
269-
ESP_LOGW(TAG, "channelsPerLight %d > 64 !", layerP->lights.header.channelsPerLight );
270-
}
271-
272262
void VirtualLayer::fill_solid(const CRGB& color) {
273263
// if (effectDimension < projectionDimension) { //only process the effect lights (so modifiers can do things with the other dimension)
274264
// for (int y=0; y < ((effectDimension == _1D)?1:size.y); y++) { //1D effects only on y=0, 2D effects loop over y

src/MoonLight/VirtualLayer.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@ class VirtualLayer {
170170
void fadeToBlackBy(const uint8_t fadeBy);
171171
void fadeToBlackMin();
172172

173-
//set all channels to 0 (e.g for multichannel to not activate unused channels, e.g. fancy modes on MHs)
174-
void resetLights();
175-
176173
void fill_solid(const CRGB& color);
177174
void fill_rainbow(const uint8_t initialhue, const uint8_t deltahue);
178175

0 commit comments

Comments
 (0)