cgnuino
cgnuino.h
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 
119 class CgnControl {
120  public:
121  CgnControl(char = 10);
122  String update();
123  int getCode();
124  String getValue();
125 
126  private:
127  int c;
128  String v;
129  char eol;
130 };
131 
232 class CgnDI {
233  public:
234  CgnDI(byte, byte = 1, byte = NULL, byte = 2);
235  void update();
236  bool on(byte = 0);
237  bool off(byte = 0);
238  bool turnon(byte = 0);
239  bool turnoff(byte = 0);
240  bool change(byte = 0);
241  bool keep(byte = 0);
242 
243  private:
244  byte first;
245  byte n;
246  byte relay;
247  bool relaid;
248  bool cur[N_CGNDI];
249  bool pre[N_CGNDI];
250  byte r;
251  byte rest[N_CGNDI];
252  uint32_t last;
253 };
254 
321 class CgnDO {
322  public:
323  CgnDO(byte, byte = 1);
324  void update();
325  void out(byte, uint32_t);
326 
327  private:
328  byte first;
329  byte n;
330  uint32_t limit[N_CGNDO];
331 };
332 
350 class CgnData {
351  public:
352  CgnData(char = 9);
353  void append(String);
354  void out();
355  void clear();
356 
357  private:
358  char sep;
359  String data;
360 };
361 
404 class CgnLogger {
405  public:
406  CgnLogger(bool = false, byte = NULL, byte = 0);
407  void update(bool);
408  bool on();
409  bool off();
410  bool turnon();
411  bool turnoff();
412  bool change();
413  bool keep();
414 
415  private:
416  bool cur;
417  bool pre;
418  byte relay;
419  bool relaid;
420  byte r;
421  byte rest;
422  uint32_t last;
423 };
424 
463 class CgnPause {
464  public:
465  CgnPause(byte, bool = LOW, uint16_t = 100);
466  void check();
467 
468  private:
469  byte pin;
470  bool b;
471  uint16_t cycle;
472 };
473 
498 class CgnPeriod {
499  public:
500  CgnPeriod();
501  void set(String, uint32_t = 0);
502  bool is(String);
503  bool expire();
504  String get();
505  uint32_t until();
506 
507  private:
508  String period;
509  uint32_t limit;
510 };
511 
527  public:
528  CgnStopwatch();
529  uint32_t lap();
530  uint32_t get();
531 
532  private:
533  uint32_t from;
534 };
535 
623 class CgnStrobe {
624  public:
625  CgnStrobe(byte, uint32_t = 5);
626  uint32_t out(String);
627 
628  private:
629  void wait();
630  byte first;
631  uint32_t len;
632  bool us;
633 };
634 
652 class CgnTone {
653  public:
654  CgnTone(byte);
655  void update();
656  void out(uint32_t, uint16_t = 440);
657 
658  private:
659  byte pin;
660  uint32_t limit;
661 };
662 
700 class CgnValtiel {
701  public:
702  CgnValtiel();
703  void start();
704  float lap();
705  uint32_t getMax();
706  uint32_t getMin();
707 
708  private:
709  uint32_t from;
710  uint32_t last;
711  uint32_t n;
712  uint32_t mx;
713  uint32_t mn;
714 };
715 
716 #endif
717 
Remembers current task period and its time constraint.
Definition: cgnuino.h:498
Communicates with external control apprication running on a secondary PC.
Definition: cgnuino.h:119
Offers convenient digital-in buffering.
Definition: cgnuino.h:232
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
Logs arbitrary boolean change in a similar way to CgnDI class.
Definition: cgnuino.h:404
Stores trial information and print it to the Serial.
Definition: cgnuino.h:350
CgnControl(char=10)
Constructor.
Definition: CgnControl.cpp:15
Temporally pauses task progression by digital-in pin state.
Definition: cgnuino.h:463
Emits asynchroneous digital-out.
Definition: cgnuino.h:321
Emits asynchroneous tone output in a similar way to CgnDO class.
Definition: cgnuino.h:652
String getValue()
Shows decomposed value for the last serial input.
Definition: CgnControl.cpp:66
Monitors average length of executed loops on Arduino.
Definition: cgnuino.h:700
Emits a text as one-by-one characters using (8 + 1)-bit digital-out.
Definition: cgnuino.h:623
Measures time difference in milliseconds.
Definition: cgnuino.h:526