Change timeout to ADT and start supporting interrupts
[mTask.git] / client / main.c
index 9fc91df..f86beff 100644 (file)
@@ -74,21 +74,19 @@ void loop(void)
 //                     debug("Task %d not implemented\n", ct);
                        continue;
                }
-               //See whether the task interval has passed
-               if(cyclestart-curtask->lastrun < curtask->interval){
-//                     debug("Task %d not scheduled\n", ct);
-                       continue;
-               }
-               debug("Current task to run: %d", ct);
-               run_task(curtask);
-               curtask->lastrun = cyclestart;
+               //Onshot task
                if(curtask->interval == 0){
+                       run_task(curtask);
                        curtask->used = false;
-//                     write_byte('m');
-//                     write_byte('d');
-//                     write_byte('\n');
+               //Interrupt task
+               } else if(curtask->interval & 32768){
+                       debug("Interrupt task %d not implemented", ct);
+               //Interval task, check if interval is passed
+               } else if(cyclestart-curtask->lastrun > curtask->interval){
+                       debug("Running interval task: %d", ct);
+                       run_task(curtask);
+                       curtask->lastrun = cyclestart;
                }
-//             write_byte('\n');
        }
 }