Created Add own functionality (markdown)

This commit is contained in:
Aircoookie 2018-02-25 14:46:39 +01:00
parent ab142e2a2f
commit 993b049ad8
1 changed files with 25 additions and 0 deletions

25
Add-own-functionality.md Normal file
View File

@ -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)`.