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

Login:
Pass:
 
 

Page 1 of 2
Topic:
Prontoscript and normal IR codes on a single button
This thread has 16 replies. Displaying posts 1 through 15.
Post 1 made on Thursday August 5, 2010 at 15:40
mkleynhans
Long Time Member
Joined:
Posts:
August 2009
54
Hi there,
I read something a few months back on this and have trawled through the posts and cannot find the information I need.. I want to put both prontoscript and an IR code on a single button.

Basically I need to fire IR commands at a television via a processor and send IP commands at a server to bring it out of soft shutdown and remember reading that I need to name the button but dont know where to put the code.. Is it on the activity properties page?

Any help appreciated..

Thanks,

Mike
Post 2 made on Thursday August 5, 2010 at 15:58
zedmtrappe
Long Time Member
Joined:
Posts:
July 2008
35
1: Add your regular IR commands etc to the button.

2: Open the pronto script editor for the same button and add your prontoscript.

3: Finish the prontoscript with executeActions() which will fire your regular button commands.

That's it!
OP | Post 3 made on Thursday August 5, 2010 at 17:01
mkleynhans
Long Time Member
Joined:
Posts:
August 2009
54
Thanks pal, that was a lot simpler than I thought it would be =)
Post 4 made on Thursday August 5, 2010 at 18:10
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
Note that if you have a jump in your Action List, you will want to surround the above with a try/catch block and ensure that the text for the error is ActionList Error and then simply discard that. Otherwise, the jump will cause this error which will be logged to the diagnostic log.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 5 made on Thursday August 5, 2010 at 18:15
Lowpro
Select Member
Joined:
Posts:
March 2004
2,081
The basic rule to remember is that if ProntoScript is enabled for a given button only the ProntoScript will be executed when you press the actual button, so if you want the action list to be invoked as well you simply need to invoke said action list via your ProntoScript as zedmtrappe pointed out using executeActions().

Below is a simple example per the "Power On" button while under the activity for my plasma display. I track the power state of my plasma display using a global variable. As such, I want two things to happen when pressing the "Power On" button. I want to update the value of the global variable used to track the power state in addition to the sending the power on IR code to my plasma. To accomplish this I simply gave my "Power On" button the ProntoScript name, "On". I then added my plasma's power on IR code to the button's action list. Lastly, I enabled ProntoScript for the button and added the below ProntoScript.

System.setGlobal ("Samsung PN58B860","On");
GUI.widget("On").executeActions(); return;


The first line sets the global variable I use to track the power state of my plasma display. Obviously if I am sending the power on IR code I want the value of my global variable to be "On" versus "Off" at that point. The second line then invokes the action list of the button which sends the power on IR code to my plasma.
LP Related Links:
View my profile to access various
links to key posts and downloads.
Post 6 made on Thursday August 5, 2010 at 18:36
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
LowPro,

What in the heck is "return;"? Is that valid Javascript? It may not cause an error but what in the heck is it meant to do?
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 7 made on Friday August 6, 2010 at 02:25
mkleynhans
Long Time Member
Joined:
Posts:
August 2009
54
Thanks guys,

Lowpro, where you track the power state of your telly using system.setglobal, can you refer to that to see whether the remote believes the television is on for other activities?
ie. If you used that for watch TV, is there some sort of if statement that could be checked and if TV power is yes, it wont send the IR command but if not, it would?

RTI has flags which I use often when discrete codes arent available and this would be a great work around for me..
Post 8 made on Friday August 6, 2010 at 03:10
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
I recommend that you yave a look at the Dev Guide for System.setGlobal/getGlobal. Yes, LowPro is tracking the power state of his Samsung Display with the big difference being that the System.xxxGlobal functions deal with strings and not boolean true/false or on/off values.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 9 made on Friday August 6, 2010 at 05:48
Lowpro
Select Member
Joined:
Posts:
March 2004
2,081
On August 5, 2010 at 18:36, Lyndel McGee said...
LowPro,

