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:
Screen saver
This thread has 10 replies. Displaying all posts.
Post 1 made on Thursday May 9, 2024 at 14:50
mpg7321
Regular Member
Joined:
Posts:
June 2020
116
I am working on a simple screen saver for my 9600 and 9800's, I am using the following script'

System.setGlobal("Screen_Saver", '5');
function Func ()
{
var ScreenSaver = System.getGlobal("Screen_Saver");
if (ScreenSaver > 0) {
ScreenSaver--;
System.setGlobal("Screen_Saver", ScreenSaver);
}else{
CF.widget("Clock_Jump", "IR", "XBOX").executeActions();
};
scheduleAfter(90000, Func);
}
scheduleAfter(5000, Func);

Each button on the page is using this,

CF.widget("XBOX_Pause", "IR", "XBOX").executeActions()
System.setGlobal("Screen_Saver", '5')
to send the IR command as well as to reset the count back to 5.

It works very well, my question is there a better way, such as a script that would monitor input from both firm keys as well from input from the touch screen?
Thanks,
Post 2 made on Friday May 10, 2024 at 19:01
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,007
Not sure what you are wanting your buttons to do, maybe reset the timer?

Have you looked at the onSleep/onWake callbacks of the Activity object?

onWake is called whenever the screen activates. That being said, it is called for sure whenever scroll wheel is touched/nudged but for Firm/Hard keys you can configure independently as follows:

1. Activate Screen
2. Activate Screen and Send IR
3. Send IR Only (Send IR also implies execute anything in the action list).

I recommend using scheduleActions instead of executeActions() as executeActions() throws an exception/error if your actionlist contains a Jump Action.

You can put combined script + action functionality on a hard/firm key. You'd need to program your actions in the actionlist and then set the firm/hard key to ProntoScript mode and put in your Javascript.

The button script is as follows:

// do whatever you like in javascript followed by.
var a=123;

// this will cause the actions in the current button to be executed and because
// you are using scheduleActions, the IR Send Icon will rotate.
// scheduleActions() can be used safely from within a page script as well as a button script. See the Dev Guide for more details on the usage.
this.scheduleActions();


Keep in mind that the above approach will not work well for any IR code that requires a long press or a button that you'd want to hold such as Volume Up/Down. The best you'd be able to do is to use the repeatInterval on a button to send and send again but volume ramping will be very sluggish.


Caveat Emptor - eval is very dangerous in the Web Browser world but for your Pronto Code, it should be just fine with no security issues.

Also note that the 'eval' keyword works too which helps to keep your common script in a single location.

Consider that you put a label on a hidden page with correct prontoscript tagging.

// You can put this in your activity ProntoScript so you have an activity-level scoped variable.
// Load common script from a panel widget in your config.
var w = CF.widget('Script1', 'Scripts', 'CommonStuff');
// The label contains the code to execute.
var script1 = w.label;


Then in your button or page script you could do this.

this.eval(script1);


The result of 'eval' call is the result of the last statement in your script.

By using 'this.eval', the variables in the button/page/activity are visible within the script you are executing.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 3 made on Saturday May 11, 2024 at 03:09
mpg7321
Regular Member
Joined:
Posts:
June 2020
116
Thanks for the reply but I may not have made it clear, regarding what the button is doing, is its sending out a command and also resetting the "timer". I use that for ever button on the page, including firm buttons. I am not trying to turn on or off the screen and nor dim the screen. When the countdown reaches zero, I page jump to a black screen where I have a script the moves objects around. Basically a screen saver. I keep the remote screen on 24/7 and concerned about possible screen burn in. My way works but I have to have a hidden page with buttons where I then assign commands too, then from the main page button's, call the commands and also reset the timer, thought there might be an easier way.
thanks.
Mike
Post 4 made on Sunday May 12, 2024 at 01:31
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,007
You can do whatever you like but let it be known that if a Firm/Hard key needs to send a press and hold action, it will not be possible if you want to reset your timer along with executing the actions on said button.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 5 made on Sunday May 12, 2024 at 14:45
mpg7321
Regular Member
Joined:
Posts:
June 2020
116
Thanks I already know how to do that, a press and hold for the firm keys. I was more interested if there is a script that I could use that would monitor any kind of input from any type of button, that was my original question. For now, I have to go back and modify a whole lot of buttons to send both a command and reset the timer. Looking for a possible "Short cut" to the work. LOL
Thanks again
Post 6 made on Sunday May 12, 2024 at 19:15
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,007
That simple shortcut/event listener/callback does not exist. The DEV Guide is helpful for the following (note that ability to create/assign an onPress function was added when Pronto began supporting dynamic widgets).

