Przeglądaj źródła

v1.9.1 _TASK_ROLLOVER_FIX is deprecated (not necessary)

 * _TASK_ROLLOVER_FIX is deprecated (not necessary)
Anatoli Arkhipenko 10 lat temu
rodzic
commit
4f0216e49e
6 zmienionych plików z 150 dodań i 174 usunięć
  1. 4 4
      README
  2. BIN
      extras/TaskScheduler.doc
  3. 116 133
      extras/TaskScheduler.html
  4. 0 1
      keywords.txt
  5. 1 1
      library.properties
  6. 29 35
      src/TaskScheduler.h

+ 4 - 4
README

@@ -1,8 +1,5 @@
 Task Scheduler – cooperative multitasking for Arduino microcontrollers
-Version 1.9.0: 2015-11-24
-
-Please note, that version 1.9.1 contained an issue affecting all delayed methods.
-The decision was made to revert back to 1.9.0 until a solution is found.
+Version 1.9.1: 2015-11-28
   
 OVERVIEW:
 A lightweight implementation of cooperative multitasking (task scheduling) supporting:
@@ -16,6 +13,9 @@ A lightweight implementation of cooperative multitasking (task scheduling) suppo
 8. Support for Local Task Storage pointer (allowing use of same callback code for multiple tasks)
 
 Changelog:
+v1.9.1:
+    2015-11-28 - _TASK_ROLLOVER_FIX is deprecated (not necessary)
+	
 v1.9.0:
     2015-11-24 - packed three byte-long status variables into one byte-long bit array structure data type - saving 2 bytes per each task instance
 

BIN
extras/TaskScheduler.doc


+ 116 - 133
extras/TaskScheduler.html

@@ -6,7 +6,7 @@
 	<META NAME="GENERATOR" CONTENT="LibreOffice 3.5  (Linux)">
 	<META NAME="CREATED" CONTENT="20150206;16300000">
 	<META NAME="CHANGEDBY" CONTENT="Anatoli Arkhipenko">
-	<META NAME="CHANGED" CONTENT="20151115;15470000">
+	<META NAME="CHANGED" CONTENT="20151128;23410000">
 	<META NAME="Info 1" CONTENT="">
 	<META NAME="Info 2" CONTENT="">
 	<META NAME="Info 3" CONTENT="">
