Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/MoonBase/Nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ void DriverNode::setup() {
addControlValue("BGR");
addControlValue("RGBW"); // e.g. 4 channel par/dmx light
addControlValue("GRBW"); // rgbw LED eg. sk6812
addControlValue("WRGB"); // rgbw ws2814 LEDs
addControlValue("Curtain GRB6"); // some LED curtains
addControlValue("Curtain RGB2040"); // curtain RGB2040
addControlValue("Lightbar RGBWYP"); // 6 channel par/dmx light with UV etc
Expand Down Expand Up @@ -458,6 +459,13 @@ void DriverNode::onUpdate(const Char<20>& oldValue, const JsonObject& control) {
header->offsetBlue = 2;
header->offsetWhite = 3;
break;
case lightPreset_WRGB:
header->channelsPerLight = 4;
header->offsetRed = 1;
header->offsetGreen = 2;
header->offsetBlue = 3;
header->offsetWhite = 0;
break;
case lightPreset_GRB6:
header->channelsPerLight = 6;
header->offsetRed = 1;
Expand Down
1 change: 1 addition & 0 deletions src/MoonBase/Nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum LightPresetsEnum {
lightPreset_BGR,
lightPreset_RGBW, // e.g. 4 channel par/dmx light
lightPreset_GRBW, // rgbw LED eg. sk6812
lightPreset_WRGB, // rgbw ws2814 LEDs
lightPreset_GRB6, // some LED curtains
lightPreset_RGB2040, // curtain 2040
lightPreset_RGBWYP, // 6 channel par/dmx light with UV etc
Expand Down
5 changes: 3 additions & 2 deletions src/MoonLight/Layers/VirtualLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class VirtualLayer {
uint16_t XYZUnModified(const Coord3D& position) const { return position.x + position.y * size.x + position.z * size.x * size.y; }

void setRGB(const uint16_t indexV, CRGB color) {
if (layerP->lights.header.offsetWhite != UINT8_MAX && layerP->lights.header.offsetWhite == layerP->lights.header.offsetRGB + 3) { // W set and after RGB
if (layerP->lights.header.offsetWhite != UINT8_MAX) { // W set
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add && channelsPerLight == 4 here to avoid problems with moving heads

// using the simple algorithm of taking the minimum of RGB as white channel, this is good enough and fastest algorithm - we need speed 🔥
uint8_t rgbw[4];
rgbw[3] = MIN(MIN(color.r, color.g), color.b);
Expand All @@ -112,7 +112,8 @@ class VirtualLayer {
void setRGB(Coord3D pos, CRGB color) { setRGB(XYZ(pos), color); }

void setWhite(const uint16_t indexV, const uint8_t value) {
if (layerP->lights.header.offsetWhite != UINT8_MAX) setLight(indexV, &value, layerP->lights.header.offsetWhite, sizeof(value));
if (layerP->lights.header.offsetWhite == 0 && layerP->lights.header.channelsPerLight == 4) setLight(indexV, &value, 3, sizeof(value));
else if (layerP->lights.header.offsetWhite != UINT8_MAX) setLight(indexV, &value, layerP->lights.header.offsetWhite, sizeof(value));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be combined into :

If offsetWhite != UINT8_MAX {
If (channelsPerLight is 4) assign to position 3; // for rgbw lights
Else assign to offsetWhite position; // for moving heads

}

}
void setWhite(Coord3D pos, const uint8_t value) { setWhite(XYZ(pos), value); }

Expand Down
8 changes: 4 additions & 4 deletions src/MoonLight/Nodes/Drivers/D_ParallelLEDDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ class ParallelLEDDriver : public DriverNode {

uint8_t savedBrightness = ledsDriver._brightness; //(initLed sets it to 255 and thats not what we want)

EXT_LOGD(ML_TAG, "init Parallel LED Driver %d %d %d %d", layerP.lights.header.channelsPerLight, layerP.lights.header.offsetRed, layerP.lights.header.offsetGreen, layerP.lights.header.offsetBlue);
ledsDriver.initled(layerP.lights.channelsD, pins, layerP.ledsPerPin, nrOfPins, layerP.lights.header.channelsPerLight, layerP.lights.header.offsetRed, layerP.lights.header.offsetGreen, layerP.lights.header.offsetBlue);
EXT_LOGD(ML_TAG, "init Parallel LED Driver %d %d %d %d %d", layerP.lights.header.channelsPerLight, layerP.lights.header.offsetRed, layerP.lights.header.offsetGreen, layerP.lights.header.offsetBlue, layerP.lights.header.offsetWhite);
ledsDriver.initled(layerP.lights.channelsD, pins, layerP.ledsPerPin, nrOfPins, layerP.lights.header.channelsPerLight, layerP.lights.header.offsetRed, layerP.lights.header.offsetGreen, layerP.lights.header.offsetBlue, layerP.lights.header.offsetWhite);

ledsDriver.setBrightness(savedBrightness); //(initLed sets it to 255 and thats not what we want)

Expand All @@ -130,8 +130,8 @@ class ParallelLEDDriver : public DriverNode {
} else {
// don't call initled again as that will crash because if channelsPerLight (nb_components) change, the dma buffers are not big enough

EXT_LOGD(ML_TAG, "update Parallel LED Driver %d %d %d %d", layerP.lights.header.channelsPerLight, layerP.lights.header.offsetRed, layerP.lights.header.offsetGreen, layerP.lights.header.offsetBlue);
ledsDriver.updateDriver(pins, layerP.ledsPerPin, nrOfPins, dmaBuffer, layerP.lights.header.channelsPerLight, layerP.lights.header.offsetRed, layerP.lights.header.offsetGreen, layerP.lights.header.offsetBlue);
EXT_LOGD(ML_TAG, "update Parallel LED Driver %d %d %d %d %d", layerP.lights.header.channelsPerLight, layerP.lights.header.offsetRed, layerP.lights.header.offsetGreen, layerP.lights.header.offsetBlue, layerP.lights.header.offsetWhite);
ledsDriver.updateDriver(pins, layerP.ledsPerPin, nrOfPins, dmaBuffer, layerP.lights.header.channelsPerLight, layerP.lights.header.offsetRed, layerP.lights.header.offsetGreen, layerP.lights.header.offsetBlue, layerP.lights.header.offsetWhite);
}

#else // P4: Parlio Troy Driver
Expand Down