-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollectionofArduinoClasses.ino
More file actions
54 lines (42 loc) · 1.02 KB
/
Copy pathCollectionofArduinoClasses.ino
File metadata and controls
54 lines (42 loc) · 1.02 KB
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
49
50
51
52
53
54
#include "ContainerLibrary/Vector.h"
#include "SCPI_Parser/SCPI.h"
//#include "ContainerLibrary/Array.h"
Vector<double> elements;
void(* resetFunc) (void) = 0; //declare reset function @ address 0
SCPI_Command_Numeric<double> add("ADD", [](double newElem){
Serial.println("Adding Element");
Serial.println(newElem);
delay(1000);
elements.push_back(newElem);
});
SCPI_Command show("SHOW", [](){
Serial.println("Showing List");
Serial.println("Size: " + String(elements.size()));
Serial.println("Capacity: " + String(elements.capacity()));
Serial.println("Elements:");
for (int i = 0; i < elements.size(); i++){
Serial.println(elements[i]);
}
});
SCPI_Command* commands[]{
&add,
&show,
new SCPI_Command("QUIT", [](){
Serial.println("Quitting");
delay(100);
resetFunc();
})
};
SCPI_Parser parser(commands, sizeof(commands) / sizeof(SCPI_Command*));
void setup()
{
Serial.begin(38400);
Serial.println("Hello World!");
}
void loop()
{
}
void serialEvent()
{
parser.processCommands(Serial.readStringUntil('\n'));
}