Custom overlay effect

Hello!

What I am trying to do is write a new effect in FX.cpp. The behavior I want is that when the effect is not active (turned off) the LEDs will rather than be turned off, will inherit the setting from the layer below. I think this is what “overlay” is supposed to be. However, I cannot seem to make this work. Is this indeed the expected behavior of overlay and how do I add overlay capability to my effect. Thanks.

Here is the code for my effect:

// effect functions
uint16_t mode_focus_light(void) {
int center = SEGLEN / 2;
float sigma = 10.0 * (SEGMENT.intensity / 255.0);

for (int i = 0; i < SEGLEN; i++) {
float distanceFromCenter = abs(i - center);
int scale = int(255.0 * exp(-pow(distanceFromCenter / sigma, 2)));
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 0, scale));
}
return FRAMETIME;
}
static const char _data_FX_MODE_FOCUS_LIGHT PROGMEM = “Focus Light@!,Sigma,Overlay;!,!,!;!”;

if you use overlapping segments, you can just switch off the segment and the one below will be shown if your FX does not do overlay. if that is what you want.
if not, you need to read what is already there and display it by “getPixelColor”, or just not draw anything and let the underlaying semgent be.

Thank you. That is the issue. Segment 0 is the entire strip which I set to a solid color effect. Segment 1 overlaps. When I turn off Segment 1, the LEDs in Segment 1 are just off, they do not pick up the Segment 0 color. My Segment 1 effect code is above in this thread.

that is not how I remember it working. is that in latest beta? does that work with any other effects?

It does not - I was just typing that reply. If I make Segment 1 be, say, a solid color effect I get the same behavior. I’m running the latest release of WLED, btw.