-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
199 lines (197 loc) · 13.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TaskSched: TaskSched</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">TaskSched
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="PageDoc"><div class="header">
<div class="headertitle">
<div class="title">TaskSched </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><a class="anchor" id="md_README"></a> </p>
<h1><a class="anchor" id="autotoc_md1"></a>
Overview</h1>
<p>TaskSched is a cooperative multitasking scheduler for Arduino processors, designed as a simpler alternative to existing schedulers like TaskScheduler. It provides a flexible and efficient way to manage multiple tasks in Arduino projects, particularly tested on ESP32 and ESP8266 processors.</p>
<p>A cooperative task scheduler is a system that manages the execution of multiple tasks, but with a twist compared to a traditional scheduler. Here's the key difference:</p>
<p>Cooperative: In a cooperative scheme, tasks are responsible for voluntarily giving up control of the processor when they're done or need to wait for something. The scheduler simply provides a starting point and trusts the tasks to behave. This is in contrast to a preemptive scheduler, where the operating system can interrupt a running task and switch to another one.</p>
<p>Here's a breakdown of how cooperative scheduling works:</p>
<ul>
<li>The scheduler starts a task.</li>
<li>The task runs until it finishes its work or needs to wait for something (like user input or data from another task).</li>
<li>The task then signals the scheduler that it's done or needs to wait.</li>
<li>The scheduler picks another task to run.</li>
</ul>
<p>Pros and Cons:</p>
<ul>
<li>Pros: Simpler to implement, fewer system resources needed.</li>
<li>Cons: Unpredictable behavior if tasks don't cooperate, can lead to unresponsive systems if a task gets stuck.</li>
</ul>
<p>Use Cases:</p>
<ul>
<li>Often used in early operating systems or embedded systems with limited resources.</li>
<li>Can be a good choice for specific situations where tasks have well-defined execution times and don't rely on external events heavily.</li>
<li>Even with events that have an ideterminite delay such as waiting for a DHCP server to issue an IP, one task may start the connect and schedule another task to monitor for a response periodically.</li>
</ul>
<h1><a class="anchor" id="autotoc_md2"></a>
Contents</h1>
<ul>
<li><a href="#main-features">Main Features</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#usage">Usage</a><ul>
<li><a href="#creating-tasks">Creating Tasks</a></li>
<li><a href="#task-methods">Task Methods</a></li>
<li><a href="#scheduler">Scheduler</a></li>
</ul>
</li>
<li><a href="#examples">Examples</a></li>
<li><a href="#api-reference">API Reference</a></li>
<li><a href="#issues">Issues</a></li>
<li><a href="#contributing">Contributing</a></li>
</ul>
<h1><a class="anchor" id="autotoc_md3"></a>
Main Features</h1>
<ol type="1">
<li><b>Periodic task execution</b>: Tasks can be set to run at specified intervals, with times specified in milliseconds or seconds.</li>
<li><b><a class="el" href="classTask.html" title="Represents a schedulable task.">Task</a> enable/disable support</b>: Tasks can be dynamically enabled or disabled.</li>
<li><b>Iteration control</b>: Tasks can be set to run for a specific number of iterations or indefinitely.</li>
<li><b>Immediate or delayed execution</b>: Tasks can be scheduled to run immediately when enabled or wait for the interval to expire.</li>
<li><b><a class="el" href="classTask.html" title="Represents a schedulable task.">Task</a> restart and parameter modification</b>: Tasks can be restarted with original or new parameters (interval, callback function, etc.).</li>
<li><b>Flexible timing control</b>: The scheduler can be run periodically in the main loop.</li>
</ol>
<h1><a class="anchor" id="autotoc_md4"></a>
Installation</h1>
<p>To install TaskSched, clone the repository:</p>
<div class="fragment"><div class="line">git clone https://github.com/AverageGuy/tasksched.git</div>
</div><!-- fragment --><p>Or download the <a href="https://github.com/AverageGuy/pyconky/archive/refs/heads/main.zip">ZIP</a> file.</p>
<h1><a class="anchor" id="autotoc_md5"></a>
Usage</h1>
<h2><a class="anchor" id="autotoc_md6"></a>
Creating Tasks</h2>
<p>Tasks are created using the <code><a class="el" href="classTask.html" title="Represents a schedulable task.">Task</a></code> constructor:</p>
<div class="fragment"><div class="line"><<a class="code" href="classTask.html">Task</a> *task =<span class="keyword">new</span> <a class="code" href="classTask.html">Task</a>(callback, interval, enabled, iterations, name, runImmediately);</div>
<div class="line"><a class="code" href="classTask.html">Task</a> *task = <span class="keyword">new</span> <a class="code" href="classTask.html">Task</a>(VoidCallBack, interval, enabled, iterations, name, runImmediately);</div>
<div class="ttc" id="aclassTask_html"><div class="ttname"><a href="classTask.html">Task</a></div><div class="ttdoc">Represents a schedulable task.</div><div class="ttdef"><b>Definition:</b> <a href="TaskSched_8h_source.html#l00080">TaskSched.h:80</a></div></div>
</div><!-- fragment --><ul>
<li><code>TaskCallback</code>: Function to be called (must accept a <code>Task*</code> parameter)</li>
<li><code>VoidCallback</code>: Function to be called (no parameter)</li>
<li><code>interval</code>: Time between calls milliseconds if integer</li>
<li><code>enabled</code>: Whether the task starts enabled</li>
<li><code>iterations</code>: Number of times to run (0 for infinite)</li>
<li><code>name</code>: Descriptive name for the task</li>
<li><code>runImmediately</code>: Whether to run immediately when enabled without waiting for interval to expire</li>
</ul>
<h2><a class="anchor" id="autotoc_md7"></a>
Task Methods</h2>
<p>Key methods for managing tasks: (<a href="https://averageguy.github.io/task-docs/classTask.html">https://averageguy.github.io/task-docs/classTask.html</a>)</p>
<ul>
<li><code>enable()</code>: Enable the task</li>
<li><code>disable()</code>: Disable the task</li>
<li><code>restart()</code>: Restart the task with original parameters</li>
<li><code>setInterval(newInterval)</code>: Set a new interval</li>
<li><code>setIterations(newIterations)</code>: Set a new iteration count</li>
<li><code>isEnabled()</code>: Check if the task is enabled</li>
<li><code>isFirstIteration()</code>: Check if it's the first iteration</li>
<li><code>isLastIteration()</code>: Check if it's the last iteration</li>
</ul>
<h2><a class="anchor" id="autotoc_md8"></a>
Scheduler</h2>
<p>The <code><a class="el" href="classSched.html" title="This class runs the scheduled tasks.">Sched</a></code> class manages multiple tasks:</p>
<div class="fragment"><div class="line"><a class="code" href="classTask.html">Task</a> *task=<span class="keyword">new</span> <a class="code" href="classTask.html">Task</a>(runTest, 500, <span class="keyword">true</span>, 6, <span class="stringliteral">"First"</span>, <span class="keyword">true</span>);</div>
<div class="line"><a class="code" href="classSched.html">Sched</a> scheduler;</div>
<div class="line">scheduler.<a class="code" href="classSched.html#aaf93c84f24063127d45584eaee3e0e98">addTask</a>(task);</div>
<div class="line">scheduler.<a class="code" href="classSched.html#a76421d3e33bc7d6f64a0acc97f9a456d">begin</a>();</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> loop() {</div>
<div class="line"> scheduler.<a class="code" href="classSched.html#a95f8b9b08bd39d6a2e9380c0d149bcd4">run</a>();</div>
<div class="line">}</div>
<div class="ttc" id="aclassSched_html"><div class="ttname"><a href="classSched.html">Sched</a></div><div class="ttdoc">This class runs the scheduled tasks.</div><div class="ttdef"><b>Definition:</b> <a href="TaskSched_8h_source.html#l00279">TaskSched.h:280</a></div></div>
<div class="ttc" id="aclassSched_html_a76421d3e33bc7d6f64a0acc97f9a456d"><div class="ttname"><a href="classSched.html#a76421d3e33bc7d6f64a0acc97f9a456d">Sched::begin</a></div><div class="ttdeci">void begin()</div><div class="ttdef"><b>Definition:</b> <a href="TaskSched_8cpp_source.html#l00241">TaskSched.cpp:241</a></div></div>
<div class="ttc" id="aclassSched_html_a95f8b9b08bd39d6a2e9380c0d149bcd4"><div class="ttname"><a href="classSched.html#a95f8b9b08bd39d6a2e9380c0d149bcd4">Sched::run</a></div><div class="ttdeci">void run()</div><div class="ttdoc">called perodically to check if a task should be scheduled</div><div class="ttdef"><b>Definition:</b> <a href="TaskSched_8cpp_source.html#l00265">TaskSched.cpp:265</a></div></div>
<div class="ttc" id="aclassSched_html_aaf93c84f24063127d45584eaee3e0e98"><div class="ttname"><a href="classSched.html#aaf93c84f24063127d45584eaee3e0e98">Sched::addTask</a></div><div class="ttdeci">void addTask(Task *task)</div><div class="ttdef"><b>Definition:</b> <a href="TaskSched_8cpp_source.html#l00244">TaskSched.cpp:244</a></div></div>
</div><!-- fragment --><p>Key methods in the <a class="el" href="classSched.html" title="This class runs the scheduled tasks.">Sched</a> class (<a href="https://averageguy.github.io/task-docs/classSched.html">https://averageguy.github.io/task-docs/classSched.html</a>)</p>
<ul>
<li><code>enable()</code>: Enable the scheduler</li>
<li><code>disable()</code>: Disable the scheduler</li>
<li><code>begin()</code>: Initialize the scheduler</li>
<li><code>run()</code>: Loop throught the tasks and run them one at a time, if they are scheduled.</li>
<li><code>getSize()</code>: Return the number of tasks in the run queue</li>
<li><code>displayStatus()</code>: Returns a String with info about some or all of the tasks in the queue.</li>
<li><code>addTask()</code>: Adds a task to the queue.</li>
<li><code>isEnabled()</code>: Returns a true if the scheduler is enabled or false if it is not.</li>
<li><code>getTasks()</code>: Returns a list of the tasks. See the example/SkedBlink2.ino file for examples of ways to use this list.</li>
</ul>
<h1><a class="anchor" id="autotoc_md9"></a>
Examples</h1>
<p>See the <code>examples</code> directory for basic examples of blinking an LED using TaskSched and others. Also look at the wiki. It has more examples and explanations.</p>
<h1><a class="anchor" id="autotoc_md10"></a>
API Reference</h1>
<p>For detailed API documentation, please refer to the Doxygen-generated documentation <a href="https://averageguy.github.io/task-docs/">https://averageguy.github.io/task-docs/</a></p>
<h1><a class="anchor" id="autotoc_md11"></a>
Issues</h1>
<p>If you encounter any issues or have feature requests, please open an issue on the GitHub repository.</p>
<h1><a class="anchor" id="autotoc_md12"></a>
Contributing</h1>
<p>Contributions to TaskSched are welcome. Please feel free to submit pull requests or open issues to discuss potential improvements. </p>
</div></div><!-- PageDoc -->
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>