-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding template file. It compiles and correctly runs one example file…
…. Theexample file is full of extraneous code and needs to be cleaned up.
- Loading branch information
1 parent
67872a9
commit 0850645
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef TASKSCHED_TPP | ||
#define TASKSCHED_TPP | ||
|
||
template<typename T> | ||
void Task::initializeTask(T interval, bool enabled, int iterations, const char* name, bool runImmediately) { | ||
if constexpr (std::is_floating_point<T>::value) { | ||
mInterval = static_cast<long>(interval * 1000.0 + 0.5); // Convert seconds to milliseconds and round | ||
} else { | ||
mInterval = static_cast<long>(interval); // Already in milliseconds | ||
} | ||
mEnabled = enabled; | ||
mIterations = iterations; | ||
mName = name; | ||
mRunImmediately = runImmediately; | ||
mOrig.mEnabled=enabled; | ||
mOrig.mInterval=mInterval; | ||
mOrig.mIterations=iterations; | ||
mOrig.mRunImmediately=runImmediately; | ||
mLastStartTime=millis(); | ||
|
||
// ... other initializations ... | ||
|
||
#ifdef DEBUG | ||
Serial.print("Interval set to: "); | ||
Serial.print(mInterval); | ||
Serial.println(" ms"); | ||
#endif | ||
} | ||
#endif // TASKSCHED_TPP |