Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Original thread:
Post 5 made on Monday December 4, 2017 at 23:09
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
On December 4, 2017 at 09:13, Martin said...
Thanks Lyndel - you're the best!

Not sure why but after toggling the overlay back to the activity, it would sometime change the activity label to "Lights Control" and stop.

I made the following changes to the "onOverlayHide" function to clear the label twice but it's not a pretty flow. Any suggestion?

Thanks again!

Martin

page("PS_OVERLAY").onOverlayHide = function()
{
CF.activity().label = null;
doAnimation = false;
function LabelOff()
{
CF.activity().label = null;
}
scheduleAfter(2000, LabelOff);
}

By the way, this double set to null is not a permanent fix as what you can experience is a timing/race condition. The control by the doAnimation variable is the only way to fix this problem. There are other ways that you could do this but they are more complex and require you to pass a JavaScript object as a 3rd parameter in the scheduleAfter calls.

This is pretty much a simplified version of what you are trying to do but outlines what I meant about the 3rd parameter.


// This goes into Activity Script
var timerStatus = {
doAnimate:false,
forceLabel=true };

function animate(status)
{
// parameter status is a reference to your original object.
if (status.doAnimate)
{
// either show or hide the label based on state.
CF.activity().label = (status.forceLabel ? 'Hello Martin' : null);
// toggle the flag
status.forceLabel = !status.forceLabel;
// do double check here just in case another entity (button press) cleared flag. If animation still active, then schedule the current function (arguments.callee again with parameter passed in to it.
if (status.doAnimate)
{
CF.activity().scheduleAfter(2000,arguments.callee, status);
}
}
}

// You want to do this in response to OnOverlayShow
function startAnimation()
{
timerStatus.doAnimate=true;
timerStatus.forceLabel=true;
CF.activity().scheduleAfter(2000, animate, timerStatus);
}

// You want to do this in response to OnOverlayHide
function stopAnimation()
{
timerStatus.doAnimate = false;
// setForceLabel to false prior to clearing label in case a task is still active (would cause label to be forced if allowed to run).
timerStatus.forceLabel = false;
// ensure label is cleared
CF.activity().label = null;
}


Create 2 buttons on a page named 'Start' and 'Stop' and put the ProntoScript in to call the functions...

Button 1 - > startAnimation();
Button 2 - > stopAnimation();

As a final task, I leave it up to you to put in the debug code to test this in PEP2 Simulator.

// add this at top of activity script.
System.setDebugMask(9);

And then put in System.print() statements as needed.

Last edited by Lyndel McGee on December 4, 2017 23:33.
Lyndel McGee
Philips Pronto Addict/Beta Tester


Hosting Services by ipHouse