Nico De Witte / simple_task_scheduler
Revision:
3:bd96023168df
Parent:
1:4eccf61f4ef7
--- a/tasks/periodic_task.cpp	Wed Jul 13 09:01:16 2016 +0000
+++ b/tasks/periodic_task.cpp	Tue Dec 13 14:48:48 2016 +0100
@@ -2,17 +2,19 @@
 
 namespace SimpleTaskScheduler {
 
-    void PeriodicTask::run(void) {
-    if (state == SHOULD_RUN) {
+  void PeriodicTask::run(void) {
+    if (nextState == SHOULD_RUN) {
       state = RUNNING;
-      this->callback.call();
+      this->call();
       state = WAITING;
+      nextState = WAITING;
     }
   }
 
   void PeriodicTask::tick(void) {
-    // Following can mess with your day if your task is long and periodic periodic
-    //period is small.
-    state = SHOULD_RUN;
+    // Following can mess with your day if task is long and period is small
+    if (nextState == WAITING) {
+      nextState = SHOULD_RUN;
+    }
   }
 };