XML: Timer

From FSDeveloper Wiki
Jump to: navigation, search


XML: Timer

With this universal code it's very simple to control not only the length of the cycle but the frequency of the blink itself:

Pseudocode:

<Visible>(P:Absolute time,seconds) "seed" % "blink lapse" "seed" * > !</Visible>

The seed parameter is the total length of the blinking cycle. For example, if you want something to blink once every second, you use 1, if you want it blink every half a second, use 0.5 , every two seconds, 2 ,etc.

For each seed, you can determine how long would be the duration of both the visible and invisible part. Then:

(P:Absolute time,seconds) 1 % 0.5 1 * > ! 

this will make the visible and invisible parts of half a second each.

(P:Absolute time,seconds) 1 % 0.7 1 * > ! 

this will make the visible part 70% of the cycle (0.7 secs) and invisible parts of 30 % (0.3 secs).

(P:Absolute time,seconds) 0.5 % 0.25 1 * > ! 

this will make the visible and invisible parts a quarter of second each.

(P:Absolute time,seconds) 12 % 0.5 12 * > ! 

this will make the visible and invisible parts of 6 seconds each.

(P:Absolute time,seconds) 12 % 0.7 12 * > ! 

this will make the visible part 70% of the cycle (8.4 secs) and invisible parts of 30 % (3.6 secs).

You can invert the cycle by removing the "!" char.