Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions TaskScheduler.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Cooperative multitasking library for Arduino version 1.51
// Cooperative multitasking library for Arduino version 1.6
// Copyright (c) 2015 Anatoli Arkhipenko
//

Expand Down Expand Up @@ -50,7 +50,6 @@ void Task::reset() {
iPrev = NULL;
iNext = NULL;
iScheduler = NULL;
iDisableOnLastIteration = false;
#ifdef _TASK_TIMECRITICAL
iOverrun = 0;
#endif
Expand All @@ -63,7 +62,6 @@ void Task::reset() {
*/
void Task::set(unsigned long aInterval, long aIterations, void (*aCallback)()) {
iInterval = aInterval;
if (iEnabled && iIterations == 0) enable();
iSetIterations = iIterations = aIterations;
iCallback = aCallback;
}
Expand All @@ -73,7 +71,6 @@ void Task::set(unsigned long aInterval, long aIterations, void (*aCallback)()) {
* @param aIterations - number of iterations, use -1 for no limit
*/
void Task::setIterations(long aIterations) {
if (iEnabled && iIterations == 0) enable();
iSetIterations = iIterations = aIterations;
}

Expand Down Expand Up @@ -240,7 +237,7 @@ void Scheduler::execute() {
do {
if (iCurrent->iEnabled) {
if (iCurrent->iIterations == 0) {
if (iCurrent->iDisableOnLastIteration) iCurrent->disable();
iCurrent->disable();
break;
}
if (iCurrent->iInterval > 0) {
Expand Down
9 changes: 6 additions & 3 deletions TaskScheduler.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Cooperative multitasking library for Arduino version 1.51
// Cooperative multitasking library for Arduino version 1.6
// Copyright (c) 2015 Anatoli Arkhipenko
//
// Changelog:
Expand All @@ -20,6 +20,11 @@
// v1.51:
// 2015-09-21 - bug fix: incorrect handling of active tasks via set() and setIterations().
// Thanks to Hannes Morgenstern for catching this one
// v1.6:
// 2015-09-22 - revert back to having all tasks disable on last iteration.
// 2015-09-22 - deprecated disableOnLastIteration method as a result
// 2015-09-22 - created a separate branch 'disable-on-last-iteration' for this



/* ============================================
Expand Down Expand Up @@ -105,7 +110,6 @@ class Task {
void setIterations(long aIterations);
inline long getIterations() { return iIterations; }
inline void setCallback(void (*aCallback)()) { iCallback = aCallback; }
inline void disableOnLastIteration(bool aBool) { iDisableOnLastIteration = aBool; } // default is false
#ifdef _TASK_TIMECRITICAL
inline long getOverrun() { return iOverrun; }
#endif
Expand All @@ -116,7 +120,6 @@ class Task {
void reset();

volatile bool iEnabled;
volatile bool iDisableOnLastIteration;
volatile unsigned long iInterval;
volatile unsigned long iPreviousMillis;
#ifdef _TASK_TIMECRITICAL
Expand Down
Binary file modified documentation/TaskScheduler.doc
Binary file not shown.
Loading