Sidebar

Home



Expressions V4


Tutorials

How-To

Reference

  Lexical basics
  Type system
  Variables and assignment
  Operators
  Expression rules
  Control flow
  Functions
  Built-in functions
   None and NaN
   Arithmetic
   Algebra
   Logarithmic and Exponential
   Trigonometric
   Rounding and Centering
   Strings
   Output, Formatting, and Errors
   Dialogs, Clipboard, Platform, and Paths
  Methods and properties
  Built-in methods
   Common Value Methods
   Number Methods
   String Basic Methods
   String Slice Methods
   String Parsing Methods
   String Formatting Methods
   String Regex Methods
   String Trim and Case Methods
  Objects
  Built-in objects
   Global objects
    settings
    session
    python
   Collections
    array
    map
    data_array
   File Format I/O
    image_data
    image_stream
   Utils
    crypto
    timer
   Comm
    serial
   Dialogs
    file_open
    file_save
    msg_ok
    msg_ok_cancel
    msg_yes_no
    msg_password
   GUI objects
    window
    panel
    group
    splitpanel
    label
    textbutton
    drawablebutton
    togglebutton
    togglegroup
    textinput
    textedit
    numinput
    slider
    combobox
    listbox
    progressbar
    led
    separator
    menu
    image
    snake
  Classes and user-defined objects
  Include system
  Error model
  Execution model and sessions
  Host integration
  Limits and performance
  Formal reference
  Glossary

Cookbook

exprv4:reference:objects:timer

timer

`timer` calls a callback repeatedly from a timer thread.

The callback receives one argument: the timer call count. The first callback receives `1`.


Constructor

timer(callback)

Creates a timer object using a callable object.

Arguments:

Argument Description
`callback` Function reference, method reference, or other object that implements `call(count)`.
function OnTimer(count)
{
    print('timer ', count);
}
 
t = timer(OnTimer);

Methods

start(intervalMs)

Starts the timer and returns `true` on success.

Arguments:

Argument Description
`intervalMs` Timer interval in milliseconds. Values less than or equal to zero are treated as `1`.
t = timer(OnTimer);
t.start(1000);

start(intervalMs, count)

Starts the timer with a repeat count and returns `true` on success.

Arguments:

Argument Description
`intervalMs` Timer interval in milliseconds.
`count` Number of callbacks. Values less than or equal to zero mean continuous periodic execution.
t = timer(OnTimer);
t.start(500, 3);     // call OnTimer three times

stop()

Stops the timer and returns `true` if it was running.

t.stop();

is_running()

Returns `true` while the timer is running.

if (t.is_running())
{
    print('timer is active');
}

help()

Returns a short text summary of timer methods.


Callback Errors

If the callback raises an error, the timer prints a timer callback error message and stops.

Previous: crypto

Next: Comm

exprv4/reference/objects/timer.txt · Last modified: by 127.0.0.1

Page Tools