11/*
22Copyright (C) 2016 Albert van Dalen http://www.avdweb.nl
3- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
4- as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
5- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
6- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at http://www.gnu.org/licenses .
3+ This program is free software: you can redistribute it and/or modify it under
4+ the terms of the GNU General Public License as published by the Free Software
5+ Foundation, either version 3 of the License, or (at your option) any later
6+ version. This program is distributed in the hope that it will be useful, but
7+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at
9+ http://www.gnu.org/licenses .
710
811AUTHOR: Albert van Dalen
912WEBSITE: http://www.avdweb.nl/arduino/libraries/virtualdelay.html
@@ -12,17 +15,30 @@ WEBSITE: http://www.avdweb.nl/arduino/libraries/virtualdelay.html
1215#ifndef VirtualDelay_H
1316#define VirtualDelay_H
1417
15- class VirtualDelay
16- {
17- public:
18- VirtualDelay (unsigned long (*timerFunctionPtr)() = millis);
18+ #if ARDUINO >= 100
19+ #include < Arduino.h>
20+ #else
21+ #include < WProgram.h>
22+ #include < wiring.h>
23+ #endif
24+
25+ class VirtualDelay {
26+ public:
27+ VirtualDelay (unsigned long (*timerFunctionPtr)() = millis);
1928 void start (signed long delay);
2029 bool elapsed ();
21-
22- bool running= 0 ;
23- unsigned long timeOut, (*timerFunctionPtr)();
30+
31+ bool running = 0 ;
32+ unsigned long timeOut, (*timerFunctionPtr)();
2433};
2534
26- #define DO_ONCE (x ) {static bool b; if (!b) {b=1 ; x;}}
35+ #define DO_ONCE (x ) \
36+ { \
37+ static bool b; \
38+ if (!b) { \
39+ b = 1 ; \
40+ x; \
41+ } \
42+ }
2743
28- #endif
44+ #endif
0 commit comments