|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--stamp.core.VirtualPeripheral | +--stamp.core.Timer
A general purpose 32 bit timer.
There
is only a single instantiation of the timer itself, but there can be
multiple Timer
objects which use the timer value.
The first Timer
created starts the timer VP. Subsequent
instantiations use the same VP. Caution should be taken that stopping
the timer VP does not affect other Timer
objects.
The timer is a 32 bit counter which is incremented every 8.68us. Therefore:
A timer would typically be used in code like the following:
Timer t = new Timer(); t.mark(); while (true) { // Perform some action. if ( t.timeout(100) ) { // Check for a 100ms timeout. t.mark(); // Perform a periodic action. } }
Constructor Summary | |
Timer()
Creates a Timer object. |
Method Summary | |
void |
mark()
Remembers the current timer value. |
static void |
start(Timer vp)
Starts the timer VP. |
static void |
stop()
Stops the timer VP. |
int |
tickHi()
Retrieves the high 16 bits of the timer value. |
int |
tickLo()
Retrieves the low 16 bits of the timer value. |
boolean |
timeout(int timeMS)
Checks whether timeMS milliseconds have elapsed since
the last call to mark() . |
boolean |
timeout(int hi,
int lo)
Compares the current timer value with the value remembered by the last call to the mark() method. |
boolean |
timeoutSec(int timeS)
Checks whether timeS seconds have elapsed since
the last call to mark() . |
Methods inherited from class java.lang.Object |
equals |
Constructor Detail |
public Timer()
Timer
object. The first instantiation of this class
starts the timer VP. Subsequent instantiations use the same VP.Method Detail |
public static void start(Timer vp)
stop()
then
start()
will start it again with the same set of parameters.
It is an error to call start if the Timer is already running.
public static void stop()
public int tickHi()
public int tickLo()
tickLo()
should always be called before tickHi()
.
public void mark()
public boolean timeout(int hi, int lo)
mark()
method. If the difference is greater than
or equal to the parameter then returns true.public boolean timeout(int timeMS)
timeMS
milliseconds have elapsed since
the last call to mark()
.public boolean timeoutSec(int timeS)
timeS
seconds have elapsed since
the last call to mark()
. The maximum timeout is 935 seconds.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |