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 6 made on Monday January 26, 2009 at 10:02
Spudnic
Long Time Member
Joined:
Posts:
January 2009
10
I did something like this with my 9400. At first, coming from an old pronto b&w unit, I thought it was kind of stupid that the 9400 had a hard power button. But, after learning that it could support JavaScript ... oh sorry, ProntoScript ... I was thrilled. I'd always used a discret all on and all off button previously, but now I wanted the power button to toggle state, but still do an all on and all off. This would keep all the equipment from getting out of sync if toggle IR codes were used. Here is my setup.

Activity:Store
PS Name: PSA_STORE

Page: Store
PS Name: PSP_STORE

On that page are two buttons, all on (PS Name: PSB_ALLON) and all off (PS Name: PSB_ALLOFF). Attach all the codes you want to the actions on these buttons. And that's the main setup. The activity is never shown to the user, it's basically just a place to store code (hence my name). Then I attached the following code to the power button in the System activity ... but you could use the same code from any button anywhere.

// *** begin code ***
var pwrOn = System.getGlobal("PSG_PWRON");
if ( pwrOn == null ) { pwrOn = "On"; }
if ( pwrOn == "On" ) {
// System.print("Powering Off: " + pwrOn);
CF.widget("PSB_ALLOFF", "PSP_STORE", "PSA_STORE").executeActions();
pwrOn = "Off";
} else {
// System.print("Powering On: " + pwrOn);
CF.widget("PSB_ALLON", "PSP_STORE", "PSA_STORE").executeActions();
pwrOn = "On";
};
System.setGlobal("PSG_PWRON", pwrOn);
// *** end code ***

Basically what's happening here is it pulls a global variable for the power state. This is done because as you switch activities and pages, your variables will disappear. We want it to maintain state across all of that. The next line is basically for setting the intial state on the first load where the global variable has not had a chance to set itself. After that, it's calling the actions on the correct button based on current state. Then finally setting the global variable again. Really all very simple. You can see where the PS Names come in on the script if you wanted to reuse this for something else ... or you have a problem with my naming conventions.

Best of luck.


Hosting Services by ipHouse