There are currently 0 users and 4 guests online.
C++ Library for $50 robot Version 2
Submitted by Webbot on January 2, 2009 - 12:44am.
This class allows you request a call back after a given number of milliseconds.
There is only one scheduler but it can queue up a finite maximum number of jobs - the default is 16 but can be chnaged via MAX_JOBS in Scheduler.hpp. This is used by PWMOUT and its derived classes but may also be used by you for queuing up any kind of job.
To schedule a call back use
Scheduler::get()->schedule(SCHEDULED_JOB* job, uint16_t delay_ms);
The job that is scheduled must be derived from SCHEDULED_JOB and after the delay has elapsed then the 'schedule' method is called on the object. Look at PWMOut.hpp and PWMOut.cpp for a working example that implements PWM via the scheduler.