diff --git a/libraries/AP_Scheduler/AP_Scheduler.h b/libraries/AP_Scheduler/AP_Scheduler.h index 73221a45d2..9b79e1063d 100644 --- a/libraries/AP_Scheduler/AP_Scheduler.h +++ b/libraries/AP_Scheduler/AP_Scheduler.h @@ -29,7 +29,7 @@ A task scheduler for APM main loops Sketches should call scheduler.init() on startup, then call - scheduler.tick() at regular intervals (typically every 10ms). + scheduler.tick() at regular intervals (typically every 10ms). To run tasks use scheduler.run(), passing the amount of time that the scheduler is allowed to use before it must return @@ -53,25 +53,25 @@ public: typedef void (*task_fn_t)(void); #endif - struct Task { - task_fn_t function; - uint16_t interval_ticks; - uint16_t max_time_micros; - }; + struct Task { + task_fn_t function; + uint16_t interval_ticks; + uint16_t max_time_micros; + }; - // initialise scheduler - void init(const Task *tasks, uint8_t num_tasks, void *classptr); + // initialise scheduler + void init(const Task *tasks, uint8_t num_tasks, void *classptr); - // call when one tick has passed - void tick(void); + // call when one tick has passed + void tick(void); - // run the tasks. Call this once per 'tick'. - // time_available is the amount of time available to run - // tasks in microseconds - void run(uint16_t time_available); + // run the tasks. Call this once per 'tick'. + // time_available is the amount of time available to run + // tasks in microseconds + void run(uint16_t time_available); - // return the number of microseconds available for the current task - uint16_t time_available_usec(void); + // return the number of microseconds available for the current task + uint16_t time_available_usec(void); // return debug parameter uint8_t debug(void) { return _debug; } @@ -81,33 +81,33 @@ public: // end of a run() float load_average(uint32_t tick_time_usec) const; - static const struct AP_Param::GroupInfo var_info[]; + static const struct AP_Param::GroupInfo var_info[]; // current running task, or -1 if none. Used to debug stuck tasks static int8_t current_task; private: - // used to enable scheduler debugging - AP_Int8 _debug; - - // progmem list of tasks to run - const struct Task *_tasks; - - // number of tasks in _tasks list - uint8_t _num_tasks; + // used to enable scheduler debugging + AP_Int8 _debug; - // number of 'ticks' that have passed (number of times that - // tick() has been called - uint16_t _tick_counter; + // progmem list of tasks to run + const struct Task *_tasks; - // tick counter at the time we last ran each task - uint16_t *_last_run; + // number of tasks in _tasks list + uint8_t _num_tasks; - // number of microseconds allowed for the current task - uint32_t _task_time_allowed; + // number of 'ticks' that have passed (number of times that + // tick() has been called + uint16_t _tick_counter; - // the time in microseconds when the task started - uint32_t _task_time_started; + // tick counter at the time we last ran each task + uint16_t *_last_run; + + // number of microseconds allowed for the current task + uint32_t _task_time_allowed; + + // the time in microseconds when the task started + uint32_t _task_time_started; // number of spare microseconds accumulated uint32_t _spare_micros;