SafeString  4.1.27
SafeString is a safe, robust and debuggable replacement for string processing in Arduino
loopTimer.h
Go to the documentation of this file.
1 
2 #ifndef LOOP_TIMER_H
3 #define LOOP_TIMER_H
4 // loopTimer.h
5 /*
6  * (c)2019 Forward Computing and Control Pty. Ltd.
7  * NSW Australia, www.forward.com.au
8  * This code is not warranted to be fit for any purpose. You may only use it at your own risk.
9  * This generated code may be freely used for both private and commercial use
10  * provided this copyright is maintained.
11  */
12 
13 #include <Arduino.h>
14 
15 // download millisDelay from https://www.forward.com.au/pfod/ArduinoProgramming/TimingDelaysInArduino.html
16 #include <millisDelay.h>
17 
18 
51  public:
52  loopTimerClass(const char *_name = NULL); // name of this timer, if NULL then "loop" is used as the name
53  void check(Print *out = NULL); // if loopTimer.check() called nothing is printed but timing done
54  void check(Print &out); // if loopTimer.check() called nothing is printed but timing done
55  void print(Print &out); // this prints the latest timings
56  void print(Print *out); // this prints the latest timings
57  void clear(); // clears all previous data
58 
59  private:
60  void init();
61  const char *name;
62  bool initialized; // true after first call.
63  unsigned long maxLoop5sec_us; // max in last 5 sec
64  unsigned long totalLoop5sec_us; // total for last 5 sec
65  unsigned long loopCount5sec; // count in last 5 sec
66  unsigned long lastLoopRun_us; // start us last call
67 
68  // print vars
69  unsigned long p_avgLoop5sec_us; // last calculated 5 sec average latency
70  unsigned long p_maxLoop5sec_us; // last max value in 5 sec
71 
72  unsigned long p_maxLoop_us; // max so far update every 5 sec
73  unsigned long p_maxAvgLoop_us; // max avg so far , updated every 5
74 
75  unsigned long PRINT_US_DELAY = 5000; // ms calculate and print every 5 sec
76  millisDelay print_us_Delay;
77 };
78 
79 static loopTimerClass loopTimer;
80 #endif // LOOP_TIMER_H
There is a predefined loopTimer object that is ready to use, see the detailed description.
Definition: loopTimer.h:50
void print(Print &out)
void check(Print *out=NULL)
void check(Print &out)
loopTimerClass(const char *_name=NULL)
void print(Print *out)
millisDelay** implements a non-blocking, repeatable delay, see the detailed description.
Definition: millisDelay.h:35