diff --git a/.vscode/settings.json b/.vscode/settings.json index ba52e2e..86bb909 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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": { diff --git a/README.md b/README.md index 50ca46e..723aedf 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,15 @@ lib_deps = Example main.cpp: ```cpp +#include +#include + 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 -p 8266 -a -f .pioenvs/ota/firmware.bin diff --git a/platformio.ini b/platformio.ini index 06852b4..4bd8d95 100644 --- a/platformio.ini +++ b/platformio.ini @@ -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 = +<*> - + upload_speed = ${common.upload_speed} monitor_baud = ${common.monitor_baud} -lib_deps = ${common.lib_deps} \ No newline at end of file +lib_deps = ${common.lib_deps} + + +[env:basic_esp01] +platform = ${common.platform} +board = esp01 +framework = ${common.framework} +src_filter = +<*> - + +upload_speed = ${common.upload_speed} +monitor_baud = ${common.monitor_baud} +lib_deps = ${common.lib_deps}