A guide to the Timer control

Using the Timer control in Helm can be a little less than intuitive. Here are some examples and explanations.

Let’s use this simple setup to demonstrate a few things

wpid1111-media_1386745480556.png

We’ll use four controls only, a Timer and a Text Label, and two Buttons to start and stop the Timer.

The Start has an OnClick event script TIMER_1:Start(), the Stop button has TIMER_1:Stop().

Timer behaviour is controlled by these properties

wpid1112-media_1386746194583.png

In this case when you start the Timer it counts up to 10 seconds and then stops – here’s why.

  • Continuous = false, means the timer does not loop back to 0 when it reaches the trigger time.
  • Countdown = false, means that the timer counts up.
  • StartSeconds = 0, means that the timer starts counting from zero.
  • Trigger Time = 10 means that when the timer value reaches 10, the timers OnTimer event is triggered and the timer stops

To make the Timer countdown from 10 to 0 in frames we would use these settings

wpid1113-media_1386746848089.png
  • Continuous = false, we want it to stop when it reaches zero
  • CountDown = true, so that it counts down not up
  • FramesPerSecond = 25, so that frames are included in the timer value
  • StartSeconds = 10, because we want it to start at 10 seconds
  • TriggerTime = 0, so that it stops at zero

More variations – updating a Text Label to show the time

wpid1114-media_1386747300289.png

This time we’ve set the Timer to loop continuously by setting Continuous to true.

And we’ve also added an event script to update the Text Label to repeat the Timer time value. We did this by putting the command

LABEL_1:SetText(_TIMER_1:Text)

in the OnTimerTick event script.

Note:
you should be careful about using OnTimerTick to send commands to broadcast devices because while the timer is running it is called 50 times each second! If you try to update an ImageStore 50 times a second it will probably fail. The best approach for sending regular updates to devices is to use the OnTimer event and set the timer to continuous.

How to do something after a short delay

wpid1115-media_1386748171379.png

This time we’ve set Continuous to false so that the timer counts down to zero, triggers and stops.

We’ve set the OnTimer event script to LABEL_1:SetText(“Time’s up !!!”)

Showing the time of day

wpid1116-media_1386748601945.png

To make the Timer show time-of-day we set WallClock to true.

In this example we’ve repeated the time to the Text Label using the OnTimerTick event as previously. This shows a slightly confusing aspect of the Timer. In WallClock mode the timer can be Running or Stopped even though the time value updates constantly regardless of this state. The effect of this is unless you actually start the timer, the OnTimer and OnTimerTick events appear not to be working.

Custom date / time formating

wpid1117-media_1386749936179.png

The CustomFormat property let’s you format the time (and date) display. You can display hours, minutes, seconds and frames, plus dates in long or abbreviated forms. Above are some example formats.

Because at Rascular we believe in ‘eating our own dog food’ we did this in Helm by creating several Timer controls and Property Linking a Text Label to the CustomFormat property of each Timer. Harder to describe in words than to do.

Footnote

Timers provide a lot of ways to do some basic sequencing of actions in Helm. But for more comprehensive event scheduling you should definitely use the Helm ClockWork option.