diff --git a/Add-own-functionality.md b/Add-own-functionality.md new file mode 100644 index 0000000..e9656c7 --- /dev/null +++ b/Add-own-functionality.md @@ -0,0 +1,25 @@ +This page is intended for those wishing to modify the WLED code to add their own functionality. + +### Basics +Programming is done in the Arduino IDE. There is a special file, `wled06_usermod.ino`, to write your own code. +(however, if you think your code may be relevant to many users, feel free to code it in directly and open a pull request) + +This file has three empty methods: +- `userBeginPreConnection()` is called after loading settings but before connecting to WiFi. +Use it to load custom settings or to specify own server pages with the `server.on()` method. +- `userBegin()` is the main initialization. Use it to start own interfaces (IR, UDP ports, Websockets, GPIOs,...). +- `userLoop()` is called by the main `loop()` function. + +### Modify WLED values +If you know what you're doing, you may choose to change the value of any global variable declared in `wled00.ino`. +However, for basic color and brightness changes, these are the most important: + +Variable Name | Type | Purpose +--- | --- | --- +bri | byte (0-255) | Master Brightness (0 is off, 255 is maximum) +col[0] | byte (0-255) | Red color value +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