mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-14 20:56:38 +01:00
docs
This commit is contained in:
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"terminal.integrated.env.linux": {
|
||||
"PATH": "/home/master/.platformio/penv/bin:/home/master/.platformio/penv:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl",
|
||||
"PATH": "/home/master/.platformio/penv/bin:/home/master/.platformio/penv:/home/master/bin:/opt/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/sbin:/usr/sbin",
|
||||
"PLATFORMIO_CALLER": "vscode"
|
||||
},
|
||||
"files.associations": {
|
||||
|
||||
39
README.md
39
README.md
@@ -31,12 +31,15 @@ lib_deps =
|
||||
|
||||
Example main.cpp:
|
||||
```cpp
|
||||
#include <Sprocket.h>
|
||||
#include <MyPlugin.h>
|
||||
|
||||
Sprocket *sprocket;
|
||||
|
||||
void setup()
|
||||
{
|
||||
sprocket = new Sprocket({STARTUP_DELAY, SERIAL_BAUD_RATE});
|
||||
sprocket->addPlugin(new SomePlugin());
|
||||
sprocket->addPlugin(new MyPlugin());
|
||||
sprocket->activate();
|
||||
}
|
||||
|
||||
@@ -65,13 +68,43 @@ See the "Getting Started" section for an example of skeleton Sprocket.
|
||||
|
||||
### Plugins
|
||||
To extend the functionality of a Sprocket, plugins can be hooked into the activation phase with the addPlugin method. They are activated on the order the've been added.
|
||||
The Sprocket internal scheduler is passed into the activation method of the plugin in order to add tasks.
|
||||
The Sprocket internal scheduler is passed into the activation method of the plugin in order to add tasks.
|
||||
Plugins can communicate with each other over the EvenChannel by a simple publish-subscribe mechanism.
|
||||
|
||||
Example plugin:
|
||||
```cpp
|
||||
#include "Arduino.h"
|
||||
#include "TaskSchedulerDeclarations.h"
|
||||
#include "Plugin.h"
|
||||
|
||||
class MyPlugin : public Plugin
|
||||
{
|
||||
public:
|
||||
MyPlugin() {}
|
||||
void activate(Scheduler *userScheduler)
|
||||
{
|
||||
subscribe("someTopic", [](String msg){
|
||||
Serial.println(msg);
|
||||
});
|
||||
publish("someTopic", "calling someTopic");
|
||||
}
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
|
||||
# Useful commands
|
||||
## Useful tools and commands
|
||||
|
||||
Commands:
|
||||
```sh
|
||||
# erase flash
|
||||
esptool --port /dev/ttyUSB0 erase_flash
|
||||
|
||||
# build environment esp32 and upload the binary
|
||||
pio run -e esp32 -t upload
|
||||
|
||||
# build environment esp32 and upload the filesystem
|
||||
pio run -e esp32 -t uploadfs
|
||||
|
||||
# OTA
|
||||
~/.platformio/packages/tool-espotapy/espota.py -i <espIP> -p 8266 -a <authPW> -f .pioenvs/ota/firmware.bin
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
|
||||
;[platformio]
|
||||
;env_default = basic
|
||||
[platformio]
|
||||
env_default = basic
|
||||
|
||||
[common]
|
||||
framework = arduino
|
||||
platform = espressif8266
|
||||
board = esp12e
|
||||
board = esp01
|
||||
upload_speed = 921600
|
||||
monitor_baud = 115200
|
||||
lib_deps =
|
||||
@@ -53,4 +53,14 @@ build_flags = -std=c++14
|
||||
src_filter = +<*> -<examples/> +<examples/basic/>
|
||||
upload_speed = ${common.upload_speed}
|
||||
monitor_baud = ${common.monitor_baud}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_deps = ${common.lib_deps}
|
||||
|
||||
|
||||
[env:basic_esp01]
|
||||
platform = ${common.platform}
|
||||
board = esp01
|
||||
framework = ${common.framework}
|
||||
src_filter = +<*> -<examples/> +<examples/basic/>
|
||||
upload_speed = ${common.upload_speed}
|
||||
monitor_baud = ${common.monitor_baud}
|
||||
lib_deps = ${common.lib_deps}
|
||||
|
||||
Reference in New Issue
Block a user