diff --git a/Add-own-functionality.md b/Add-own-functionality.md index e9656c7..923887e 100644 --- a/Add-own-functionality.md +++ b/Add-own-functionality.md @@ -22,4 +22,21 @@ col[1] | byte (0-255) | Green color value col[2] | byte (0-255) | Blue color value white | byte (0-255) | White color value -After updating the color, you must call the `colorUpdated(int)` method. If you want to send a notification with the new color to other ESPs, use `colorUpdated(1)`, otherwise `colorUpdated(5)`. \ No newline at end of file +After updating the color, you must call the `colorUpdated(int)` method. If you want to send a notification with the new color to other ESPs, use `colorUpdated(1)`, otherwise `colorUpdated(5)`. + +### Timing + +If you'd just like a simple modification that requires timing (like sending a request every 2 seconds), please **never** use the `delay()` function in your `userLoop()`! It will block everything else and WLED will become unresponsive and effects won't work! Instead, try this instead: +``` +long lastTime; +int delayMs = 2000; //we want to do something every 2 seconds + +void userLoop() +{ + if (millis()-lastTime > delayMs) + { + lastTime = millis(); + //do something you want to do every 2 seconds + } +} +``` \ No newline at end of file