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

Login:
Pass:
 
 

Topic:
Press and hold power button for off, Help ! (TSU9600)
This thread has 4 replies. Displaying all posts.
Post 1 made on Thursday July 28, 2016 at 12:00
DavidinCT
Long Time Member
Joined:
Posts:
September 2008
53
Hi all,

For the last day I have been searching and searching and found some examples but, I just don't understand the logic of them on the pronto.

Here are some of the things I have been looking over TRYING hard to understand

[Link: remotecentral.com]

[Link: remotecentral.com]

and a few others.

I am using PEP 2.4.18 I have Macros setup in reusable macros.

ALL_OFF - Turns the system off
ALL_ON - Turns the system on.


I want a simple setup. If the button is pushed quickly, it turns it on, If the button is held, to turn off.

Looking over the examples, I did a quick read on the pronto dev guide, just to understand widgets and such. I just don't understand the logic on it.

I am sure I am doing something stupid, can anyone help ?

Thanks in advance !
OP | Post 2 made on Thursday July 28, 2016 at 13:04
DavidinCT
Long Time Member
Joined:
Posts:
September 2008
53
Ok, I tried this.. and got it partly working...(thank you Lyndel McGee for the post). If I just quickly hit the power button nothing happens but, IF I hold it for like 4 seconds, it does run the ALL_OFF macro and shuts the system off.

How do I get this script to do a ALL_ON if it's quickly pressed ?


var intervalms = 1000;
var counter = 0;
var threshold = 3; // 3 executions of 1000ms
var executeReleaseActions = true;

onHold=function()
{
System.print('Counter: ' + counter);
counter = counter + 1;
if (counter >= threshold)
{
// set boolean so that onRelease does not do Jump.
executeReleaseActions = false;
// clear holdInterval so only reach threshold 1 time
this.onHoldInterval = 0;
var w = CF.widget('ALL_OFF', 'POWER', 'PS_MACROS');
System.print('ThresholdMet w: ' + w);
if (w != null)
{
// instead of this try/catch block with executeActions, if using newer firmware, can also call
// w.scheduleActions
try
{
w.executeActions();
}
catch(e)
{
System.print('Err. e:' + e)
Diagnostics.log('Err. e:' + e);
}
}
}
}

onRelease = function ()
{
if (executeReleaseActions)
{
// instead of this try/catch block with executeActions, if using newer firmware, can also call
// this.scheduleActions
try
{
this.executeActions();
}
catch(e)
{
System.print('Err. e:' + e)
Diagnostics.log('Err. e:' + e);
}
}
}

onHoldInterval = intervalms;


Thanks for any help you can provide !
Post 3 made on Thursday July 28, 2016 at 13:54
Lowpro
Select Member
Joined:
Posts:
March 2004
2,081
There's a number of ways to skin a cat. In my TSU9600 configuration file anyway I use the below ProntoScript when I want a given button to do one thing on a normal press and another on an extended press. Have catered the below example to what you are trying to do.

var counter = 0;
onHold = function()
{ counter++;
if (counter==1) { CF.widget('ALL_OFF', 'POWER', 'PS_MACROS').executeActions(); }
}
onHoldInterval = 1000; onRelease = function()
{ if (counter==0) { CF.widget('ALL_ON', 'POWER', 'PS_MACROS').executeActions(); }
}
LP Related Links:
View my profile to access various
links to key posts and downloads.
OP | Post 4 made on Thursday July 28, 2016 at 14:04
DavidinCT
Long Time Member
Joined:
Posts:
September 2008
53
On July 28, 2016 at 13:54, Lowpro said...
There's a number of ways to skin a cat. In my TSU9600 configuration file anyway I use the below ProntoScript when I want a given button to do one thing on a normal press and another on an extended press. Have catered the below example to what you are trying to do.

var counter = 0;
onHold = function()
{ counter++;
if (counter==1) { CF.widget('ALL_OFF', 'POWER', 'PS_MACROS').executeActions(); }
}
onHoldInterval = 1000; onRelease = function()
{ if (counter==0) { CF.widget('ALL_ON', 'POWER', 'PS_MACROS').executeActions(); }
}

After tweaking my macros a little, that worked perfect. Thank you.

What you did makes sense as I go through it, I am not a writer but, in IT for over 20 years so I do understand some fundamentals of it.

This gets me over the major milestones on my build, now it's about creating pages for each device.

Thank you again for your help !!!!
Post 5 made on Thursday July 28, 2016 at 14:59
Lowpro
Select Member
Joined:
Posts:
March 2004
2,081
On July 28, 2016 at 14:04, DavidinCT said...
After tweaking my macros a little, that worked perfect. Thank you.

What you did makes sense as I go through it, I am not a writer but, in IT for over 20 years so I do understand some fundamentals of it.

This gets me over the major milestones on my build, now it's about creating pages for each device.

Thank you again for your help !!!!

Great to hear. Also, not so much for what you're doing here, but in general I do recommend keeping as much ProntoScript at the Activity (Device) level as possible, then referencing to it when needed at the Page/Button level. Updated example below.

Activity (Device) Level:
function doPowerOff() {
CF.widget('ALL_OFF', 'POWER', 'PS_MACROS').executeActions();
}
//
function doPowerOn() {
CF.widget('ALL_ON', 'POWER', 'PS_MACROS').executeActions();
}

On the button itself:
var counter = 0;
onHold = function() {
counter++; if (counter==1) { doPowerOff(); }
}
onHoldInterval = 1000;
onRelease = function() {
if (counter==0) { doPowerOn(); }
}

I always limit the amount of ProntoScript used at the Page/Button level when possible. Keeping the majority of your ProntoScript at the Activity (Device) level makes it easier to work with. Following this practice is especially helpful in cases where the same ProntoScript is used in different places at the Page/Button level. Takes far less time to update something at the Activity (Device) level once than hunting down and updating each instance at the Page/Button level instead.

Last edited by Lowpro on July 29, 2016 09:10.
LP Related Links:
View my profile to access various
links to key posts and downloads.


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse