more infos on lifecycle

This commit is contained in:
Patrick Balsiger
2018-12-28 21:06:36 +01:00
parent e947e124c7
commit 3d9281bcf7

View File

@@ -5,7 +5,7 @@ A lightweight Arduino framework for event driven programming.
## Getting Started
Install sprocket-lib on your favorite dev environment.
Either by cloning this repository into the Arduino library path or by adding it as a dependency to your platformio.ini file.
In addition, following dependencies need to be installed as well:
Additionally, sprocket-lib depends on following libraries:
```
Hash
TaskScheduler
@@ -52,12 +52,20 @@ void loop()
... plugin system
### Lifecycle
As the initialization order of core components is critical on embedded devices, it has been split up into different phases of a lifecycle.
In most cases a Sprocket is bootstraped in the setup() method. Addidional plugins are hooked into the Sprocket after initialisation.
During loop, the internal Scheduler needs to be updated by calling the corresponding method.
See the "Getting Started" section for an example of skeleton Sprocket.
|Phase|Purpose|
|---|---|
|init|Setup Serial and SPIFFS|
|activation|Activate all plugins|
|loop|Update the scheduler|
### Plugins
To extend the functionality of a Sprocket, plugins can be hooked into the activation lifecycle.
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.
# Useful commands