cgnuino
cgnuino.h
Go to the documentation of this file.
1 
7 #ifndef INCLUDED_CGNUINO
8 #define INCLUDED_CGNUINO
9 
10 #include "Arduino.h"
11 
16 #define countof(array) (sizeof(array) / sizeof(array[0]))
17 
18 constexpr uint32_t ULONG_MAX = 4294967295;
19 constexpr byte BYTE_MAX = 255;
20 constexpr byte N_CGNDI = 10;
21 constexpr byte N_CGNDO = 10;
22 
26 class CgnControl {
27  public:
28  CgnControl(char = 10);
29  String update(bool = true);
30  int getCode();
31  String getValue();
32 
33  private:
34  int c;
35  String v;
36  char eol;
37 };
38 
139 class CgnDI {
140  public:
141  CgnDI(byte, byte = 1, byte = NULL, byte = 2);
142  void update();
143  bool on(byte = 0);
144  bool off(byte = 0);
145  bool turnon(byte = 0);
146  bool turnoff(byte = 0);
147  bool change(byte = 0);
148  bool keep(byte = 0);
149 
150  private:
151  byte first;
152  byte n;
153  byte relay;
154  bool relaid;
155  bool cur[N_CGNDI];
156  bool pre[N_CGNDI];
157  byte r;
158  byte rest[N_CGNDI];
159  uint32_t last;
160 };
161 
168 class CgnDO {
169  public:
170  CgnDO(byte, byte = 1);
171  void update();
172  void out(byte, uint32_t);
173 
174  private:
175  byte first;
176  byte n;
177  uint32_t limit[N_CGNDO];
178 };
179 
183 class CgnData {
184  public:
185  CgnData(char = 9);
186  void append(String);
187  void out();
188  void clear();
189 
190  private:
191  char sep;
192  String data;
193 };
194 
198 class CgnLogger {
199  public:
200  CgnLogger(bool = false, byte = NULL, byte = 0);
201  void update(bool);
202  bool on();
203  bool off();
204  bool turnon();
205  bool turnoff();
206  bool change();
207  bool keep();
208 
209  private:
210  bool cur;
211  bool pre;
212  byte relay;
213  bool relaid;
214  byte r;
215  byte rest;
216  uint32_t last;
217 };
218 
222 class CgnPause {
223  public:
224  CgnPause(byte, bool = LOW, uint16_t = 100);
225  void check();
226 
227  private:
228  byte pin;
229  bool stopwhen;
230  uint16_t cycle;
231 };
232 
236 class CgnPeriod {
237  public:
238  CgnPeriod();
239  void set(String, uint32_t = 0);
240  bool is(String);
241  bool expire();
242  String get();
243  uint32_t until();
244 
245  private:
246  String period;
247  uint32_t limit;
248 };
249 
254  public:
255  CgnStopwatch();
256  uint32_t lap();
257  uint32_t get();
258 
259  private:
260  uint32_t from;
261 };
262 
266 class CgnStrobe {
267  public:
268  CgnStrobe(byte, uint32_t = 5);
269  uint32_t out(String);
270 
271  private:
272  void wait();
273  byte first;
274  uint32_t len;
275  bool us;
276 };
277 
281 class CgnTone {
282  public:
283  CgnTone(byte);
284  void update();
285  void out(uint32_t, uint16_t = 440);
286 
287  private:
288  byte pin;
289  uint32_t limit;
290 };
291 
295 class CgnValtiel {
296  public:
297  CgnValtiel();
298  void start();
299  float lap();
300  uint32_t getMax();
301  uint32_t getMin();
302 
303  private:
304  uint32_t from;
305  uint32_t last;
306  uint32_t n;
307  uint32_t mx;
308  uint32_t mn;
309 };
310 
311 #endif
312 
constexpr byte BYTE_MAX
Maximal value for byte.
Definition: cgnuino.h:19
constexpr uint32_t ULONG_MAX
Maximal value for unsigned long.
Definition: cgnuino.h:18
Remembers current task period and its time constraint.
Definition: cgnuino.h:236
Communicates with external control apprication running on the PC.
Definition: cgnuino.h:26
Offers convenient digital-in buffering.
Definition: cgnuino.h:139
int getCode()
Shows decomposed code for the last serial input.
Definition: CgnControl.cpp:62
Logs arbitorary bit change similar to CgnDI class.
Definition: cgnuino.h:198
Stores trial information and print it to the Serial.
Definition: cgnuino.h:183
CgnControl(char=10)
Constructor.
Definition: CgnControl.cpp:14
Temporally pauses task progression by digital-in pin state.
Definition: cgnuino.h:222
Emits asynchroneous digital-out.
Definition: cgnuino.h:168
String update(bool=true)
Checks the serial buffer for a new input line.
Definition: CgnControl.cpp:24
Emits asynchroneous tone output.
Definition: cgnuino.h:281
String getValue()
Shows decomposed value for the last serial input.
Definition: CgnControl.cpp:69
Monitors average length of executed loops on Arduino.
Definition: cgnuino.h:295
constexpr byte N_CGNDO
Number of pins that can be simultaneously set for a CgnDO instance.
Definition: cgnuino.h:21
Emits a text as one-by-one characters using (8 + 1)-bit digital-out.
Definition: cgnuino.h:266
Measures time difference in milliseconds.
Definition: cgnuino.h:253
constexpr byte N_CGNDI
Number of pins that can be simultaneously set for a CgnDI instance.
Definition: cgnuino.h:20