Timer

See the Timer Entity for generic information.

class brainstem.entity.Timer(module, index)[source]

The Timer Class provides access to a simple scheduler. The timer can set to fire only once, or to repeat at a certain interval. Additionally, a timer entity can execute custom Reflex routines upon firing.

getExpiration()[source]

Get the currently set expiration time in microseconds. This is not a “live” timer. That is, it shows the expiration time originally set with setExpiration; it does not “tick down” to show the time remaining before expiration.

Returns:

Object containing error code and returned value on success.
errorunsigned byte

An error result from the list of defined error codes

valueunsigned int

The timer expiration duration in microseconds.

Return type:

brainstem.result.Result

getMode()[source]

Get the mode of the timer which is either single or repeat mode.

Returns:

Object containing error code and returned value on success.
errorunsigned byte

An error result from the list of defined error codes

valueunsigned char

The mode of the time. aTIMER_MODE_REPEAT or aTIMER_MODE_SINGLE.

Return type:

brainstem.result.Result

setExpiration(usec_duration)[source]

Set the expiration time for the timer entity. When the timer expires, it will fire the associated timer[index]() reflex.

Parameters:

usec_duration (unsigned int) – The duration before timer expiration in microseconds.

Returns:

An error result from the list of defined error codes in brainstem.result.Result

Return type:

unsigned byte

setMode(mode)[source]

Set the mode of the timer which is either single or repeat mode.

Parameters:

mode (unsigned char) – The mode of the timer. aTIMER_MODE_REPEAT or aTIMER_MODE_SINGLE.

Returns:

An error result from the list of defined error codes in brainstem.result.Result

Return type:

unsigned byte