@@ -15,7 +15,7 @@
 	<!--
 		@page { margin: 0.79in }
 		P { margin-bottom: 0.08in; direction: ltr; color: #000000; widows: 0; orphans: 0 }
-		P.western { font-family: "Liberation Serif", "Times New Roman", serif; font-size: 12pt; so-language: en-US }
+		P.western { font-family: "Liberation Serif", "MS PMincho", serif; font-size: 12pt; so-language: en-US }
 		P.cjk { font-family: "WenQuanYi Micro Hei", "MS Mincho"; font-size: 12pt; so-language: zh-CN }
 		P.ctl { font-family: "Lohit Hindi", "MS Mincho"; font-size: 12pt; so-language: hi-IN }
 		A:link { color: #0000ff }
@@ -28,7 +28,7 @@ Scheduler</B></FONT></P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><B>cooperative
 multitasking for Arduino microcontrollers</B></P>
 <P CLASS="western" STYLE="margin-bottom: 0in; border-top: none; border-bottom: 1px solid #000000; border-left: none; border-right: none; padding-top: 0in; padding-bottom: 0.01in; padding-left: 0in; padding-right: 0in">
-<FONT SIZE=2 STYLE="font-size: 11pt"><B>Version 1.9.0: 2015-11-24</B></FONT></P>
+<FONT SIZE=2 STYLE="font-size: 11pt"><B>Version 1.9.1: 2015-11-28</B></FONT></P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><B>OVERVIEW</B>:</P>
@@ -122,7 +122,7 @@ than the Scheduler's <B>execute</B>() method).</P>
 </P>
 <P CLASS="western" STYLE="margin-bottom: 0in; page-break-after: avoid">
 <B>Below is the flowchart of a Task lifecycle:</B></P>
-<P CLASS="western" STYLE="margin-bottom: 0in"><IMG SRC="TaskScheduler_html.png" NAME="graphics1" ALIGN=BOTTOM WIDTH=664 HEIGHT=616 BORDER=0></P>
+<P CLASS="western" STYLE="margin-bottom: 0in"><IMG SRC="TaskScheduler_html.png" NAME="graphics1" ALIGN=BOTTOM WIDTH=664 HEIGHT=570 BORDER=0></P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><B>TaskScheduler</B>
@@ -276,19 +276,6 @@ LTS pointer to the appropriate pointer type.
 </P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
 </P>
-<P CLASS="western" STYLE="margin-bottom: 0in">#define
-<B>_TASK_ROLLOVER_FIX</B></P>
-<P CLASS="western" STYLE="margin-bottom: 0in">…will compile
-TaskScheduler with support for millis() rollover approximately every
-47 days. Only required if you plan for your sketch to run for
-extended amount of time (over 47 days).</P>
-<P CLASS="western" STYLE="margin-bottom: 0in">The problem here is
-when scheduler calculates next execution time for a task, a rollover
-may place next execution time “in the past” and cause task to be
-invoked incorrectly once every 47 days. 
-</P>
-<P CLASS="western" STYLE="margin-bottom: 0in"><BR>
-</P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><B>NOTE: </B>above
 parameters are<B> DISABLED </B>by default, and need to be explicitly
 enabled by placing appropriate #define statements in front of the
@@ -297,6 +284,10 @@ enabled by placing appropriate #define statements in front of the
 </P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
 </P>
+<P CLASS="western" STYLE="margin-bottom: 0in"><BR>
+</P>
+<P CLASS="western" STYLE="margin-bottom: 0in"><BR>
+</P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><B>TASK PRIORITY AND
 COOPERATIVE MULTITASKING:</B></P>
 <P CLASS="western" STYLE="margin-bottom: 0in">TaskScheduler <B>does
@@ -317,7 +308,7 @@ TaskScheduler is inspired by, support it), but decided against it.
 simple and efficient. The main idea is to minimize scheduling
 overhead by Scheduler going through the chain. Implementing true
 priority would require looking ahead through the entire chain,
-ranking and aging tasks by priorities. It would slow the <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">execute()
+ranking and aging tasks by priorities. It would slow the <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">execute()
 </FONT></FONT>loop significantly.</P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
 </P>
@@ -368,27 +359,27 @@ the same callback and &quot;sprinkle&quot; them around the chain:</P>
 </P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
 </P>
-<P CLASS="western" STYLE="margin-bottom: 0in">    <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Scheduler
+<P CLASS="western" STYLE="margin-bottom: 0in">    <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Scheduler
 ts;</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
 </P>
-<P CLASS="western" STYLE="margin-bottom: 0in">    <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
+<P CLASS="western" STYLE="margin-bottom: 0in">    <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
 t1(20, TASK_FOREVER, &amp;callback1, &amp;ts);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
 </P>
-<P CLASS="western" STYLE="margin-bottom: 0in">    <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
+<P CLASS="western" STYLE="margin-bottom: 0in">    <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
 t2(1000, TASK_FOREVER, &amp;callback2, &amp;ts);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
 </P>
-<P CLASS="western" STYLE="margin-bottom: 0in">    <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
+<P CLASS="western" STYLE="margin-bottom: 0in">    <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
 t3(20, TASK_FOREVER, &amp;callback1, &amp;ts);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
 </P>
-<P CLASS="western" STYLE="margin-bottom: 0in">    <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
+<P CLASS="western" STYLE="margin-bottom: 0in">    <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
 t4(1000, TASK_FOREVER, &amp;callback4, &amp;ts);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
 </P>
-<P CLASS="western" STYLE="margin-bottom: 0in">    <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t3.delay(10);</FONT></FONT></P>
+<P CLASS="western" STYLE="margin-bottom: 0in">    <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t3.delay(10);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
@@ -422,7 +413,7 @@ callback methods written for cooperative multitasking.</P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">a)
-<B>DO NOT</B> use Arduino's  <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">delay()</FONT></FONT><FONT FACE="Andale Mono">
+<B>DO NOT</B> use Arduino's  <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">delay()</FONT></FONT><FONT FACE="Andale Mono, MS Mincho">
 </FONT>function. It is blocking and will hold the entire chain.
 Instead break the callback method into two, switch the callback
 method of the task where delay is necessary and delay the task by
@@ -443,26 +434,26 @@ of:</P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
 callback() {</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-  <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
+  <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
 stuff</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-  <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">delay(1000);</FONT></FONT></P>
+  <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">delay(1000);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-  <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
+  <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
 more stuff</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
@@ -479,45 +470,45 @@ this:</P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
 callback1() {</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-  <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
+  <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
 stuff</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-  <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback2);</FONT></FONT></P>
+  <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback2);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-  <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.delay(1000);</FONT></FONT></P>
+  <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.delay(1000);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
 callback2() {</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-  <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
+  <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
 more stuff</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-  <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback1);</FONT></FONT></P>
+  <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback1);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
@@ -529,7 +520,7 @@ more stuff</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">b)
-Same goes to <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">pulseIn()</FONT></FONT>
+Same goes to <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">pulseIn()</FONT></FONT>
 function. If you have to use it, set the timeout parameter such that
 it is not a default 1 second. PulseIn functionality could be achieved
 via pin interrupts, and that solution is non-blocking.</P>
@@ -557,7 +548,7 @@ of:</P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
 callback() {</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
@@ -567,21 +558,21 @@ callback() {</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">for(int
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">for(int
 i=0; i&lt;1000; i++) {</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-     <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
+     <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
 stuff // one loop action</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
@@ -597,7 +588,7 @@ this:</P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
 t1(TASK_IMMEDIATE, 1000, &amp;callback);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
@@ -607,22 +598,22 @@ t1(TASK_IMMEDIATE, 1000, &amp;callback);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
 callback() {</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">int
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">int
 i = t1.getRunCounter() -1;</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
 stuff // one loop action</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
@@ -638,7 +629,7 @@ this:</P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
 t1(TASK_IMMEDIATE, 1000, &amp;callback, true, &amp;t1On);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
@@ -648,27 +639,27 @@ t1(TASK_IMMEDIATE, 1000, &amp;callback, true, &amp;t1On);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">int
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">int
 i;</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">bool
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">bool
 t1On() {</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">i
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">i
 = 0;</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">return
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">return
 true;</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
@@ -677,21 +668,21 @@ true;</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
 callback() {</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
 stuff // one loop action</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">i++;</FONT></FONT></P>
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">i++;</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
@@ -707,7 +698,7 @@ stuff // one loop action</FONT></FONT></P>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">d)
 Break long running callback methods into several shorter ones, and
-pass control from one to the other via <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">setCallback()
+pass control from one to the other via <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">setCallback()
 </FONT></FONT>method:</P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
@@ -716,7 +707,7 @@ pass control from one to the other via <FONT FACE="FreeMono, monospace"><FONT SI
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
 t1(TASK_IMMEDIATE, TASK_FAREVER, &amp;callback);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
@@ -726,61 +717,61 @@ t1(TASK_IMMEDIATE, TASK_FAREVER, &amp;callback);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
 callback() {</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
 do some stuff</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback_step2);</FONT></FONT></P>
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback_step2);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
 callback_step2() {</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
 do more stuff</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback_step3);</FONT></FONT></P>
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback_step3);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
 callback_step3() {</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
 do last part of the stuff</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback);</FONT></FONT></P>
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.delay(1000);</FONT></FONT></P>
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.delay(1000);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
@@ -798,7 +789,7 @@ step.
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">Alternatively
 you could schedule the task to run every 1000 millis and use
-<FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">forceNextIteration()</FONT></FONT>
+<FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">forceNextIteration()</FONT></FONT>
 method in steps 1 and 2 (but not 3!)</P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
@@ -807,7 +798,7 @@ method in steps 1 and 2 (but not 3!)</P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">Task
 t1(1000, TASK_FOREVER, &amp;callback);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
@@ -817,65 +808,65 @@ t1(1000, TASK_FOREVER, &amp;callback);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
 callback() {</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
 do some stuff</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback_step2);</FONT></FONT></P>
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback_step2);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.forceNextIteration();</FONT></FONT></P>
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.forceNextIteration();</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
 callback_step2() {</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
 do more stuff</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback_step3);</FONT></FONT></P>
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback_step3);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.forceNextIteration();</FONT></FONT></P>
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.forceNextIteration();</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">void
 callback_step3() {</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">...
 do last part of the stuff</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
-   <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback);</FONT></FONT></P>
+   <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">t1.setCallback(&amp;callback);</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">  
- <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
+ <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt">}</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
@@ -887,7 +878,7 @@ do last part of the stuff</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">e)
-Compile the library with <FONT FACE="FreeMono, monospace"><FONT SIZE=2 STYLE="font-size: 10pt"><B>_TASK_TIMECRITICAL</B></FONT></FONT>
+Compile the library with <FONT FACE="FreeMono, MS Mincho, monospace"><FONT SIZE=2 STYLE="font-size: 10pt"><B>_TASK_TIMECRITICAL</B></FONT></FONT>
 enabled and check if your tasks are falling behind schedule. If they
 are - you need to optimize your code further (or maybe re-evaluate
 your schedule). If they are not - all is well and you don't need to
@@ -1122,23 +1113,20 @@ millis() is performed after <B>OnEnable</B> exits, so any changes to
 the interval inside <B>OnEnable</B> is taken into consideration.</P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">TaskScheduler
 allows tasks to be added to the a Scheduler and enabled at the time
-of creation. <B>Be very careful</B><SPAN STYLE="font-weight: normal">
-with such tasks – the </SPAN><B>OnEnable </B><SPAN STYLE="font-weight: normal">method
-will be executed immediately, while certain objects (i.e., other
-Tasks, libraries) are not yet ready (e.g., </SPAN><B>Wire.begin()</B><SPAN STYLE="font-weight: normal">
+of creation. <B>Be very careful</B> with such tasks – the <B>OnEnable
+</B>method will be executed immediately, while certain objects (i.e.,
+other Tasks, libraries) are not yet ready (e.g., <B>Wire.begin()</B>
 was not yet called), or hardware not yet activated (pins not set to
-INPUT or OUTPUT). </SPAN>
+INPUT or OUTPUT). 
 </P>
-<P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><SPAN STYLE="font-weight: normal">It
-is very much recommended to to enable all tasks at the end of </SPAN><B>setup()</B><SPAN STYLE="font-weight: normal">
-method after all initializations are done. </SPAN>
+<P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">It
+is very much recommended to to enable all tasks at the end of <B>setup()</B>
+method after all initializations are done. 
 </P>
-<P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><SPAN STYLE="font-weight: normal">If
+<P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">If
 you require immediate execution of already enabled task, use
-</SPAN><B>forceNextIteratoin</B><SPAN STYLE="font-weight: normal">()
-method instead of </SPAN><B>enable</B><SPAN STYLE="font-weight: normal">():
-it achieves the result, but does not call </SPAN><B>OnEnable</B><SPAN STYLE="font-weight: normal">
-method. </SPAN>
+<B>forceNextIteratoin</B>() method instead of <B>enable</B>(): it
+achieves the result, but does not call <B>OnEnable</B> method. 
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
@@ -1306,10 +1294,9 @@ ran through all their allocated iterations are disabled.
 <B>enable</B> explicitly, or use <B>restart</B> methods. 
 </P>
 <P CLASS="western" STYLE="margin-bottom: 0in">Please note that as a
-result execution of the taks is <B>delayed</B><SPAN STYLE="font-weight: normal">
-by the provided interval. If immediate invocation is required, call
-</SPAN><B>forceNextIteration</B><SPAN STYLE="font-weight: normal">()
-method after setting a new interval. </SPAN>
+result execution of the taks is <B>delayed</B> by the provided
+interval. If immediate invocation is required, call
+<B>forceNextIteration</B>() method after setting a new interval. 
 </P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
 </P>
@@ -1603,36 +1590,32 @@ one scheduling pass, including end-of-pass sleep. This method is
 typically placed inside the <B>loop()</B> method of the sketch. Since
 <B>execute</B> exits after every pass, you can put additional
 statements after <B>execute</B> inside the <B>loop().</B></P>
-<P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in; font-weight: normal">
-Generally, execute will perform the following steps:</P>
+<P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in">Generally,
+execute will perform the following steps:</P>
 <OL>
-	<LI><P CLASS="western" STYLE="margin-bottom: 0in; font-weight: normal">
-	Ignore task completely if it is disabled.</P>
-	<LI><P CLASS="western" STYLE="margin-bottom: 0in; font-weight: normal">
-	Disable task if it ran out of iterations (calling OnDesable, if
-	necessary).</P>
-	<LI><P CLASS="western" STYLE="margin-bottom: 0in; font-weight: normal">
-	Check if task is waiting on a StatusRequest object, and make
-	appropriate scheduling arrangements</P>
-	<LI><P CLASS="western" STYLE="margin-bottom: 0in; font-weight: normal">
-	Perform necessary timing calculations (including millis() rollover
-	fix, if requested)</P>
-	<LI><P CLASS="western" STYLE="margin-bottom: 0in; font-weight: normal">
-	Invoke task's callback method, if it is time to do so, and one is
-	provided. 
+	<LI><P CLASS="western" STYLE="margin-bottom: 0in">Ignore task
+	completely if it is disabled.</P>
+	<LI><P CLASS="western" STYLE="margin-bottom: 0in">Disable task if it
+	ran out of iterations (calling OnDesable, if necessary).</P>
+	<LI><P CLASS="western" STYLE="margin-bottom: 0in">Check if task is
+	waiting on a StatusRequest object, and make appropriate scheduling
+	arrangements</P>
+	<LI><P CLASS="western" STYLE="margin-bottom: 0in">Perform necessary
+	timing calculations</P>
+	<LI><P CLASS="western" STYLE="margin-bottom: 0in">Invoke task's
+	callback method, if it is time to do so, and one is provided. 
 	</P>
-	<LI><P CLASS="western" STYLE="margin-bottom: 0in; font-weight: normal">
-	Put microcontroller to sleep (if requested and supported) if none of
-	the tasks were invoked. 
+	<LI><P CLASS="western" STYLE="margin-bottom: 0in">Put
+	microcontroller to sleep (if requested and supported) if none of the
+	tasks were invoked. 
 	</P>
 </OL>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><B>Please
-NOTE:</B><SPAN STYLE="font-weight: normal"> schedule-related
-calculations are performed prior to task's callback method
-invocation. This allows tasks to manipulate their runtime parameters
-(like execution interval) directly.</SPAN></P>
+NOTE:</B> schedule-related calculations are performed prior to task's
+callback method invocation. This allows tasks to manipulate their
+runtime parameters (like execution interval) directly.</P>
 <P CLASS="western" STYLE="margin-left: 0.49in; margin-bottom: 0in"><BR>
 </P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><B>bool isOverrun()</B></P>
@@ -2811,7 +2794,7 @@ time examples of TaskScheduler are available here:</FONT></FONT></P>
 <P CLASS="western" STYLE="margin-bottom: 0in"><BR>
 </P>
 <DIV TYPE=FOOTER>
-	<P STYLE="margin-top: 0.35in; margin-bottom: 0in">	<SDFIELD TYPE=PAGE SUBTYPE=RANDOM FORMAT=ARABIC>31</SDFIELD></P>
+	<P STYLE="margin-top: 0.35in; margin-bottom: 0in">	<SDFIELD TYPE=PAGE SUBTYPE=RANDOM FORMAT=ARABIC>4</SDFIELD></P>
 </DIV>
 </BODY>
 </HTML>

+ 0 - 1
keywords.txt

@@ -75,6 +75,5 @@ _TASK_SLEEP_ON_IDLE_RUN	LITERAL1
 _TASK_STATUS_REQUEST	LITERAL1
 _TASK_WDT_IDS	LITERAL1
 _TASK_LTS_POINTER	LITERAL1
-_TASK_ROLLOVER_FIX	LITERAL1
 #######################################
 

+ 1 - 1
library.properties

@@ -1,5 +1,5 @@
 name=TaskScheduler
-version=1.9.0
+version=1.9.1
 author=Anatoli Arkhipenko <arkhipenko@hotmail.com>
 maintainer=Anatoli Arkhipenko <arkhipenko@hotmail.com>
 sentence=A light-weight cooperative multitasking library for arduino microcontrollers.

+ 29 - 35
src/TaskScheduler.h

@@ -68,7 +68,9 @@
 //
 // v1.9.0:
 //    2015-11-24 - packed three byte-long status variables into bit array structure data type - saving 2 bytes per each task instance
-
+//
+// v1.9.1:
+//    2015-11-28 - _TASK_ROLLOVER_FIX is deprecated (not necessary)
 
 /* ============================================
 Cooperative multitasking library code is placed under the MIT license
@@ -110,7 +112,6 @@ THE SOFTWARE.
  *  #define _TASK_STATUS_REQUEST    // Compile with support for StatusRequest functionality - triggering tasks on status change events in addition to time only
  *  #define _TASK_WDT_IDS           // Compile with support for wdt control points and task ids
  *  #define _TASK_LTS_POINTER       // Compile with support for local task storage pointer
- *  #define _TASK_ROLLOVER_FIX		// Compensate for millis() rollover once every 47 days
  */
 
 #ifdef _TASK_SLEEP_ON_IDLE_RUN
@@ -210,13 +211,14 @@ class Task {
 
 		volatile __task_status	iStatus;
 		volatile unsigned long	iInterval;			// execution interval in milliseconds. 0 - immediate
-		volatile unsigned long	iPreviousMillis;		// previous invocation time (millis).  Next invocation = iPreviousMillis + iInterval.  Delayed tasks will "catch up" 
+		volatile unsigned long	iDelay; 			// actual delay until next execution (usually equal iInterval)
+		volatile unsigned long	iPreviousMillis;	// previous invocation time (millis).  Next invocation = iPreviousMillis + iInterval.  Delayed tasks will "catch up" 
 #ifdef _TASK_TIMECRITICAL
 		volatile long			iOverrun; 		// negative if task is "catching up" to it's schedule (next invocation time is already in the past)
 #endif
 		volatile long			iIterations;		// number of iterations left. 0 - last iteration. -1 - infinite iterations
 		long					iSetIterations; 		// number of iterations originally requested (for restarts)
-		unsigned long		iRunCounter;		// current number of iteration (starting with 1). Resets on enable. 
+		unsigned long			iRunCounter;		// current number of iteration (starting with 1). Resets on enable. 
 		void					(*iCallback)();		// pointer to the void callback method
 		bool					(*iOnEnable)();	// pointer to the bolol OnEnable callback method
 		void					(*iOnDisable)();	// pointer to the void OnDisable method
@@ -351,6 +353,7 @@ void Task::reset() {
 	iStatus.enabled = false;
 	iStatus.inonenable = false;
 	iPreviousMillis = 0;
+	iInterval = iDelay = 0;
 	iPrev = NULL;
 	iNext = NULL;
 	iScheduler = NULL;
@@ -410,7 +413,7 @@ void Task::enable() {
 		else {
 			iStatus.enabled = true;
 		}
-		iPreviousMillis = millis() - iInterval;
+		iPreviousMillis = millis() - (iDelay = iInterval);
 	}
 }
 
@@ -436,8 +439,9 @@ void Task::enableDelayed(unsigned long aDelay) {
  * if aDelay is zero, delays for the original scheduling interval from now
  */
 void Task::delay(unsigned long aDelay) {
-	if (!aDelay) aDelay = iInterval;
-	iPreviousMillis = millis() - iInterval + aDelay;
+//	if (!aDelay) aDelay = iInterval;
+	iDelay = aDelay ? aDelay : iInterval;
+	iPreviousMillis = millis(); // - iInterval + aDelay;
 }
 
 /** Schedules next iteration of Task for execution immediately (if enabled)
@@ -445,7 +449,7 @@ void Task::delay(unsigned long aDelay) {
  * Task's original schedule is shifted, and all subsequent iterations will continue from this point in time
  */
 void Task::forceNextIteration() {
-	iPreviousMillis = millis() - iInterval;
+	iPreviousMillis = millis() - (iDelay = iInterval);
 }
 
 /** Sets the execution interval.
@@ -455,7 +459,7 @@ void Task::forceNextIteration() {
  */
 void Task::setInterval (unsigned long aInterval) {
  	iInterval = aInterval; 
-	delay();
+	delay(); // iDelay will be updated by the delay() function
 }
 
 /** Disables task
@@ -589,8 +593,8 @@ void Scheduler::execute() {
 #ifdef _TASK_SLEEP_ON_IDLE_RUN
 	bool		idleRun = true;
 #endif
-	unsigned long targetMillis;
-	register unsigned long m, i, p;
+//	unsigned long targetMillis;
+	register unsigned long m, p, i; //, d;
 	
 	iCurrent = iFirst;
 
@@ -609,47 +613,37 @@ void Scheduler::execute() {
 				}
 				m = millis();
 				i = iCurrent->iInterval;
+//				d = iCurrent->iDelay;
 	#ifdef  _TASK_STATUS_REQUEST
 	// If StatusRequest object was provided, and still pending, and task is waiting, this task should not run
 	// Otherwise, continue with execution as usual.  Tasks waiting to StatusRequest need to be rescheduled according to 
 	// how they were placed into waiting state (waitFor or waitForDelayed)
 				if ( iCurrent->iStatus.waiting ) {
 					if ( (iCurrent->iStatusRequest)->pending() ) break;
-					iCurrent->iPreviousMillis = (iCurrent->iStatus.waiting == _TASK_SR_NODELAY) ? m - i : m;
+					if (iCurrent->iStatus.waiting == _TASK_SR_NODELAY) {
+						iCurrent->iPreviousMillis = m - (iCurrent->iDelay = i);
+					}
+					else {
+						iCurrent->iPreviousMillis = m;
+					}
 					iCurrent->iStatus.waiting = 0;
 				}
 	#endif
 				p = iCurrent->iPreviousMillis;
-
-	// Determine when current task is supposed to run
-	// Once every 47 days there is a rollover execution which will occur due to millis and targetMillis rollovers
-	// That is why there is an option to compile with rollover fix
-	// Example
-	//	iPreviousMillis = 65000
-	//	iInterval = 600
-	//	millis() = 65500
-	//  targetMillis = 65000 + 600 = (should be 65600) 65 (due to rollover)
-	//	so 65 < 65500. should be 65600 > 65500. - task will be scheduled incorrectly
-	//  since targetMillis (65) < iPreviousMillis (65000), rollover fix kicks in:
-	//  iPreviousMillis(65000) > millis(65500) - iInterval(600) = 64900 - task will not be scheduled
-	
-				targetMillis = p + i;
-	#ifdef _TASK_ROLLOVER_FIX
-				if ( targetMillis < p ) {  // targetMillis rolled over!
-					if ( p > ( m - i) )  break;
-				}
-				else
-	#endif
-					if ( targetMillis > m ) break;
+				
+	//			targetMillis = p + i;
+				if ( m - p < iCurrent->iDelay ) break;
 	
 	#ifdef _TASK_TIMECRITICAL
 	// Updated_previous+current interval should put us into the future, so iOverrun should be positive or zero. 
 	// If negative - the task is behind (next execution time is already in the past) 
-				iCurrent->iOverrun = (long) ( targetMillis - m + i );
+				iCurrent->iOverrun = (long) ( p - m + (i<<1) );
 	#endif
 				if ( iCurrent->iIterations > 0 ) iCurrent->iIterations--;  // do not decrement (-1) being a signal of never-ending task
 				iCurrent->iRunCounter++;
-				iCurrent->iPreviousMillis = targetMillis; //p + i
+				iCurrent->iPreviousMillis = p + iCurrent->iDelay;
+				iCurrent->iDelay = i;
+//				iCurrent->iDelay = iCurrent->iInterval; // get rid of one time delay
 				if ( iCurrent->iCallback ) {
 					( *(iCurrent->iCallback) )();
 	#ifdef _TASK_SLEEP_ON_IDLE_RUN