beautypg.com

ETC Unison Mosaic Designer v1.11.0 User Manual

Page 223

background image

Trigger Programming Guide

Of course here I have assumed that the corners of the building neatly line up with 0°,90°,180° and 270°. What if
they are at 45°,135°,225° and 315°?

-- get the value in degrees

dir = variable[1]

-- which face is getting the wind?

if dir < 45 or dir >= 315 then

start_timeline(1)

elseif dir < 135 then

start_timeline(2)

elseif dir < 225 then

start_timeline(3)

else

start_timeline(4)

end

As the wind direction sensor is sending us data every second, when the wind direction is very near a corner then
the lights are changing back and forth a lot. The client doesn't like this and wants it limited so that it will only
change at most every minute. How should we do that?

Lots of ways to solve this, but one option using script would be:

-- get the current minutes

now = realtime.minute

if now == lastMinute then

return -- this will exit the script early

end

-- store in lastMinute, then continue as before

lastMinute = now

-- get the value in degrees

dir = variable[1]

-- which face is getting the wind?

if dir < 45 or dir >= 315 then

start_timeline(1)

elseif dir < 135 then

start_timeline(2)

elseif dir < 225 then

start_timeline(3)

else

start_timeline(4)

end

But actually a better solution in this case would probably use a dummy timeline that runs for 1 minute (place a flag
at 1 minute to force its length). Add a 'timeline is running' condition to the RS232 input trigger that only allows the
trigger to fire if the dummy timeline is not running. And add a second action to the trigger that starts the dummy
timeline. This will ensure that the script is only allowed to run once every minute.

- 223 -