Skip to content

Commit

Permalink
Adding template file. It compiles and correctly runs one example file…
Browse files Browse the repository at this point in the history
…. Theexample file is full of extraneous code and needs to be cleaned up.
  • Loading branch information
AverageGuy committed Jul 5, 2024
1 parent 67872a9 commit 0850645
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions TaskSched.tpp
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

0 comments on commit 0850645

Please sign in to comment.