Skip to content

Commit cbf1e1d

Browse files
authored
Update README.md
made some final nitpick changes suggested by coderabbit
1 parent 6c427b7 commit cbf1e1d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

usermods/user_fx/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ const uint8_t turbulence = SEGMENT.custom2;
117117
Next we will look at some lines of code that handle memory allocation and effect initialization:
118118

119119
```cpp
120-
unsigned dataSize = cols * rows; // or: SEGLEN for virtual length
120+
unsigned dataSize = cols * rows; // SEGLEN (virtual length) is equivalent to vWidth()*vHeight() for 2D
121121
```
122122
* This part calculates how much memory we need to represent per-pixel state.
123123
* `cols * rows` or `(or SEGLEN)` returns the total number of LEDs in the current segment.
@@ -149,7 +149,7 @@ if (SEGENV.call == 0) {
149149
The next block of code is where the animation update logic starts to kick in:
150150
```cpp
151151
if ((strip.now - SEGENV.step) >= refresh_ms) {
152-
uint8_t tmp_row[cols];
152+
uint8_t tmp_row[cols]; // Keep for ≤~1 KiB; otherwise consider heap or reuse SEGENV.data as scratch.
153153
SEGENV.step = strip.now;
154154
// scroll up
155155
for (unsigned y = 1; y < rows; y++)
@@ -165,7 +165,7 @@ if ((strip.now - SEGENV.step) >= refresh_ms) {
165165
* You'll see later that it writes results here before updating `SEGMENT.data`.
166166
* Note: this is allocated on the stack each frame. Keep such VLAs ≤ ~1 KiB; for larger sizes, prefer a buffer in `SEGENV.data`.
167167
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.
169169
170170
171171
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
200200
// diffuse
201201
for (unsigned y = 0; y < rows; y++) {
202202
for (unsigned x = 0; x < cols; x++) {
203-
unsigned v = SEGENV.data[XY(x, y)];
203+
uint16_t v = SEGENV.data[XY(x, y)];
204204
if (x > 0) {
205205
v += SEGENV.data[XY(x - 1, y)];
206206
}
@@ -226,7 +226,7 @@ After calculating tmp_row, we now handle rendering the pixels by updating the ac
226226
```cpp
227227
for (unsigned x = 0; x < cols; x++) {
228228
SEGENV.data[XY(x, y)] = tmp_row[x];
229-
if (SEGMENT.option1) {
229+
if (SEGMENT.check1) {
230230
uint32_t color = SEGMENT.color_from_palette(tmp_row[x], true, false, 0);
231231
SEGMENT.setPixelColorXY(x, y, color);
232232
} else {
@@ -238,7 +238,7 @@ After calculating tmp_row, we now handle rendering the pixels by updating the ac
238238
```
239239
* This next loop starts iterating over each row from top to bottom. (We're now doing this for color-rendering for each pixel row.)
240240
* 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.
242242
* 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.
243243
* This creates rich gradient flames (e.g., yellow → red → black).
244244
* 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:
291291
| !, | Use default UI entry; for the first space, this will automatically create a slider for Speed |
292292
| 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. |
293293
| (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. |
295295
| Color; | Custom color field `(SEGCOLOR(0))` |
296296
| (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. |
297297
| 2; | Flag specifying that the effect requires a 2D matrix setup |

0 commit comments

Comments
 (0)