cgnuino
CgnControl.cpp
1 
8 #include "Arduino.h"
9 #include "cgnuino.h"
10 
16  c = 0;
17  v = "";
18  eol = e;
19 }
20 
25  int i;
26  String s;
27 
28  c = 0;
29  v = "";
30  if (Serial.available() > 0) {
31  s = Serial.readStringUntil(eol);
32  s.trim();
33  if (s.length() > 0) {
34  if (s.length() == 1) {
35  // for one-character command
36  c = int(s[0]);
37  } else {
38  i = s.indexOf(":");
39  if (i == -1) {
40  // when separater did not exist
41  v = s;
42  } else {
43  // for online variable modulation
44  v = s.substring(i + 1);
45  v.trim();
46  s = s.substring(0, i); // this does not include i-th char
47  s.trim();
48  c = s.toInt();
49  }
50  }
51  }
52  }
53  return v;
54 }
55 
60  return c;
61 }
62 
67  return v;
68 }
69 
String update()
Checks the serial buffer for a new input line.
Definition: CgnControl.cpp:24
int getCode()
Shows decomposed code for the last serial input.
Definition: CgnControl.cpp:59
CgnControl(char=10)
Constructor.
Definition: CgnControl.cpp:15
String getValue()
Shows decomposed value for the last serial input.
Definition: CgnControl.cpp:66