cgnuino
CgnValtiel.cpp
1 
8 #include "Arduino.h"
9 #include "cgnuino.h"
10 
15  from = millis();
16  last = from;
17  n = 0;
18  mx = 0;
19  mn = ULONG_MAX;
20 }
21 
26  from = millis();
27  last = from;
28  n = 0;
29  mx = 0;
30  mn = ULONG_MAX;
31 }
32 
38 float CgnValtiel::lap() {
39  uint32_t cur;
40  cur = millis();
41 
42  n += 1;
43  mx = max(mx, cur - last);
44  mn = min(mn, cur - last);
45  last = cur;
46  return (float)(cur - from) / (float)n;
47 }
48 
52 uint32_t CgnValtiel::getMax() {
53  return mx;
54 }
55 
59 uint32_t CgnValtiel::getMin() {
60  return mn;
61 }
62 
uint32_t getMax()
Show maximal length of past loop in [ms].
Definition: CgnValtiel.cpp:52
float lap()
Show average length of past loops and count up the counter.
Definition: CgnValtiel.cpp:38
void start()
Start monitoring loop length by resetting the counter.
Definition: CgnValtiel.cpp:25
uint32_t getMin()
Show minimal length of past loop in [ms].
Definition: CgnValtiel.cpp:59
CgnValtiel()
Constructor.
Definition: CgnValtiel.cpp:14