This library allows you to set repeating or one-time functions that happen after an interval like in JavaScript. You can use .setInterval() to create a repeating event, and .setTimeout() to create a one-time event. You can also change the interval delay using .setDelay(). Once you’ve created an interval, you have to continually check it in the main loop using .check(). When the interval has passed, .check will be true.
myInterval.setInterval(function, delay);
function - a function to call when the delay passes delay (unsigned long) - the delay before the function is called.
void
Sets the function to be called when the interval delay passes. When the delay passes, the interval is reset, and starts again.
myInterval.setTimeout(function, delay);
function - a function to call when the delay passes delay (unsigned long) - the delay before the function is called.
void
Sets the function to be called when the interval delay passes. When the delay passes, the interval is stopped.
myInterval.setDelay(delay);
delay (unsigned long) - the delay before the function is called.
void
Changes the delay of the interval. Takes effect immediately, so calling setDelay() in the middle of an interval’s delay will extend the delay.
myInterval.check(); // or unsigned long remaining = myInterval.check();
none
remaining (unsigned long) - the remaining time before the current delay is over. Reading this return value is optional.
Must be called every time through the main loop to update the interval.
myInterval.reset();
none
void
resets the interval to the current millis. Takes effect immediately, so calling setDelay() in the middle of an interval’s delay will restart the delay.
myInterval.stop();
none
void
Stops the interval. This function stops both recurring intervals (setInterval) and non-recurring intervals (setTimeout).
if (myInterval.repeating == true) { // this is a recurring interval };
none
repeating (boolean) - whether or not the interval will repeat
A boolean variable. Determines whether an interval should restart when the delay ends, or whether it should stop.
if (myInterval.done == true) { // this interval will no longer run };
none
done (boolean) - whether or not the interval is done
A boolean variable. Determines whether an interval is done or not.
Copyright (c) Tom Igoe. All right reserved.
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; either version 2.1 of the License, or (at your option) any later version.
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