SimpleScheduler.cpp
// private function which does the heavy lifting for the public task creation functions above
private function which does the heavy lifting for the public task creation functions above
private function which does the heavy lifting for the public task creation functions above
SimpleTask SimpleScheduler::taskBuilder(void (*theTask)(void), uint32_t timing, uint16_t count, bool immediateRun, bool sendSelf, bool inMicros) {
  SimpleTask newTask = (SimpleTask) malloc(sizeof(t_scheduledTask)) ;
  newTask->taskFlags = _m_taskFirstRun ;
  if (count != 1) newTask->taskFlags |= _m_taskRepeats ;
  if (sendSelf)   newTask->taskFlags |= _m_taskSendSelf ;
  if (inMicros)   newTask->taskFlags |= _m_taskUseMicros ;
  newTask->theTask = theTask ;
  newTask->lastRun = immediateRun ? 0 : (inMicros ? micros() : millis()) ;
  newTask->period = timing ;
  newTask->loopMax = count ;
  newTask->loopCount = 0 ;
   while (taskPtr) {
     prevPtr = taskPtr ;
     taskPtr = taskPtr->next ;
   }
   newTask->next = NULL ;
   newTask->prev = prevPtr ;
   if (prevPtr)
     prevPtr->next = newTask ;
   else
     taskList = newTask ;
 on the theory that newer tasks are probably the most transitory and time
 sensitive as opposed to early defined tasks, we stick the new ones at the
 front of the list.
  newTask->next = taskList ; newTask->prev = NULL ;
  if (taskList) taskList->prev = newTask ;
  taskList = newTask ;
  return newTask ;
}
SimpleTask SimpleScheduler :: taskBuilder ( void ( * theTask ) ( void ) , uint32_t timing , uint16_t count , bool immediateRun , bool sendSelf , bool inMicros ) { SimpleTask newTask = ( SimpleTask ) malloc ( sizeof ( t_scheduledTask ) ) ; newTask -> taskFlags = _m_taskFirstRun ; if ( count != 1 ) newTask -> taskFlags |= _m_taskRepeats ; if ( sendSelf ) newTask -> taskFlags |= _m_taskSendSelf ; if ( inMicros ) newTask -> taskFlags |= _m_taskUseMicros ; newTask -> theTask = theTask ; newTask -> lastRun = immediateRun ? 0 : ( inMicros ? micros ( ) : millis ( ) ) ; newTask -> period = timing ; newTask -> loopMax = count ; newTask -> loopCount = 0 ; newTask -> next = taskList ; newTask -> prev = NULL ; if ( taskList ) taskList -> prev = newTask ; taskList = newTask ; return newTask ; }
private function which does the heavy lifting for the public task creation functions above
private function which does the heavy lifting for the public task creation functions above
//   SimpleTask taskPtr = taskList, prevPtr = NULL ; // //   while (taskPtr) { //     prevPtr = taskPtr ; //     taskPtr = taskPtr->next ; //   } // //   newTask->next = NULL ; //   newTask->prev = prevPtr ; //   if (prevPtr) //     prevPtr->next = newTask ; //   else //     taskList = newTask ; // on the theory that newer tasks are probably the most transitory and time // sensitive as opposed to early defined tasks, we stick the new ones at the // front of the list.