Skip to content

Commit 2d17bff

Browse files
Support for older version of Arduino IDE
1 parent 5157c35 commit 2d17bff

File tree

1 file changed

+29
-13
lines changed

1 file changed

+29
-13
lines changed

avdweb_VirtualDelay.h

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
/*
22
Copyright (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
811
AUTHOR: Albert van Dalen
912
WEBSITE: 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

Comments
 (0)