Runtime for Elrond Modules for Arduino IDE based platforms. The runtime application is the engine of projects based on Elrond Modules. The application runtime is responsible for load and initialize the modules instances and control to everything runs fine.
- Arduino Uno;
- Arduino Nano
*
; - Arduino Mega;
- ESP32;
*
The Arduino with ATmega168 is not recommended because low memory.
Currently the library build process is based in makefile on linux. The requirements are:
- GNU Make;
- Git;
- Arduino IDE
After the repository clone, will need initialize the git submodule:
$ git submodule init
$ git submodule update
To install to Arduino IDE (Linux only):
$ make arduino-install
Copy and paste the code in bellow in a new Arduino Sketch and upload to your board.
#include <elrond-ino.hpp>
elrond::Example test;
SETUP(
MODULES(
INSTANCE(test, CONFIG(100,
KEY_CFG("allowLoop", true)
KEY_CFG("timeLoop", 1000)
))
),
OPTIONS(
DEBUG(Serial, 115200)
)
)
To more details, see Sketch configuration structure
In the Serial Monitor
with speed defined to 115200 baud
, the output will be some like:
Elrond Runtime for Arduino v0.0-alpha
Initializing instance "gpio-ino"...
Initializing instance "test"...
Example::onInit
Starting modules...
Example::onStart
Application running...
Example::loop (sync)
Example::loop (sync)
Example::loop (sync)
The sketch structure used to configure an Elrond Application on Arduino IDE must have inicialized by #include
macros of modules that will be used. After comes the instances definitions, in variable declaration C++ style, like module_type instance_name;
. Bellow of the instances definitions, must have the SETUP(MODULES(...), OPTIONS(...))
macro function call.
Macro function with list of instances used by application. To define an instance, must be called the macro function INSTANCE(inst, CONFIG(...))
, where:
inst
: Module instance name;CONFIG(...)
: Module configuration. The module configuration must be made using the macro functionCONFIG(buffer_s, KEY_CFG() ... )
. Thebuffer_s
parameter is an unsigned integer to defines an internal buffer used to store configuration data temporarily. After the buffer size, must have a no comma (,
) separated list ofKEY_CFG(key, value)
. Thekey
parameter is aconst char *
string that will be associated to thevalue
paramter. Thevalue
can be of the typeint
,double
,char
,bool
orconst char *
. In case the module does not require a configuration, use theNULL_CFG
macro instead ofCONFIG()
macro function.
Every module have your own set of configuration params, see documentation of every one.
Macro function used to define extra options of the application, like the channel managers. The parameters must be in a no comma (,
) separated list, and can be:
CH_MGR(transport, tx, rx)
: Macro function to define a channel manager. Thetransport
parameter must be an instance of a transport module. Thetx
andrx
parameters indicate the total of transmit and receive channels, respectively;DEBUG(serial, baud_rate)
: Macro function to define a serial interface used to debug output. Theserial
parameter must be an instance ofHardwareSerial
. Thebaud_rate
defines the data speed for serial setup.
For better understanding, a more complex example of sketch structure:
// Includes
#include <elrond-ino.hpp>
// Module instances
elrond::DigitalLed led;
elrond::runtime::Serial serial;
SETUP(
MODULES(
INSTANCE(led, CONFIG(100,
KEY_CFG("pin", 13)
KEY_CFG("channel", 0)
)),
INSTANCE(serial, CONFIG(100,
KEY_CFG("serial", 0)
))
),
OPTIONS(
CH_MGR(serial, 0, 1)
)
)
In this example, the channel manager is defined for a receive channel by the serial
module. The led
module will listen to channel 0
. When this channel is triggered, the digital pin 13
will be triggered and the connected LED will flash (built-in led on Arduino boards).
The Internal modules from Elrond Common Library are available. More details see Elrond Common Library - Internal Modules.
This is a Serial/UART transport module. The module configuration is:
- serial (int): Index of Arduino serial object;
Arduino Uno and Nano have the baud rate defined to
9600
. Arduino Mega and Esp32 have the baud rate defined to115200
.
This modules are unstable and not recommend to use yet.
elrond::runtime::modules::UdpWifi
: Udp transport module;elrond::runtime::modules::WifiManager
: Wifi Manager for Esp32;
Maybe will be modified or removed in the future.