mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-16 13:25:03 +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": {
|
"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"
|
"PLATFORMIO_CALLER": "vscode"
|
||||||
},
|
},
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
|
|||||||
37
README.md
37
README.md
@@ -31,12 +31,15 @@ lib_deps =
|
|||||||
|
|
||||||
Example main.cpp:
|
Example main.cpp:
|
||||||
```cpp
|
```cpp
|
||||||
|
#include <Sprocket.h>
|
||||||
|
#include <MyPlugin.h>
|
||||||
|
|
||||||
Sprocket *sprocket;
|
Sprocket *sprocket;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
sprocket = new Sprocket({STARTUP_DELAY, SERIAL_BAUD_RATE});
|
sprocket = new Sprocket({STARTUP_DELAY, SERIAL_BAUD_RATE});
|
||||||
sprocket->addPlugin(new SomePlugin());
|
sprocket->addPlugin(new MyPlugin());
|
||||||
sprocket->activate();
|
sprocket->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,13 +69,43 @@ See the "Getting Started" section for an example of skeleton Sprocket.
|
|||||||
### Plugins
|
### 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.
|
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
|
```sh
|
||||||
# erase flash
|
# erase flash
|
||||||
esptool --port /dev/ttyUSB0 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
|
# OTA
|
||||||
~/.platformio/packages/tool-espotapy/espota.py -i <espIP> -p 8266 -a <authPW> -f .pioenvs/ota/firmware.bin
|
~/.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
|
; Please visit documentation for the other options and examples
|
||||||
; http://docs.platformio.org/page/projectconf.html
|
; http://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
;[platformio]
|
[platformio]
|
||||||
;env_default = basic
|
env_default = basic
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
framework = arduino
|
framework = arduino
|
||||||
platform = espressif8266
|
platform = espressif8266
|
||||||
board = esp12e
|
board = esp01
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
monitor_baud = 115200
|
monitor_baud = 115200
|
||||||
lib_deps =
|
lib_deps =
|
||||||
@@ -54,3 +54,13 @@ src_filter = +<*> -<examples/> +<examples/basic/>
|
|||||||
upload_speed = ${common.upload_speed}
|
upload_speed = ${common.upload_speed}
|
||||||
monitor_baud = ${common.monitor_baud}
|
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