You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* You'll see later that it writes results here before updating `SEGMENT.data`.
166
166
* Note: this is allocated on the stack each frame. Keep such VLAs ≤ ~1 KiB; for larger sizes, prefer a buffer in `SEGENV.data`.
167
167
168
-
> **_IMPORTANT NOTE:_** Creating variable‑length arrays (VLAs) is non‑standard C++, but this practice is used throughout WLED and works in practice. Bbut be aware that VLAs live on the stack, which is limited. If the array scales with segment length (1D), it can overflow the stack and crash. Keep VLAs ≲ ~1 KiB; an array with 4000 LEDs is ~4 KiB and will likely crash. It’s worse with `uint16_t`. Anything larger than ~1 KiB should go into `SEGENV.data`, which has a higher limit.
168
+
> **_IMPORTANT NOTE:_** Creating variable‑length arrays (VLAs) is non‑standard C++, but this practice is used throughout WLED and works in practice. But be aware that VLAs live on the stack, which is limited. If the array scales with segment length (1D), it can overflow the stack and crash. Keep VLAs ≲ ~1 KiB; an array with 4000 LEDs is ~4 KiB and will likely crash. It’s worse with `uint16_t`. Anything larger than ~1 KiB should go into `SEGENV.data`, which has a higher limit.
169
169
170
170
171
171
Now we get to the spark generation portion, where new bursts of heat appear at the bottom of the matrix:
@@ -200,7 +200,7 @@ Next we reach the first part of the core of the fire simulation, which is diffus
200
200
// diffuse
201
201
for (unsigned y = 0; y < rows; y++) {
202
202
for (unsigned x = 0; x < cols; x++) {
203
-
unsigned v = SEGENV.data[XY(x, y)];
203
+
uint16_t v = SEGENV.data[XY(x, y)];
204
204
if (x > 0) {
205
205
v += SEGENV.data[XY(x - 1, y)];
206
206
}
@@ -226,7 +226,7 @@ After calculating tmp_row, we now handle rendering the pixels by updating the ac
226
226
```cpp
227
227
for (unsigned x = 0; x < cols; x++) {
228
228
SEGENV.data[XY(x, y)] = tmp_row[x];
229
-
if (SEGMENT.option1) {
229
+
if (SEGMENT.check1) {
230
230
uint32_t color = SEGMENT.color_from_palette(tmp_row[x], true, false, 0);
231
231
SEGMENT.setPixelColorXY(x, y, color);
232
232
} else {
@@ -238,7 +238,7 @@ After calculating tmp_row, we now handle rendering the pixels by updating the ac
238
238
```
239
239
* This next loop starts iterating over each row from top to bottom. (We're now doing this for color-rendering for each pixel row.)
240
240
* Next we update the main segment data with the smoothed value for this pixel.
241
-
* The if statement creates a conditional rendering path — the user can toggle this. If `option1` is enabled in the effect metadata, we use a color palette to display the flame.
241
+
* The if statement creates a conditional rendering path — the user can toggle this. If `check1` is enabled in the effect metadata, we use a color palette to display the flame.
242
242
* The next line converts the heat value (`tmp_row[x]`) into a `color` from the current palette with 255 brightness, and no wrapping in palette lookup.
243
243
* This creates rich gradient flames (e.g., yellow → red → black).
244
244
* Finally we set the rendered color for the pixel (x, y).
@@ -291,7 +291,7 @@ Using this info, let’s split the Metadata string above into logical sections:
291
291
| !, | Use default UI entry; for the first space, this will automatically create a slider for Speed |
292
292
| Spark rate, Diffusion Speed, Turbulence, | UI sliders for Spark Rate, Diffusion Speed, and Turbulence. Defining slider 2 as "Spark Rate" overwrites the default value of Intensity. |
293
293
| (blank), | unused (empty field with not even a space) |
294
-
| Use palette; | This occupies the spot for the 6th effect parameter, which automatically makes this a checkbox argument `o1` called Use palette in the UI. When this is enabled, the effect uses a palette `ColorFromPalette()`, otherwise it fades from `SEGCOLOR(0)`. The first semicolon marks the end of the Effect Parameters and the beginning of the `Colors` parameter. |
294
+
| Use palette; | This occupies the spot for the 6th effect parameter, which automatically makes this a checkbox argument `o1` called Use palette in the UI. When this is enabled, the effect uses `SEGMENT.color_from_palette(...)` (RGBW-aware, respects wrap), otherwise it fades from `SEGCOLOR(0)`. The first semicolon marks the end of the Effect Parameters and the beginning of the `Colors` parameter. |
295
295
| Color; | Custom color field `(SEGCOLOR(0))`|
296
296
| (blank); | Empty means the effect does not allow Palettes to be selected by the user. But used in conjunction with the checkbox argument, palette use can be turned on/off by the user. |
297
297
| 2; | Flag specifying that the effect requires a 2D matrix setup |
0 commit comments