Need some help on timelines
kmenshouse
Posts: 32
I'm a newbie to programming and am trying to get used to using timelines. I have 2 cameras I'm controlling from the same panel. I want to repeat sending the command on a push but I need it to stop when I release the button. It's not stopping. I just keeps sending the commands.
Here's the code with the TIMELINE_KILL command"
BUTTON_EVENT[dvTP,nCAM_BUTTONS]
{
HOLD[3]:
{
TIMELINE_CREATE(TL1,tCAM_HOLD,1,TIMELINE_ABSOLUTE,TIMELINE_REPEAT)
}
RELEASE:
{
IF (TIMELINE_ACTIVE(TL1))
TIMELINE_KILL(TL1)
}
}
TIMELINE_EVENT[TL1]
{
IF(nCAMERA_LOCALE = 0)
{
WHILE(TIMELINE_ACTIVE(TL1))
{
SWITCH(GET_LAST(nCAM_BUTTONS))
{
CASE 1:
{
SEND_STRING dvLOC_CAM,'PR'
}
CASE 2:
{
SEND_STRING dvLOC_CAM,'PL'
}
CASE 3:
{
SEND_STRING dvLOC_CAM,'TU'
}
CASE 4:
{
SEND_STRING dvLOC_CAM,'TD'
}
CASE 5:
{
SEND_STRING dvLOC_CAM,'Z+'
}
CASE 6:
{
SEND_STRING dvLOC_CAM,'Z-'
}
CASE 7:
{
SEND_STRING dvLOC_CAM,'F+'
}
CASE 8:
{
SEND_STRING dvLOC_CAM,'F-'
}
}
}
}
ELSE
{
WHILE(TIMELINE_ACTIVE(TL1))
{
SWITCH(GET_LAST(nCAM_BUTTONS))
{
CASE 1:
{
SEND_STRING dvREM_CAM,'PR'
}
CASE 2:
{
SEND_STRING dvREM_CAM,'PL'
}
CASE 3:
{
SEND_STRING dvREM_CAM,'TU'
}
CASE 4:
{
SEND_STRING dvREM_CAM,'TD'
}
CASE 5:
{
SEND_STRING dvREM_CAM,'Z+'
}
CASE 6:
{
SEND_STRING dvREM_CAM,'Z-'
}
CASE 7:
{
SEND_STRING dvREM_CAM,'F+'
}
CASE 8:
{
SEND_STRING dvREM_CAM,'F-'
}
}
}
}
}
So why won't this thing stop when I release the button? Thanks.
Here's the code with the TIMELINE_KILL command"
BUTTON_EVENT[dvTP,nCAM_BUTTONS]
{
HOLD[3]:
{
TIMELINE_CREATE(TL1,tCAM_HOLD,1,TIMELINE_ABSOLUTE,TIMELINE_REPEAT)
}
RELEASE:
{
IF (TIMELINE_ACTIVE(TL1))
TIMELINE_KILL(TL1)
}
}
TIMELINE_EVENT[TL1]
{
IF(nCAMERA_LOCALE = 0)
{
WHILE(TIMELINE_ACTIVE(TL1))
{
SWITCH(GET_LAST(nCAM_BUTTONS))
{
CASE 1:
{
SEND_STRING dvLOC_CAM,'PR'
}
CASE 2:
{
SEND_STRING dvLOC_CAM,'PL'
}
CASE 3:
{
SEND_STRING dvLOC_CAM,'TU'
}
CASE 4:
{
SEND_STRING dvLOC_CAM,'TD'
}
CASE 5:
{
SEND_STRING dvLOC_CAM,'Z+'
}
CASE 6:
{
SEND_STRING dvLOC_CAM,'Z-'
}
CASE 7:
{
SEND_STRING dvLOC_CAM,'F+'
}
CASE 8:
{
SEND_STRING dvLOC_CAM,'F-'
}
}
}
}
ELSE
{
WHILE(TIMELINE_ACTIVE(TL1))
{
SWITCH(GET_LAST(nCAM_BUTTONS))
{
CASE 1:
{
SEND_STRING dvREM_CAM,'PR'
}
CASE 2:
{
SEND_STRING dvREM_CAM,'PL'
}
CASE 3:
{
SEND_STRING dvREM_CAM,'TU'
}
CASE 4:
{
SEND_STRING dvREM_CAM,'TD'
}
CASE 5:
{
SEND_STRING dvREM_CAM,'Z+'
}
CASE 6:
{
SEND_STRING dvREM_CAM,'Z-'
}
CASE 7:
{
SEND_STRING dvREM_CAM,'F+'
}
CASE 8:
{
SEND_STRING dvREM_CAM,'F-'
}
}
}
}
}
So why won't this thing stop when I release the button? Thanks.
0
Comments
You may also need to increase the time interval of the timeline to prevent commands from being queued.
Personally I would create an active camera button variable for each camera to allow both of them to function simultaneously and set the variable to 0 when not in use.
Jeff
Third, you could simplify this and do everything in the Button_Event:
--D
Both of you guys were right, it was the while statement. I know it might be asking too much, but if someone is bored and can explain why that can't be used there, I would love to learn more about it. I assumed that as soon as you release the button, the timeline would be killed and the while statement would become false and that would stop the send commands. Obviously not!
One more newbie question - how do you post your code in the blue inset box?
Thanks tremendously guys!
Relative to GET_LAST, it is only valid inside the event handler for the button, and even that can get screwed up if you use it inside a WAIT. If you'll need the button number later, store it in a global variable. {code}type code here{/code}, except use square brackets [] instead of {}
Hope this helps,
Jeff
Thanks Jeff. I wasn't aware of that but it's certainly how the program acted - as if I never released the button.
Keith
I prefer the camera device array to the if statement you were using. This will let you control more than 2 cameras easily. You'll also notice that this one starts sending move commands immediately, not only after you've held for .3 seconds.
Hope this helps
J