Commit b385ea19 authored by Arjen Stens's avatar Arjen Stens

Merge branch 'master' of gitlab.com:arduino-libraries/stens-timer

parents b5e18f8a e32d055f
......@@ -16,5 +16,5 @@
"frameworks": "arduino",
"platforms": "*",
"license": "GPL-3.0",
"version": "1.1.0"
"version": "1.1.1"
}
name=StensTimer
version=1.1.0
version=1.1.1
author=Arjen Stens <me@arjenstens.com>
maintainer=Arjen Stens <me@arjenstens.com>
sentence=An accessible Arduino timer library that enables you to use callbacks on class-instances as well as static callbacks (most commonly used).
......
......@@ -60,12 +60,12 @@ Timer* StensTimer::createTimer(IStensTimerListener* listener, int action, long i
}
/* Creates and returns timer that runs once */
Timer* StensTimer::setTimer(IStensTimerListener* listener, int action, long delay, long repetitions = 1){
Timer* StensTimer::setTimer(IStensTimerListener* listener, int action, long delay, long repetitions){
return createTimer(listener, action, delay, repetitions);
}
/* Sets timer without listener object */
Timer* StensTimer::setTimer(int action, long delay, long repetitions = 1){
Timer* StensTimer::setTimer(int action, long delay, long repetitions){
/* Static callback must be set */
if(_staticTimerCallback == NULL){
return NULL;
......@@ -157,6 +157,11 @@ void StensTimer::run(){
_staticTimerCallback(timer);
}
/* if user deleted timer while being called, skip over last lines */
if(_timers[i] == NULL){
continue;
}
int repetitions = timer->getRepetitions();
/* Check if timer is done repeating, if so, delete it */
......
......@@ -18,13 +18,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef StensTimer_h
#define StensTimer_h
#include <arduino.h>
#include <Arduino.h>
#include <timer/Timer.h>
#include <IStensTimerListener.h>
#ifdef Arduino_h
// arduino is not compatible with std::vector
#undef min
#undef max
#endif
class StensTimer {
#define MAX_TIMERS 10
#define MAX_TIMERS 20
public:
static StensTimer* getInstance();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment