SafeString  4.1.27
SafeString is a safe, robust and debuggable replacement for string processing in Arduino
millisDelay.h
Go to the documentation of this file.
1 // millisDelay.h
2 // see the tutorial https://www.forward.com.au/pfod/ArduinoProgramming/TimingDelaysInArduino.html
3 
4 #ifndef MILLIS_DELAY_H
5 #define MILLIS_DELAY_H
6 
7 /*
8  * (c)2018 Forward Computing and Control Pty. Ltd.
9  * NSW Australia, www.forward.com.au
10  * This code is not warranted to be fit for any purpose. You may only use it at your own risk.
11  * This generated code may be freely used for both private and commercial use
12  * provided this copyright is maintained.
13  */
14 
15 
35 class millisDelay {
36  public:
37 
39 
44  void start(unsigned long delay);
45 
51  void stop();
52 
57  void repeat();
58 
64  void restart();
65 
69  void finish();
70 
75  bool justFinished();
76 
80  bool isRunning();
81 
86  unsigned long getStartTime();
87 
92  unsigned long remaining();
93 
97  unsigned long delay();
98 
99  private:
100  unsigned long ms_delay;
101  unsigned long startTime;
102  bool running; // true if delay running false when ended
103  bool finishNow; // true if finish() called to finish delay early, false after justFinished() returns true
104 };
105 #endif
millisDelay** implements a non-blocking, repeatable delay, see the detailed description.
Definition: millisDelay.h:35
void repeat()
repeat() Do same delay again but allow for a possible delay in calling justFinished()
unsigned long remaining()
How many ms remaining until delay finishes Returns 0 if finished or stopped.
void finish()
Force delay to end now.
bool justFinished()
Has the delay ended/expired or has finish() been called? justFinished() returns true just once when d...
void stop()
Stop the delay justFinished() will now never return true until after start(),restart() or repeat() ca...
void restart()
restart() Start the same delay again starting from now Note: use repeat() when justFinished() returns...
unsigned long delay()
The delay set in start.
bool isRunning()
Is the delay running, i.e.
void start(unsigned long delay)
Start a delay of this many milliseconds.
unsigned long getStartTime()
Returns the last time this delay was started, in ms, by calling start(), repeat() or restart() Return...