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
Copy file name to clipboardExpand all lines: usermods/user_fx/README.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ if (!strip.isMatrix || !SEGMENT.is2D())
51
51
return mode_static(); // not a 2D set-up
52
52
```
53
53
The next code block contains several constant variable definitions which essentially serve to extract the dimensions of the user's 2D matrix and allow WLED to interpret the matrix as a 1D coordinate system (WLED must do this for all 2D animations):
54
-
```
54
+
```cpp
55
55
constint cols = SEG_W;
56
56
constint rows = SEG_H;
57
57
constauto XY = [&](int x, int y) { return x + y * cols; };
@@ -64,7 +64,7 @@ const auto XY = [&](int x, int y) { return x + y * cols; };
64
64
* WLED internally treats the LED strip as a 1D array, so effects must translate 2D coordinates into 1D indices. This lambda helps with that.
65
65
66
66
The next lines of code further the setup process by defining variables that allow the effect's settings to be configurable using the UI sliders (or alternatively, through API calls):
The next lines of code clear the LEDs and initialize timing:
106
-
```
106
+
```cpp
107
107
if (SEGENV.call == 0) {
108
108
SEGMENT.fill(BLACK);
109
109
SEGENV.step = 0;
@@ -115,7 +115,7 @@ if (SEGENV.call == 0) {
115
115
* It also initializes `SEGENV.step`, a timing marker, to 0. This value is later used as a timestamp to control when the next animation frame should occur (based on elapsed time).
116
116
117
117
The next block of code is where the animation update logic starts to kick in:
This string is passed into `strip.addEffect()` and parsed by WLED to determine how your effect appears and behaves in the UI.
@@ -241,7 +241,7 @@ Let’s split this into logical sections (delimited by semicolons ;):
241
241
### The UserFxUsermod Class
242
242
243
243
The `UserFxUsermod` class registers the `mode_diffusionfire` effect with WLED. This section starts right after the effect function and metadata string, and is responsible for making the effect usable in the WLED interface:
244
-
```
244
+
```cpp
245
245
classUserFxUsermod : publicUsermod {
246
246
private:
247
247
public:
@@ -278,7 +278,7 @@ class UserFxUsermod : public Usermod {
278
278
* USERMOD_ID_USER_FX is defined in [const.h](https://github.com/wled/WLED/blob/main/wled00/const.h). WLED uses this for tracking, debugging, or referencing usermods internally.
279
279
280
280
The final part of this file handles instatiation and initialization:
0 commit comments