What in the heck is "return;"? Is that valid Javascript? It may not cause an error but what in the heck is it meant to do?

The ProntoScript example I provided in my prior reply is actually contained within a function at the activity level per my configuration file.

function doPowerOn() {
System.setGlobal ("Samsung PN58B860","On");
GUI.widget("On").executeActions();
return;
}


My actual "Power On" button then simply contains the below.

doPowerOn();

In my example above the "return" is not needed. I've just gotten into the habit of including it at the end of my functions as there are many examples of this within the SlimPronto activity which is where I've picked up all my ProntoScript knowledge from. Have yet to take the time to actually learn JavaScript per se as I've been able to accomplish everything I've wanted to per my configuration file without taking the time. That being said, "return" can be used to stop a script from executing at that given point if something happens or if you want the function to return a value to the calling function.

Last edited by Lowpro on August 6, 2010 16:42.
LP Related Links:
View my profile to access various
links to key posts and downloads.
Post 10 made on Friday August 6, 2010 at 06:17
BluPhenix
Long Time Member
Joined:
Posts:
December 2008
371
Ok now it's more clear.

Although I'm not really sure, but I think you don't need a return statement at the end of the function if the function doesn't actually return anything.

You can use it in a conditional script break thought:

function stoppable() {
if (sky==="blue") {
return;
} else {
doSomething;
}

This will break the execution of the function if the sky is blue.
Post 11 made on Friday August 6, 2010 at 07:53
Lowpro
Select Member
Joined:
Posts:
March 2004
2,081
On August 6, 2010 at 02:25, mkleynhans said...
Thanks guys,

Lowpro, where you track the power state of your telly using system.setglobal, can you refer to that to see whether the remote believes the television is on for other activities?

Yes, this is exactly why I'm doing so.

ie. If you used that for watch TV, is there some sort of if statement that could be checked and if TV power is yes, it wont send the IR command but if not, it would?

RTI has flags which I use often when discrete codes arent available and this would be a great work around for me..

Yes, and while I have discrete power codes for all my components I still track the power states using ProntoScript as I have three different macros for each activity. The appropriate macro is then run when switching to a given activity based on the values of the different global variables which apply.

The ProntoScript shown below is taken from the activity level of the device I use solely for selecting activities and shows you what happens when you choose the "HD DVR" activity from my "Activities" page. On the actual "Activities" page there are various buttons for each activity. You can select a given activity by using the directional pad and OK button or by pressing the given button directly. With a normal press the function doHDDVR() is executed as shown below. This function simply states, if the display and receiver are already powered on, run the macro on the button with the ProntoScript name, "HD DVR (Bypass)" from the appropriate page and device. The resulting macro takes you directly to the main page for the activity, then sending the source selects only as the required components are already powered on. If the display and receiver are not both powered on the else part of the statement is then run which states, if the display is already powered on, but the receiver is powered off, set the global used to track the power state of the receiver to "On", then run the macro on the button with the ProntoScript name, "HD DVR (Full)" from the appropriate page and device. This macro displays loading pages while sending the power on IR codes for all the needed components, then sending the source selects and lastly taking you to the main page of the activity. If that condition is not met it is assumed that the display is not powered on. In this case the globals used to track the power states of the display and receiver are updated accordingly, then the macro on the button with the ProntoScript name, "HD DVR (Ext)" is run. This macro is identical to the "HD DVR (Full)" macro, but accounts for the length of time (12.5 seconds) my display needs to be powered on before it will accept another IR command, in this case the IR code for setting the display to the proper input. I should also note that I don't address the power state of my HD DVR in any way, because it is left powered on 24/7/365.



So as you can see, the benefit here per ProntoScript is that I've been able to customize the activity macro based on certain conditions thereby minimizing the length of time the end user has to wait before being given control of the given activity.

The last function shown above, doHDDVRforce() is a fail-safe. If an extended press is used from my "Activities" page when selecting a given activity this function is executed which forces the extended macro to be run. This can be useful if the remote gets out of sync with the true power states of my equipment, i.e. someone physically powers off a component rather than doing so with the remote or if the remote is reset while one or more components are still powered on. This rarely happens, but having the fail-safe is nice to have. Of course running System On or System Off from my "Activities" page is the best way to ensure the remote is back in sync with the whole system. I also provide for a way to force the extended macro to run once on the main page of a given activity. The power hard button throughout my configuration file serves as the home button in addition to the on-screen button in the upper left corner of the screen. A regular press of either of these buttons will take you back to the "Activities" page. An extended press of either of these buttons will force that extended macro to run for the selected activity.

As if that wasn't enough I provide yet another way to get things back in sync if needed. I use this quite a bit in cases where a portion of my system is still powered on and I have either downloaded a new configuration file to the remote or reset the remote. Performing an extended press in the upper right corner of screen where the system items are displayed will take you to my "System Status" page which is shown below.



The "System Status" page reports the current activity selected, the last DVD changer activity which was in use, and the power states of key components. By simply tapping on a given value you are able to update that system global on the fly. Tapping the value, "On" will then change it to read "Off" in addition to updating the appropriate system global. Tapping the value for the Last Changer will cycle in order through my 6 DVD changers. When going to my DVD Changer activity you have the option of going directly to the activity for a given changer or to the activity for the last DVD changer which was in use which is very convenient when you want to resume watching a DVD from the prior day and you don't remember which DVD changer it happened to be in. The value for the activity currently selected I don't allow to be changed. I've also just recently add settings options for the scroll wheel while under my DVD Juke activity.

Last edited by Lowpro on November 21, 2011 13:40.
LP Related Links:
View my profile to access various
links to key posts and downloads.
Post 12 made on Friday August 6, 2010 at 10:49
Lowpro
Select Member
Joined:
Posts:
March 2004
2,081
On August 6, 2010 at 06:17, BluPhenix said...
Ok now it's more clear.

Although I'm not really sure, but I think you don't need a return statement at the end of the function if the function doesn't actually return anything.

You can use it in a conditional script break thought:

function stoppable() {
if (sky==="blue") {
return;
} else {
doSomething;
}

This will break the execution of the function if the sky is blue.

Yeah, I do use "return" as a conditional script break quite often. That being said, I've gotten into the habit of including a "return" at the end of my functions as well as I don't really know JavaScript per se. I worked on the SlimPronto activity with Barry Gordon and all my JavaScript knowledge has been gained by studying Barry's ProntoScript. In many cases, Barry will end a function with a "return", so I'm just following that practice even though I don't recall the purpose it serves. Doesn't break anything, so I figure it's all good.

Last edited by Lowpro on August 6, 2010 11:42.
LP Related Links:
View my profile to access various
links to key posts and downloads.
OP | Post 13 made on Friday August 6, 2010 at 16:23
mkleynhans
Long Time Member
Joined:
Posts:
August 2009
54
Thanks once again chaps, its really cool when you learn such good stuff on here..
Post 14 made on Saturday August 7, 2010 at 02:43
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
LowPro,

I'm sure you likely know that the 'return;' statement is not necessary in the context of the function you declared. It is the last line of the function and as the function returns nothing (undefined), then having this line only serves to bloat the code.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 15 made on Saturday August 7, 2010 at 08:41
Lowpro
Select Member
Joined:
Posts:
March 2004
2,081
On August 7, 2010 at 02:43, Lyndel McGee said...
LowPro,

I'm sure you likely know that the 'return;' statement is not necessary in the context of the function you declared. It is the last line of the function and as the function returns nothing (undefined), then having this line only serves to bloat the code.

I do know and I feel bloated enough already! :-P In fact, I've already attended to such instances within my configuration file as I've been making some updates to it over past day or two here. Appreciate the feedback.
LP Related Links:
View my profile to access various
links to key posts and downloads.
Page 1 of 2


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