-
Notifications
You must be signed in to change notification settings - Fork 0
/
Neutrino.ino
48 lines (39 loc) · 905 Bytes
/
Neutrino.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "Neutrino.h"
uint8_t greet()
{
Serial.println("Just want to say hello!");
return 0;
}
uint8_t init_greet()
{
Serial.println("Actually nothing needs initialization...");
return 0;
}
uint8_t print_args(int argc, String *argv)
{
Serial.print("\nargc = "); Serial.println(argc);
Serial.println("arg list:");
for (int i=0; i<argc; i++)
Serial.println(argv[i]);
return 0;
}
Neutrino neu = Neutrino(true);
void setup()
{
Serial.begin(115200);
Serial.println();
neu.add_command("hello", greet, init_greet);
neu.add_command("print", print_args);
bool inited = neu.init_commands();
if (inited)
Serial.println("All tasks initialized.");
neu.print_help_info();
}
void loop()
{
while(!Serial.available());
String command = Serial.readString();
command.trim();
uint8_t retval = neu.parse_command(command);
Serial.print("\nReturned value: "); Serial.println(retval);
}