Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Task.h
00001 #ifndef Task_h 00002 #define Task_h 00003 00004 #include "mbed.h" 00005 00006 #define DEFAULT_INTERVAL 1000 //1ms 00007 00008 /** 00009 * Override this class to create a Task that can be managed with the TaskManager. 00010 */ 00011 class Task 00012 { 00013 00014 public: 00015 00016 /** 00017 * Contructor. Sets interval to default of 1ms. 00018 */ 00019 Task(); 00020 00021 /** 00022 * Constructor. 00023 * @param _interval The running interval of the task in us. 00024 */ 00025 Task(int _interval); 00026 00027 /** 00028 * Starts the task. Should be automatically called from the TaskManager when it is added. 00029 */ 00030 void start(); 00031 00032 /** 00033 * Virtual method which gets called at the specified interval. 00034 */ 00035 virtual void tick() = 0; 00036 00037 /** 00038 * Stops the task from running 00039 */ 00040 void stop(); 00041 00042 /** 00043 * Returns true if the task is running. 00044 */ 00045 bool isRunning() { return running; } 00046 00047 00048 protected: 00049 00050 /** 00051 * Set the interval that the task tick method runs. 00052 * @_interval Interval in us. 00053 */ 00054 void setInterval(int _interval) { interval = _interval; } 00055 00056 00057 private: 00058 00059 Ticker ticker; 00060 int interval; 00061 bool running; 00062 00063 void preTick(); 00064 00065 }; 00066 00067 #endif
Generated on Wed Jul 13 2022 20:54:05 by
1.7.2