- What must be done?
- Optional
- Rules
- Recommendations
- Typical use cases
- Traps and pitfalls
- SW Architecture
- Static View
- Issues, Ideas And Bugs
- License
- Contribution
- Create the plugin as library:
- Create a folder in
/lib/<plugin-name>with the plugin name. Very important: The plugin name shall end with "Plugin", e.g. "FirePlugin". - Create two additional folders underneath:
src: Contains the plugin sourcecode.web: Contains all web relevant files, including icons the plugin may need.
- Create a
library.jsonwith the library meta information.
- Create a folder in
- The plugin sources (.h/.cpp) shall be in
/lib/<plugin-name>/srcfolder. - The plugin shall be added in all configurations in
/config/config-<type>.inilike PlatformIO libraries. Please add it in alphabetic order. To skip it in a config file, because e.g. there is not enough space in the flash, comment it out there via ";". - A short plugin description shall be in
/doc/PLUGINS.md. - A plugin specific HTML page shall be in
/lib/<plugin-name>/web. - Place a plugin screenshot as image in
/lib/<plugin-name>/web, using the plugin name and the file extension. It shall be shown in the HTML page. - If the plugin spawns a REST API:
- The HTML page must be able to get/set the corresponding information via REST API.
- The REST API description shall be extended. Ask the owner to do this via issue or pull-request.
If the plugin supports different display sizes, you might want to copy display size depended icons to the filesystem. This can be achieved by adding a pixelix.json to the folder /lib/<plugin-name>.
Example:
{
"pixelix": {
"type": "plugin",
"name": "OpenWeatherPlugin",
"web": {
"files": [
"./web/OpenWeatherPlugin.html"
],
"layouts": [{
"name": "LAYOUT_GENERIC",
"files": [
"./web/generic/01.gif"
]
}, {
"name": "LAYOUT_32X8",
"files": [
"./web/32x8/01.gif"
]
}, {
"name": "LAYOUT_64X64",
"files": [
"./web/64x64/01.gif"
]
}]
}
}
}Note, the file paths are relative from /lib/<plugin-name>.
- Follow the boy scout rule, especially for coding style. Check other plugins or sourcecode in the repository, to know how to do it right.
- All one time jobs shall be done in
start()method. E.g. the initial layout creation. - The
update()method shall be efficient, therefore- never read/write something from filesystem,
- never perform any web related stuff,
- never do one time jobs inside,
- just update the display!
- Remove the metadata from jpeg files to avoid wasting filesystem space, which can be done e.g. with Exiv2.
$ exiv2 rm image.jpg
- Update the display always to support animated GIFs and scrolling texts.
The first time a plugin instance starts up, it will try to load a configuration from the filesystem (if applicable) in start() method. If this fails, it creates a default one.
Because a plugin instance configuration in the filesystem can be edited via file browser too, it makes sense to periodically reload it. It is recommended to do this in the process() method.
Any http request can be started in the process() method. The response will be evaluated in the context of the corresponding web task. Only the take over of the relevant data shall be protected against concurrent access.
The active() and inactive() methods are called once before a plugin instance is activated or deactivated. But consider the case, that only one plugin instance is installed at all (except SysMsgPlugin). active() will be called just once and stays active.
Therefore if you need periodically stuff, but you can't do it in the update() method, use the process() method.
If you have further ideas or you found some bugs, great! Create a issue or if you are able and willing to fix it by yourself, clone the repository and create a pull request.
The whole source code is published under the MIT license. Consider the different licenses of the used third party libraries too!
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions.