forked from matthewturner/EventuallyCommand Compared with matthewturner/EventuallyCommand, its data type is String, which is more convenient for data transmission and interaction, but it also requires more memory
Built on the Eventually library, this provides a listener which reads commands from any Serial device.
This works alongside any other listener you might already have in your sketch.
Commands can be sent from a laptop through the serial monitor or Bluetooth-connected phone.
Commands must start with '>' and end with '!', eg:
>set!
// or
>update!
Commands can optionally include an string data element, separated by a colon:
>set:hello!
The data element will be passed into your registered EvtCommandAction callback.
EvtManager mgr;
EvtCommandListener commandListener(&Serial);
void setup()
{
Serial.begin(115200);
// register other listeners as normal
mgr.addListener(new EvtPinListener(...));
// register the command and the action to trigger
commandListener.when("update", (EvtCommandAction)update); // only trigger once
commandListener.whenever("set", (EvtCommandAction)set); // trigger every time
mgr.addListener(&commandListener);
}
At the top of your main.h (before the other headers), define EVENTUALLY_MAX_COMMANDS:
#define EVENTUALLY_MAX_COMMANDS 20
#include <EventuallyCommand.h>
deprecated, use String instead of char array
At the top of your main.h (before the other headers), define the following:
Install command line tools by following the installation instructions for Windows
Deploy code to your Arduino and run the following command in a terminal:
pio device monitor --eol=CRLF --echo --filter=send_on_enter
Run the following command after installing Platform IO:
pio test -e native