-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimedAction.h
73 lines (63 loc) · 2.2 KB
/
TimedAction.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Updated on 3/28/2016 for use with modern versions of Arduino.
// Changes on line 35.
/*
||
|| @file TimedAction.cpp
|| @version 1.6
|| @author Alexander Brevig
|| @contact [email protected]
||
|| @description
|| | Provide an easy way of triggering functions at a set interval
|| #
||
|| @license
|| | This library is free software; you can redistribute it and/or
|| | modify it under the terms of the GNU Lesser General Public
|| | License as published by the Free Software Foundation; version
|| | 2.1 of the License.
|| |
|| | This library is distributed in the hope that it will be useful,
|| | but WITHOUT ANY WARRANTY; without even the implied warranty of
|| | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|| | Lesser General Public License for more details.
|| |
|| | You should have received a copy of the GNU Lesser General Public
|| | License along with this library; if not, write to the Free Software
|| | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|| #
||
*/
#ifndef TIMEDACTION_H
#define TIMEDACTION_H
#include "Arduino.h"
//#include "WProgram.h"
// updated for use with csarc
#define NO_PREDELAY 0
class TimedAction {
public:
TimedAction(unsigned long interval,void (*function)());
TimedAction(unsigned long prev,unsigned long interval,void (*function)());
void reset();
void disable();
void enable();
void check();
void setInterval( unsigned long interval );
private:
bool active;
unsigned long previous;
unsigned long interval;
void (*execute)();
};
#endif
/*
|| @changelog
|| | 1.6 2010-10-08 - Alexander Brevig : Changed datatype of interval from unsigned int to unsigned long
|| | 1.5 2009-10-25 - Alexander Brevig : Added setInterval , requested by: Boris Neumann
|| | 1.4 2009-05-06 - Alexander Brevig : Added reset()
|| | 1.3 2009-04-16 - Alexander Brevig : Added disable() and enable(), requested by: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?action=viewprofile;username=ryno
|| | 1.2 2009-04-13 - Alexander Brevig : Added a constructor
|| | 1.1 2009-04-08 - Alexander Brevig : Added an example that demonstrates three arduino examples at once
|| | 1.0 2009-03-23 - Alexander Brevig : Initial Release
|| #
*/