You can override onPress function for all your buttons that don't have ProntoScript assigned to them already. Note that by assigning onPress for a button, you will effectively remove any script you currently have defined/configured in the editor for a button widget.

This can be done in a Page Script vs having to edit each and every button.

For example, in a page script.

function clearTimerAndExecute() {
// whatever logic to clear your timer but cannot jump to a page.
this.scheduleActions();
}


GUI.widget("PS_FIRM1").onPress = clearTimerAndExecute;
GUI.widget("PS_FIRM2").onPress = clearTimerAndExecute;
GUI.widget("PS_FIRM3").onPress = clearTimerAndExecute;
// you get the idea.



Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 7 made on Wednesday May 15, 2024 at 14:34
mpg7321
Regular Member
Joined:
Posts:
June 2020
116
So I was thinking that you may have pointed me in the right direction with,
GUI.widget("PS_FIRM3").onPress = clearTimerAndExecute;

the issues I ran into was it seems that you cannot also send an IR command from the same button. seems the remote will only run the script.

Thanks again for your help.
Post 8 made on Wednesday May 15, 2024 at 19:58
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,007
This does indeed not work for Firm/Hard Keys but does work with a Soft Button. I suspect the reason is because of the ways Firm/Hard keys for an activity are wired together.

However, I've found a way to make this work with zero issues but it does require a little bit of extra work. You have to put your actions into a Macro Category and instead of saying this.execute actions, you have to grab the CF.widget and then schedule or execute the widget.

Macro Category named "MikeG_Macros" with ProntoScript name "MIKEG_MACROS".
Inside this category, add a Macro named "PS_FIRM3" with ProntoScript name "PS_FIRM3"
For the PS_FIRM3 macro actions, add a sound such as 'error mono'.


In an Activity, Add the following script.

System.setDebugMask(9);
function doSomethingAndExecute () {
// at the time doSomethingAndExecute is called, Javascript
// 'this' will be the button widget you just pressed (firm1, firm2, firm3, etc)
System.print("abc easy as 123 tag:" + this.tag);
// Load the widget from reusable macros based on the current button's tag.
// These can be executed or scheduled.
var w = CF.widget(this.tag, "MIKEG_MACROS", "PS_MACROS");
if (w) w.scheduleActions();
}

As a convenience, you might want to define your normal Firm/Hard key actions to Link to a Component Macro as well. The same one you defined above.

Then in each page script, do the following:


GUI.widget('PS_FIRM3').onPress = doSomethingAndExecute;


Send me an email from an address where you can receive a zip and I will send the file I just tested. The solution is not necessarily pretty but something for you to ponder/expand on if you really want the desired behavior and the ability to assign onPress to be able to clear/set your globals as well as execute one-shot IR actions.

Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 9 made on Wednesday May 15, 2024 at 20:08
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,007
Wow, I just put a config together, tested it, saved it. Upon reload, same issue you are seeing is there. Under no circumstances can I get this to work reliably.

Go figure.!!!

Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 10 made on Wednesday May 15, 2024 at 20:20
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,007
OK. This has something to do with the PS_XXXXX names being reserved even in Macro categories. Looks like the widgets (yes, macros are buttons on a Macro Category page made to look like they are not really an Activity as there are no Firm/Hard buttons supported there) with reserved names are having actions stripped during download to simulator and remote for some reason.

I changed the macro's prontoscript name to PS_FIRM3_OVERRIDE and things seem to work reliably.

Send me an email an I'll send you the file.

In short. Instead of having your Reusable Macro have a ProntoScript name of "PS_FIRM3", change it to "PS_FIRM3_OVERRIDE"

Then, use this function

System.setDebugMask(9);
function doSomethingAndExecute () {
// at the time doSomethingAndExecute is called, Javascript
// 'this' will be the button widget you just pressed (firm1, firm2, firm3, etc)
System.print("abc easy as 123 tag:" + this.tag);
// Load the widget from reusable macros based on the current button's tag.
// These can be executed or scheduled.
var w = CF.widget(this.tag + "_OVERRIDE", "MIKEG_MACROS", "PS_MACROS");
if (w) w.scheduleActions();
}

Last edited by Lyndel McGee on May 15, 2024 20:27.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 11 made on Thursday May 16, 2024 at 14:21
mpg7321
Regular Member
Joined:
Posts:
June 2020
116
I'm off to work so I will dive into this later, I can say though I could not get this to work at all with soft buttons as well, or at least the way I was trying. I will PM you my work email, hopefully you can send .zip files through there.


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